+
diff --git a/src/lib/utils/rag/index.ts b/src/lib/utils/rag/index.ts
index 6b219ef2..ba1f29f8 100644
--- a/src/lib/utils/rag/index.ts
+++ b/src/lib/utils/rag/index.ts
@@ -1,17 +1,21 @@
-export const RAGTemplate = (context: string, query: string) => {
- let template = `Use the following context as your learned knowledge, inside XML tags.
-
- [context]
-
-
- When answer to user:
- - If you don't know, just say that you don't know.
- - If you don't know when you are not sure, ask for clarification.
- Avoid mentioning that you obtained the information from the context.
- And answer according to the language of the user's question.
-
- Given the context information, answer the query.
- Query: [query]`;
+import { getRAGTemplate } from '$lib/apis/rag';
+
+export const RAGTemplate = async (token: string, context: string, query: string) => {
+ let template = await getRAGTemplate(token).catch(() => {
+ return `Use the following context as your learned knowledge, inside XML tags.
+
+ [context]
+
+
+ When answer to user:
+ - If you don't know, just say that you don't know.
+ - If you don't know when you are not sure, ask for clarification.
+ Avoid mentioning that you obtained the information from the context.
+ And answer according to the language of the user's question.
+
+ Given the context information, answer the query.
+ Query: [query]`;
+ });
template = template.replace(/\[context\]/g, context);
template = template.replace(/\[query\]/g, query);
diff --git a/src/routes/(app)/+page.svelte b/src/routes/(app)/+page.svelte
index 604cb544..1d91a614 100644
--- a/src/routes/(app)/+page.svelte
+++ b/src/routes/(app)/+page.svelte
@@ -266,7 +266,11 @@
console.log(contextString);
- history.messages[parentId].raContent = RAGTemplate(contextString, query);
+ history.messages[parentId].raContent = await RAGTemplate(
+ localStorage.token,
+ contextString,
+ query
+ );
history.messages[parentId].contexts = relevantContexts;
await tick();
processing = '';
diff --git a/src/routes/(app)/c/[id]/+page.svelte b/src/routes/(app)/c/[id]/+page.svelte
index aab03d74..b719ebf2 100644
--- a/src/routes/(app)/c/[id]/+page.svelte
+++ b/src/routes/(app)/c/[id]/+page.svelte
@@ -280,7 +280,11 @@
console.log(contextString);
- history.messages[parentId].raContent = RAGTemplate(contextString, query);
+ history.messages[parentId].raContent = await RAGTemplate(
+ localStorage.token,
+ contextString,
+ query
+ );
history.messages[parentId].contexts = relevantContexts;
await tick();
processing = '';
diff --git a/src/routes/(app)/documents/+page.svelte b/src/routes/(app)/documents/+page.svelte
index a5653483..ab3d6553 100644
--- a/src/routes/(app)/documents/+page.svelte
+++ b/src/routes/(app)/documents/+page.svelte
@@ -13,6 +13,7 @@
import EditDocModal from '$lib/components/documents/EditDocModal.svelte';
import AddFilesPlaceholder from '$lib/components/AddFilesPlaceholder.svelte';
+ import SettingsModal from '$lib/components/documents/SettingsModal.svelte';
let importFiles = '';
let inputFiles = '';
@@ -20,6 +21,7 @@
let tags = [];
+ let showSettingsModal = false;
let showEditDocModal = false;
let selectedDoc;
let selectedTag = '';
@@ -179,11 +181,38 @@
}}
/>
+
+