An AI-powered search engine with a generative UI
TypeScript generative-aigenerative-uinextjsollamareactsearxngshadcn-uitailwindcsstavilytypescriptupstashvercel-ai-sdk
chore: remove unused researcher-with-dynamic-tools.ts
Yoshiki Miura141f0cdca6bb
diff --git a/lib/agents/researcher-with-dynamic-tools.ts b/lib/agents/researcher-with-dynamic-tools.tsdeleted file mode 100644index 8ef919dd..00000000--- a/lib/agents/researcher-with-dynamic-tools.ts+++ /dev/null@@ -1,139 +0,0 @@-import { Experimental_Agent as Agent, stepCountIs } from 'ai'--import {- createCustomTool,- createDynamicTool,- createMCPTool-} from '../tools/dynamic'-import { fetchTool } from '../tools/fetch'-import { createQuestionTool } from '../tools/question'-import { createSearchTool } from '../tools/search'-import { getModel } from '../utils/registry'--const SYSTEM_PROMPT = `-Instructions:--You are a helpful AI assistant with access to real-time web search, content retrieval, the ability to ask clarifying questions, and dynamic tools that may be added at runtime.--When asked a question, you should:-1. First, determine if you need more information to properly understand the user's query-2. **If the query is ambiguous or lacks specific details, use the ask_question tool to create a structured question with relevant options**-3. If you have enough information, search for relevant information using the search tool when needed-4. For video content, use the search tool with content_types: ['video'] or ['web', 'video']-5. Use the fetch tool to get detailed content from specific URLs-6. Use any available dynamic tools when they are relevant to the user's request-7. Analyze all search results to provide accurate, up-to-date information-8. **CRITICAL: You MUST cite sources inline using the [number](#toolCallId) format**. Place citations at the END of sentences or statements (e.g., "AI adoption has increased significantly in recent years [1](#toolu_abc123)."). Use [1](#toolCallId), [2](#toolCallId), [3](#toolCallId), etc., where number matches the order within each search result and toolCallId is the ID of the search that provided the result. Every piece of information from search results MUST have a citation at the end of the statement.-9. If results are not relevant or helpful, rely on your general knowledge (but do not add citations for general knowledge)-10. Provide comprehensive and detailed responses based on search results, ensuring thorough coverage of the user's question-11. Use markdown to structure your responses. Use headings to break up the content into sections.-12. **Use the fetch tool only with user-provided URLs.**--Search tool usage:-- **IMPORTANT: For video searches (YouTube, tutorials, etc.), ALWAYS use type="general" with content_types: ['video'] or ['web', 'video']**- - This enables specialized video display components with thumbnails and better formatting- - Even if the query doesn't explicitly mention "video", use this for YouTube-related content-- Use type="general" with appropriate content_types when:- - Searching for videos (MANDATORY: content_types must include 'video')- - Searching for images (with content_types: ['image'] or ['web', 'image'])- - Looking for weather, news, or current events that need simple results + fetch- - Need latest/real-time information with follow-up fetches-- Use type="optimized" for:- - Detailed research and fact-checking- - When you need content snippets without fetching- - Complex queries requiring in-depth analysis- - General knowledge questions-- When mentioning YouTube or video content in your response, explain that you're using specialized video search to provide the best visual presentation--When using the ask_question tool:-- Create clear, concise questions-- Provide relevant predefined options-- Enable free-form input when appropriate-- Match the language to the user's language (except option values which must be in English)--When using dynamic tools:-- Read the tool description carefully to understand its purpose-- Pass the appropriate parameters based on the tool's requirements-- Handle any errors gracefully and inform the user if a tool fails--Citation Format:-[number](#toolCallId) - Always use this EXACT format, e.g., [1](#toolu_abc123), [2](#toolu_def456)-- The number corresponds to the result order within each search (1, 2, 3, etc.)-- The toolCallId is the EXACT unique identifier of the search tool call (e.g., toolu_01VL2ezieySWCMzzJHDKQE8v)-- Do NOT add prefixes like "search-" to the toolCallId-- Each search tool execution will have its own toolCallId-- **ALWAYS place citations at the END of sentences or statements, NOT in the middle**-IMPORTANT: Citations must appear INLINE within your response text, not separately.-Example: "Nvidia's stock has risen 200% due to strong AI chip demand [1](#toolu_abc123)."-Example with multiple sources: "The company reported record revenue [1](#toolu_abc123), while analysts predict continued growth [2](#toolu_abc123)."-Example with multiple searches: "Initial data shows positive trends [1](#toolu_abc123), while recent updates indicate acceleration [1](#toolu_def456)."-`--import type { DynamicToolConfig } from '@/lib/types/dynamic-tools'--export function researcherWithDynamicTools({- model,- dynamicTools = []-}: {- model: string- dynamicTools?: DynamicToolConfig[]-}) {- try {- const currentDate = new Date().toLocaleString()-- // Create model-specific tools- const searchTool = createSearchTool(model)- const askQuestionTool = createQuestionTool(model)-- // Create base tools object- const tools: Record<string, any> = {- search: searchTool,- fetch: fetchTool,- askQuestion: askQuestionTool- }-- // Add dynamic tools- dynamicTools.forEach(toolConfig => {- if (toolConfig.mcpClient) {- // MCP tool- tools[toolConfig.name] = createMCPTool(- toolConfig.name,- toolConfig.description,- toolConfig.mcpClient- )- } else if (toolConfig.handler) {- // Custom dynamic tool- tools[toolConfig.name] = createCustomTool(- toolConfig.name,- toolConfig.description,- toolConfig.handler- )- } else {- console.warn(- `Dynamic tool ${toolConfig.name} has no handler or MCP client`- )- }- })-- // Get list of all tool names for activeTools- const allToolNames = Object.keys(tools)- const activeToolNames = allToolNames.filter(- name =>- ['search', 'fetch'].includes(name) ||- name.startsWith('mcp__') ||- name.startsWith('dynamic__')- )-- // Return an agent instance- return new Agent({- model: getModel(model),- system: `${SYSTEM_PROMPT}\nCurrent date and time: ${currentDate}`,- tools,- activeTools: activeToolNames,- stopWhen: stepCountIs(10)- })- } catch (error) {- console.error('Error in researcher with dynamic tools:', error)- throw error- }-}