ChatMessage class final
A chat message.
- Annotations
Constructors
-
ChatMessage({required ChatMessageRole role, List<
StandardPart> parts = const [], Map<String, Object?> metadata = const {}, FinishStatus? finishStatus}) - Creates a new message.
-
ChatMessage.fromJson(Map<
String, Object?> json) -
Deserializes a message.
factory
-
ChatMessage.model(String text, {List<
StandardPart> parts = const [], Map<String, Object?> metadata = const {}, FinishStatus? finishStatus}) - Creates a model message.
-
ChatMessage.system(String text, {List<
StandardPart> parts = const [], Map<String, Object?> metadata = const {}, FinishStatus? finishStatus}) - Creates a system message.
-
ChatMessage.user(String text, {List<
StandardPart> parts = const [], Map<String, Object?> metadata = const {}, FinishStatus? finishStatus}) - Creates a user message.
Properties
- finishStatus → FinishStatus?
-
The finish status of the message.
final
- hashCode → int
-
The hash code for this object.
no setteroverride
- hasToolCalls → bool
-
Whether this message contains any tool calls.
no setter
- hasToolResults → bool
-
Whether this message contains any tool results.
no setter
-
metadata
→ Map<
String, Object?> -
Optional metadata associated with this message.
final
-
parts
→ List<
StandardPart> -
The content parts of the message.
final
- role → ChatMessageRole
-
The role of the message author.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- text → String
-
Concatenated TextPart parts.
no setter
-
toolCalls
→ List<
ToolPart> -
Gets all tool calls in this message.
no setter
-
toolResults
→ List<
ToolPart> -
Gets all tool results in this message.
no setter
Methods
-
concatenate(
ChatMessage other) → ChatMessage - Concatenates this message with another message.
-
copyWith(
{ChatMessageRole? role, List< StandardPart> ? parts, Map<String, Object?> ? metadata, FinishStatus? finishStatus}) → ChatMessage - Creates a copy of this message with optional fields replaced.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → Map< String, Object?> - Serializes the message to JSON.
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override