fix: web search

This commit is contained in:
Timothy J. Baek 2024-06-22 13:13:46 -07:00
parent c1971fd8d7
commit 98c18b3032

View File

@ -600,10 +600,14 @@
files = model.info.meta.knowledge; files = model.info.meta.knowledge;
} }
const lastUserMessage = messages.filter((message) => message.role === 'user').at(-1); const lastUserMessage = messages.filter((message) => message.role === 'user').at(-1);
files = [ files = [
...files, ...files,
...(lastUserMessage?.files?.filter((item) => ...(lastUserMessage?.files?.filter((item) =>
['doc', 'file', 'collection', 'web_search_results'].includes(item.type) ['doc', 'file', 'collection', 'web_search_results'].includes(item.type)
) ?? []),
...(responseMessage?.files?.filter((item) =>
['doc', 'file', 'collection', 'web_search_results'].includes(item.type)
) ?? []) ) ?? [])
].filter( ].filter(
// Remove duplicates // Remove duplicates
@ -844,6 +848,9 @@
...files, ...files,
...(lastUserMessage?.files?.filter((item) => ...(lastUserMessage?.files?.filter((item) =>
['doc', 'file', 'collection', 'web_search_results'].includes(item.type) ['doc', 'file', 'collection', 'web_search_results'].includes(item.type)
) ?? []),
...(responseMessage?.files?.filter((item) =>
['doc', 'file', 'collection', 'web_search_results'].includes(item.type)
) ?? []) ) ?? [])
].filter( ].filter(
// Remove duplicates // Remove duplicates
@ -1213,6 +1220,7 @@
const getWebSearchResults = async (model: string, parentId: string, responseId: string) => { const getWebSearchResults = async (model: string, parentId: string, responseId: string) => {
const responseMessage = history.messages[responseId]; const responseMessage = history.messages[responseId];
const userMessage = history.messages[parentId];
responseMessage.statusHistory = [ responseMessage.statusHistory = [
{ {
@ -1223,7 +1231,7 @@
]; ];
messages = messages; messages = messages;
const prompt = history.messages[parentId].content; const prompt = userMessage.content;
let searchQuery = await generateSearchQuery(localStorage.token, model, messages, prompt).catch( let searchQuery = await generateSearchQuery(localStorage.token, model, messages, prompt).catch(
(error) => { (error) => {
console.log(error); console.log(error);