use ambi::llm::providers::openai_api::OpenAIEngineConfig;
use ambi::{Agent, ChatPipeline, LLMEngineConfig};
use anyhow::Result;
use futures::StreamExt;
use std::io::Write;
#[tokio::main]
async fn main() -> Result<()> {
let engine_config = LLMEngineConfig::OpenAI(OpenAIEngineConfig {
api_key: "mock-key".to_string(),
base_url: "https://api.openai.com/v1".to_string(),
model_name: "gpt-4o-mini".to_string(),
temp: 0.7,
top_p: 0.9,
});
let mut agent = Agent::make(engine_config).await?;
let mut res_stream = agent
.chat_stream("Who are you?")
.await
.map_err(|_| anyhow::anyhow!("Failed to create chat stream"))?;
while let Some(chunk) = res_stream.next().await {
if let Ok(text) = chunk {
print!("{}", text);
let _ = std::io::stdout().flush();
}
}
println!();
Ok(())
}