send method

Future<AIResponse> send(
  1. String conversationId,
  2. String message, {
  3. List<AITool>? tools,
})

Sends a message in a conversation and returns the response.

Implementation

Future<AIResponse> send(
  String conversationId,
  String message, {
  List<AITool>? tools,
}) async {
  final conversation = _conversations[conversationId];
  if (conversation == null) {
    throw StateError('Conversation $conversationId not found');
  }

  // Add user message
  conversation.addMessage(AIMessage.user(message));
  storage?.saveConversation(conversation);

  return _processConversation(conversation, tools);
}