use rig::{
completion::Prompt,
providers::gemini::{self, completion::gemini_api_types::GenerationConfig},
};
#[tracing::instrument(ret)]
#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
tracing_subscriber::fmt()
.with_max_level(tracing::Level::DEBUG)
.with_target(false)
.init();
let client = gemini::Client::from_env();
let agent = client
.agent(gemini::completion::GEMINI_1_5_PRO)
.preamble("Be creative and concise. Answer directly and clearly.")
.temperature(0.5)
.additional_params(serde_json::to_value(GenerationConfig {
top_k: Some(1),
top_p: Some(0.95),
candidate_count: Some(1),
..Default::default()
})?) .build();
tracing::info!("Prompting the agent...");
let response = agent
.prompt("How much wood would a woodchuck chuck if a woodchuck could chuck wood? Infer an answer.")
.await;
tracing::info!("Response: {:?}", response);
match response {
Ok(response) => println!("{}", response),
Err(e) => {
tracing::error!("Error: {:?}", e);
return Err(e.into());
}
}
Ok(())
}