forked from XiaoMo/ChatGPT-Next-Web
perf: models接口返回数据的容错处理
This commit is contained in:
parent
9a285ab935
commit
6653a31eb7
@ -254,13 +254,15 @@ export class ChatGPTApi implements LLMApi {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const resJson = (await res.json()) as OpenAIListModelResponse;
|
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);
|
console.log("[Models]", chatModels);
|
||||||
|
|
||||||
return chatModels.map((m) => ({
|
return (
|
||||||
|
chatModels?.map((m) => ({
|
||||||
name: m.id,
|
name: m.id,
|
||||||
available: true,
|
available: true,
|
||||||
}));
|
})) || []
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export { OpenaiPath };
|
export { OpenaiPath };
|
||||||
|
Loading…
Reference in New Issue
Block a user