use rig::prelude::*;
use rig::providers::cohere;
use rig::streaming::{stream_to_stdout, StreamingPrompt};
#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
let agent = cohere::Client::from_env()
.agent(cohere::COMMAND)
.preamble("Be precise and concise.")
.temperature(0.5)
.build();
let mut stream = agent
.stream_prompt("When and where and what type is the next solar eclipse?")
.await?;
stream_to_stdout(&agent, &mut stream).await?;
if let Some(response) = stream.response {
println!("Usage: {:?} tokens", response.usage);
};
println!("Message: {:?}", stream.choice);
Ok(())
}