Interface IQueryRewriter
Rewrites a query into retrieval-ready form using conversation history, and decides whether the query needs document search (search gate). This solves the classic multi-turn RAG problem where pronouns like "that", "it", or "tell me more" fail to retrieve relevant documents because they lack key terms. Implementations may also derive retrieval-oriented query terms for keyword or hybrid search.
public interface IQueryRewriter
Methods
RewriteAsync(string, IReadOnlyList<ConversationTurn>?, CancellationToken)
Rewrites the query into retrieval-ready form without depending on the caller's conversation state, and determines whether document search is needed.
Task<QueryRewriteResult> RewriteAsync(string query, IReadOnlyList<ConversationTurn>? conversationHistory, CancellationToken cancellationToken = default)
Parameters
querystringThe current user query (e.g., "Tell me more about that").
conversationHistoryIReadOnlyList<ConversationTurn>Previous conversation turns for context.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<QueryRewriteResult>
A QueryRewriteResult containing the processed semantic query, optional retrieval-oriented keywords, and search gate decision.