An AI-powered search engine with a generative UI
TypeScript generative-aigenerative-uinextjsollamareactsearxngshadcn-uitailwindcsstavilytypescriptupstashvercel-ai-sdk
fix: remove searchMode parameter from streaming and agent functions
Yoshiki Miura4e5a12c05455
diff --git a/lib/agents/researcher-with-dynamic-tools.ts b/lib/agents/researcher-with-dynamic-tools.tsindex 77fe1a81..8ef919dd 100644--- a/lib/agents/researcher-with-dynamic-tools.ts+++ b/lib/agents/researcher-with-dynamic-tools.ts@@ -73,11 +73,9 @@ import type { DynamicToolConfig } from '@/lib/types/dynamic-tools'export function researcherWithDynamicTools({model,- searchMode,dynamicTools = []}: {model: string- searchMode: booleandynamicTools?: DynamicToolConfig[]}) {try {@@ -119,14 +117,12 @@ export function researcherWithDynamicTools({// Get list of all tool names for activeToolsconst allToolNames = Object.keys(tools)- const activeToolNames = searchMode- ? allToolNames.filter(- name =>- ['search', 'fetch'].includes(name) ||- name.startsWith('mcp__') ||- name.startsWith('dynamic__')- )- : undefined+ const activeToolNames = allToolNames.filter(+ name =>+ ['search', 'fetch'].includes(name) ||+ name.startsWith('mcp__') ||+ name.startsWith('dynamic__')+ )// Return an agent instancereturn new Agent({@@ -134,7 +130,7 @@ export function researcherWithDynamicTools({system: `${SYSTEM_PROMPT}\nCurrent date and time: ${currentDate}`,tools,activeTools: activeToolNames,- stopWhen: searchMode ? stepCountIs(10) : stepCountIs(1)+ stopWhen: stepCountIs(10)})} catch (error) {console.error('Error in researcher with dynamic tools:', error)diff --git a/lib/agents/researcher.ts b/lib/agents/researcher.tsindex 02b7caf7..c98936af 100644--- a/lib/agents/researcher.ts+++ b/lib/agents/researcher.ts@@ -72,12 +72,10 @@ For complex queries requiring systematic investigation:export function researcher({model,- searchMode,abortSignal,writer}: {model: string- searchMode: booleanabortSignal?: AbortSignalwriter?: UIMessageStreamWriter}) {@@ -101,13 +99,10 @@ export function researcher({// Build activeTools array based on available toolstype ToolNames = keyof typeof tools- const activeToolsList: ToolNames[] = []-- if (searchMode) {- activeToolsList.push('search', 'fetch')- if (writer && 'todoWrite' in todoTools) {- activeToolsList.push('todoWrite' as ToolNames, 'todoRead' as ToolNames)- }+ const activeToolsList: ToolNames[] = ['search', 'fetch']++ if (writer && 'todoWrite' in todoTools) {+ activeToolsList.push('todoWrite' as ToolNames, 'todoRead' as ToolNames)}// Return an agent instance@@ -115,8 +110,8 @@ export function researcher({model: getModel(model),system: `${SYSTEM_PROMPT}\nCurrent date and time: ${currentDate}`,tools,- activeTools: searchMode ? activeToolsList : undefined,- stopWhen: searchMode ? stepCountIs(20) : stepCountIs(1),+ activeTools: activeToolsList,+ stopWhen: stepCountIs(20),abortSignal})} catch (error) {diff --git a/lib/streaming/create-chat-stream-response.ts b/lib/streaming/create-chat-stream-response.tsindex faf1b449..3a43107f 100644--- a/lib/streaming/create-chat-stream-response.ts+++ b/lib/streaming/create-chat-stream-response.ts@@ -33,7 +33,6 @@ export async function createChatStreamResponse(message,model,chatId,- searchMode,userId,trigger,messageId,@@ -81,7 +80,6 @@ export async function createChatStreamResponse(// Get the researcher agentconst researchAgent = researcher({model: context.modelId,- searchMode,abortSignal,writer})diff --git a/lib/streaming/types.ts b/lib/streaming/types.tsindex 87ce38e9..47894df4 100644--- a/lib/streaming/types.ts+++ b/lib/streaming/types.ts@@ -6,7 +6,6 @@ export interface BaseStreamConfig {message: UIMessage | nullmodel: ModelchatId: string- searchMode: booleanuserId: stringtrigger?: 'submit-user-message' | 'regenerate-assistant-message'messageId?: string