From cbfab59222af1d64bb851319be97ebae035d9868 Mon Sep 17 00:00:00 2001 From: ronalds Date: Wed, 26 Nov 2025 00:31:25 -0300 Subject: [PATCH] De nuevo actulizar configuraciones con los modelos --- frontend/src/App.jsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index 7ec7538..5661136 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -410,6 +410,7 @@ function SettingsTab({ user }) { try { const token = localStorage.getItem('token'); const API_URL = import.meta.env.VITE_API_URL || ''; + // Cargar modelos disponibles const modelsRes = await fetch(`${API_URL}/api/ai/models`, { headers: { 'Authorization': `Bearer ${token}` } @@ -418,22 +419,27 @@ function SettingsTab({ user }) { const models = await modelsRes.json(); setAvailableModels(models); } + // Cargar configuración actual const configRes = await fetch(`${API_URL}/api/ai/configuration`, { headers: { 'Authorization': `Bearer ${token}` } }); + if (configRes.ok) { const config = await configRes.json(); setAiConfig(config); setFormData({ - provider: config.provider, - api_key: config.api_key, - model_name: config.model_name + provider: config.provider || 'openai', + api_key: config.api_key || '', + model_name: config.model_name || 'gpt-4o' }); + } else if (configRes.status === 404) { + // No hay configuración guardada, usar valores por defecto + console.log('No hay configuración de IA guardada'); } - setLoading(false); } catch (error) { console.error('Error loading settings:', error); + } finally { setLoading(false); } }; @@ -529,7 +535,7 @@ function SettingsTab({ user }) {