ChatMessage class abstract
An abstract class representing a chat message.
This class provides a base for different types of chat messages, each with a specific role and content.
Properties:
role
: A string representing the role of the message sender.content
: The content of the message.
Constructors:
ChatMessage(String content)
: Initializes a chat message with the given content.ChatMessage.withRole({required String role, required String content})
: Factory constructor that creates a chat message based on the specified role. Throws anArgumentError
if the role is invalid.ChatMessage._fromRecord(_ChatMessageRecord record)
: Factory constructor that creates a chat message from a record.ChatMessage.fromNative(llama_chat_message message)
: Factory constructor that creates a chat message from a nativellama_chat_message
.
Methods:
llama_chat_message toNative()
: Converts the chat message to a nativellama_chat_message
._ChatMessageRecord _toRecord()
: Converts the chat message to a record.
- Implementers
Constructors
- ChatMessage.new(String content)
- Creates a new instance of ChatMessage with the given content.
-
ChatMessage.fromMap(Map<
String, dynamic> map) -
Creates a ChatMessage instance from a map.
factory
- ChatMessage.withRole({required String role, required String content})
-
Factory constructor to create a
ChatMessage
instance based on the provided role.factory
Properties
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toMap(
) → Map< String, String> -
Converts the current
ChatMessage
instance to a map. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
messageToMap(
ChatMessage message) → Map< String, String> - Converts a ChatMessage object to a map representation.