forked from XiaoMo/ChatGPT-Next-Web
feat: close #2175 use default api host if endpoint is empty
This commit is contained in:
parent
64c4f512ce
commit
0140f771c6
@ -1,4 +1,8 @@
|
|||||||
import { OpenaiPath, REQUEST_TIMEOUT_MS } from "@/app/constant";
|
import {
|
||||||
|
DEFAULT_API_HOST,
|
||||||
|
OpenaiPath,
|
||||||
|
REQUEST_TIMEOUT_MS,
|
||||||
|
} from "@/app/constant";
|
||||||
import { useAccessStore, useAppConfig, useChatStore } from "@/app/store";
|
import { useAccessStore, useAppConfig, useChatStore } from "@/app/store";
|
||||||
|
|
||||||
import { ChatOptions, getHeaders, LLMApi, LLMUsage } from "../api";
|
import { ChatOptions, getHeaders, LLMApi, LLMUsage } from "../api";
|
||||||
@ -12,6 +16,9 @@ import { prettyObject } from "@/app/utils/format";
|
|||||||
export class ChatGPTApi implements LLMApi {
|
export class ChatGPTApi implements LLMApi {
|
||||||
path(path: string): string {
|
path(path: string): string {
|
||||||
let openaiUrl = useAccessStore.getState().openaiUrl;
|
let openaiUrl = useAccessStore.getState().openaiUrl;
|
||||||
|
if (openaiUrl.length === 0) {
|
||||||
|
openaiUrl = DEFAULT_API_HOST;
|
||||||
|
}
|
||||||
if (openaiUrl.endsWith("/")) {
|
if (openaiUrl.endsWith("/")) {
|
||||||
openaiUrl = openaiUrl.slice(0, openaiUrl.length - 1);
|
openaiUrl = openaiUrl.slice(0, openaiUrl.length - 1);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user