use llm_pipeline::payload::Payload;
use llm_pipeline::{ExecCtx, LlmCall, MockBackend};
use serde::Deserialize;
use serde_json::json;
use std::sync::Arc;
#[derive(Debug, Deserialize)]
struct MovieReview {
title: String,
rating: f64,
summary: String,
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mock = MockBackend::fixed(
r#"{"title": "Inception", "rating": 9.2, "summary": "A mind-bending thriller about dreams within dreams."}"#,
);
let ctx = ExecCtx::builder("http://unused")
.backend(Arc::new(mock))
.build();
let call = LlmCall::new("review", "Review the movie: {input}").expecting_json();
let output = call.invoke(&ctx, json!("Inception")).await?;
let review: MovieReview = output.parse_as()?;
println!("Movie: {}", review.title);
println!("Rating: {}/10", review.rating);
println!("Summary: {}", review.summary);
if let Some(ref diag) = output.diagnostics {
println!("Parse strategy: {:?}", diag.strategy);
println!("Parse OK: {}", diag.ok());
}
Ok(())
}