feat(agent): Enhanced structured output support for chat models

- Introduced `withStructuredOutput` function to configure structured output for LLMs.
- Added support for Groq models using 'jsonMode' method.
- Enhanced flexibility with optional parameters for naming and raw output inclusion.
This commit is contained in:
Willie Zutz 2025-07-12 15:44:17 -06:00
parent 37c93c3c9b
commit de2459a624
16 changed files with 1995 additions and 1820 deletions

View file

@ -1,5 +1,8 @@
export const contentRouterPrompt = `You are a content routing agent responsible for deciding the next step in information gathering.
# System Instructions
{systemInstructions}
# Your Role
Analyze the current task and available context to determine whether to:
1. Search attached files (\`file_search\`)
@ -46,36 +49,39 @@ When files are attached, first determine if they are likely to contain informati
- The question can be answered with general knowledge without additional research
# Response Format
Respond with your decision and reasoning:
Respond with a JSON object that matches this structure:
{{
"decision": "string", // One of: "file_search", "web_search", "analyzer"
"reasoning": "string" // Brief explanation of why this decision was made
}}
Decision: [file_search/web_search/analyzer]
Reasoning: [Brief explanation of why this choice was made, including file relevance assessment if applicable]
Your response should contain only the JSON object, no additional text or formatting.
# Examples
## Example 1: Relevant files
Current task: "Summarize the main points of this document"
File topics: "Product roadmap, feature specifications"
Decision: file_search
Reasoning: Task directly requests summary of attached document content
decision: file_search
reasoning: Task directly requests summary of attached document content
## Example 2: Irrelevant files
Current task: "What is the current weather in New York?"
File topics: "Resume, personal portfolio"
Decision: web_search
Reasoning: Attached files (resume, portfolio) are not relevant to weather query - need current web data
decision: web_search
reasoning: Attached files (resume, portfolio) are not relevant to weather query - need current web data
## Example 3: Partially relevant files
Current task: "How does machine learning work and what are the latest trends?"
File topics: "ML basics tutorial"
Decision: file_search
Reasoning: Files contain ML basics which could help with first part, then may need web search for latest trends
decision: file_search
reasoning: Files contain ML basics which could help with first part, then may need web search for latest trends
## Example 4: Technical question with unrelated files
Current task: "Explain React hooks"
File topics: "Marketing strategy document"
Decision: web_search
Reasoning: Marketing documents won't contain React programming information - need web search
decision: web_search
reasoning: Marketing documents won't contain React programming information - need web search
Your turn:
Current task: {currentTask}