diff options
| author | Fuwn <[email protected]> | 2025-07-30 11:09:39 +0200 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-07-30 11:09:39 +0200 |
| commit | 5cf1dbfd4871f0397dd3d6ec3e24edc89b49caae (patch) | |
| tree | f6a8622844d008d705e2e8b1114f60eefc08074a | |
| parent | refactor(umapyai): Update variable name (diff) | |
| download | umapyai-5cf1dbfd4871f0397dd3d6ec3e24edc89b49caae.tar.xz umapyai-5cf1dbfd4871f0397dd3d6ec3e24edc89b49caae.zip | |
feat(umapyai): Improve source pass-through
| -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; } |