use base64::{engine::general_purpose::STANDARD, Engine as _};
use marona::{Agent, Input, Marona, Runner, ToolChoice};
use serde_json::json;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let marona = Marona::builder()
.runtime_url(
std::env::var("MARONA_RUNTIME_URL").unwrap_or_else(|_| "https://edge.marona.ai".into()),
)
.build()?;
let agent = Agent::new(&marona, "Document Assistant")
.model(
std::env::var("MARONA_MODEL").unwrap_or_else(|_| "marona/qwen-qwen3.8-max-0902".into()),
)
.instructions("Answer clearly and concisely.")
.tool_choice(ToolChoice::None);
let mut input = Input::from("Reply with exactly OK.");
if let Some(path) = std::env::args().nth(1) {
let extension = std::path::Path::new(&path)
.extension()
.and_then(|value| value.to_str())
.unwrap_or("")
.to_ascii_lowercase();
let mime = match extension.as_str() {
"png" => "image/png",
"jpg" | "jpeg" => "image/jpeg",
_ => return Err("Use a PNG or JPEG image.".into()),
};
let data_url = format!(
"data:{mime};base64,{}",
STANDARD.encode(std::fs::read(path)?)
);
input = Input::Message(json!({"role": "user", "content": [
{"type": "input_text", "text": "Describe this image and transcribe any visible text."},
{"type": "input_image", "image_url": data_url}
]}));
}
let result = Runner::run(&agent, input, Some("example-user"), Some("example-session")).await?;
println!("{}", result.output);
Ok(())
}