fix model mismatch: validate selected model exists on custom API, fallback to default if not

This commit is contained in:
Russell Ballestrini 2025-07-11 00:31:52 -04:00
parent fd4cf9684b
commit f4f6ae6a9c

View file

@ -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,