From 5cf1dbfd4871f0397dd3d6ec3e24edc89b49caae Mon Sep 17 00:00:00 2001 From: Fuwn Date: Wed, 30 Jul 2025 11:09:39 +0200 Subject: feat(umapyai): Improve source pass-through --- src/umapyai/chat.html | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/umapyai/chat.html b/src/umapyai/chat.html index b339dab..da48461 100644 --- a/src/umapyai/chat.html +++ b/src/umapyai/chat.html @@ -185,7 +185,7 @@ let sendButton = document.getElementById("send-button"); let chat = []; let history = null; - let ragHistory = []; + let allSources = new Set(); let currentAIMessage = null; const webSocket = new WebSocket(`ws://${window.location.host}/api/ask`); @@ -193,13 +193,18 @@ const response = JSON.parse(event.data); if (response.type === "sources") { - currentAIMessage.sources = response.data; + const newSources = response.data + .split(",") + .map((s) => s.trim()) + .filter(Boolean); + + newSources.forEach((src) => allSources.add(src)); + + currentAIMessage.sources = Array.from(allSources).join(", "); } else if (response.type === "answer_chunk") { currentAIMessage.text += response.data; } else if (response.type === "history") { history = response.data; - } else if (response.type === "rag_context") { - ragHistory.push(response.data); } else if (response.type === "error") { currentAIMessage.text += "\n\nError: " + response.data; } -- cgit v1.2.3