|
@@ -170,27 +170,23 @@ export const updateQuerySettings = async (token: string, settings: QuerySettings
|
|
|
return res;
|
|
|
};
|
|
|
|
|
|
-export const processFile = async (token: string, file_id: string) => {
|
|
|
+export const getEmbeddingConfig = async (token: string) => {
|
|
|
let error = null;
|
|
|
|
|
|
- const res = await fetch(`${RAG_API_BASE_URL}/process/file`, {
|
|
|
- method: 'POST',
|
|
|
+ const res = await fetch(`${RAG_API_BASE_URL}/embedding`, {
|
|
|
+ method: 'GET',
|
|
|
headers: {
|
|
|
- Accept: 'application/json',
|
|
|
'Content-Type': 'application/json',
|
|
|
- authorization: `Bearer ${token}`
|
|
|
- },
|
|
|
- body: JSON.stringify({
|
|
|
- file_id: file_id
|
|
|
- })
|
|
|
+ Authorization: `Bearer ${token}`
|
|
|
+ }
|
|
|
})
|
|
|
.then(async (res) => {
|
|
|
if (!res.ok) throw await res.json();
|
|
|
return res.json();
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
- error = err.detail;
|
|
|
console.log(err);
|
|
|
+ error = err.detail;
|
|
|
return null;
|
|
|
});
|
|
|
|
|
@@ -201,51 +197,29 @@ export const processFile = async (token: string, file_id: string) => {
|
|
|
return res;
|
|
|
};
|
|
|
|
|
|
-export const uploadDocToVectorDB = async (token: string, collection_name: string, file: File) => {
|
|
|
- const data = new FormData();
|
|
|
- data.append('file', file);
|
|
|
- data.append('collection_name', collection_name);
|
|
|
-
|
|
|
- let error = null;
|
|
|
-
|
|
|
- const res = await fetch(`${RAG_API_BASE_URL}/doc`, {
|
|
|
- method: 'POST',
|
|
|
- headers: {
|
|
|
- Accept: 'application/json',
|
|
|
- authorization: `Bearer ${token}`
|
|
|
- },
|
|
|
- body: data
|
|
|
- })
|
|
|
- .then(async (res) => {
|
|
|
- if (!res.ok) throw await res.json();
|
|
|
- return res.json();
|
|
|
- })
|
|
|
- .catch((err) => {
|
|
|
- error = err.detail;
|
|
|
- console.log(err);
|
|
|
- return null;
|
|
|
- });
|
|
|
-
|
|
|
- if (error) {
|
|
|
- throw error;
|
|
|
- }
|
|
|
+type OpenAIConfigForm = {
|
|
|
+ key: string;
|
|
|
+ url: string;
|
|
|
+ batch_size: number;
|
|
|
+};
|
|
|
|
|
|
- return res;
|
|
|
+type EmbeddingModelUpdateForm = {
|
|
|
+ openai_config?: OpenAIConfigForm;
|
|
|
+ embedding_engine: string;
|
|
|
+ embedding_model: string;
|
|
|
};
|
|
|
|
|
|
-export const uploadWebToVectorDB = async (token: string, collection_name: string, url: string) => {
|
|
|
+export const updateEmbeddingConfig = async (token: string, payload: EmbeddingModelUpdateForm) => {
|
|
|
let error = null;
|
|
|
|
|
|
- const res = await fetch(`${RAG_API_BASE_URL}/web`, {
|
|
|
+ const res = await fetch(`${RAG_API_BASE_URL}/embedding/update`, {
|
|
|
method: 'POST',
|
|
|
headers: {
|
|
|
- Accept: 'application/json',
|
|
|
'Content-Type': 'application/json',
|
|
|
- authorization: `Bearer ${token}`
|
|
|
+ Authorization: `Bearer ${token}`
|
|
|
},
|
|
|
body: JSON.stringify({
|
|
|
- url: url,
|
|
|
- collection_name: collection_name
|
|
|
+ ...payload
|
|
|
})
|
|
|
})
|
|
|
.then(async (res) => {
|
|
@@ -253,8 +227,8 @@ export const uploadWebToVectorDB = async (token: string, collection_name: string
|
|
|
return res.json();
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
- error = err.detail;
|
|
|
console.log(err);
|
|
|
+ error = err.detail;
|
|
|
return null;
|
|
|
});
|
|
|
|
|
@@ -265,27 +239,23 @@ export const uploadWebToVectorDB = async (token: string, collection_name: string
|
|
|
return res;
|
|
|
};
|
|
|
|
|
|
-export const uploadYoutubeTranscriptionToVectorDB = async (token: string, url: string) => {
|
|
|
+export const getRerankingConfig = async (token: string) => {
|
|
|
let error = null;
|
|
|
|
|
|
- const res = await fetch(`${RAG_API_BASE_URL}/youtube`, {
|
|
|
- method: 'POST',
|
|
|
+ const res = await fetch(`${RAG_API_BASE_URL}/reranking`, {
|
|
|
+ method: 'GET',
|
|
|
headers: {
|
|
|
- Accept: 'application/json',
|
|
|
'Content-Type': 'application/json',
|
|
|
- authorization: `Bearer ${token}`
|
|
|
- },
|
|
|
- body: JSON.stringify({
|
|
|
- url: url
|
|
|
- })
|
|
|
+ Authorization: `Bearer ${token}`
|
|
|
+ }
|
|
|
})
|
|
|
.then(async (res) => {
|
|
|
if (!res.ok) throw await res.json();
|
|
|
return res.json();
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
- error = err.detail;
|
|
|
console.log(err);
|
|
|
+ error = err.detail;
|
|
|
return null;
|
|
|
});
|
|
|
|
|
@@ -296,25 +266,21 @@ export const uploadYoutubeTranscriptionToVectorDB = async (token: string, url: s
|
|
|
return res;
|
|
|
};
|
|
|
|
|
|
-export const queryDoc = async (
|
|
|
- token: string,
|
|
|
- collection_name: string,
|
|
|
- query: string,
|
|
|
- k: number | null = null
|
|
|
-) => {
|
|
|
+type RerankingModelUpdateForm = {
|
|
|
+ reranking_model: string;
|
|
|
+};
|
|
|
+
|
|
|
+export const updateRerankingConfig = async (token: string, payload: RerankingModelUpdateForm) => {
|
|
|
let error = null;
|
|
|
|
|
|
- const res = await fetch(`${RAG_API_BASE_URL}/query/doc`, {
|
|
|
+ const res = await fetch(`${RAG_API_BASE_URL}/reranking/update`, {
|
|
|
method: 'POST',
|
|
|
headers: {
|
|
|
- Accept: 'application/json',
|
|
|
'Content-Type': 'application/json',
|
|
|
- authorization: `Bearer ${token}`
|
|
|
+ Authorization: `Bearer ${token}`
|
|
|
},
|
|
|
body: JSON.stringify({
|
|
|
- collection_name: collection_name,
|
|
|
- query: query,
|
|
|
- k: k
|
|
|
+ ...payload
|
|
|
})
|
|
|
})
|
|
|
.then(async (res) => {
|
|
@@ -322,6 +288,7 @@ export const queryDoc = async (
|
|
|
return res.json();
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
+ console.log(err);
|
|
|
error = err.detail;
|
|
|
return null;
|
|
|
});
|
|
@@ -333,15 +300,16 @@ export const queryDoc = async (
|
|
|
return res;
|
|
|
};
|
|
|
|
|
|
-export const queryCollection = async (
|
|
|
- token: string,
|
|
|
- collection_names: string,
|
|
|
- query: string,
|
|
|
- k: number | null = null
|
|
|
-) => {
|
|
|
+export interface SearchDocument {
|
|
|
+ status: boolean;
|
|
|
+ collection_name: string;
|
|
|
+ filenames: string[];
|
|
|
+}
|
|
|
+
|
|
|
+export const processFile = async (token: string, file_id: string) => {
|
|
|
let error = null;
|
|
|
|
|
|
- const res = await fetch(`${RAG_API_BASE_URL}/query/collection`, {
|
|
|
+ const res = await fetch(`${RAG_API_BASE_URL}/process/file`, {
|
|
|
method: 'POST',
|
|
|
headers: {
|
|
|
Accept: 'application/json',
|
|
@@ -349,9 +317,7 @@ export const queryCollection = async (
|
|
|
authorization: `Bearer ${token}`
|
|
|
},
|
|
|
body: JSON.stringify({
|
|
|
- collection_names: collection_names,
|
|
|
- query: query,
|
|
|
- k: k
|
|
|
+ file_id: file_id
|
|
|
})
|
|
|
})
|
|
|
.then(async (res) => {
|
|
@@ -360,6 +326,7 @@ export const queryCollection = async (
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
error = err.detail;
|
|
|
+ console.log(err);
|
|
|
return null;
|
|
|
});
|
|
|
|
|
@@ -370,10 +337,10 @@ export const queryCollection = async (
|
|
|
return res;
|
|
|
};
|
|
|
|
|
|
-export const scanDocs = async (token: string) => {
|
|
|
+export const processDocsDir = async (token: string) => {
|
|
|
let error = null;
|
|
|
|
|
|
- const res = await fetch(`${RAG_API_BASE_URL}/scan`, {
|
|
|
+ const res = await fetch(`${RAG_API_BASE_URL}/process/dir`, {
|
|
|
method: 'GET',
|
|
|
headers: {
|
|
|
Accept: 'application/json',
|
|
@@ -396,15 +363,19 @@ export const scanDocs = async (token: string) => {
|
|
|
return res;
|
|
|
};
|
|
|
|
|
|
-export const resetUploadDir = async (token: string) => {
|
|
|
+export const processYoutubeVideo = async (token: string, url: string) => {
|
|
|
let error = null;
|
|
|
|
|
|
- const res = await fetch(`${RAG_API_BASE_URL}/reset/uploads`, {
|
|
|
+ const res = await fetch(`${RAG_API_BASE_URL}/process/youtube`, {
|
|
|
method: 'POST',
|
|
|
headers: {
|
|
|
Accept: 'application/json',
|
|
|
+ 'Content-Type': 'application/json',
|
|
|
authorization: `Bearer ${token}`
|
|
|
- }
|
|
|
+ },
|
|
|
+ body: JSON.stringify({
|
|
|
+ url: url
|
|
|
+ })
|
|
|
})
|
|
|
.then(async (res) => {
|
|
|
if (!res.ok) throw await res.json();
|
|
@@ -412,6 +383,7 @@ export const resetUploadDir = async (token: string) => {
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
error = err.detail;
|
|
|
+ console.log(err);
|
|
|
return null;
|
|
|
});
|
|
|
|
|
@@ -422,15 +394,20 @@ export const resetUploadDir = async (token: string) => {
|
|
|
return res;
|
|
|
};
|
|
|
|
|
|
-export const resetVectorDB = async (token: string) => {
|
|
|
+export const processWeb = async (token: string, collection_name: string, url: string) => {
|
|
|
let error = null;
|
|
|
|
|
|
- const res = await fetch(`${RAG_API_BASE_URL}/reset/db`, {
|
|
|
+ const res = await fetch(`${RAG_API_BASE_URL}/process/web`, {
|
|
|
method: 'POST',
|
|
|
headers: {
|
|
|
Accept: 'application/json',
|
|
|
+ 'Content-Type': 'application/json',
|
|
|
authorization: `Bearer ${token}`
|
|
|
- }
|
|
|
+ },
|
|
|
+ body: JSON.stringify({
|
|
|
+ url: url,
|
|
|
+ collection_name: collection_name
|
|
|
+ })
|
|
|
})
|
|
|
.then(async (res) => {
|
|
|
if (!res.ok) throw await res.json();
|
|
@@ -438,6 +415,7 @@ export const resetVectorDB = async (token: string) => {
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
error = err.detail;
|
|
|
+ console.log(err);
|
|
|
return null;
|
|
|
});
|
|
|
|
|
@@ -448,15 +426,23 @@ export const resetVectorDB = async (token: string) => {
|
|
|
return res;
|
|
|
};
|
|
|
|
|
|
-export const getEmbeddingConfig = async (token: string) => {
|
|
|
+export const processWebSearch = async (
|
|
|
+ token: string,
|
|
|
+ query: string,
|
|
|
+ collection_name?: string
|
|
|
+): Promise<SearchDocument | null> => {
|
|
|
let error = null;
|
|
|
|
|
|
- const res = await fetch(`${RAG_API_BASE_URL}/embedding`, {
|
|
|
- method: 'GET',
|
|
|
+ const res = await fetch(`${RAG_API_BASE_URL}/process/web/search`, {
|
|
|
+ method: 'POST',
|
|
|
headers: {
|
|
|
'Content-Type': 'application/json',
|
|
|
Authorization: `Bearer ${token}`
|
|
|
- }
|
|
|
+ },
|
|
|
+ body: JSON.stringify({
|
|
|
+ query,
|
|
|
+ collection_name: collection_name ?? ''
|
|
|
+ })
|
|
|
})
|
|
|
.then(async (res) => {
|
|
|
if (!res.ok) throw await res.json();
|
|
@@ -475,29 +461,25 @@ export const getEmbeddingConfig = async (token: string) => {
|
|
|
return res;
|
|
|
};
|
|
|
|
|
|
-type OpenAIConfigForm = {
|
|
|
- key: string;
|
|
|
- url: string;
|
|
|
- batch_size: number;
|
|
|
-};
|
|
|
-
|
|
|
-type EmbeddingModelUpdateForm = {
|
|
|
- openai_config?: OpenAIConfigForm;
|
|
|
- embedding_engine: string;
|
|
|
- embedding_model: string;
|
|
|
-};
|
|
|
-
|
|
|
-export const updateEmbeddingConfig = async (token: string, payload: EmbeddingModelUpdateForm) => {
|
|
|
+export const queryDoc = async (
|
|
|
+ token: string,
|
|
|
+ collection_name: string,
|
|
|
+ query: string,
|
|
|
+ k: number | null = null
|
|
|
+) => {
|
|
|
let error = null;
|
|
|
|
|
|
- const res = await fetch(`${RAG_API_BASE_URL}/embedding/update`, {
|
|
|
+ const res = await fetch(`${RAG_API_BASE_URL}/query/doc`, {
|
|
|
method: 'POST',
|
|
|
headers: {
|
|
|
+ Accept: 'application/json',
|
|
|
'Content-Type': 'application/json',
|
|
|
- Authorization: `Bearer ${token}`
|
|
|
+ authorization: `Bearer ${token}`
|
|
|
},
|
|
|
body: JSON.stringify({
|
|
|
- ...payload
|
|
|
+ collection_name: collection_name,
|
|
|
+ query: query,
|
|
|
+ k: k
|
|
|
})
|
|
|
})
|
|
|
.then(async (res) => {
|
|
@@ -505,7 +487,6 @@ export const updateEmbeddingConfig = async (token: string, payload: EmbeddingMod
|
|
|
return res.json();
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
- console.log(err);
|
|
|
error = err.detail;
|
|
|
return null;
|
|
|
});
|
|
@@ -517,22 +498,32 @@ export const updateEmbeddingConfig = async (token: string, payload: EmbeddingMod
|
|
|
return res;
|
|
|
};
|
|
|
|
|
|
-export const getRerankingConfig = async (token: string) => {
|
|
|
+export const queryCollection = async (
|
|
|
+ token: string,
|
|
|
+ collection_names: string,
|
|
|
+ query: string,
|
|
|
+ k: number | null = null
|
|
|
+) => {
|
|
|
let error = null;
|
|
|
|
|
|
- const res = await fetch(`${RAG_API_BASE_URL}/reranking`, {
|
|
|
- method: 'GET',
|
|
|
+ const res = await fetch(`${RAG_API_BASE_URL}/query/collection`, {
|
|
|
+ method: 'POST',
|
|
|
headers: {
|
|
|
+ Accept: 'application/json',
|
|
|
'Content-Type': 'application/json',
|
|
|
- Authorization: `Bearer ${token}`
|
|
|
- }
|
|
|
+ authorization: `Bearer ${token}`
|
|
|
+ },
|
|
|
+ body: JSON.stringify({
|
|
|
+ collection_names: collection_names,
|
|
|
+ query: query,
|
|
|
+ k: k
|
|
|
+ })
|
|
|
})
|
|
|
.then(async (res) => {
|
|
|
if (!res.ok) throw await res.json();
|
|
|
return res.json();
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
- console.log(err);
|
|
|
error = err.detail;
|
|
|
return null;
|
|
|
});
|
|
@@ -544,29 +535,21 @@ export const getRerankingConfig = async (token: string) => {
|
|
|
return res;
|
|
|
};
|
|
|
|
|
|
-type RerankingModelUpdateForm = {
|
|
|
- reranking_model: string;
|
|
|
-};
|
|
|
-
|
|
|
-export const updateRerankingConfig = async (token: string, payload: RerankingModelUpdateForm) => {
|
|
|
+export const resetUploadDir = async (token: string) => {
|
|
|
let error = null;
|
|
|
|
|
|
- const res = await fetch(`${RAG_API_BASE_URL}/reranking/update`, {
|
|
|
+ const res = await fetch(`${RAG_API_BASE_URL}/reset/uploads`, {
|
|
|
method: 'POST',
|
|
|
headers: {
|
|
|
- 'Content-Type': 'application/json',
|
|
|
- Authorization: `Bearer ${token}`
|
|
|
- },
|
|
|
- body: JSON.stringify({
|
|
|
- ...payload
|
|
|
- })
|
|
|
+ Accept: 'application/json',
|
|
|
+ authorization: `Bearer ${token}`
|
|
|
+ }
|
|
|
})
|
|
|
.then(async (res) => {
|
|
|
if (!res.ok) throw await res.json();
|
|
|
return res.json();
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
- console.log(err);
|
|
|
error = err.detail;
|
|
|
return null;
|
|
|
});
|
|
@@ -578,30 +561,21 @@ export const updateRerankingConfig = async (token: string, payload: RerankingMod
|
|
|
return res;
|
|
|
};
|
|
|
|
|
|
-export const runWebSearch = async (
|
|
|
- token: string,
|
|
|
- query: string,
|
|
|
- collection_name?: string
|
|
|
-): Promise<SearchDocument | null> => {
|
|
|
+export const resetVectorDB = async (token: string) => {
|
|
|
let error = null;
|
|
|
|
|
|
- const res = await fetch(`${RAG_API_BASE_URL}/web/search`, {
|
|
|
+ const res = await fetch(`${RAG_API_BASE_URL}/reset/db`, {
|
|
|
method: 'POST',
|
|
|
headers: {
|
|
|
- 'Content-Type': 'application/json',
|
|
|
- Authorization: `Bearer ${token}`
|
|
|
- },
|
|
|
- body: JSON.stringify({
|
|
|
- query,
|
|
|
- collection_name: collection_name ?? ''
|
|
|
- })
|
|
|
+ Accept: 'application/json',
|
|
|
+ authorization: `Bearer ${token}`
|
|
|
+ }
|
|
|
})
|
|
|
.then(async (res) => {
|
|
|
if (!res.ok) throw await res.json();
|
|
|
return res.json();
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
- console.log(err);
|
|
|
error = err.detail;
|
|
|
return null;
|
|
|
});
|
|
@@ -612,9 +586,3 @@ export const runWebSearch = async (
|
|
|
|
|
|
return res;
|
|
|
};
|
|
|
-
|
|
|
-export interface SearchDocument {
|
|
|
- status: boolean;
|
|
|
- collection_name: string;
|
|
|
- filenames: string[];
|
|
|
-}
|