From 70ea71c45569fbe8a6beec012f567ad9d177032b Mon Sep 17 00:00:00 2001 From: Yidadaa Date: Wed, 28 Jun 2023 23:12:35 +0800 Subject: [PATCH] feat: close #2175 use default api host if endpoint is empty --- app/client/platforms/openai.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/client/platforms/openai.ts b/app/client/platforms/openai.ts index fce7eee4e12..79d485562bb 100644 --- a/app/client/platforms/openai.ts +++ b/app/client/platforms/openai.ts @@ -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 { ChatOptions, getHeaders, LLMApi, LLMUsage } from "../api"; @@ -12,6 +16,9 @@ import { prettyObject } from "@/app/utils/format"; export class ChatGPTApi implements LLMApi { path(path: string): string { let openaiUrl = useAccessStore.getState().openaiUrl; + if (openaiUrl.length === 0) { + openaiUrl = DEFAULT_API_HOST; + } if (openaiUrl.endsWith("/")) { openaiUrl = openaiUrl.slice(0, openaiUrl.length - 1); }