use yoagent::decision::DecisionModel;
use yoagent::provider::ModelConfig;
use yoagent::Agent;
#[tokio::main]
async fn main() {
yoagent::provider::prices::enable_bundled();
let model = match std::env::var("CLOUDFLARE_ACCOUNT_ID") {
Ok(account) if !account.trim().is_empty() => {
eprintln!("using Clef on Workers AI (CLOUDFLARE_ACCOUNT_ID is set)");
DecisionModel::clef(account.trim())
}
_ => {
eprintln!("using TypeSafe's Jev");
DecisionModel::jev()
}
};
let message = "Help! My payouts have been failing for 3 days.";
let eval = match model
.ask(message)
.noul("urgent", "Does this convey urgency?")
.choice(
"team",
"Which team should handle this?",
["billing", "technical", "sales"],
)
.score(
"mood",
"How frustrated is the customer?",
["Calm", "Frustrated", "Very angry"],
)
.send()
.await
{
Ok(eval) => eval,
Err(e) => {
eprintln!("decision request failed: {e}");
std::process::exit(1);
}
};
let team = eval.choice("team").expect("asked");
let mood = eval.score("mood").expect("asked");
println!("answered by {}", eval.model());
println!("urgent: {:.2}", eval.p_true("urgent").unwrap_or_default());
println!(
"team: {} (confidence {:.2})",
team.choice(),
team.confidence()
);
println!(
"mood: {:.2} on 0..2 — mostly \"{}\"",
mood.score(),
mood.legend()[mood.level()]
);
println!(
"usage: {} input tokens, cost {}",
eval.usage().input_tokens,
eval.cost_usd()
.map(|c| format!("${c:.8}"))
.unwrap_or_else(|| "unpriced".into())
);
let _agent =
Agent::from_config(ModelConfig::claude_sonnet_5()).with_decision_model(model.clone());
}