Skip to main content

Crate abk

Crate abk 

Source
Expand description

Agent Builder Kit (ABK) - Modular utilities for building LLM agents

ABK provides a set of feature-gated modules for building LLM-based agents:

  • config - Configuration and environment loading
  • observability - Structured logging, metrics, and tracing
  • cli - CLI display utilities and formatting helpers
  • checkpoint - Session persistence and checkpoint management

§Features

Enable the features you need in your Cargo.toml:

[dependencies]
abk = { version = "0.1", features = ["config"] }
# Or enable multiple features:
abk = { version = "0.1", features = ["config", "observability"] }
# Or enable everything:
abk = { version = "0.1", features = ["all"] }

§Example: Using the config feature

use abk::config::{ConfigurationLoader, EnvironmentLoader};
use std::path::Path;

// Load environment variables
let env = EnvironmentLoader::new(None);

// Load configuration from TOML
let config_loader = ConfigurationLoader::new(Some(Path::new("config/agent.toml"))).unwrap();
let config = &config_loader.config;

// Access configuration
println!("Max iterations: {}", config.execution.max_iterations);
println!("LLM provider: {:?}", env.llm_provider());

§Example: Using the observability feature

use abk::observability::Logger;
use std::collections::HashMap;

// Create a logger
let logger = Logger::new(None, Some("DEBUG")).unwrap();

// Log a session start
let config = HashMap::new();
logger.log_session_start("auto", &config).unwrap();

// Log an LLM interaction
let messages = vec![];
logger.log_llm_interaction(&messages, "Hello, world!", "gpt-4").unwrap();

§Example: Using the checkpoint feature

use abk::checkpoint::{get_storage_manager, CheckpointResult};
use std::path::Path;

async fn example() -> CheckpointResult<()> {
    let manager = get_storage_manager()?;
    let project_path = Path::new(".");
    let project_storage = manager.get_project_storage(project_path).await?;
    Ok(())
}

Modules§

prelude
Prelude module for convenient imports