agentai 0.3.2

AgentAI is a Rust library designed to simplify the creation of AI agents.
Documentation
//! OpenRouter Example
//!
//! This example uses OpenRouter through `Agent::new_with_provider(Provider::OpenRouter, ..)`.
//! No base URL is needed: agentai knows OpenRouter's endpoint, and every model name
//! (for example `nvidia/nemotron-3.5-super-vl:free`) is sent to OpenRouter as is.

use agentai::tool::buildin::CurrentDateAndTimeToolBox;
use agentai::{Agent, AgentResult, Provider};
use anyhow::Result;
use log::{LevelFilter, info};
use simplelog::{ColorChoice, Config, TermLogger, TerminalMode};

const SYSTEM: &str = "You are helpful assistant. Use tools when you need the current date or time.";

#[tokio::main]
async fn main() -> Result<()> {
    TermLogger::init(
        LevelFilter::Info,
        Config::default(),
        TerminalMode::Mixed,
        ColorChoice::Auto,
    )?;
    info!("Starting AgentAI");

    let question = "What day of the week is it today?";

    info!("Question: {}", question);

    let api_key = std::env::var("OPENROUTER_API_KEY")?;

    // `None` keeps the default OpenRouter endpoint
    let agent = Agent::new_with_provider(Provider::OpenRouter, None, &api_key, SYSTEM)?
        .with_model("nvidia/nemotron-3.5-super-vl:free")
        .with_toolbox(CurrentDateAndTimeToolBox {});

    let result: AgentResult<String> = agent.run(question).await?;

    info!("Answer: {}", result.answer);

    Ok(())
}