Skip to main content

QueryRewriterAgent

Defined in the query_rewriter_agent module.
Agent for rewriting queries to improve retrieval quality in RAG applications. This agent transforms user queries using various strategies to bridge the gap between how users ask questions and how information is stored in knowledge bases. Attributes: name: Name of the agent model: LLM model to use for rewriting (alias for llm=) max_queries: Maximum number of queries to generate for multi-query strategy abbreviations: Dictionary of common abbreviations to expand

Constructor

name
str
default:"'QueryRewriterAgent'"
No description available.
model
str
default:"'gpt-4o-mini'"
No description available.
instructions
Optional
No description available.
verbose
bool
default:"False"
No description available.
max_queries
int
default:"5"
No description available.
abbreviations
Optional
No description available.
temperature
float
default:"0.3"
No description available.
max_tokens
int
default:"500"
No description available.
tools
Optional
No description available.

Methods

Usage

agent = QueryRewriterAgent(model="gpt-4o-mini")
    result = agent.rewrite("ML best practices", strategy=RewriteStrategy.MULTI_QUERY)
    for query in result.rewritten_queries:
        print(query)