pub struct Copilot { /* private fields */ }Expand description
GitHub Copilot: its CopilotConfig on a transport. Every model it
builds sends through that transport.
Implementations§
Source§impl Copilot
impl Copilot
Sourcepub fn with_http(self, http: impl HttpClientExt + 'static) -> Self
pub fn with_http(self, http: impl HttpClientExt + 'static) -> Self
The same configuration, sending through http.
Sourcepub fn config(&self) -> &CopilotConfig
pub fn config(&self) -> &CopilotConfig
The configuration this client sends with.
Source§impl Copilot
impl Copilot
Sourcepub fn new(api_key: impl Into<Secret>) -> Self
Available on crate feature reqwest only.
pub fn new(api_key: impl Into<Secret>) -> Self
reqwest only.Copilot with an exchanged session token, on the shared reqwest
client. See CopilotConfig::new for how the endpoint is chosen.
Sourcepub fn from_env() -> Result<Self, EnvError>
Available on crate feature reqwest only.
pub fn from_env() -> Result<Self, EnvError>
reqwest only.Copilot from the environment (CopilotConfig::from_env), on the
shared reqwest client. This does not exchange a token.
Sourcepub fn completion(&self, model: impl Into<String>) -> Model<CopilotWire>
pub fn completion(&self, model: impl Into<String>) -> Model<CopilotWire>
The completion model for model, on whichever route answers it.
Sourcepub fn embedding(
&self,
model: impl Into<String>,
ndims: Option<usize>,
) -> Model<Embeddings>
pub fn embedding( &self, model: impl Into<String>, ndims: Option<usize>, ) -> Model<Embeddings>
The embedding model for model, ndims wide when set.
Sourcepub async fn list_models(&self) -> Result<ModelList, ProviderError>
pub async fn list_models(&self) -> Result<ModelList, ProviderError>
The models this session can use.
Sourcepub async fn authenticate(
self,
authenticator: &Authenticator,
) -> Result<Self, AuthError>
pub async fn authenticate( self, authenticator: &Authenticator, ) -> Result<Self, AuthError>
A client on this client’s transport, configured with the session
authenticator resolves: the device login, the GitHub token
exchange and the refresh all send through this client’s transport.
The session token replaces the credential; the API root is the one
the exchange names, unless this client’s was set explicitly.
use rig_core::providers::copilot::{CopilotConfig, auth::{AuthSource, Authenticator, DeviceCodeHandler}};
let authenticator = Authenticator::new(AuthSource::OAuth, None, None, DeviceCodeHandler::default(), true);
let copilot = CopilotConfig::new("").connect(http).authenticate(&authenticator).await?;Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Copilot
impl !UnwindSafe for Copilot
impl Freeze for Copilot
impl Send for Copilot
impl Sync for Copilot
impl Unpin for Copilot
impl UnsafeUnpin for Copilot
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more