blind_chat / src /lib /server /websearch /generateQuery.ts
lauro1's picture
test
faca43f
raw
history blame
516 Bytes
import type { Message } from "$lib/types/Message";
import { generateFromDefaultEndpoint } from "../generateFromDefaultEndpoint";
import { defaultModel } from "../models";
export async function generateQuery(messages: Message[]) {
const promptSearchQuery = defaultModel.webSearchQueryPromptRender({ messages });
const searchQuery = await generateFromDefaultEndpoint(promptSearchQuery).then((query) => {
const arr = query.split(/\r?\n/);
return arr[0].length > 0 ? arr[0] : arr[1];
});
return searchQuery;
}