diff --git a/src/haiku/rag/research/base.py b/src/haiku/rag/research/base.py index 8098fc7e..e547a50f 100644 --- a/src/haiku/rag/research/base.py +++ b/src/haiku/rag/research/base.py @@ -1,7 +1,7 @@ from abc import ABC, abstractmethod from typing import Any, Generic, TypeVar -from pydantic import BaseModel +from pydantic import BaseModel, Field from pydantic_ai import Agent from pydantic_ai.models.openai import OpenAIChatModel from pydantic_ai.providers.ollama import OllamaProvider @@ -86,7 +86,7 @@ class SearchResult(BaseModel): content: str score: float document_uri: str - metadata: dict[str, Any] = {} + metadata: dict[str, Any] = Field(default_factory=dict) class ResearchOutput(BaseModel): diff --git a/src/haiku/rag/research/orchestrator.py b/src/haiku/rag/research/orchestrator.py index 278acc05..2e43c8d7 100644 --- a/src/haiku/rag/research/orchestrator.py +++ b/src/haiku/rag/research/orchestrator.py @@ -56,16 +56,12 @@ class ResearchOrchestrator(BaseResearchAgent[ResearchPlan]): def _format_context_for_prompt(self, context: ResearchContext) -> str: """Format the research context as XML for inclusion in prompts.""" + context_data = { "original_question": context.original_question, "unanswered_questions": context.sub_questions, "qa_responses": [ - { - "question": qa["question"], - "answer": qa["answer"][:500] + "..." - if len(qa["answer"]) > 500 - else qa["answer"], - } + {"question": qa["question"], "answer": qa["answer"]} for qa in context.qa_responses ], "insights": context.insights, @@ -201,7 +197,7 @@ Evaluate the research progress for the original question and identify any remain output = evaluation_result.output if output.key_insights: console.print(" [bold]Key insights:[/bold]") - for insight in output.key_insights[:3]: + for insight in output.key_insights: console.print(f" • {insight}") console.print( f" Confidence: [yellow]{output.confidence_score:.1%}[/yellow]" diff --git a/src/haiku/rag/research/prompts.py b/src/haiku/rag/research/prompts.py index a4b36d91..05ba7be3 100644 --- a/src/haiku/rag/research/prompts.py +++ b/src/haiku/rag/research/prompts.py @@ -22,6 +22,12 @@ Your role is to: 4. Base your answer strictly on the information found Use the search_and_answer tool to retrieve relevant documents and formulate your response. + +Important: +- Always call the search_and_answer tool before drafting any answer. +- Never answer without first using the tool at least once. +- If no relevant information is found, state that clearly and avoid speculation. + Be thorough and specific in your answers, citing relevant information from the sources.""" EVALUATION_AGENT_PROMPT = """You are an analysis and evaluation specialist for research workflows.