From 78ed2e4d883330ea98ca212da76d45635dc7b7ee Mon Sep 17 00:00:00 2001 From: silence Date: Sun, 3 Dec 2023 23:07:43 +0800 Subject: [PATCH] =?UTF-8?q?feat(access):=20llm=20=E6=8A=BD=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/client/platforms/openai.ts | 3 ++- app/requests.ts | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/client/platforms/openai.ts b/app/client/platforms/openai.ts index 8f22701db0f..2735150f10c 100644 --- a/app/client/platforms/openai.ts +++ b/app/client/platforms/openai.ts @@ -263,6 +263,7 @@ export class ChatGPTApi implements LLMApi { const controller = new AbortController(); const reqTimeoutId = setTimeout(() => controller.abort(), TIME_OUT_MS); options?.onController?.(controller); + let imagePath = this.path(OpenaiPath.ImagePath); async function fetchImageAndUpdateMessage() { try { @@ -271,7 +272,7 @@ export class ChatGPTApi implements LLMApi { const sanitizedMessage = keyword.replace(/[\n\r]+/g, " "); const req = makeImageRequestParam(sanitizedMessage); - const res = await requestOpenaiClient(OpenaiPath.ImagePath)(req); + const res = await requestOpenaiClient(imagePath)(req); clearTimeout(reqTimeoutId); diff --git a/app/requests.ts b/app/requests.ts index a6190fcacfa..a5b024bc3f4 100644 --- a/app/requests.ts +++ b/app/requests.ts @@ -63,10 +63,9 @@ export function getHeaders() { return headers; } -export function requestOpenaiClient(path: string) { - const openaiUrl = useAccessStore.getState().openaiUrl; +export function requestOpenaiClient(url: string) { return (body: any, method = "POST") => - fetch(openaiUrl + path, { + fetch(url, { method, body: body && JSON.stringify(body), headers: getHeaders(),