|
@@ -1,10 +1,10 @@
|
|
|
<script lang="ts">
|
|
|
import { getDocs } from '$lib/apis/documents';
|
|
|
import {
|
|
|
- getChunkParams,
|
|
|
+ getRAGConfig,
|
|
|
+ updateRAGConfig,
|
|
|
getQuerySettings,
|
|
|
scanDocs,
|
|
|
- updateChunkParams,
|
|
|
updateQuerySettings
|
|
|
} from '$lib/apis/rag';
|
|
|
import { documents } from '$lib/stores';
|
|
@@ -17,6 +17,7 @@
|
|
|
|
|
|
let chunkSize = 0;
|
|
|
let chunkOverlap = 0;
|
|
|
+ let pdfExtractImages = true;
|
|
|
|
|
|
let querySettings = {
|
|
|
template: '',
|
|
@@ -35,16 +36,24 @@
|
|
|
};
|
|
|
|
|
|
const submitHandler = async () => {
|
|
|
- const res = await updateChunkParams(localStorage.token, chunkSize, chunkOverlap);
|
|
|
+ const res = await updateRAGConfig(localStorage.token, {
|
|
|
+ pdf_extract_images: pdfExtractImages,
|
|
|
+ chunk: {
|
|
|
+ chunk_overlap: chunkOverlap,
|
|
|
+ chunk_size: chunkSize
|
|
|
+ }
|
|
|
+ });
|
|
|
querySettings = await updateQuerySettings(localStorage.token, querySettings);
|
|
|
};
|
|
|
|
|
|
onMount(async () => {
|
|
|
- const res = await getChunkParams(localStorage.token);
|
|
|
+ const res = await getRAGConfig(localStorage.token);
|
|
|
|
|
|
if (res) {
|
|
|
- chunkSize = res.chunk_size;
|
|
|
- chunkOverlap = res.chunk_overlap;
|
|
|
+ pdfExtractImages = res.pdf_extract_images;
|
|
|
+
|
|
|
+ chunkSize = res.chunk.chunk_size;
|
|
|
+ chunkOverlap = res.chunk.chunk_overlap;
|
|
|
}
|
|
|
|
|
|
querySettings = await getQuerySettings(localStorage.token);
|
|
@@ -124,82 +133,100 @@
|
|
|
|
|
|
<hr class=" dark:border-gray-700" />
|
|
|
|
|
|
- <div class=" ">
|
|
|
- <div class=" text-sm font-medium">Chunk Params</div>
|
|
|
-
|
|
|
- <div class=" flex">
|
|
|
- <div class=" flex w-full justify-between">
|
|
|
- <div class="self-center text-xs font-medium min-w-fit">Chunk Size</div>
|
|
|
-
|
|
|
- <div class="self-center p-3">
|
|
|
- <input
|
|
|
- class=" w-full rounded py-1.5 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none border border-gray-100 dark:border-gray-600"
|
|
|
- type="number"
|
|
|
- placeholder="Enter Chunk Size"
|
|
|
- bind:value={chunkSize}
|
|
|
- autocomplete="off"
|
|
|
- min="0"
|
|
|
- />
|
|
|
+ <div class=" space-y-3">
|
|
|
+ <div class=" space-y-3">
|
|
|
+ <div class=" text-sm font-medium">Chunk Params</div>
|
|
|
+
|
|
|
+ <div class=" flex gap-2">
|
|
|
+ <div class=" flex w-full justify-between gap-2">
|
|
|
+ <div class="self-center text-xs font-medium min-w-fit">Chunk Size</div>
|
|
|
+
|
|
|
+ <div class="self-center">
|
|
|
+ <input
|
|
|
+ class=" w-full rounded py-1.5 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none border border-gray-100 dark:border-gray-600"
|
|
|
+ type="number"
|
|
|
+ placeholder="Enter Chunk Size"
|
|
|
+ bind:value={chunkSize}
|
|
|
+ autocomplete="off"
|
|
|
+ min="0"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
|
|
|
- <div class="flex w-full">
|
|
|
- <div class=" self-center text-xs font-medium min-w-fit">Chunk Overlap</div>
|
|
|
-
|
|
|
- <div class="self-center p-3">
|
|
|
- <input
|
|
|
- class="w-full rounded py-1.5 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none border border-gray-100 dark:border-gray-600"
|
|
|
- type="number"
|
|
|
- placeholder="Enter Chunk Overlap"
|
|
|
- bind:value={chunkOverlap}
|
|
|
- autocomplete="off"
|
|
|
- min="0"
|
|
|
- />
|
|
|
+ <div class="flex w-full gap-2">
|
|
|
+ <div class=" self-center text-xs font-medium min-w-fit">Chunk Overlap</div>
|
|
|
+
|
|
|
+ <div class="self-center">
|
|
|
+ <input
|
|
|
+ class="w-full rounded py-1.5 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none border border-gray-100 dark:border-gray-600"
|
|
|
+ type="number"
|
|
|
+ placeholder="Enter Chunk Overlap"
|
|
|
+ bind:value={chunkOverlap}
|
|
|
+ autocomplete="off"
|
|
|
+ min="0"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
-
|
|
|
- <div class=" text-sm font-medium">Query Params</div>
|
|
|
|
|
|
- <div class=" flex">
|
|
|
- <div class=" flex w-full justify-between">
|
|
|
- <div class="self-center text-xs font-medium flex-1">Top K</div>
|
|
|
-
|
|
|
- <div class="self-center p-3">
|
|
|
- <input
|
|
|
- class=" w-full rounded py-1.5 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none border border-gray-100 dark:border-gray-600"
|
|
|
- type="number"
|
|
|
- placeholder="Enter Top K"
|
|
|
- bind:value={querySettings.k}
|
|
|
- autocomplete="off"
|
|
|
- min="0"
|
|
|
- />
|
|
|
+ <div>
|
|
|
+ <div class="flex justify-between items-center text-xs">
|
|
|
+ <div class=" text-xs font-medium">PDF Extract Images (OCR)</div>
|
|
|
+
|
|
|
+ <button
|
|
|
+ class=" text-xs font-medium text-gray-500"
|
|
|
+ type="button"
|
|
|
+ on:click={() => {
|
|
|
+ pdfExtractImages = !pdfExtractImages;
|
|
|
+ }}>{pdfExtractImages ? 'On' : 'Off'}</button
|
|
|
+ >
|
|
|
</div>
|
|
|
</div>
|
|
|
-
|
|
|
- <!-- <div class="flex w-full">
|
|
|
- <div class=" self-center text-xs font-medium min-w-fit">Chunk Overlap</div>
|
|
|
-
|
|
|
- <div class="self-center p-3">
|
|
|
- <input
|
|
|
- class="w-full rounded py-1.5 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none border border-gray-100 dark:border-gray-600"
|
|
|
- type="number"
|
|
|
- placeholder="Enter Chunk Overlap"
|
|
|
- bind:value={chunkOverlap}
|
|
|
- autocomplete="off"
|
|
|
- min="0"
|
|
|
- />
|
|
|
- </div>
|
|
|
- </div> -->
|
|
|
</div>
|
|
|
|
|
|
<div>
|
|
|
- <div class=" mb-2.5 text-sm font-medium">RAG Template</div>
|
|
|
- <textarea
|
|
|
- bind:value={querySettings.template}
|
|
|
- class="w-full rounded p-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none resize-none"
|
|
|
- rows="4"
|
|
|
- />
|
|
|
+ <div class=" text-sm font-medium">Query Params</div>
|
|
|
+
|
|
|
+ <div class=" flex py-2">
|
|
|
+ <div class=" flex w-full justify-between gap-2">
|
|
|
+ <div class="self-center text-xs font-medium flex-1">Top K</div>
|
|
|
+
|
|
|
+ <div class="self-center">
|
|
|
+ <input
|
|
|
+ class=" w-full rounded py-1.5 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none border border-gray-100 dark:border-gray-600"
|
|
|
+ type="number"
|
|
|
+ placeholder="Enter Top K"
|
|
|
+ bind:value={querySettings.k}
|
|
|
+ autocomplete="off"
|
|
|
+ min="0"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- <div class="flex w-full">
|
|
|
+ <div class=" self-center text-xs font-medium min-w-fit">Chunk Overlap</div>
|
|
|
+
|
|
|
+ <div class="self-center p-3">
|
|
|
+ <input
|
|
|
+ class="w-full rounded py-1.5 px-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none border border-gray-100 dark:border-gray-600"
|
|
|
+ type="number"
|
|
|
+ placeholder="Enter Chunk Overlap"
|
|
|
+ bind:value={chunkOverlap}
|
|
|
+ autocomplete="off"
|
|
|
+ min="0"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </div> -->
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div>
|
|
|
+ <div class=" mb-2.5 text-sm font-medium">RAG Template</div>
|
|
|
+ <textarea
|
|
|
+ bind:value={querySettings.template}
|
|
|
+ class="w-full rounded p-4 text-sm dark:text-gray-300 dark:bg-gray-800 outline-none resize-none"
|
|
|
+ rows="4"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|