ConversationManager class
Manages conversations with AI providers.
Handles context tracking, token counting, conversation history, and automatic summarization for long conversations.
Constructors
- ConversationManager({required AIProvider provider, int maxContextTokens = 4096, int maxToolIterations = 10, TokenTracker? tokenTracker, StorageProvider? storage})
Properties
-
all
→ List<
Conversation> -
Returns all active conversations.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- maxContextTokens → int
-
Maximum tokens to keep in context window.
final
- maxToolIterations → int
-
Maximum recursive tool call iterations before aborting.
final
- provider → AIProvider
-
The AI provider to use for completions.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- storage → StorageProvider?
-
Optional storage provider for saving and loading conversations automatically.
final
- tokenTracker → TokenTracker
-
Token tracker for monitoring usage.
final
Methods
-
clearAll(
) → void - Clears all conversations from memory (but not storage).
-
create(
{String? systemPrompt, String? title}) → Conversation - Creates a new conversation with an optional system prompt.
-
delete(
String conversationId) → void - Deletes a conversation from memory and storage.
-
get(
String conversationId) → Conversation? - Gets a conversation by ID from memory.
-
load(
String conversationId) → Future< Conversation?> - Asynchronously loads a conversation from storage.
-
loadAll(
) → Future< List< Conversation> > - Asynchronously loads all conversations from storage into memory.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
send(
String conversationId, String message, {List< AITool> ? tools}) → Future<AIResponse> - Sends a message in a conversation and returns the response.
-
sendStream(
String conversationId, String message) → Stream< AIStreamChunk> - Sends a message in a conversation and returns a stream of chunks.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited