use copilot_client::{CopilotClient, Message};
use std::error::Error;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
let editor_version = "Neovim/0.9.0".to_string();
let client = CopilotClient::from_env_with_models(editor_version).await?;
let agents = client.get_agents().await?;
println!("Agents: {agents:?}");
let models = client.get_models().await?;
println!("Available models: {models:?}");
let messages = vec![
Message {
role: "system".to_string(),
content: "You are a highly skilled assistant.".to_string(),
},
Message {
role: "user".to_string(),
content: "Can you explain how to send an HTTP request in Rust?".to_string(),
},
];
let model_id = "gemini-2.0-flash-001".to_string();
match client.chat_completion(messages, model_id).await {
Ok(chat_response) => println!("Chat Response: {chat_response:?}"),
Err(e) => println!("Chat completion request error: {e}"),
}
let inputs = vec!["Rust programming language".to_string()];
let embeddings = client.get_embeddings(inputs).await?;
println!("Embeddings: {embeddings:?}");
Ok(())
}