Method RegenerateResponseAsync
RegenerateResponseAsync(CancellationToken)
Asynchronously regenerates the last response using the same context.
public Task<DocumentQueryResult> RegenerateResponseAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenToken to cancel the operation.
Returns
- Task<DocumentQueryResult>
A task containing a DocumentQueryResult with the regenerated response.
Examples
using var chat = new PdfChat(chatModel, embeddingModel);
await chat.LoadDocumentAsync("report.pdf");
chat.SamplingMode = new RandomSampling { Temperature = 0.5f };
var result = await chat.SubmitAsync("Summarize the report.");
// Get an alternative response asynchronously
var alternative = await chat.RegenerateResponseAsync();
Console.WriteLine(alternative.Response.Completion);
Remarks
Useful for obtaining an alternative phrasing or exploring different reasoning paths when using non-deterministic sampling modes.
Exceptions
- InvalidOperationException
Thrown if no documents have been loaded or no previous response exists.
- ObjectDisposedException
Thrown if this instance has been disposed.