use allama::mock::MockStreamingProvider;
use allama::prelude::*;
use allama::wrappers::{TracingContentConfig, TracingProvider};
use tracing_subscriber::FmtSubscriber;
use tracing_subscriber::fmt::format::FmtSpan;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let _ = tracing::subscriber::set_global_default(
FmtSubscriber::builder()
.with_span_events(FmtSpan::CLOSE)
.with_target(false)
.without_time()
.finish(),
);
let provider = TracingProvider::new(MockStreamingProvider::build(|b| {
b.text("Traced hello from allama.")
.text("Traced hello from allama.")
}))
.with_content_capture(TracingContentConfig::all());
let request = ChatRequest::new("demo-model")
.system("You are concise.")
.user("Say hello");
let response = provider.chat(&request).await?;
println!("traced chat text: {}", response.text_or_empty());
let streamed = provider
.chat_stream(&request)
.await?
.collect_response()
.await?;
println!("traced stream text: {}", streamed.text_or_empty());
Ok(())
}