createConversation method

Future<String> createConversation({
  1. String? systemMessage,
  2. double? temperature,
  3. int? topK,
  4. double? topP,
})

Create a new conversation

Implementation

Future<String> createConversation({
  String? systemMessage,
  double? temperature,
  int? topK,
  double? topP,
}) async {
  _assertInitialized();

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

  // Add sampler config if any parameter provided
  if (temperature != null || topK != null || topP != null) {
    request.samplerConfig = SamplerConfig()
      ..temperature = temperature ?? 0.8
      ..topK = topK ?? 40
      ..topP = (topP ?? 0.95);
  }

  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!;
}