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

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

Parameters

ParamField str

The original user query

ParamField RewriteStrategy

Rewriting strategy to use

ParamField Optional

Previous conversation messages for contextual rewriting

ParamField Optional[str]

Additional context about the knowledge base

ParamField int

Number of queries for multi-query strategy

Returns

ResponseField RewriteResult

RewriteResult containing rewritten queries

Uses

  • debug

Used By

Source

View on GitHub

praisonaiagents/agent/query_rewriter_agent.py at line 343