diff --git a/src/lib/apis/files/index.ts b/src/lib/apis/files/index.ts index 261fe56db..32fd8121f 100644 --- a/src/lib/apis/files/index.ts +++ b/src/lib/apis/files/index.ts @@ -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/`, { diff --git a/src/lib/apis/knowledge/index.ts b/src/lib/apis/knowledge/index.ts index c01c986a2..888c90c6b 100644 --- a/src/lib/apis/knowledge/index.ts +++ b/src/lib/apis/knowledge/index.ts @@ -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) => { diff --git a/src/lib/apis/retrieval/index.ts b/src/lib/apis/retrieval/index.ts index 8fa6578ed..7415af6c3 100644 --- a/src/lib/apis/retrieval/index.ts +++ b/src/lib/apis/retrieval/index.ts @@ -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) => {