Skip to content

Commit

Permalink
hotfix: custom comfig for Gemini api. ChatGPTNextWeb#4944
Browse files Browse the repository at this point in the history
  • Loading branch information
lloydzhou authored and sijinhui committed Jul 17, 2024
1 parent 2cfdf34 commit c3eaa47
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
15 changes: 6 additions & 9 deletions app/client/platforms/google.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
}
Expand Down
1 change: 1 addition & 0 deletions app/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,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",
Expand Down
10 changes: 5 additions & 5 deletions app/store/access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ const DEFAULT_OPENAI_URL =
? DEFAULT_API_HOST + "/api/proxy/openai"
: ApiPath.OpenAI;

const DEFAULT_AZURE_URL =
const DEFAULT_GOOGLE_URL =
getClientConfig()?.buildMode === "export"
? DEFAULT_API_HOST + "/api/proxy/azure/{resource_name}"
: ApiPath.Azure;
? DEFAULT_API_HOST + "/api/proxy/google"
: ApiPath.Google;

const DEFAULT_ACCESS_STATE = {
accessCode: "",
Expand All @@ -33,13 +33,13 @@ const DEFAULT_ACCESS_STATE = {
openaiApiKey: "",

// azure
azureUrl: DEFAULT_AZURE_URL,
azureUrl: "",
azureApiKey: "",
azureApiVersion: "2023-05-15",
azureVoiceKey: "",

// google ai studio
googleUrl: "",
googleUrl: DEFAULT_GOOGLE_URL,
googleApiKey: "",
googleApiVersion: "v1",

Expand Down

0 comments on commit c3eaa47

Please sign in to comment.