mirror of
https://github.com/decolua/9router.git
synced 2026-05-08 12:01:28 +00:00
Add Cloudflare AI provider support and enhance connection management
- Introduced Cloudflare AI as a new provider with specific configurations in providerModels.js and providers.js. - Updated DefaultExecutor to handle account ID resolution for Cloudflare AI connections. - Enhanced AddApiKeyModal and EditConnectionModal to include account ID input for Cloudflare AI. - Implemented validation for Cloudflare AI API key connections in testUtils.js and route.js. - Updated UI components to reflect changes in provider management and connection handling.
This commit is contained in:
@@ -344,6 +344,10 @@ export const PROVIDER_MODELS = {
|
||||
{ id: "GLM-4.7", name: "GLM-4.7" },
|
||||
{ id: "DeepSeek-V3.2", name: "DeepSeek-V3.2" },
|
||||
],
|
||||
"cloudflare-ai": [
|
||||
{ id: "@cf/moonshotai/kimi-k2.6", name: "Kimi K2.6" },
|
||||
{ id: "@cf/zai-org/glm-4.7-flash", name: "GLM 4.7 Flash" },
|
||||
],
|
||||
byteplus: [
|
||||
{ id: "seed-2-0-pro-260328", name: "Seed 2.0 Pro" },
|
||||
{ id: "seed-2-0-code-preview-260328", name: "Seed 2.0 Code Preview" },
|
||||
|
||||
@@ -367,6 +367,11 @@ export const PROVIDERS = {
|
||||
format: "openai",
|
||||
headers: {}
|
||||
},
|
||||
// Cloudflare Workers AI - {accountId} resolved from credentials.providerSpecificData.accountId
|
||||
"cloudflare-ai": {
|
||||
baseUrl: "https://api.cloudflare.com/client/v4/accounts/{accountId}/ai/v1/chat/completions",
|
||||
format: "openai"
|
||||
},
|
||||
};
|
||||
|
||||
export const OLLAMA_LOCAL_DEFAULT_HOST = "http://localhost:11434";
|
||||
|
||||
@@ -32,8 +32,15 @@ export class DefaultExecutor extends BaseExecutor {
|
||||
return `${this.config.baseUrl}?beta=true`;
|
||||
case "gemini":
|
||||
return `${this.config.baseUrl}/${model}:${stream ? "streamGenerateContent?alt=sse" : "generateContent"}`;
|
||||
default:
|
||||
return this.config.baseUrl;
|
||||
default: {
|
||||
const url = this.config.baseUrl;
|
||||
if (url?.includes("{accountId}")) {
|
||||
const accountId = credentials?.providerSpecificData?.accountId;
|
||||
if (!accountId) throw new Error(`${this.provider} requires accountId in providerSpecificData`);
|
||||
return url.replace("{accountId}", accountId);
|
||||
}
|
||||
return url;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -206,7 +206,7 @@ export async function refreshCodexToken(refreshToken, log) {
|
||||
grant_type: "refresh_token",
|
||||
refresh_token: refreshToken,
|
||||
client_id: PROVIDERS.codex.clientId,
|
||||
scope: "openid profile email",
|
||||
scope: "openid profile email offline_access",
|
||||
}),
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user