diff --git a/frontend/src/pages/SettingsPage.tsx b/frontend/src/pages/SettingsPage.tsx index 9d688d9..91435e4 100644 --- a/frontend/src/pages/SettingsPage.tsx +++ b/frontend/src/pages/SettingsPage.tsx @@ -558,12 +558,6 @@ const SettingsPage: React.FC = () => { }); }; - const saveSmartRoutingConfig = async ( - key: 'dbUrl' | 'openaiApiBaseUrl' | 'openaiApiKey' | 'openaiApiEmbeddingModel', - ) => { - await updateSmartRoutingConfig(key, tempSmartRoutingConfig[key]); - }; - const handleMCPRouterConfigChange = ( key: 'apiKey' | 'referer' | 'title' | 'baseUrl', value: string, @@ -705,6 +699,31 @@ const SettingsPage: React.FC = () => { } }; + const handleSaveSmartRoutingConfig = async () => { + const updates: any = {}; + + if (tempSmartRoutingConfig.dbUrl !== smartRoutingConfig.dbUrl) { + updates.dbUrl = tempSmartRoutingConfig.dbUrl; + } + if (tempSmartRoutingConfig.openaiApiBaseUrl !== smartRoutingConfig.openaiApiBaseUrl) { + updates.openaiApiBaseUrl = tempSmartRoutingConfig.openaiApiBaseUrl; + } + if (tempSmartRoutingConfig.openaiApiKey !== smartRoutingConfig.openaiApiKey) { + updates.openaiApiKey = tempSmartRoutingConfig.openaiApiKey; + } + if ( + tempSmartRoutingConfig.openaiApiEmbeddingModel !== smartRoutingConfig.openaiApiEmbeddingModel + ) { + updates.openaiApiEmbeddingModel = tempSmartRoutingConfig.openaiApiEmbeddingModel; + } + + if (Object.keys(updates).length > 0) { + await updateSmartRoutingConfigBatch(updates); + } else { + showToast(t('settings.noChanges') || 'No changes to save', 'info'); + } + }; + const handlePasswordChangeSuccess = () => { setTimeout(() => { navigate('/'); @@ -1230,13 +1249,6 @@ const SettingsPage: React.FC = () => { className="flex-1 mt-1 block w-full py-2 px-3 border rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm border-gray-300 form-input" disabled={loading} /> - @@ -1256,13 +1268,6 @@ const SettingsPage: React.FC = () => { className="flex-1 mt-1 block w-full py-2 px-3 border rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm border-gray-300" disabled={loading} /> - @@ -1281,13 +1286,6 @@ const SettingsPage: React.FC = () => { className="flex-1 mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm form-input" disabled={loading} /> - @@ -1308,15 +1306,18 @@ const SettingsPage: React.FC = () => { className="flex-1 mt-1 block w-full py-2 px-3 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm form-input" disabled={loading} /> - + +
+ +
)}