userMessageContents property

List<String> get userMessageContents

Returns a List of Strings of all messages between the user and the model Assistant messages and tool use messages are not included Example:

final messages = chat.userMessageContent;
print(messages.first); //prints the first user message in the conversation

Implementation

List<String> get userMessageContents {
  List<String> messages = [];
  for (final item in _chatItems) {
    if (item is RequestChatEvent) {
      if (item.message.role == GroqMessageRole.user) {
        messages.add(item.message.content);
      }
    } else if (item is ResponseChatEvent) {
      if (item.response.choices.isNotEmpty &&
          !item.response.choices.first.messageData.isToolCall) {
        messages.add(item.response.choices.first.message);
      }
    }
  }
  return messages;
}