Method ContextualizeAsync
ContextualizeAsync(string, ChatHistory, LM, QueryContextualizationOptions, CancellationToken)
Reformulates a follow-up question into a self-contained query using the recent conversation history.
public static Task<string> ContextualizeAsync(string question, ChatHistory chatHistory, LM model, QueryContextualizationOptions options = null, CancellationToken cancellationToken = default)
Parameters
questionstringThe follow-up question to contextualize.
chatHistoryChatHistoryThe conversation history to draw context from. When
nullor empty, the question is returned unchanged.modelLMThe language model used for reformulation. Must not be
null.optionsQueryContextualizationOptionsConfiguration controlling history depth and token budget. Defaults are used when
null.cancellationTokenCancellationTokenA token to cancel the operation.
Returns
- Task<string>
The reformulated self-contained query, or the original
questionif contextualization is not needed or fails.
Exceptions
- ArgumentNullException
Thrown when
modelisnull.