troupekit 0.4.0

Rust framework for LLM agents that run inside your own program: #[agent] functions or persona TOML files, tools, memory, document search and graph workflows that survive a restart.
Documentation
use std::error::Error;
use std::path::Path;
use troupekit::agent::Limits;
use troupekit::prelude::*;

const MODEL: &str = "anthropic/claude-haiku-5-5";

/// Builds a travel helper that remembers facts about `user` in the SQLite
/// file `db`. Your code picks the user and the session, never the model.
/// Input: file, user and session. Output: the built agent.
async fn concierge(db: &Path, user: &str, session: &str) -> Result<BuiltAgent, KitError> {
    Agent::new("concierge")
        .model(MODEL)
        .instructions(
            "You help a customer plan trips. When the customer tells you a lasting \
             preference, save it with remember_fact. Use what you know about the \
             customer in every answer, in at most three sentences.",
        )
        .memory(AgentMemory::new(user, session).sqlite(db))
        .max_turns(4)
        .limits(Limits {
            run: Some(30_000),
            ..Limits::default()
        })
        .build()
        .await
}

/// Tells the agent two facts as ada, builds it again as if the program
/// had restarted, asks ada's question, then asks bob the same question.
/// Input: ANTHROPIC_API_KEY. Output: the three answers on stdout.
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    let dir = tempfile::tempdir()?;
    let db = dir.path().join("memory.db");
    let monday = concierge(&db, "ada", "monday").await?;
    let told = monday
        .run("I am vegetarian and I never take flights before 9 am. Please remember that.")
        .await?;
    println!("ada, monday:\n{told}\n");
    drop(monday);
    let question = "Plan dinner and the flight for my trip to Lisbon on Friday.";
    let tuesday = concierge(&db, "ada", "tuesday").await?;
    println!("ada, tuesday:\n{}\n", tuesday.run(question).await?);
    let bob = concierge(&db, "bob", "tuesday").await?;
    println!("bob, tuesday:\n{}", bob.run(question).await?);
    Ok(())
}