AssistantMessage class final
A message produced by the assistant (the model), final or partial.
Ported from pi's AssistantMessage. The role is implicit in the type.
Partial instances are the live snapshots carried by every
AssistantMessageEvent (partial-first design): consumers can render them
directly without accumulating deltas themselves.
- Implemented types
Constructors
-
AssistantMessage({required List<
ContentBlock> content, required String api, required String provider, required String model, String? responseModel, String? responseId, required Usage usage, required StopReason stopReason, String? rawStopReason, String? errorMessage, RateLimitInfo? rateLimit, required DateTime timestamp}) -
const
-
AssistantMessage.fromJson(Map<
String, dynamic> json) -
Deserializes from a JSON map produced by toJson.
factory
Properties
- api → String
-
The API dialect that produced this message (e.g.
openai-completions,anthropic-messages,google-generative-ai).final -
content
→ List<
ContentBlock> -
Ordered content blocks (text, thinking, tool calls).
final
- errorMessage → String?
-
Human-readable error description when stopReason is
StopReason.error or StopReason.aborted.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- model → String
-
The requested model id.
final
- provider → String
-
The provider id (e.g.
openai,anthropic,openrouter).final - rateLimit → RateLimitInfo?
-
The structured decode of a 429 rate-limit failure (issue #867), when
the provider surfaced one. Carried on the error event so every surface
renders from the structure; RateLimitInfo.rawBody stays diagnostics-
only and never reaches a render.
final
- rawStopReason → String?
-
The provider's raw terminal stop/finish reason as reported on the wire
(e.g.
end_turn,max_tokens,SAFETY), when the adapter parsed one. Values that do not map onto StopReason surface as StopReason.error with the original string preserved here.final - responseId → String?
-
Provider-specific response/message identifier, when exposed upstream.
final
- responseModel → String?
-
Concrete model id reported by the provider, when different from model
(e.g. OpenRouter
autorouting toanthropic/...).final - role → String
-
The role discriminator:
user,assistant, ortoolResult.no setteroverride - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- stopReason → StopReason
-
Why the stream terminated. On partial snapshots this is the provider's
current best guess (usually StopReason.stop until the terminal event).
final
- timestamp → DateTime
-
When this message was created (pi stores Unix milliseconds; Dart uses
DateTime).
final
- usage → Usage
-
Token and cost accounting for this response.
final
Methods
-
copyWith(
{List< ContentBlock> ? content, String? api, String? provider, String? model, String? responseModel, String? responseId, Usage? usage, StopReason? stopReason, String? rawStopReason, String? errorMessage, RateLimitInfo? rateLimit, DateTime? timestamp}) → AssistantMessage -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → Map< String, dynamic> -
Serializes to a JSON map with a
rolediscriminator (pi shape).override -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited