refac
This commit is contained in:
1 parent
060648f939
commit
8fbfd14a8b
4 files changed
+317
-29
No files matched your search
@@ -330,6 +330,48 @@ export const processYoutubeVideo = async (token: string, url: string) => {
|
||||
return res;
|
||||
};
|
||||
|
||||
export const processUrl = async (
|
||||
token: string,
|
||||
url: string,
|
||||
collection_name: string | null = null,
|
||||
process: boolean = true
|
||||
) => {
|
||||
let error = null;
|
||||
|
||||
const searchParams = new URLSearchParams();
|
||||
if (!process) {
|
||||
searchParams.append('process', 'false');
|
||||
}
|
||||
|
||||
const res = await fetch(`${RETRIEVAL_API_BASE_URL}/process/url?${searchParams.toString()}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
authorization: `Bearer ${token}`
|
||||
},
|
||||
body: JSON.stringify({
|
||||
url,
|
||||
collection_name
|
||||
})
|
||||
})
|
||||
.then(async (res) => {
|
||||
if (!res.ok) throw await res.json();
|
||||
return res.json();
|
||||
})
|
||||
.catch((err) => {
|
||||
error = err.detail;
|
||||
console.error(err);
|
||||
return null;
|
||||
});
|
||||
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
export const processWeb = async (
|
||||
token: string,
|
||||
collection_name: string,
|
||||
|
||||
Reference in new issue
Block a user