Simplify structured output for research agents
This commit is contained in:
parent
714c6c627e
commit
a807f3ea36
6 changed files with 13 additions and 12 deletions
|
|
@ -122,12 +122,7 @@ class HaikuRAGApp:
|
||||||
self.console.print(f"• {finding}")
|
self.console.print(f"• {finding}")
|
||||||
self.console.print()
|
self.console.print()
|
||||||
|
|
||||||
# Themes
|
# (Themes section removed)
|
||||||
if report.themes:
|
|
||||||
self.console.print("[bold cyan]Key Themes:[/bold cyan]")
|
|
||||||
for theme, explanation in report.themes.items():
|
|
||||||
self.console.print(f"• [bold]{theme}[/bold]: {explanation}")
|
|
||||||
self.console.print()
|
|
||||||
|
|
||||||
# Conclusions
|
# Conclusions
|
||||||
if report.conclusions:
|
if report.conclusions:
|
||||||
|
|
@ -261,7 +256,7 @@ class HaikuRAGApp:
|
||||||
elif transport == "sse":
|
elif transport == "sse":
|
||||||
await server.run_sse_async()
|
await server.run_sse_async()
|
||||||
else:
|
else:
|
||||||
await server.run_http_async("streamable-http")
|
await server.run_http_async(transport="streamable-http")
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
pass
|
pass
|
||||||
finally:
|
finally:
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,9 @@ class QuestionAnswerAgent:
|
||||||
limit: int = 3,
|
limit: int = 3,
|
||||||
) -> list[SearchResult]:
|
) -> list[SearchResult]:
|
||||||
"""Search the knowledge base for relevant documents."""
|
"""Search the knowledge base for relevant documents."""
|
||||||
|
|
||||||
|
# Remove quotes from queries as this requires positional indexing in lancedb
|
||||||
|
query = query.replace('"', "")
|
||||||
search_results = await ctx.deps.client.search(query, limit=limit)
|
search_results = await ctx.deps.client.search(query, limit=limit)
|
||||||
expanded_results = await ctx.deps.client.expand_context(search_results)
|
expanded_results = await ctx.deps.client.expand_context(search_results)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,9 @@ class EvaluationResult(BaseModel):
|
||||||
description="Main insights extracted from the research so far"
|
description="Main insights extracted from the research so far"
|
||||||
)
|
)
|
||||||
new_questions: list[str] = Field(
|
new_questions: list[str] = Field(
|
||||||
description="New sub-questions to add to the research (max 3)", max_length=3
|
description="New sub-questions to add to the research (max 3)",
|
||||||
|
max_length=3,
|
||||||
|
default=[],
|
||||||
)
|
)
|
||||||
confidence_score: float = Field(
|
confidence_score: float = Field(
|
||||||
description="Confidence level in the completeness of research (0-1)",
|
description="Confidence level in the completeness of research (0-1)",
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ class SearchSpecialistAgent(BaseResearchAgent[SearchAnswer]):
|
||||||
) -> str:
|
) -> str:
|
||||||
"""Search the KB and return a concise context pack."""
|
"""Search the KB and return a concise context pack."""
|
||||||
# Remove quotes from queries as this requires positional indexing in lancedb
|
# Remove quotes from queries as this requires positional indexing in lancedb
|
||||||
|
# XXX: Investigate how to do that with lancedb
|
||||||
query = query.replace('"', "")
|
query = query.replace('"', "")
|
||||||
search_results = await ctx.deps.client.search(query, limit=limit)
|
search_results = await ctx.deps.client.search(query, limit=limit)
|
||||||
expanded = await ctx.deps.client.expand_context(search_results)
|
expanded = await ctx.deps.client.expand_context(search_results)
|
||||||
|
|
|
||||||
|
|
@ -12,11 +12,12 @@ class ResearchReport(BaseModel):
|
||||||
main_findings: list[str] = Field(
|
main_findings: list[str] = Field(
|
||||||
description="Primary research findings with supporting evidence"
|
description="Primary research findings with supporting evidence"
|
||||||
)
|
)
|
||||||
themes: dict[str, str] = Field(description="Major themes and their explanations")
|
|
||||||
conclusions: list[str] = Field(description="Evidence-based conclusions")
|
conclusions: list[str] = Field(description="Evidence-based conclusions")
|
||||||
limitations: list[str] = Field(description="Limitations of the current research")
|
limitations: list[str] = Field(
|
||||||
|
description="Limitations of the current research", default=[]
|
||||||
|
)
|
||||||
recommendations: list[str] = Field(
|
recommendations: list[str] = Field(
|
||||||
description="Actionable recommendations based on findings"
|
description="Actionable recommendations based on findings", default=[]
|
||||||
)
|
)
|
||||||
sources_summary: str = Field(
|
sources_summary: str = Field(
|
||||||
description="Summary of sources used and their reliability"
|
description="Summary of sources used and their reliability"
|
||||||
|
|
|
||||||
|
|
@ -172,7 +172,6 @@ class TestResearchOrchestrator:
|
||||||
assert report.title
|
assert report.title
|
||||||
assert report.executive_summary
|
assert report.executive_summary
|
||||||
assert isinstance(report.main_findings, list)
|
assert isinstance(report.main_findings, list)
|
||||||
assert isinstance(report.themes, dict)
|
|
||||||
assert isinstance(report.conclusions, list)
|
assert isinstance(report.conclusions, list)
|
||||||
assert isinstance(report.limitations, list)
|
assert isinstance(report.limitations, list)
|
||||||
assert isinstance(report.recommendations, list)
|
assert isinstance(report.recommendations, list)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue