AiConversation class final
An ordered, immutable transcript of AiMessages.
The conversation retains the full message history; trimming for token budgets is deliberately out of scope and belongs to the server or provider integration, so the user can always scroll back through the entire session.
Every mutating helper returns a new instance, preserving value semantics.
Constructors
-
AiConversation({required String id, List<
AiMessage> messages = const []}) -
Creates a conversation.
const
- AiConversation.empty(String id)
-
An empty conversation with the given
id.const -
AiConversation.fromJson(Map<
String, Object?> json) -
Reconstructs a conversation from
json.factory
Properties
- hashCode → int
-
The hash code for this object.
no setteroverride
- id → String
-
A stable, unique identifier for this conversation.
final
- lastMessage → AiMessage?
-
The most recent message, or
nullif the conversation is empty.no setter -
messages
→ List<
AiMessage> -
The full ordered transcript.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
append(
AiMessage message) → AiConversation -
Returns a copy with
messageappended. -
copyWith(
{String? id, List< AiMessage> ? messages}) → AiConversation - Returns a copy with the given fields replaced.
-
messageById(
String messageId) → AiMessage? -
Returns the message with the given
messageId, ornullif absent. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
replace(
AiMessage message) → AiConversation -
Returns a copy in which the message sharing
message's id is replaced. -
toJson(
) → Map< String, Object?> - Serializes this conversation.
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override