continueConversation method

  1. @override
Future<ChatResponse> continueConversation(
  1. String previousResponseId,
  2. List<ChatMessage> newMessages, {
  3. List<Tool>? tools,
  4. bool background = false,
})
override

Create a new response that continues from a previous response

This enables stateful conversations where the provider maintains the conversation history automatically.

Implementation

@override
Future<ChatResponse> continueConversation(
  String previousResponseId,
  List<ChatMessage> newMessages, {
  List<Tool>? tools,
  bool background = false,
}) async {
  // Create a new config with the previous response ID
  final updatedConfig =
      config.copyWith(previousResponseId: previousResponseId);
  final tempResponses = OpenAIResponses(client, updatedConfig);

  final requestBody =
      tempResponses._buildRequestBody(newMessages, tools, false, background);
  final responseData = await client.postJson(responsesEndpoint, requestBody);
  return _parseResponse(responseData);
}