hotfix: custom comfig for Gemini api. #4944

This commit is contained in:
lloydzhou 2024-07-12 21:27:30 +08:00
parent 9203870df5
commit 9b97dca601
3 changed files with 12 additions and 14 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

@ -17,10 +17,10 @@ const DEFAULT_OPENAI_URL =
? DEFAULT_API_HOST + "/api/proxy/openai" ? DEFAULT_API_HOST + "/api/proxy/openai"
: ApiPath.OpenAI; : ApiPath.OpenAI;
const DEFAULT_AZURE_URL = const DEFAULT_GOOGLE_URL =
getClientConfig()?.buildMode === "export" getClientConfig()?.buildMode === "export"
? DEFAULT_API_HOST + "/api/proxy/azure/{resource_name}" ? DEFAULT_API_HOST + "/api/proxy/google"
: ApiPath.Azure; : ApiPath.Google;
const DEFAULT_ACCESS_STATE = { const DEFAULT_ACCESS_STATE = {
accessCode: "", accessCode: "",
@ -33,12 +33,12 @@ 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",