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,