Provide full report on deep ask, modify prompt to not just summarize

This commit is contained in:
Yiorgis Gozadinos 2025-12-15 13:22:51 +02:00
parent f0a7abd953
commit 6e621ea34d
No known key found for this signature in database
2 changed files with 38 additions and 16 deletions

View file

@ -329,6 +329,8 @@ class HaikuRAGApp:
try:
citations = []
if deep:
from haiku.rag.graph.research.models import ResearchReport
graph = build_research_graph(config=self.config)
context = ResearchContext(original_question=question)
state = ResearchState.from_config(
@ -345,24 +347,40 @@ class HaikuRAGApp:
result_dict = await renderer.render(
stream_graph(graph, state, deps)
)
answer = (
result_dict.get("executive_summary", "")
report = (
ResearchReport.model_validate(result_dict)
if result_dict
else ""
else None
)
else:
result = await graph.run(state=state, deps=deps)
answer = result.executive_summary
report = await graph.run(state=state, deps=deps)
self.console.print(f"[bold blue]Question:[/bold blue] {question}")
self.console.print()
if report:
self.console.print("[bold green]Answer:[/bold green]")
self.console.print(Markdown(report.executive_summary))
if report.main_findings:
self.console.print()
self.console.print("[bold cyan]Key Findings:[/bold cyan]")
for finding in report.main_findings:
self.console.print(f"{finding}")
if report.sources_summary:
self.console.print()
self.console.print("[bold cyan]Sources:[/bold cyan]")
self.console.print(report.sources_summary)
else:
self.console.print("[yellow]No answer generated.[/yellow]")
else:
answer, citations = await self.client.ask(question, filter=filter)
self.console.print(f"[bold blue]Question:[/bold blue] {question}")
self.console.print()
self.console.print("[bold green]Answer:[/bold green]")
self.console.print(Markdown(answer))
if cite and citations:
for renderable in format_citations_rich(citations):
self.console.print(renderable)
self.console.print(f"[bold blue]Question:[/bold blue] {question}")
self.console.print()
self.console.print("[bold green]Answer:[/bold green]")
self.console.print(Markdown(answer))
if cite and citations:
for renderable in format_citations_rich(citations):
self.console.print(renderable)
except Exception as e:
self.console.print(f"[red]Error: {e}[/red]")

View file

@ -20,17 +20,20 @@ Output fields:
Be strict: only mark sufficient when key aspects are addressed with reliable evidence."""
SYNTHESIS_AGENT_PROMPT = """You are a synthesis specialist producing the final
research report.
research report that directly answers the original question.
Goals:
1. Synthesize all gathered information into a coherent narrative.
1. Directly answer the research question using gathered evidence.
2. Present findings clearly and concisely.
3. Draw evidence-based conclusions and recommendations.
4. State limitations and uncertainties transparently.
Report guidelines (map to output fields):
- title: concise (5-12 words), informative.
- executive_summary: 3-5 sentences summarizing the overall answer.
- executive_summary: 3-5 sentences that DIRECTLY ANSWER the original question.
Write the actual answer, not a description of what the report contains.
BAD: "This report examines the topic and presents findings..."
GOOD: "The system requires configuration X and supports features Y and Z..."
- main_findings: list of plain strings, 4-8 one-sentence bullets reflecting evidence.
- conclusions: list of plain strings, 2-4 bullets following logically from findings.
- recommendations: list of plain strings, 2-5 actionable bullets tied to findings.
@ -42,7 +45,8 @@ All list fields must contain plain strings only, not objects.
Style:
- Base all content solely on the collected evidence.
- Be professional, objective, and specific.
- Avoid meta commentary and refrain from speculation beyond the evidence."""
- NEVER use meta-commentary like "This report covers..." or "The findings show...".
Instead, state the actual information directly."""
PRESEARCH_AGENT_PROMPT = """You are a rapid research surveyor.