Skip to main content

rewrite

Method
This is a method of the QueryRewriterAgent class in the query_rewriter_agent module.
Rewrite a query using the specified strategy. All operations go through an internal Agent which automatically handles tool calling when tools are provided. The agent decides when to use tools based on the query context.

Signature

def rewrite(query: str, strategy: RewriteStrategy, chat_history: Optional[List[Dict[str, str]]], context: Optional[str], num_queries: int) -> RewriteResult

Parameters

query
str
required
The original user query
strategy
RewriteStrategy
default:"RewriteStrategy.AUTO"
Rewriting strategy to use
chat_history
Optional
Previous conversation messages for contextual rewriting
context
Optional
Additional context about the knowledge base
num_queries
int
Number of queries for multi-query strategy

Returns

Returns
RewriteResult
RewriteResult containing rewritten queries