feat: add in-message progress indicator for web search

This commit is contained in:
Jun Siang Cheah
2024-05-12 15:21:03 +08:00
parent d45804d7f4
commit 3baeda7edc
4 changed files with 138 additions and 72 deletions

View File

@@ -519,9 +519,7 @@ export const runWebSearch = async (
query: string,
collection_name?: string
): Promise<SearchDocument | undefined> => {
let error = null;
const res = await fetch(`${RAG_API_BASE_URL}/websearch`, {
return await fetch(`${RAG_API_BASE_URL}/websearch`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
@@ -529,7 +527,7 @@ export const runWebSearch = async (
},
body: JSON.stringify({
query,
collection_name
collection_name: collection_name ?? ''
})
})
.then(async (res) => {
@@ -538,15 +536,8 @@ export const runWebSearch = async (
})
.catch((err) => {
console.log(err);
error = err.detail;
return undefined;
});
if (error) {
throw error;
}
return res;
};
export interface SearchDocument {