use flarer::{Account, Flarer, JsonOptions, ResponseFormat};
use serde_json::json;
#[tokio::main]
async fn main() -> flarer::Result<()> {
let url = std::env::args()
.nth(1)
.unwrap_or_else(|| "https://example.com".to_string());
let schema = json!({
"type": "object",
"properties": {
"title": { "type": "string" },
"links": {
"type": "array",
"items": { "type": "string" }
}
},
"required": ["title"]
});
let account = Account::from_env()?;
let flarer = Flarer::builder().account(account).build()?;
let opts = JsonOptions::new()
.with_prompt("Extract the page title and all hyperlinks.")
.with_response_format(ResponseFormat::json_schema(schema));
let value = flarer.json(&url, opts).await?;
println!("{}", serde_json::to_string_pretty(&value)?);
Ok(())
}