feat(settings): bouton "Réinitialiser" fournisseur IA + correctif JS (page complète)
- Nouveau bouton « 🗑 Réinitialiser » dans Réglages → Agent & IA (réservé aux
admins) : bascule le fournisseur par défaut sur « hors-ligne » et efface la
clé API/base/état vérifié stockés (clear_keys dans set_llm_config).
- Confirmation avant suppression des clés API utilisateur (deleteUserKey).
- Correctif : chaîne JS de confirm("…") sur deux lignes provoquait une erreur
de syntaxe → le script alpine:init ne s'exécutait pas et la page paramètres
restait figée sur « Agent & AI » ; la chaîne est désormais sur une ligne.
This commit is contained in:
@@ -600,6 +600,7 @@
|
||||
<span x-show="!llmTesting">🔌 Tester la connexion</span>
|
||||
<span x-show="llmTesting">Test…</span>
|
||||
</button>
|
||||
<button class="btn" @click="resetGlobalLlm()" :disabled="llmSaving" x-show="llmDefaultProvider !== 'offline'" style="font-size:13px;color:var(--danger);">🗑 Réinitialiser</button>
|
||||
</div>
|
||||
<div style="margin-top:10px;font-size:12.5px;">
|
||||
<span x-show="llmMsg" x-text="llmMsg" :style="{color: llmMsgOk ? 'var(--toast-success-bg)' : 'var(--danger)'}"></span>
|
||||
@@ -1107,6 +1108,8 @@ document.addEventListener('alpine:init', function() {
|
||||
finally { f.testing = false; }
|
||||
},
|
||||
async deleteUserKey(id) {
|
||||
var pname = id.charAt(0).toUpperCase() + id.slice(1);
|
||||
if (!confirm('Supprimer la clé API pour ' + pname + ' ?\nLe fournisseur ne sera plus disponible dans le panneau Agent.')) return;
|
||||
var f = this.keyForm(id);
|
||||
f.deleting = true; f.msg = ''; f.ok = false;
|
||||
try {
|
||||
@@ -1185,6 +1188,31 @@ document.addEventListener('alpine:init', function() {
|
||||
} catch(e) { this.llmMsg = 'Erreur réseau'; }
|
||||
finally { this.llmSaving = false; }
|
||||
},
|
||||
async resetGlobalLlm() {
|
||||
if (!confirm("Réinitialiser le fournisseur par défaut à « hors-ligne » ?\nTous les utilisateurs perdront l'accès au fournisseur IA actuel.")) return;
|
||||
this.llmSaving = true;
|
||||
this.llmMsg = ''; this.llmMsgOk = false;
|
||||
try {
|
||||
var r = await this.adminFetch('/api/agent/providers', {
|
||||
method: 'PATCH',
|
||||
headers: {'Content-Type':'application/json'},
|
||||
body: JSON.stringify({provider: 'offline', model: '', api_key: '', api_base: ''})
|
||||
});
|
||||
var d = await r.json();
|
||||
if (r.ok) {
|
||||
this.llmForm = {provider: 'offline', model: '', api_key: '', api_base: ''};
|
||||
this.llmHasKey = false;
|
||||
this.llmDefaultProvider = 'offline';
|
||||
this.llmProviderModels = [];
|
||||
this.llmMsgOk = true;
|
||||
this.llmMsg = 'Fournisseur réinitialisé : mode hors-ligne actif.';
|
||||
this.syncLlmStatus();
|
||||
} else {
|
||||
this.llmMsg = d.detail || 'Erreur lors de la réinitialisation';
|
||||
}
|
||||
} catch(e) { this.llmMsg = 'Erreur réseau'; }
|
||||
finally { this.llmSaving = false; }
|
||||
},
|
||||
async testLlm() {
|
||||
if (!this.llmForm.provider) return;
|
||||
this.llmTesting = true;
|
||||
|
||||
Reference in New Issue
Block a user