toast fix
frdel committed
Dec 6, 2024 at 14:58 UTC
6aa37744fc9ca77271e33c195bf67a78dd7937a7
2 files changed
+10
-7
webui/index.js
+4
@@ -263,6 +263,7 @@ window.loadKnowledge = async function () {
263
input.multiple = true;
264
265
input.onchange = async () => {
266
+ try{
267
const formData = new FormData();
268
for (let file of input.files) {
269
formData.append('files[]', file);
@@ -279,6 +280,9 @@ window.loadKnowledge = async function () {
280
const data = await response.json();
281
toast("Knowledge files imported: " + data.filenames.join(", "), "success");
282
}
283
+ } catch (e) {
284
+ toastFetchError("Error loading knowledge", e)
285
+ }
286
};
287
288
input.click();
webui/js/history.js
+6
-7
@@ -3,26 +3,25 @@ import { getContext } from "../index.js";
3
export async function openHistoryModal() {
4
try {
5
const hist = await window.sendJsonData("/history_get", { context: getContext() });
6
+ const data = JSON.stringify(hist.history, null, 4);
7
+ const size = hist.tokens
8
+ await showEditorModal(data, "json", `History ~${size} tokens`, "Conversation history visible to the LLM. History is compressed to fit into the context window over time.");
9
} catch (e) {
10
window.toastFetchError("Error fetching history", e)
11
return
12
}
10
- const data = JSON.stringify(hist.history, null, 4);
11
- const size = hist.tokens
12
- await showEditorModal(data, "json", `History ~${size} tokens`, "Conversation history visible to the LLM. History is compressed to fit into the context window over time.");
13
-
13
}
14
15
export async function openCtxWindowModal() {
16
try {
17
const win = await window.sendJsonData("/ctx_window_get", { context: getContext() });
18
+ const data = win.content
19
+ const size = win.tokens
20
+ await showEditorModal(data, "markdown", `Context window ~${size} tokens`, "Data passed to the LLM during last interaction. Contains system message, conversation history and RAG.");
21
} catch (e) {
22
window.toastFetchError("Error fetching context", e)
23
return
24
}
23
- const data = win.content
24
- const size = win.tokens
25
- await showEditorModal(data, "markdown", `Context window ~${size} tokens`, "Data passed to the LLM during last interaction. Contains system message, conversation history and RAG.");
25
}
26
27
async function showEditorModal(data, type = "json", title, description = "") {