Skip to main content

aither_copilot/
lib.rs

1//! GitHub Copilot integration for the Aither framework.
2//!
3//! This crate provides a `Copilot` client that implements the `LanguageModel` trait,
4//! allowing you to use GitHub Copilot's chat API through the unified aither interface.
5//!
6//! GitHub Copilot uses OAuth device flow for authentication. The typical flow is:
7//!
8//! 1. Call [`auth::request_device_code`] to get a device code and verification URL
9//! 2. Direct the user to the verification URL to enter the code
10//! 3. Call [`auth::poll_for_token`] to wait for the user to complete authentication
11//! 4. Use the token to create a [`Copilot`] client
12//!
13//! ```no_run
14//! use aither_copilot::{Copilot, auth};
15//! use aither_core::LanguageModel;
16//!
17//! # async fn demo() -> Result<(), Box<dyn std::error::Error>> {
18//! // Request device code
19//! let device_code = auth::request_device_code().await?;
20//! println!("Visit {} and enter code: {}", device_code.verification_uri, device_code.user_code);
21//!
22//! // Poll for token
23//! let token = auth::poll_for_token(&device_code.device_code, device_code.interval).await?;
24//!
25//! // Create client
26//! let copilot = Copilot::new(token.access_token);
27//! # Ok(())
28//! # }
29//! ```
30
31mod client;
32mod constant;
33mod error;
34mod provider;
35
36pub mod auth;
37
38pub use client::{Builder, Copilot};
39pub use constant::*;
40pub use error::CopilotError;
41pub use provider::CopilotProvider;