added a script to add all documents (IWM articles) from a local folder. won't work on other machines
This commit is contained in:
+4
-1
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user