Feature: adjusted retrieval restpoints to handle indivudal rag config - passing rag config and changing from get to post

This commit is contained in:
Maytown 2025-05-02 20:14:11 +02:00
parent 6e2155dd8c
commit 4f1c9a8c4f

View File

@ -1,14 +1,17 @@
import { RETRIEVAL_API_BASE_URL } from '$lib/constants'; import { RETRIEVAL_API_BASE_URL } from '$lib/constants';
export const getRAGConfig = async (token: string) => { export const getRAGConfig = async (token: string, collectionForm?: CollectionNameForm) => {
let error = null; let error = null;
const res = await fetch(`${RETRIEVAL_API_BASE_URL}/config`, { const res = await fetch(`${RETRIEVAL_API_BASE_URL}/config`, {
method: 'GET', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
Authorization: `Bearer ${token}` Authorization: `Bearer ${token}`
} },
body: JSON.stringify(
collectionForm ? {collectionForm: collectionForm} : {}
)
}) })
.then(async (res) => { .then(async (res) => {
if (!res.ok) throw await res.json(); if (!res.ok) throw await res.json();
@ -59,7 +62,11 @@ type RAGConfigForm = {
youtube?: YoutubeConfigForm; youtube?: YoutubeConfigForm;
}; };
export const updateRAGConfig = async (token: string, payload: RAGConfigForm) => { type CollectionNameForm = {
collection_name: string;
};
export const updateRAGConfig = async (token: string, payload: RAGConfigForm, collectionForm?: CollectionNameForm) => {
let error = null; let error = null;
const res = await fetch(`${RETRIEVAL_API_BASE_URL}/config/update`, { const res = await fetch(`${RETRIEVAL_API_BASE_URL}/config/update`, {
@ -69,7 +76,8 @@ export const updateRAGConfig = async (token: string, payload: RAGConfigForm) =>
Authorization: `Bearer ${token}` Authorization: `Bearer ${token}`
}, },
body: JSON.stringify({ body: JSON.stringify({
...payload ...payload,
...(collectionForm ? { collectionForm: collectionForm } : {})
}) })
}) })
.then(async (res) => { .then(async (res) => {
@ -152,15 +160,18 @@ export const updateQuerySettings = async (token: string, settings: QuerySettings
return res; return res;
}; };
export const getEmbeddingConfig = async (token: string) => { export const getEmbeddingConfig = async (token: string, collectionForm?: CollectionNameForm) => {
let error = null; let error = null;
const res = await fetch(`${RETRIEVAL_API_BASE_URL}/embedding`, { const res = await fetch(`${RETRIEVAL_API_BASE_URL}/embedding`, {
method: 'GET', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
Authorization: `Bearer ${token}` Authorization: `Bearer ${token}`
} },
body: JSON.stringify(
collectionForm ? {collectionForm: collectionForm} : {}
)
}) })
.then(async (res) => { .then(async (res) => {
if (!res.ok) throw await res.json(); if (!res.ok) throw await res.json();
@ -221,15 +232,18 @@ export const updateEmbeddingConfig = async (token: string, payload: EmbeddingMod
return res; return res;
}; };
export const getRerankingConfig = async (token: string) => { export const getRerankingConfig = async (token: string, collectionForm?: CollectionNameForm) => {
let error = null; let error = null;
const res = await fetch(`${RETRIEVAL_API_BASE_URL}/reranking`, { const res = await fetch(`${RETRIEVAL_API_BASE_URL}/reranking`, {
method: 'GET', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
Authorization: `Bearer ${token}` Authorization: `Bearer ${token}`
} },
body: JSON.stringify(
collectionForm ? {collectionForm: collectionForm} : {}
)
}) })
.then(async (res) => { .then(async (res) => {
if (!res.ok) throw await res.json(); if (!res.ok) throw await res.json();