diff options
| -rw-r--r-- | src/umapyai/chat.html | 13 |
1 files changed, 9 insertions, 4 deletions
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; } |