Päivitetty juttuja

This commit is contained in:
Jaakko Vanhala
2026-04-04 21:13:20 +03:00
parent 2e7ddf6f1e
commit 3ada8949d0
11 changed files with 457 additions and 105 deletions

View File

@@ -384,6 +384,7 @@
height:500px;
overflow-y:auto;
text-align:left;
white-space: pre-wrap;
}
.terminal-line { margin: 4px 0; }
.terminal-prompt { color: #d29922; }
@@ -1696,8 +1697,8 @@
// Lähettää promptin mallille ja palauttaa vastauksen (tai null virhetilanteessa)
async function kpnRun(model, prompt, silent) {
termLog(` → <span style="color:#58a6ff">${model}</span> käsittelee...`, '#8b949e');
const taskId = crypto.randomUUID();
try {
const taskId = crypto.randomUUID();
const agent = Object.values(agentPrompts).find(a => a.model === model);
const parts = [];
if (sharedPrompt) parts.push(sharedPrompt);
@@ -1722,12 +1723,6 @@
body: JSON.stringify({ model, prompt: fullPrompt, task_id: taskId }),
});
// Poistetaan streaming-rivi
if (activeStreams[taskId]) {
activeStreams[taskId].remove();
delete activeStreams[taskId];
}
if (!res.ok) {
const errText = await res.text().catch(() => res.statusText);
termLog(`${errText}`, '#f85149');
@@ -1744,6 +1739,11 @@
} catch (e) {
termLog(`${e.message}`, '#f85149');
return null;
} finally {
if (activeStreams[taskId]) {
activeStreams[taskId].remove();
delete activeStreams[taskId];
}
}
}
@@ -1832,15 +1832,21 @@
}
if (sub === 'run') {
const model = parts[2];
let model = parts[2];
const afterModel = cmd.replace(/^kpn\s+run\s+\S+\s*/, '');
const promptMatch = afterModel.match(/^"(.+)"$|^'(.+)'$|^(.+)$/);
const prompt = (promptMatch && (promptMatch[1] || promptMatch[2] || promptMatch[3] || '')).trim();
if (!model || !prompt) {
termLog(' Käyttö: kpn run &lt;malli&gt; "&lt;prompti&gt;"', '#f85149');
termLog(' Käyttö: kpn run &lt;agentti/malli&gt; "&lt;prompti&gt;"', '#f85149');
return;
}
// Jos käyttäjä syötti agentin nimen (esim. "coder"), vaihdetaan se oikeaksi tekoälymalliksi ("qwen-coder")
if (agentPrompts[model]) {
model = agentPrompts[model].model;
}
kpnRun(model, prompt);
return;
}