Cleanup console logging
This commit is contained in:
parent
3fc461e1b1
commit
fbb43c06c7
4 changed files with 27 additions and 24 deletions
|
|
@ -145,6 +145,12 @@ class HaikuRAGApp:
|
||||||
self.console.print(report.executive_summary)
|
self.console.print(report.executive_summary)
|
||||||
self.console.print()
|
self.console.print()
|
||||||
|
|
||||||
|
# Confidence (from last evaluation)
|
||||||
|
if state.last_eval:
|
||||||
|
conf = state.last_eval.confidence_score # type: ignore[attr-defined]
|
||||||
|
self.console.print(f"[bold cyan]Confidence:[/bold cyan] {conf:.1%}")
|
||||||
|
self.console.print()
|
||||||
|
|
||||||
# Main Findings
|
# Main Findings
|
||||||
if report.main_findings:
|
if report.main_findings:
|
||||||
self.console.print("[bold cyan]Main Findings:[/bold cyan]")
|
self.console.print("[bold cyan]Main Findings:[/bold cyan]")
|
||||||
|
|
|
||||||
|
|
@ -57,16 +57,16 @@ class EvaluateNode(BaseNode[ResearchState, ResearchDeps, ResearchReport]):
|
||||||
state.last_eval = output
|
state.last_eval = output
|
||||||
state.iterations += 1
|
state.iterations += 1
|
||||||
|
|
||||||
if deps.console:
|
if output.key_insights:
|
||||||
if output.key_insights:
|
log(deps.console, " [bold]Key insights:[/bold]")
|
||||||
deps.console.print(" [bold]Key insights:[/bold]")
|
for ins in output.key_insights:
|
||||||
for ins in output.key_insights:
|
log(deps.console, f" • {ins}")
|
||||||
deps.console.print(f" • {ins}")
|
log(
|
||||||
deps.console.print(
|
deps.console,
|
||||||
f" Confidence: [yellow]{output.confidence_score:.1%}[/yellow]"
|
f" Confidence: [yellow]{output.confidence_score:.1%}[/yellow]",
|
||||||
)
|
)
|
||||||
status = "[green]Yes[/green]" if output.is_sufficient else "[red]No[/red]"
|
status = "[green]Yes[/green]" if output.is_sufficient else "[red]No[/red]"
|
||||||
deps.console.print(f" Sufficient: {status}")
|
log(deps.console, f" Sufficient: {status}")
|
||||||
|
|
||||||
from haiku.rag.research.nodes.search import SearchDispatchNode
|
from haiku.rag.research.nodes.search import SearchDispatchNode
|
||||||
|
|
||||||
|
|
@ -74,8 +74,7 @@ class EvaluateNode(BaseNode[ResearchState, ResearchDeps, ResearchReport]):
|
||||||
output.is_sufficient
|
output.is_sufficient
|
||||||
and output.confidence_score >= state.confidence_threshold
|
and output.confidence_score >= state.confidence_threshold
|
||||||
) or state.iterations >= state.max_iterations:
|
) or state.iterations >= state.max_iterations:
|
||||||
if deps.console:
|
log(deps.console, "\n[bold green]✅ Stopping research.[/bold green]")
|
||||||
deps.console.print("\n[bold green]✅ Stopping research.[/bold green]")
|
|
||||||
return SynthesizeNode(self.provider, self.model)
|
return SynthesizeNode(self.provider, self.model)
|
||||||
|
|
||||||
return SearchDispatchNode(self.provider, self.model)
|
return SearchDispatchNode(self.provider, self.model)
|
||||||
|
|
|
||||||
|
|
@ -54,11 +54,10 @@ class PlanNode(BaseNode[ResearchState, ResearchDeps, ResearchReport]):
|
||||||
plan_result = await plan_agent.run(prompt, deps=agent_deps)
|
plan_result = await plan_agent.run(prompt, deps=agent_deps)
|
||||||
state.sub_questions = list(plan_result.output.sub_questions)
|
state.sub_questions = list(plan_result.output.sub_questions)
|
||||||
|
|
||||||
if deps.console:
|
log(deps.console, "\n[bold green]✅ Research Plan Created:[/bold green]")
|
||||||
deps.console.print("\n[bold green]✅ Research Plan Created:[/bold green]")
|
log(deps.console, f" [bold]Main Question:[/bold] {state.question}")
|
||||||
deps.console.print(f" [bold]Main Question:[/bold] {state.question}")
|
log(deps.console, " [bold]Sub-questions:[/bold]")
|
||||||
deps.console.print(" [bold]Sub-questions:[/bold]")
|
for i, sq in enumerate(state.sub_questions, 1):
|
||||||
for i, sq in enumerate(state.sub_questions, 1):
|
log(deps.console, f" {i}. {sq}")
|
||||||
deps.console.print(f" {i}. {sq}")
|
|
||||||
|
|
||||||
return SearchDispatchNode(self.provider, self.model)
|
return SearchDispatchNode(self.provider, self.model)
|
||||||
|
|
|
||||||
|
|
@ -36,11 +36,10 @@ class SearchDispatchNode(BaseNode[ResearchState, ResearchDeps, ResearchReport]):
|
||||||
batch.append(state.sub_questions.pop(0))
|
batch.append(state.sub_questions.pop(0))
|
||||||
|
|
||||||
async def answer_one(sub_q: str) -> SearchAnswer | None:
|
async def answer_one(sub_q: str) -> SearchAnswer | None:
|
||||||
if deps.console:
|
log(
|
||||||
deps.console.print(
|
deps.console,
|
||||||
f"\n[bold cyan]🔍 Searching & Answering:[/bold cyan] {sub_q}"
|
f"\n[bold cyan]🔍 Searching & Answering:[/bold cyan] {sub_q}",
|
||||||
)
|
)
|
||||||
|
|
||||||
agent = Agent(
|
agent = Agent(
|
||||||
model=get_model(self.provider, self.model),
|
model=get_model(self.provider, self.model),
|
||||||
output_type=ToolOutput(SearchAnswer, max_retries=3),
|
output_type=ToolOutput(SearchAnswer, max_retries=3),
|
||||||
|
|
@ -87,6 +86,6 @@ class SearchDispatchNode(BaseNode[ResearchState, ResearchDeps, ResearchReport]):
|
||||||
state.context.add_qa_response(ans)
|
state.context.add_qa_response(ans)
|
||||||
if deps.console:
|
if deps.console:
|
||||||
preview = ans.answer[:150] + ("…" if len(ans.answer) > 150 else "")
|
preview = ans.answer[:150] + ("…" if len(ans.answer) > 150 else "")
|
||||||
deps.console.log(f" [green]✓[/green] {preview}")
|
log(deps.console, f" [green]✓[/green] {preview}")
|
||||||
|
|
||||||
return SearchDispatchNode(self.provider, self.model)
|
return SearchDispatchNode(self.provider, self.model)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue