Feat: adjusted to handle indivdual rag config without disturbing default setting

This commit is contained in:
weberm1
2025-05-23 10:48:15 +02:00
parent b7023eb564
commit 5a1effb372
3 changed files with 22 additions and 9 deletions

View File

@@ -1,8 +1,11 @@
import { WEBUI_API_BASE_URL } from '$lib/constants';
export const uploadFile = async (token: string, file: File) => {
export const uploadFile = async (token: string, file: File, knowledge_id?: string) => {
const data = new FormData();
data.append('file', file);
if (knowledge_id) {
data.append('knowledge_id', knowledge_id);
}
let error = null;
const res = await fetch(`${WEBUI_API_BASE_URL}/files/`, {

View File

@@ -4,7 +4,8 @@ export const createNewKnowledge = async (
token: string,
name: string,
description: string,
accessControl: null | object
accessControl: null | object,
rag_config: null | object
) => {
let error = null;
@@ -18,7 +19,8 @@ export const createNewKnowledge = async (
body: JSON.stringify({
name: name,
description: description,
access_control: accessControl
access_control: accessControl,
rag_config: rag_config
})
})
.then(async (res) => {

View File

@@ -1,14 +1,17 @@
import { RETRIEVAL_API_BASE_URL } from '$lib/constants';
export const getRAGConfig = async (token: string) => {
export const getRAGConfig = async (token: string, collectionForm?: CollectionForm) => {
let error = null;
const res = await fetch(`${RETRIEVAL_API_BASE_URL}/config`, {
method: 'GET',
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`
}
},
body: JSON.stringify(
collectionForm ? {collectionForm: collectionForm} : {}
)
})
.then(async (res) => {
if (!res.ok) throw await res.json();
@@ -57,6 +60,7 @@ type RAGConfigForm = {
content_extraction?: ContentExtractConfigForm;
web_loader_ssl_verification?: boolean;
youtube?: YoutubeConfigForm;
knowledge_id?: string;
};
export const updateRAGConfig = async (token: string, payload: RAGConfigForm) => {
@@ -152,15 +156,18 @@ export const updateQuerySettings = async (token: string, settings: QuerySettings
return res;
};
export const getEmbeddingConfig = async (token: string) => {
export const getEmbeddingConfig = async (token: string, collectionForm?: CollectionForm) => {
let error = null;
const res = await fetch(`${RETRIEVAL_API_BASE_URL}/embedding`, {
method: 'GET',
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`
}
},
body: JSON.stringify(
collectionForm ? {collectionForm: collectionForm} : {}
)
})
.then(async (res) => {
if (!res.ok) throw await res.json();
@@ -189,6 +196,7 @@ type EmbeddingModelUpdateForm = {
embedding_engine: string;
embedding_model: string;
embedding_batch_size?: number;
knowledge_id?: string;
};
export const updateEmbeddingConfig = async (token: string, payload: EmbeddingModelUpdateForm) => {