createConversationHandle method

LiteRtLmConversationHandle createConversationHandle({
  1. String? systemMessage,
  2. String? toolsJson,
  3. String? messagesJson,
  4. double temperature = 0.8,
  5. int topK = 40,
  6. double? topP,
  7. int seed = 1,
})

Create a new conversation handle with optional system message and tools. The engine allows only ONE live conversation at a time (upstream LiteRT-LM #966), so the caller must delete any prior conversation before creating a new one — this is how virtual-session multiplexing rebuilds context. The caller owns the handle and must call LiteRtLmConversationHandle.close.

messagesJson optionally seeds the conversation with prior turns (a JSON array of {role, content} objects). Used by the virtual- session multiplexer to replay a session's history into a fresh conversation. When null the conversation starts empty (legacy behaviour).

Implementation

LiteRtLmConversationHandle createConversationHandle({
  String? systemMessage,
  String? toolsJson,
  String? messagesJson,
  double temperature = 0.8,
  int topK = 40,
  double? topP,
  int seed = 1,
}) {
  final conv = _createRawConversation(
    systemMessage: systemMessage,
    toolsJson: toolsJson,
    messagesJson: messagesJson,
    temperature: temperature,
    topK: topK,
    topP: topP,
    seed: seed,
  );
  gemmaLog('[LiteRtLmFfi] Conversation created');
  final handle = LiteRtLmConversationHandle._(this, conv);
  _handles.add(handle);
  return handle;
}