Merge pull request #4988 from ConnectAI-E/hotfix/cf-ai-gateway

Hotfix: default config
This commit is contained in:
Lloyd Zhou 2024-07-12 22:06:02 +08:00 committed by GitHub
commit b4ae706914
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 41 additions and 25 deletions

View File

@ -122,16 +122,13 @@ export class GeminiProApi implements LLMApi {
const controller = new AbortController(); const controller = new AbortController();
options.onController?.(controller); options.onController?.(controller);
try { try {
// let baseUrl = accessStore.googleUrl; if (!baseUrl && isApp) {
baseUrl = DEFAULT_API_HOST + "/api/proxy/google/";
if (!baseUrl) {
baseUrl = isApp
? DEFAULT_API_HOST +
"/api/proxy/google/" +
Google.ChatPath(modelConfig.model)
: this.path(Google.ChatPath(modelConfig.model));
} }
baseUrl = `${baseUrl}/${Google.ChatPath(modelConfig.model)}`.replaceAll(
"//",
"/",
);
if (isApp) { if (isApp) {
baseUrl += `?key=${accessStore.googleApiKey}`; baseUrl += `?key=${accessStore.googleApiKey}`;
} }

View File

@ -35,6 +35,7 @@ export enum ApiPath {
Azure = "/api/azure", Azure = "/api/azure",
OpenAI = "/api/openai", OpenAI = "/api/openai",
Anthropic = "/api/anthropic", Anthropic = "/api/anthropic",
Google = "/api/google",
Baidu = "/api/baidu", Baidu = "/api/baidu",
ByteDance = "/api/bytedance", ByteDance = "/api/bytedance",
Alibaba = "/api/alibaba", Alibaba = "/api/alibaba",

View File

@ -349,12 +349,12 @@ const cn = {
}, },
Baidu: { Baidu: {
ApiKey: { ApiKey: {
Title: "接口密钥", Title: "API Key",
SubTitle: "使用自定义 Baidu API Key", SubTitle: "使用自定义 Baidu API Key",
Placeholder: "Baidu API Key", Placeholder: "Baidu API Key",
}, },
SecretKey: { SecretKey: {
Title: "接口密钥", Title: "Secret Key",
SubTitle: "使用自定义 Baidu Secret Key", SubTitle: "使用自定义 Baidu Secret Key",
Placeholder: "Baidu Secret Key", Placeholder: "Baidu Secret Key",
}, },

View File

@ -12,15 +12,33 @@ import { DEFAULT_CONFIG } from "./config";
let fetchState = 0; // 0 not fetch, 1 fetching, 2 done let fetchState = 0; // 0 not fetch, 1 fetching, 2 done
const DEFAULT_OPENAI_URL = const isApp = getClientConfig()?.buildMode === "export";
getClientConfig()?.buildMode === "export"
const DEFAULT_OPENAI_URL = isApp
? DEFAULT_API_HOST + "/api/proxy/openai" ? DEFAULT_API_HOST + "/api/proxy/openai"
: ApiPath.OpenAI; : ApiPath.OpenAI;
const DEFAULT_AZURE_URL = const DEFAULT_GOOGLE_URL = isApp
getClientConfig()?.buildMode === "export" ? DEFAULT_API_HOST + "/api/proxy/google"
? DEFAULT_API_HOST + "/api/proxy/azure/{resource_name}" : ApiPath.Google;
: ApiPath.Azure;
const DEFAULT_ANTHROPIC_URL = isApp
? DEFAULT_API_HOST + "/api/proxy/anthropic"
: ApiPath.Anthropic;
const DEFAULT_BAIDU_URL = isApp
? DEFAULT_API_HOST + "/api/proxy/baidu"
: ApiPath.Baidu;
const DEFAULT_BYTEDANCE_URL = isApp
? DEFAULT_API_HOST + "/api/proxy/bytedance"
: ApiPath.ByteDance;
const DEFAULT_ALIBABA_URL = isApp
? DEFAULT_API_HOST + "/api/proxy/alibaba"
: ApiPath.Alibaba;
console.log("DEFAULT_ANTHROPIC_URL", DEFAULT_ANTHROPIC_URL);
const DEFAULT_ACCESS_STATE = { const DEFAULT_ACCESS_STATE = {
accessCode: "", accessCode: "",
@ -33,31 +51,31 @@ const DEFAULT_ACCESS_STATE = {
openaiApiKey: "", openaiApiKey: "",
// azure // azure
azureUrl: DEFAULT_AZURE_URL, azureUrl: "",
azureApiKey: "", azureApiKey: "",
azureApiVersion: "2023-08-01-preview", azureApiVersion: "2023-08-01-preview",
// google ai studio // google ai studio
googleUrl: "", googleUrl: DEFAULT_GOOGLE_URL,
googleApiKey: "", googleApiKey: "",
googleApiVersion: "v1", googleApiVersion: "v1",
// anthropic // anthropic
anthropicUrl: DEFAULT_ANTHROPIC_URL,
anthropicApiKey: "", anthropicApiKey: "",
anthropicApiVersion: "2023-06-01", anthropicApiVersion: "2023-06-01",
anthropicUrl: "",
// baidu // baidu
baiduUrl: "", baiduUrl: DEFAULT_BAIDU_URL,
baiduApiKey: "", baiduApiKey: "",
baiduSecretKey: "", baiduSecretKey: "",
// bytedance // bytedance
bytedanceUrl: DEFAULT_BYTEDANCE_URL,
bytedanceApiKey: "", bytedanceApiKey: "",
bytedanceUrl: "",
// alibaba // alibaba
alibabaUrl: "", alibabaUrl: DEFAULT_ALIBABA_URL,
alibabaApiKey: "", alibabaApiKey: "",
// server config // server config