feat: prototype frontend web search integration
This commit is contained in:
@@ -507,3 +507,44 @@ export const updateRerankingConfig = async (token: string, payload: RerankingMod
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
export const runWebSearch = async (
|
||||
token: string,
|
||||
query: string,
|
||||
collection_name?: string
|
||||
): Promise<SearchDocument | undefined> => {
|
||||
let error = null;
|
||||
|
||||
const res = await fetch(`${RAG_API_BASE_URL}/websearch`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${token}`
|
||||
},
|
||||
body: JSON.stringify({
|
||||
query,
|
||||
collection_name
|
||||
})
|
||||
})
|
||||
.then(async (res) => {
|
||||
if (!res.ok) throw await res.json();
|
||||
return res.json();
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
error = err.detail;
|
||||
return undefined;
|
||||
});
|
||||
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
export interface SearchDocument {
|
||||
status: boolean;
|
||||
collection_name: string;
|
||||
filenames: string[];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user