Rust

conversation

Module

Conversations: the messages exchanged with an agent.

Contents

use utopia_agents::Conversation;
Rust
pub struct Conversation<A>

A conversation with an agent: messages added in order, sent together, the answer added as the assistant's, and the tokens every send used.

Rust
use utopia_agents::{Agent, Conversation, Message, OpenAi, User};

let mut agent = Agent::new(OpenAi::new("sk-..."));
agent.set_description("You are a helpful assistant.");

let mut conversation = Conversation::new(agent);
conversation.listen(|token: &str| print!("{token}"));
conversation.message(&User::new("user-1", "Ada"), Message::new("Hello!"), Vec::new())?;
let answer = conversation.send().await?;
println!("\n{} tokens", conversation.usage().total());
Compiles in CI; needs a running service to execute.
Also implements Debug.