|
@@ -13,6 +13,7 @@ import {
|
|
|
fetchEventSource,
|
|
|
} from "@fortaine/fetch-event-source";
|
|
|
import { prettyObject } from "@/app/utils/format";
|
|
|
+import { getClientConfig } from "@/app/config/client";
|
|
|
|
|
|
export interface OpenAIListModelResponse {
|
|
|
object: string;
|
|
@@ -28,13 +29,16 @@ export class ChatGPTApi implements LLMApi {
|
|
|
|
|
|
path(path: string): string {
|
|
|
let openaiUrl = useAccessStore.getState().openaiUrl;
|
|
|
+ const apiPath = "/api/openai";
|
|
|
+
|
|
|
if (openaiUrl.length === 0) {
|
|
|
- openaiUrl = DEFAULT_API_HOST;
|
|
|
+ const isApp = !!getClientConfig()?.isApp;
|
|
|
+ openaiUrl = isApp ? DEFAULT_API_HOST : apiPath;
|
|
|
}
|
|
|
if (openaiUrl.endsWith("/")) {
|
|
|
openaiUrl = openaiUrl.slice(0, openaiUrl.length - 1);
|
|
|
}
|
|
|
- if (!openaiUrl.startsWith("http") && !openaiUrl.startsWith("/api/openai")) {
|
|
|
+ if (!openaiUrl.startsWith("http") && !openaiUrl.startsWith(apiPath)) {
|
|
|
openaiUrl = "https://" + openaiUrl;
|
|
|
}
|
|
|
return [openaiUrl, path].join("/");
|