getChatResponse method

  1. @override
Future<ChatResponse> getChatResponse({
  1. required Iterable<ChatMessage> messages,
  2. ChatOptions? options,
  3. CancellationToken? cancellationToken,
})
override

Sends a chat request and returns the complete response.

Implementation

@override
Future<ChatResponse> getChatResponse({
  required Iterable<ChatMessage> messages,
  ChatOptions? options,
  CancellationToken? cancellationToken,
}) async {
  _logInvoked('getChatResponse');
  _logInvokedSensitive('getChatResponse', messages, options);

  try {
    final response = await super.getChatResponse(
      messages: messages,
      options: options,
      cancellationToken: cancellationToken,
    );

    _logCompleted('getChatResponse');
    _logCompletedSensitive('getChatResponse', response);

    return response;
  } on OperationCanceledException {
    _logInvocationCanceled('getChatResponse');
    rethrow;
  } catch (e) {
    _logInvocationFailed('getChatResponse', e);
    rethrow;
  }
}