De nuevo actulizar configuraciones con los modelos
This commit is contained in:
@@ -410,6 +410,7 @@ function SettingsTab({ user }) {
|
|||||||
try {
|
try {
|
||||||
const token = localStorage.getItem('token');
|
const token = localStorage.getItem('token');
|
||||||
const API_URL = import.meta.env.VITE_API_URL || '';
|
const API_URL = import.meta.env.VITE_API_URL || '';
|
||||||
|
|
||||||
// Cargar modelos disponibles
|
// Cargar modelos disponibles
|
||||||
const modelsRes = await fetch(`${API_URL}/api/ai/models`, {
|
const modelsRes = await fetch(`${API_URL}/api/ai/models`, {
|
||||||
headers: { 'Authorization': `Bearer ${token}` }
|
headers: { 'Authorization': `Bearer ${token}` }
|
||||||
@@ -418,22 +419,27 @@ function SettingsTab({ user }) {
|
|||||||
const models = await modelsRes.json();
|
const models = await modelsRes.json();
|
||||||
setAvailableModels(models);
|
setAvailableModels(models);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cargar configuración actual
|
// Cargar configuración actual
|
||||||
const configRes = await fetch(`${API_URL}/api/ai/configuration`, {
|
const configRes = await fetch(`${API_URL}/api/ai/configuration`, {
|
||||||
headers: { 'Authorization': `Bearer ${token}` }
|
headers: { 'Authorization': `Bearer ${token}` }
|
||||||
});
|
});
|
||||||
|
|
||||||
if (configRes.ok) {
|
if (configRes.ok) {
|
||||||
const config = await configRes.json();
|
const config = await configRes.json();
|
||||||
setAiConfig(config);
|
setAiConfig(config);
|
||||||
setFormData({
|
setFormData({
|
||||||
provider: config.provider,
|
provider: config.provider || 'openai',
|
||||||
api_key: config.api_key,
|
api_key: config.api_key || '',
|
||||||
model_name: config.model_name
|
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) {
|
} catch (error) {
|
||||||
console.error('Error loading settings:', error);
|
console.error('Error loading settings:', error);
|
||||||
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -529,7 +535,7 @@ function SettingsTab({ user }) {
|
|||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
type="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'}`}
|
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>
|
<div className="text-4xl mb-2">✨</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user