An AI-powered search engine with a generative UI
TypeScript generative-aigenerative-uinextjsollamareactsearxngshadcn-uitailwindcsstavilytypescriptupstashvercel-ai-sdk
feat: enhance model selection for related questions and update tool stream configuration
Yoshiki Miura225daf91f39a
diff --git a/lib/agents/generate-related-questions.ts b/lib/agents/generate-related-questions.tsindex 86ddfd56..907e3244 100644--- a/lib/agents/generate-related-questions.ts+++ b/lib/agents/generate-related-questions.ts@@ -1,6 +1,10 @@-import { CoreMessage, generateObject } from 'ai'import { relatedSchema } from '@/lib/schema/related'-import { getModel } from '../utils/registry'+import { CoreMessage, generateObject } from 'ai'+import {+ getModel,+ getToolCallModel,+ isToolCallSupported+} from '../utils/registry'export async function generateRelatedQuestions(messages: CoreMessage[],@@ -11,8 +15,13 @@ export async function generateRelatedQuestions(role: 'user'})) as CoreMessage[]+ const supportedModel = isToolCallSupported(model)+ const currentModel = supportedModel+ ? getModel(model)+ : getToolCallModel(model)+const result = await generateObject({- model: getModel(model),+ model: currentModel,system: `As a professional web researcher, your task is to generate a set of three queries that explore the subject matter more deeply, building upon the initial query and the information uncovered in its search results.For instance, if the original query was "Starship's third test flight key milestones", your output should follow this format:diff --git a/lib/streaming/create-manual-tool-stream.ts b/lib/streaming/create-manual-tool-stream.tsindex 6792651e..3eae4a50 100644--- a/lib/streaming/create-manual-tool-stream.ts+++ b/lib/streaming/create-manual-tool-stream.ts@@ -46,7 +46,7 @@ export function createManualToolStreamResponse(config: BaseStreamConfig) {model,chatId,dataStream,- skipRelatedQuestions: true,+ skipRelatedQuestions: false,annotations})}diff --git a/lib/utils/registry.ts b/lib/utils/registry.tsindex c6fd4bda..df7442ab 100644--- a/lib/utils/registry.ts+++ b/lib/utils/registry.ts@@ -98,7 +98,8 @@ export function getToolCallModel(model?: string) {const provider = model?.split(':')[0]switch (provider) {case 'groq':- return getModel('groq:llama3.3-70b-versatile')+ return getModel('openai:gpt-4o-mini')+ // return getModel(model!)case 'deepseek':return getModel('deepseek:deepseek-chat')default: