mirror of
https://github.com/open-webui/open-webui
synced 2025-06-23 02:16:52 +00:00
Feat: Added rag config settings and adjusted file uploads to handle individual rag config
This commit is contained in:
parent
fd3a4f2b28
commit
baeecbb9d1
@ -45,6 +45,7 @@
|
||||
import ChevronLeft from '$lib/components/icons/ChevronLeft.svelte';
|
||||
import LockClosed from '$lib/components/icons/LockClosed.svelte';
|
||||
import AccessControlModal from '../common/AccessControlModal.svelte';
|
||||
import RagConfigModal from '../common/RagConfigModal.svelte';
|
||||
|
||||
let largeScreen = true;
|
||||
|
||||
@ -69,7 +70,8 @@
|
||||
let showAddTextContentModal = false;
|
||||
let showSyncConfirmModal = false;
|
||||
let showAccessControlModal = false;
|
||||
|
||||
let showRagConfigModal = false;
|
||||
|
||||
let inputFiles = null;
|
||||
|
||||
let filteredItems = [];
|
||||
@ -118,7 +120,7 @@
|
||||
return file;
|
||||
};
|
||||
|
||||
const uploadFileHandler = async (file) => {
|
||||
const uploadFileHandler = async (file, knowledgeId) => {
|
||||
console.log(file);
|
||||
|
||||
const tempItemId = uuidv4();
|
||||
@ -158,7 +160,7 @@
|
||||
knowledge.files = [...(knowledge.files ?? []), fileItem];
|
||||
|
||||
try {
|
||||
const uploadedFile = await uploadFile(localStorage.token, file).catch((e) => {
|
||||
const uploadedFile = await uploadFile(localStorage.token, file, knowledgeId).catch((e) => {
|
||||
toast.error(`${e}`);
|
||||
return null;
|
||||
});
|
||||
@ -249,7 +251,7 @@
|
||||
const file = await entry.getFile();
|
||||
const fileWithPath = new File([file], entryPath, { type: file.type });
|
||||
|
||||
await uploadFileHandler(fileWithPath);
|
||||
await uploadFileHandler(fileWithPath, id);
|
||||
uploadedFiles++;
|
||||
updateProgress();
|
||||
} else if (entry.kind === 'directory') {
|
||||
@ -311,7 +313,7 @@
|
||||
const relativePath = file.webkitRelativePath || file.name;
|
||||
const fileWithPath = new File([file], relativePath, { type: file.type });
|
||||
|
||||
await uploadFileHandler(fileWithPath);
|
||||
await uploadFileHandler(fileWithPath, id);
|
||||
uploadedFiles++;
|
||||
updateProgress();
|
||||
}
|
||||
@ -509,7 +511,7 @@
|
||||
|
||||
if (inputFiles && inputFiles.length > 0) {
|
||||
for (const file of inputFiles) {
|
||||
await uploadFileHandler(file);
|
||||
await uploadFileHandler(file, id);
|
||||
}
|
||||
} else {
|
||||
toast.error($i18n.t(`File not found.`));
|
||||
@ -628,7 +630,7 @@
|
||||
bind:show={showAddTextContentModal}
|
||||
on:submit={(e) => {
|
||||
const file = createFileFromText(e.detail.name, e.detail.content);
|
||||
uploadFileHandler(file);
|
||||
uploadFileHandler(file, id);
|
||||
}}
|
||||
/>
|
||||
|
||||
@ -641,7 +643,7 @@
|
||||
on:change={async () => {
|
||||
if (inputFiles && inputFiles.length > 0) {
|
||||
for (const file of inputFiles) {
|
||||
await uploadFileHandler(file);
|
||||
await uploadFileHandler(file, id);
|
||||
}
|
||||
|
||||
inputFiles = null;
|
||||
@ -667,6 +669,16 @@
|
||||
}}
|
||||
accessRoles={['read', 'write']}
|
||||
/>
|
||||
{#if knowledge.rag_config.DEFAULT_RAG_SETTINGS == false}
|
||||
<RagConfigModal
|
||||
bind:show={showRagConfigModal}
|
||||
RAGConfig={knowledge.rag_config}
|
||||
knowledgeId={knowledge.id}
|
||||
on:update={(e) => {
|
||||
knowledge.rag_config = e.detail; // sync updated config
|
||||
}}
|
||||
/>
|
||||
{/if}
|
||||
<div class="w-full mb-2.5">
|
||||
<div class=" flex w-full">
|
||||
<div class="flex-1">
|
||||
@ -698,6 +710,33 @@
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{#if knowledge.rag_config.DEFAULT_RAG_SETTINGS == false}
|
||||
<button
|
||||
class="bg-gray-50 hover:bg-gray-100 text-black dark:bg-gray-850 dark:hover:bg-gray-800 dark:text-white transition px-2 py-1 rounded-full flex gap-1 items-center"
|
||||
style="width: 150px;"
|
||||
type="button"
|
||||
on:click={() => {
|
||||
showRagConfigModal = true;
|
||||
}}
|
||||
>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 16 16"
|
||||
fill="currentColor"
|
||||
class="w-4 h-4"
|
||||
>
|
||||
<path
|
||||
fill-rule="evenodd"
|
||||
d="M6.955 1.45A.5.5 0 0 1 7.452 1h1.096a.5.5 0 0 1 .497.45l.17 1.699c.484.12.94.312 1.356.562l1.321-1.081a.5.5 0 0 1 .67.033l.774.775a.5.5 0 0 1 .034.67l-1.08 1.32c.25.417.44.873.561 1.357l1.699.17a.5.5 0 0 1 .45.497v1.096a.5.5 0 0 1-.45.497l-1.699.17c-.12.484-.312.94-.562 1.356l1.082 1.322a.5.5 0 0 1-.034.67l-.774.774a.5.5 0 0 1-.67.033l-1.322-1.08c-.416.25-.872.44-1.356.561l-.17 1.699a.5.5 0 0 1-.497.45H7.452a.5.5 0 0 1-.497-.45l-.17-1.699a4.973 4.973 0 0 1-1.356-.562L4.108 13.37a.5.5 0 0 1-.67-.033l-.774-.775a.5.5 0 0 1-.034-.67l1.08-1.32a4.971 4.971 0 0 1-.561-1.357l-1.699-.17A.5.5 0 0 1 1 8.548V7.452a.5.5 0 0 1 .45-.497l1.699-.17c.12-.484.312-.94.562-1.356L2.629 4.107a.5.5 0 0 1 .034-.67l.774-.774a.5.5 0 0 1 .67-.033L5.43 3.71a4.97 4.97 0 0 1 1.356-.561l.17-1.699ZM6 8c0 .538.212 1.026.558 1.385l.057.057a2 2 0 0 0 2.828-2.828l-.058-.056A2 2 0 0 0 6 8Z"
|
||||
clip-rule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
<div class="text-sm font-medium shrink-0">
|
||||
{$i18n.t('RAG Config')}
|
||||
</div>
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class="flex w-full px-1">
|
||||
|
Loading…
Reference in New Issue
Block a user