From 6653a31eb7e97d88affe88e3b58844632052e678 Mon Sep 17 00:00:00 2001 From: guochao <463561248@qq.com> Date: Thu, 6 Jul 2023 20:00:30 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=20models=E6=8E=A5=E5=8F=A3=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E6=95=B0=E6=8D=AE=E7=9A=84=E5=AE=B9=E9=94=99=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/client/platforms/openai.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/client/platforms/openai.ts b/app/client/platforms/openai.ts index 3384aeef..7e44909e 100644 --- a/app/client/platforms/openai.ts +++ b/app/client/platforms/openai.ts @@ -254,13 +254,15 @@ export class ChatGPTApi implements LLMApi { }); const resJson = (await res.json()) as OpenAIListModelResponse; - const chatModels = resJson.data.filter((m) => m.id.startsWith("gpt-")); + const chatModels = resJson.data?.filter((m) => m.id.startsWith("gpt-")); console.log("[Models]", chatModels); - return chatModels.map((m) => ({ - name: m.id, - available: true, - })); + return ( + chatModels?.map((m) => ({ + name: m.id, + available: true, + })) || [] + ); } } export { OpenaiPath };