Expand description
§Conversation History Manager
Tracks multi-turn conversation history per SessionId, automatically injects
prior turns into outgoing prompts, and compresses old history when approaching
a configurable token budget.
§Quick start
use tokio_prompt_orchestrator::conversation::{ConversationManager, ConversationConfig};
use tokio_prompt_orchestrator::SessionId;
#[tokio::main]
async fn main() {
let mgr = ConversationManager::new(ConversationConfig::default());
let sid = SessionId::new("user-42");
// Record a user turn
mgr.push_user(&sid, "What is backpressure?").await;
// Build a prompt that includes conversation history
let prompt = mgr.build_prompt(&sid, "Explain it with an example.").await;
println!("{prompt}");
// Record the assistant's reply
mgr.push_assistant(&sid, "Backpressure is…").await;
}Structs§
- Conversation
- A single conversation thread.
- Conversation
Config - Configuration for
ConversationManager. - Conversation
Manager - Shared, async conversation history manager.
- Turn
- A single turn in a conversation.
Enums§
- Prompt
Format - Wire format used when serialising conversation history into a prompt string.
- Role
- Role of a conversation turn.
Functions§
- estimate_
tokens - Estimate token count for a string (4 chars ≈ 1 token is a well-known heuristic).