From 04e7e71e2e347c56b223db63558124942ec2bb72 Mon Sep 17 00:00:00 2001 From: Russell Ballestrini Date: Fri, 11 Jul 2025 15:36:23 -0400 Subject: [PATCH] fix model refresh: include custom endpoint in model fetching when checkbox is checked regardless of current model routing --- src/models.js | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/models.js b/src/models.js index 11aadf1..6c2152a 100644 --- a/src/models.js +++ b/src/models.js @@ -42,13 +42,15 @@ export async function fetchModelsFromEndpoints() { // Collect endpoints to fetch from const endpointsToFetch = [...VLLM_ENDPOINTS]; - // Add custom API endpoint if configured - const apiConfig = await getAPIConfig(); - if (apiConfig.isCustom) { - console.log("🔧 Adding custom API endpoint to model fetch:", apiConfig.endpoint); + // Add custom API endpoint if the checkbox is checked (regardless of current model routing) + const useCustomAPI = localStorage.getItem("useCustomAPI") === "true"; + const customBaseURL = localStorage.getItem("customBaseURL"); + + if (useCustomAPI && customBaseURL) { + console.log("🔧 Adding custom API endpoint to model fetch:", customBaseURL); endpointsToFetch.push({ - id: apiConfig.endpoint, - url: apiConfig.endpoint + id: customBaseURL, + url: customBaseURL }); } else { console.log("🏠 No custom API configured, using default endpoints only"); @@ -64,8 +66,11 @@ export async function fetchModelsFromEndpoints() { }; // Add authorization for custom API - if (endpoint.id === apiConfig.endpoint && apiConfig.isCustom) { - headers["Authorization"] = `Bearer ${apiConfig.apiKey}`; + if (endpoint.id === customBaseURL && useCustomAPI) { + const customAPIKey = localStorage.getItem("customAPIKey"); + if (customAPIKey) { + headers["Authorization"] = `Bearer ${customAPIKey}`; + } } const res = await fetch(`${endpoint.url}/models`, { headers });