mirror of
				https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
				synced 2025-11-04 16:23:41 +08:00 
			
		
		
		
	Merge pull request #4988 from ConnectAI-E/hotfix/cf-ai-gateway
Hotfix: default config
This commit is contained in:
		@@ -122,16 +122,13 @@ export class GeminiProApi implements LLMApi {
 | 
			
		||||
    const controller = new AbortController();
 | 
			
		||||
    options.onController?.(controller);
 | 
			
		||||
    try {
 | 
			
		||||
      // let baseUrl = accessStore.googleUrl;
 | 
			
		||||
 | 
			
		||||
      if (!baseUrl) {
 | 
			
		||||
        baseUrl = isApp
 | 
			
		||||
          ? DEFAULT_API_HOST +
 | 
			
		||||
            "/api/proxy/google/" +
 | 
			
		||||
            Google.ChatPath(modelConfig.model)
 | 
			
		||||
          : this.path(Google.ChatPath(modelConfig.model));
 | 
			
		||||
      if (!baseUrl && isApp) {
 | 
			
		||||
        baseUrl = DEFAULT_API_HOST + "/api/proxy/google/";
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      baseUrl = `${baseUrl}/${Google.ChatPath(modelConfig.model)}`.replaceAll(
 | 
			
		||||
        "//",
 | 
			
		||||
        "/",
 | 
			
		||||
      );
 | 
			
		||||
      if (isApp) {
 | 
			
		||||
        baseUrl += `?key=${accessStore.googleApiKey}`;
 | 
			
		||||
      }
 | 
			
		||||
 
 | 
			
		||||
@@ -35,6 +35,7 @@ export enum ApiPath {
 | 
			
		||||
  Azure = "/api/azure",
 | 
			
		||||
  OpenAI = "/api/openai",
 | 
			
		||||
  Anthropic = "/api/anthropic",
 | 
			
		||||
  Google = "/api/google",
 | 
			
		||||
  Baidu = "/api/baidu",
 | 
			
		||||
  ByteDance = "/api/bytedance",
 | 
			
		||||
  Alibaba = "/api/alibaba",
 | 
			
		||||
 
 | 
			
		||||
@@ -349,12 +349,12 @@ const cn = {
 | 
			
		||||
      },
 | 
			
		||||
      Baidu: {
 | 
			
		||||
        ApiKey: {
 | 
			
		||||
          Title: "接口密钥",
 | 
			
		||||
          Title: "API Key",
 | 
			
		||||
          SubTitle: "使用自定义 Baidu API Key",
 | 
			
		||||
          Placeholder: "Baidu API Key",
 | 
			
		||||
        },
 | 
			
		||||
        SecretKey: {
 | 
			
		||||
          Title: "接口密钥",
 | 
			
		||||
          Title: "Secret Key",
 | 
			
		||||
          SubTitle: "使用自定义 Baidu Secret Key",
 | 
			
		||||
          Placeholder: "Baidu Secret Key",
 | 
			
		||||
        },
 | 
			
		||||
 
 | 
			
		||||
@@ -12,15 +12,33 @@ import { DEFAULT_CONFIG } from "./config";
 | 
			
		||||
 | 
			
		||||
let fetchState = 0; // 0 not fetch, 1 fetching, 2 done
 | 
			
		||||
 | 
			
		||||
const DEFAULT_OPENAI_URL =
 | 
			
		||||
  getClientConfig()?.buildMode === "export"
 | 
			
		||||
    ? DEFAULT_API_HOST + "/api/proxy/openai"
 | 
			
		||||
    : ApiPath.OpenAI;
 | 
			
		||||
const isApp = getClientConfig()?.buildMode === "export";
 | 
			
		||||
 | 
			
		||||
const DEFAULT_AZURE_URL =
 | 
			
		||||
  getClientConfig()?.buildMode === "export"
 | 
			
		||||
    ? DEFAULT_API_HOST + "/api/proxy/azure/{resource_name}"
 | 
			
		||||
    : ApiPath.Azure;
 | 
			
		||||
const DEFAULT_OPENAI_URL = isApp
 | 
			
		||||
  ? DEFAULT_API_HOST + "/api/proxy/openai"
 | 
			
		||||
  : ApiPath.OpenAI;
 | 
			
		||||
 | 
			
		||||
const DEFAULT_GOOGLE_URL = isApp
 | 
			
		||||
  ? DEFAULT_API_HOST + "/api/proxy/google"
 | 
			
		||||
  : ApiPath.Google;
 | 
			
		||||
 | 
			
		||||
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 = {
 | 
			
		||||
  accessCode: "",
 | 
			
		||||
@@ -33,31 +51,31 @@ const DEFAULT_ACCESS_STATE = {
 | 
			
		||||
  openaiApiKey: "",
 | 
			
		||||
 | 
			
		||||
  // azure
 | 
			
		||||
  azureUrl: DEFAULT_AZURE_URL,
 | 
			
		||||
  azureUrl: "",
 | 
			
		||||
  azureApiKey: "",
 | 
			
		||||
  azureApiVersion: "2023-08-01-preview",
 | 
			
		||||
 | 
			
		||||
  // google ai studio
 | 
			
		||||
  googleUrl: "",
 | 
			
		||||
  googleUrl: DEFAULT_GOOGLE_URL,
 | 
			
		||||
  googleApiKey: "",
 | 
			
		||||
  googleApiVersion: "v1",
 | 
			
		||||
 | 
			
		||||
  // anthropic
 | 
			
		||||
  anthropicUrl: DEFAULT_ANTHROPIC_URL,
 | 
			
		||||
  anthropicApiKey: "",
 | 
			
		||||
  anthropicApiVersion: "2023-06-01",
 | 
			
		||||
  anthropicUrl: "",
 | 
			
		||||
 | 
			
		||||
  // baidu
 | 
			
		||||
  baiduUrl: "",
 | 
			
		||||
  baiduUrl: DEFAULT_BAIDU_URL,
 | 
			
		||||
  baiduApiKey: "",
 | 
			
		||||
  baiduSecretKey: "",
 | 
			
		||||
 | 
			
		||||
  // bytedance
 | 
			
		||||
  bytedanceUrl: DEFAULT_BYTEDANCE_URL,
 | 
			
		||||
  bytedanceApiKey: "",
 | 
			
		||||
  bytedanceUrl: "",
 | 
			
		||||
 | 
			
		||||
  // alibaba
 | 
			
		||||
  alibabaUrl: "",
 | 
			
		||||
  alibabaUrl: DEFAULT_ALIBABA_URL,
 | 
			
		||||
  alibabaApiKey: "",
 | 
			
		||||
 | 
			
		||||
  // server config
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user