Skip to content

Commit

Permalink
Merge pull request ChatGPTNextWeb#5141 from ConnectAI-E/hotfix-google…
Browse files Browse the repository at this point in the history
…-api-in-app

hotfix for using google api in app
  • Loading branch information
Dogtiti authored Jul 30, 2024
2 parents 90e1fad + 64c3dcd commit c9eb9f3
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app/client/platforms/google.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ export class GeminiProApi implements LLMApi {
baseUrl = accessStore.googleUrl;
}

const isApp = !!getClientConfig()?.isApp;
if (baseUrl.length === 0) {
const isApp = !!getClientConfig()?.isApp;
baseUrl = isApp
? DEFAULT_API_HOST + `/api/proxy/google?key=${accessStore.googleApiKey}`
: ApiPath.Google;
baseUrl = isApp ? DEFAULT_API_HOST + `/api/proxy/google` : ApiPath.Google;
}
if (baseUrl.endsWith("/")) {
baseUrl = baseUrl.slice(0, baseUrl.length - 1);
Expand All @@ -43,6 +41,10 @@ export class GeminiProApi implements LLMApi {
let chatPath = [baseUrl, path].join("/");

chatPath += chatPath.includes("?") ? "&alt=sse" : "?alt=sse";
// if chatPath.startsWith('http') then add key in query string
if (chatPath.startsWith("http") && accessStore.googleApiKey) {
chatPath += `&key=${accessStore.googleApiKey}`;
}
return chatPath;
}
extractMessage(res: any) {
Expand Down

0 comments on commit c9eb9f3

Please sign in to comment.