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