Token-Optimierung: Prompt Caching + Tool-Result-Truncation in History
This commit is contained in:
1 parent
ec5917ef63
commit
f74409dd89
12 files changed
+220
-59
No files matched your search
@@ -112,6 +112,12 @@ async function apiExecCommand(sessionId, command) {
|
||||
});
|
||||
}
|
||||
|
||||
async function apiGetSystemPrompt(sessionId) {
|
||||
const resp = await fetch(`/api/sessions/${sessionId}/system-prompt`);
|
||||
if (!resp.ok) throw new Error('System-Prompt konnte nicht geladen werden');
|
||||
return resp.text();
|
||||
}
|
||||
|
||||
async function apiIsStreaming(sessionId) {
|
||||
const resp = await fetch(`/api/sessions/${sessionId}/streaming`);
|
||||
return resp.json();
|
||||
|
||||
@@ -183,6 +183,13 @@ registerPage('chat', {
|
||||
});
|
||||
}
|
||||
|
||||
// System-Prompt anzeigen
|
||||
const systemPromptBtn = document.getElementById('systemPromptBtn');
|
||||
if (systemPromptBtn) systemPromptBtn.addEventListener('click', () => {
|
||||
if (chatMenuDropdown) chatMenuDropdown.hidden = true;
|
||||
showSystemPromptModal(sessionId);
|
||||
});
|
||||
|
||||
// Archivieren
|
||||
const archiveBtn = document.getElementById('archiveBtn');
|
||||
if (archiveBtn) archiveBtn.addEventListener('click', () => {
|
||||
|
||||
@@ -409,6 +409,58 @@ async function loadAndShowAttachments(messageId, indicator) {
|
||||
}
|
||||
}
|
||||
|
||||
// ── System-Prompt Modal ──
|
||||
|
||||
async function showSystemPromptModal(sessionId) {
|
||||
// Overlay
|
||||
const overlay = document.createElement('div');
|
||||
overlay.className = 'sp-overlay';
|
||||
|
||||
// Modal
|
||||
const modal = document.createElement('div');
|
||||
modal.className = 'sp-modal';
|
||||
|
||||
// Header
|
||||
const header = document.createElement('div');
|
||||
header.className = 'sp-header';
|
||||
const title = document.createElement('span');
|
||||
title.textContent = 'System-Prompt';
|
||||
const closeBtn = document.createElement('button');
|
||||
closeBtn.textContent = '✕';
|
||||
closeBtn.className = 'sp-close';
|
||||
header.appendChild(title);
|
||||
header.appendChild(closeBtn);
|
||||
|
||||
// Body
|
||||
const body = document.createElement('div');
|
||||
body.className = 'sp-body markdown';
|
||||
body.innerHTML = '<div class="sp-loading">Laden...</div>';
|
||||
|
||||
modal.appendChild(header);
|
||||
modal.appendChild(body);
|
||||
overlay.appendChild(modal);
|
||||
document.body.appendChild(overlay);
|
||||
|
||||
// Schließen
|
||||
const close = () => overlay.remove();
|
||||
closeBtn.addEventListener('click', close);
|
||||
overlay.addEventListener('click', (e) => {
|
||||
if (e.target === overlay) close();
|
||||
});
|
||||
const onKey = (e) => {
|
||||
if (e.key === 'Escape') { close(); document.removeEventListener('keydown', onKey); }
|
||||
};
|
||||
document.addEventListener('keydown', onKey);
|
||||
|
||||
// Laden
|
||||
try {
|
||||
const prompt = await apiGetSystemPrompt(sessionId);
|
||||
body.innerHTML = renderMarkdown(prompt);
|
||||
} catch (e) {
|
||||
body.innerHTML = '<div class="sp-loading" style="color:var(--dangerous)">Fehler beim Laden des System-Prompts</div>';
|
||||
}
|
||||
}
|
||||
|
||||
// ── Meta Bar ──
|
||||
|
||||
function setMeta(text) {
|
||||
|
||||
Reference in new issue
Block a user