From 81f1e2bc37e5aa5f01fc93e5d1baf13af5eb1772 Mon Sep 17 00:00:00 2001 From: nai-degen Date: Sun, 14 Jan 2024 05:33:24 -0600 Subject: [PATCH] fixes broken GET models endpoint for openai/mistral --- src/proxy/mistral-ai.ts | 4 +++- src/proxy/openai-image.ts | 4 +++- src/proxy/openai.ts | 6 ++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/proxy/mistral-ai.ts b/src/proxy/mistral-ai.ts index 619e4b2..0334c25 100644 --- a/src/proxy/mistral-ai.ts +++ b/src/proxy/mistral-ai.ts @@ -54,7 +54,9 @@ export function generateModelList(models = KNOWN_MISTRAL_AI_MODELS) { } const handleModelRequest: RequestHandler = (_req, res) => { - if (new Date().getTime() - modelsCacheTime < 1000 * 60) return modelsCache; + if (new Date().getTime() - modelsCacheTime < 1000 * 60){ + return res.status(200).json(modelsCache); + } const result = generateModelList(); modelsCache = { object: "list", data: result }; modelsCacheTime = new Date().getTime(); diff --git a/src/proxy/openai-image.ts b/src/proxy/openai-image.ts index f47107e..40803e6 100644 --- a/src/proxy/openai-image.ts +++ b/src/proxy/openai-image.ts @@ -25,7 +25,9 @@ const KNOWN_MODELS = ["dall-e-2", "dall-e-3"]; let modelListCache: any = null; let modelListValid = 0; const handleModelRequest: RequestHandler = (_req, res) => { - if (new Date().getTime() - modelListValid < 1000 * 60) return modelListCache; + if (new Date().getTime() - modelListValid < 1000 * 60) { + return res.status(200).json(modelListCache); + } const result = generateModelList(KNOWN_MODELS); modelListCache = { object: "list", data: result }; modelListValid = new Date().getTime(); diff --git a/src/proxy/openai.ts b/src/proxy/openai.ts index 499422b..48eb07e 100644 --- a/src/proxy/openai.ts +++ b/src/proxy/openai.ts @@ -35,7 +35,7 @@ export const KNOWN_OPENAI_MODELS = [ "gpt-4-0314", // EOL 2024-06-13 "gpt-4-32k", "gpt-4-32k-0613", - "gpt-4-32k-0314", // EOL 2024-06-13 + // "gpt-4-32k-0314", // EOL 2024-06-13 "gpt-3.5-turbo", "gpt-3.5-turbo-0301", // EOL 2024-06-13 "gpt-3.5-turbo-0613", @@ -83,7 +83,9 @@ export function generateModelList(models = KNOWN_OPENAI_MODELS) { } const handleModelRequest: RequestHandler = (_req, res) => { - if (new Date().getTime() - modelsCacheTime < 1000 * 60) return modelsCache; + if (new Date().getTime() - modelsCacheTime < 1000 * 60) { + return res.status(200).json(modelsCache); + } const result = generateModelList(); modelsCache = { object: "list", data: result }; modelsCacheTime = new Date().getTime();