From 59ec47b2e8695eff6d9f07ea5a08b8f3d8592cd0 Mon Sep 17 00:00:00 2001 From: mic Date: Mon, 22 Jul 2024 23:35:54 +0200 Subject: [PATCH] fetchModels ouput are only the gpt- models ordered by id desc --- js/api/openai.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/js/api/openai.js b/js/api/openai.js index 40c99d01..1a91ad1e 100644 --- a/js/api/openai.js +++ b/js/api/openai.js @@ -45,7 +45,10 @@ export class OpenAI { console.log(err_msg); throw new Error(err_msg); } - return await response.json(); + + let output = await response.json(); + + return output.data.filter(item => item.id.startsWith('gpt-')).sort((a, b) => b.id.localeCompare(a.id)); } fetchResponse = async (model, messages, maxTokens = 0) => {