rewrite • AI Agent SDK
rewrite: Rewrite a query using the specified strategy.
rewrite
Method
</div>
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) -> RewriteResultParameters
ParamField
strThe original user query
ParamField
RewriteStrategyRewriting strategy to use
ParamField
OptionalPrevious conversation messages for contextual rewriting
ParamField
Optional[str]Additional context about the knowledge base
ParamField
intNumber of queries for multi-query strategy
Returns
ResponseField
RewriteResultRewriteResult containing rewritten queries
Uses
debug
Used By
QueryRewriterAgent.rewrite_basicQueryRewriterAgent.rewrite_hydeQueryRewriterAgent.rewrite_step_backQueryRewriterAgent.rewrite_sub_queriesQueryRewriterAgent.rewrite_multi_query
Source
View on GitHubpraisonaiagents/agent/query_rewriter_agent.py at line 343