added a script to add all documents (IWM articles) from a local folder. won't work on other machines

This commit is contained in:
2026-02-04 15:31:24 +01:00
parent 62dc69374a
commit 4364ddcd71
4 changed files with 98 additions and 22 deletions
+4 -1
View File
@@ -140,6 +140,7 @@
const messagesEl = document.getElementById('messages');
const inputEl = document.getElementById('input');
const sendBtn = document.getElementById('send');
const chatHistory = [];
function appendMessage(role, text, isError = false) {
const div = document.createElement('div');
@@ -148,6 +149,7 @@
div.innerHTML = '<span class="label">' + label + '</span>' + escapeHtml(text);
messagesEl.appendChild(div);
messagesEl.scrollTop = messagesEl.scrollHeight;
chatHistory.push({ role: role, content: text });
}
function escapeHtml(s) {
@@ -179,10 +181,11 @@
setLoading(true);
try {
const history = chatHistory.slice(0, -1);
const res = await fetch('/api/chat', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ message: text })
body: JSON.stringify({ message: text, history: history })
});
const data = await res.json();
setLoading(false);