feat: explain-archive LLM endpoint + UI button v1.3.40
This commit is contained in:
@@ -100,7 +100,7 @@
|
||||
<div class="nubes">NUBES</div>
|
||||
<div class="product">FISSION CONSOLE</div>
|
||||
</div>
|
||||
<div style="font-size:0.65rem; color:var(--text-secondary); margin-left:10px; align-self:center; opacity:0.7;">v1.3.39</div>
|
||||
<div style="font-size:0.65rem; color:var(--text-secondary); margin-left:10px; align-self:center; opacity:0.7;">v1.3.40</div>
|
||||
</div>
|
||||
<div class="row" style="margin:0;">
|
||||
<button class="btn ghost" onclick="reloadAll()">Refresh</button>
|
||||
@@ -229,6 +229,7 @@
|
||||
<input type="file" id="c-archive-file" accept=".zip" style="display:block; margin-bottom:8px; color:var(--text-primary);">
|
||||
<div style="display:flex; gap:6px; flex-wrap:wrap;">
|
||||
<button id="c-lint-btn" class="btn ghost" onclick="lintArchiveFile('c')">🔍 Проверка архива линтером</button>
|
||||
<button id="c-explain-archive-btn" class="btn ghost" onclick="explainArchiveFile('c')">📖 LLM: Что делает?</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="c-gen-prompt" style="display:none; margin-top:8px; display:none; gap:6px; align-items:center;">
|
||||
@@ -307,6 +308,7 @@
|
||||
<input type="file" id="e-archive-file" accept=".zip" style="display:block; margin-bottom:8px; color:var(--text-primary);">
|
||||
<div style="display:flex; gap:6px; flex-wrap:wrap;">
|
||||
<button id="e-lint-btn" class="btn ghost" onclick="lintArchiveFile('e')">🔍 Проверка архива линтером</button>
|
||||
<button id="e-explain-archive-btn" class="btn ghost" onclick="explainArchiveFile('e')">📖 LLM: Что делает?</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="e-ai-result"
|
||||
@@ -398,7 +400,7 @@
|
||||
</div>
|
||||
|
||||
<div class="actions" style="justify-content:space-between; align-items:center;">
|
||||
<span style="font-size:0.75rem; color:var(--text-secondary);">v1.3.39</span>
|
||||
<span style="font-size:0.75rem; color:var(--text-secondary);">v1.3.40</span>
|
||||
<button class="btn ghost" onclick="closeHelp()">Закрыть</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -75,6 +75,53 @@ function lintArchiveFile(prefix) {
|
||||
});
|
||||
}
|
||||
|
||||
// explainArchiveFile — отправляет zip-архив на /console/api/ai/explain-archive,
|
||||
// показывает ответ LLM в блоке {prefix}-ai-result.
|
||||
function explainArchiveFile(prefix) {
|
||||
var input = document.getElementById(prefix + '-archive-file');
|
||||
var resEl = document.getElementById(prefix + '-ai-result');
|
||||
var btn = document.getElementById(prefix + '-explain-archive-btn');
|
||||
function showRes(text, bg, color) {
|
||||
if (resEl) {
|
||||
resEl.style.display = 'block';
|
||||
resEl.style.background = bg;
|
||||
resEl.style.color = color;
|
||||
resEl.textContent = text;
|
||||
}
|
||||
}
|
||||
if (!input || !input.files || !input.files[0]) {
|
||||
showRes('Выберите .zip файл', '#3a1a1a', '#f88');
|
||||
return;
|
||||
}
|
||||
var file = input.files[0];
|
||||
if (file.size > 100 * 1024) {
|
||||
showRes('Архив слишком большой: максимум 100 KB', '#3a1a1a', '#f88');
|
||||
return;
|
||||
}
|
||||
if (btn) { btn.disabled = true; btn.textContent = '⏳ Спрашиваю LLM…'; }
|
||||
showRes('Запрашиваю у LLM…', 'var(--bg-alt)', 'var(--fg)');
|
||||
var fd = new FormData();
|
||||
fd.append('archive', file);
|
||||
fetch(API_BASE + '/ai/explain-archive', {
|
||||
method: 'POST',
|
||||
headers: authHeaders(),
|
||||
body: fd
|
||||
})
|
||||
.then(function(r) { return r.json(); })
|
||||
.then(function(data) {
|
||||
if (btn) { btn.disabled = false; btn.textContent = '📖 LLM: Что делает?'; }
|
||||
if (data.error) {
|
||||
showRes('Ошибка: ' + data.error, '#3a2a00', '#ffa');
|
||||
return;
|
||||
}
|
||||
showRes(data.answer || '(пустой ответ)', '#1a2a3a', '#8cf');
|
||||
})
|
||||
.catch(function(e) {
|
||||
if (btn) { btn.disabled = false; btn.textContent = '📖 LLM: Что делает?'; }
|
||||
showRes('Ошибка сети: ' + e.message, '#3a2a00', '#ffa');
|
||||
});
|
||||
}
|
||||
|
||||
function parseMethods(v) {
|
||||
const items = String(v || '').split(',').map(s => s.trim().toUpperCase()).filter(Boolean);
|
||||
return items.length ? Array.from(new Set(items)) : ['GET'];
|
||||
|
||||
Reference in New Issue
Block a user