From 645d7e9d917306969f23899dc97cefc42b7ef73e Mon Sep 17 00:00:00 2001 From: gramps Date: Mon, 13 Jul 2026 09:59:11 -0700 Subject: [PATCH] =?UTF-8?q?v0.17.19:=20fix=20token=20count=20badge=20?= =?UTF-8?q?=E2=80=94=20use=20client-side=20tokenCount=20instead=20of=20ser?= =?UTF-8?q?ver=20completion=5Ftokens;=20add=20tok=20badge=20to=20search=20?= =?UTF-8?q?responses?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.py | 2 +- templates/index.html | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/config.py b/config.py index 63f622c..58ff42a 100644 --- a/config.py +++ b/config.py @@ -9,7 +9,7 @@ import logging log = logging.getLogger("caic") -VERSION = "v0.17.18" +VERSION = "v0.17.19" OLLAMA_BASE = os.environ.get("OLLAMA_BASE", "http://localhost:11434") LLAMA_SERVER_BASE = os.environ.get("LLAMA_SERVER_BASE", "http://192.168.50.108:8081") SEARXNG_BASE = "http://localhost:8888" diff --git a/templates/index.html b/templates/index.html index 6822697..a4c0cd6 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1133,6 +1133,7 @@ async function sendSearch() { setStreamingState(true); const ttrStart = performance.now(); let ttr = 0; + let tokenCount = 0; try { abortController = new AbortController(); const resp = await authFetch('/api/search', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ conversation_id: currentConvId, query, model }), signal: abortController.signal }); @@ -1154,7 +1155,7 @@ async function sendSearch() { if (data.error) { textEl.textContent = 'Error: ' + data.error; setStreamingState(false); return; } if (data.conversation_id && !currentConvId) { currentConvId = data.conversation_id; await loadConversations(); } if (data.search_results) { textEl.innerHTML = '
🔍 Found ' + data.search_results + ' results, summarizing...
'; } - if (data.token) { if (firstToken) { textEl.innerHTML = ''; firstToken = false; ttr = performance.now() - ttrStart; } fullText += data.token; textEl.innerHTML = renderMarkdown(fullText); scrollToTop(); } + if (data.token) { if (firstToken) { textEl.innerHTML = ''; firstToken = false; ttr = performance.now() - ttrStart; tokenCount = 0; } fullText += data.token; tokenCount++; textEl.innerHTML = renderMarkdown(fullText); scrollToTop(); } if (data.raw_results) { let rawHtml = '
🔍 View raw search results (' + data.raw_results.length + ')