areev 0.2.0

Rust SDK for the Areev knowledge database — gRPC and HTTP transports
Documentation
//! End-to-end example: Harness chat with a client-executed tool (HPL).
//!
//! Demonstrates the `harness().chat_interactive` sugar that abstracts the
//! Flow-A pause/resume round-trip.
//!
//! Run (with a live Areev + harness bound to a `client://get_weather` tool):
//!
//! ```bash
//! AREEV_URL=http://localhost:4009 \
//! AREEV_MEMORY_ID=default \
//! AREEV_API_KEY=ar_... \
//!   cargo run --example harness_client_tool
//! ```

use std::pin::Pin;

use areev::{Areev, ChatExecutors, Result};
use serde_json::json;

#[tokio::main]
async fn main() -> Result<()> {
    let areev = Areev::from_env();

    // Register a trivial in-process executor for `get_weather(city: String)`.
    let mut executors: ChatExecutors = ChatExecutors::new();
    executors.insert(
        "get_weather",
        Box::new(|_name, args| {
            Pin::from(Box::new(async move {
                let city = args
                    .get("city")
                    .and_then(|v| v.as_str())
                    .unwrap_or("unknown");
                Ok(json!({
                    "city": city,
                    "temp_c": 22,
                    "conditions": "sunny",
                }))
            }))
        }),
    );

    let response = areev
        .harness()
        .chat_interactive(
            "weather-harness",
            "conv-example-1",
            "What's the weather in Paris?",
            &executors,
        )
        .await?;

    println!("assistant: {}", response.text);
    println!(
        "iterations={} tool_calls={} provider={}",
        response.iterations,
        response.tool_calls.len(),
        response.provider
    );
    Ok(())
}