createConversation method

Future<String> createConversation({
  1. String? systemMessage,
})

Create a new conversation

Implementation

Future<String> createConversation({String? systemMessage}) async {
  _assertInitialized();

  final request = CreateConversationRequest();
  if (systemMessage != null) {
    request.systemMessage = systemMessage;
  }

  final response = await _client!.createConversation(request);

  if (response.hasError() && response.error.isNotEmpty) {
    throw Exception('Failed to create conversation: ${response.error}');
  }

  _currentConversationId = response.conversationId;
  debugPrint('[LiteRtLmClient] Conversation created: $_currentConversationId');

  return _currentConversationId!;
}