File size: 516 Bytes
6434339
 
447c0ca
6434339
447c0ca
 
6434339
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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;
}