sendMessageWithCallback method
Sends a message to the conversation and streams chunks to callback.
Implementation
Future<void> sendMessageWithCallback(
Message message,
MessageCallback callback, {
Map<String, Object?>? extraContext,
int? maxOutputTokens,
}) async {
final handle = _handle;
if (handle == null) {
throw const LiteRtLmException('Conversation is already disposed.');
}
final extraContextJson = extraContext == null || extraContext.isEmpty
? null
: jsonEncode(extraContext);
final controller = _ToolCallingMessageCallback(
handle: handle,
userCallback: callback,
handleToolCalls: _handleToolCalls,
automaticToolCalling: _automaticToolCalling,
extraContextJson: extraContextJson,
maxOutputTokens: maxOutputTokens,
);
return controller.send(message);
}