critic_agent
langroid/agent/special/lance_rag/critic_agent.py
QueryPlanCritic is a ChatAgent that is created with a specific document schema.
Its role is to provide feedback on a Query Plan, which consists of:
- filter condition if needed (or empty string if no filter is needed)
- query - a possibly rephrased query that can be used to match the content
field
- dataframe_calc - a Pandas-dataframe calculation/aggregation string, possibly empty
- original_query - the original query for reference
- result - the answer received from an assistant that used this QUERY PLAN.
This agent has access to two tools: - QueryPlanTool: The handler method for this tool re-writes the query plan in plain text (non-JSON) so the LLM can provide its feedback using the QueryPlanFeedbackTool. - QueryPlanFeedbackTool: LLM uses this tool to provide feedback on the Query Plan
QueryPlanCritic(cfg)
¶
Bases: ChatAgent
Critic for LanceQueryPlanAgent, provides feedback on query plan + answer.
Source code in langroid/agent/special/lance_rag/critic_agent.py
query_plan_answer(msg)
¶
Present query plan + answer in plain text (not JSON) so LLM can give feedback
query_plan_feedback(msg)
¶
Format Valid so return to Query Planner
Source code in langroid/agent/special/lance_rag/critic_agent.py
handle_message_fallback(msg)
¶
Remind the LLM to use QueryPlanFeedbackTool since it forgot