De nuevo actulizar configuraciones con los modelos
This commit is contained in:
@@ -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 }) {
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setFormData({ ...formData, provider: 'gemini', model_name: 'gemini-1.5-pro' })}
|
||||
onClick={() => setFormData({ ...formData, provider: 'gemini', model_name: 'gemini-2.5-pro' })}
|
||||
className={`p-4 border-2 rounded-lg transition ${formData.provider === 'gemini' ? 'border-blue-500 bg-blue-50' : 'border-gray-300 hover:border-gray-400'}`}
|
||||
>
|
||||
<div className="text-4xl mb-2">✨</div>
|
||||
|
||||
Reference in New Issue
Block a user