Table of Contents

Interface IQueryRewriter

Namespace
Mythosia.AI.Rag
Assembly
Mythosia.AI.Rag.Abstractions.dll

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

query string

The current user query (e.g., "Tell me more about that").

conversationHistory IReadOnlyList<ConversationTurn>

Previous conversation turns for context.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<QueryRewriteResult>

A QueryRewriteResult containing the processed semantic query, optional retrieval-oriented keywords, and search gate decision.