use std::env;
use std::process;
use cactus_rs::needle::{Needle, Tool, Weights};
use serde_json::json;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let Some(path) = env::args().nth(1) else {
eprintln!("usage: custom_weights <path to needle3.cact>");
process::exit(2);
};
let weights = Weights::from_file(&path)?;
println!("{path}");
println!(" generation {}", weights.generation());
println!(" {} bytes", weights.len());
let mut needle = Needle::builder(weights)
.system("You control the lights.")
.tool(Tool::new(
"set_light",
"Turn a room light on or off",
json!({
"type": "object",
"properties": { "room": { "type": "string" }, "on": { "type": "boolean" } },
"required": ["room", "on"]
}),
))
.build()?;
println!(" prefix {} tokens", needle.prefix_tokens());
let completion = needle.complete("turn the study light off")?;
for call in completion.calls() {
println!("{} {}", call.name(), call.arguments_json());
}
Ok(())
}