From f4f6ae6a9c2a180a01c459338393dd230860312d Mon Sep 17 00:00:00 2001 From: Russell Ballestrini Date: Fri, 11 Jul 2025 00:31:52 -0400 Subject: [PATCH] fix model mismatch: validate selected model exists on custom API, fallback to default if not --- src/config.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/config.js b/src/config.js index ea5c4ca..c9ff212 100644 --- a/src/config.js +++ b/src/config.js @@ -80,9 +80,29 @@ export async function getAPIConfig() { if (customBaseURL && customAPIKey) { // Import model functions to get the currently selected model - const { getSelectedModel } = await import("./models.js"); + const { getSelectedModel, modelRegistry } = await import("./models.js"); const selectedModel = getSelectedModel(); + // Check if the selected model is from the custom API endpoint + const selectedModelEntry = Object.entries(modelRegistry).find(([uniqueId, data]) => + data.modelName === selectedModel && data.endpointId === customBaseURL + ); + + if (!selectedModelEntry) { + console.warn("⚠️ Selected model not available on custom API, falling back to default"); + // Return default configuration instead + console.log("🏠 Using DEFAULT Hermes API (model mismatch)"); + return { + isCustom: false, + endpoints: VLLM_ENDPOINTS, + model: MODEL, + apiKey: API_KEY, + headers: { + "Content-Type": "application/json" + } + }; + } + console.log("🔧 Using CUSTOM API:", { endpoint: customBaseURL, model: selectedModel,