getResponse method
Future<ChatResponse>
getResponse({
- required Iterable<
ChatMessage> messages, - ChatOptions? options,
- CancellationToken? cancellationToken,
override
Sends a chat request and returns the complete response.
Implementation
@override
Future<ChatResponse> getResponse({
required Iterable<ChatMessage> messages,
ChatOptions? options,
CancellationToken? cancellationToken,
}) async {
final stopwatch = Stopwatch()..start();
final response = await super.getResponse(
messages: messages,
options: options,
cancellationToken: cancellationToken,
);
stopwatch.stop();
final cached = await getCachedResponse(getCacheKey(messages, options));
if (cached == null) {
_chatDetails.addTurnDetails(ChatTurnDetails(
latency: stopwatch.elapsed,
model: response.modelId,
usage: response.usage,
cacheHit: false,
));
}
return response;
}