oxide-agent 0.1.0

Type-safe, high-performance Rust crate for building agentic systems on Ollama
Documentation
//! Basic single-turn and multi-turn chat via `HttpOllamaClient`.
//!
//! Run with:
//!   cargo run --example basic_chat

use oxide_agent::client::{HttpOllamaClient, OllamaClient};
use oxide_agent::types::{ChatRequest, Message, Role};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let client = HttpOllamaClient::new("http://localhost:11434");

    // ── Single-turn chat ──────────────────────────────────────────────────────
    let req = ChatRequest {
        model: "llama3".into(),
        messages: vec![Message {
            role: Role::User,
            content: "Explain ownership in Rust in one sentence.".into(),
            tool_calls: None,
        }],
        tools: None,
        stream: false,
    };

    let response = client.chat(req).await?;
    println!("Assistant: {}", response.message.content);

    // ── List available models ─────────────────────────────────────────────────
    let models = client.list_models().await?;
    println!("\nModels available on your server:");
    for m in models.models {
        println!("  {} ({} bytes)", m.name, m.size);
    }

    Ok(())
}