pub struct SignedInModel<A> { /* private fields */ }Expand description
A catalog model as an effect handler whose every request carries the
credential its CredentialSource resolves at that moment, refreshed
when it has expired: the key, the account it belongs to, and the API root the
sign-in names. The model connected with a credential serves every
request until the credential changes, so its memos last across turns.
Described as ModelAdapter describes the model, under its
reference.
use rig_core::catalog::Catalog;
use rig_core::providers::chatgpt::auth::{AuthSource, Authenticator, DeviceCodeHandler, FileTokenStore};
use rig_core::client::signed_in::SignedInModel;
use rig_core::serve::ErasedHandler;
let spec = Catalog::builtin().resolve("chatgpt/gpt-5.5")?.spec.clone();
let auth = Authenticator::new(AuthSource::OAuth, FileTokenStore::new("/path/to/credentials"), DeviceCodeHandler::default(), false);
let handler = ErasedHandler::new(SignedInModel::new(spec, auth, http)?);Implementations§
Source§impl<A: CredentialSource> SignedInModel<A>
impl<A: CredentialSource> SignedInModel<A>
Sourcepub fn new(
spec: ModelSpec,
credentials: A,
http: DynHttpClient,
) -> Result<Self, ConnectError>
pub fn new( spec: ModelSpec, credentials: A, http: DynHttpClient, ) -> Result<Self, ConnectError>
spec served with what credentials resolves, through http.
§Errors
What Catalog::connect_with reports for spec.
Trait Implementations§
Source§impl<A: CredentialSource> Serve for SignedInModel<A>
impl<A: CredentialSource> Serve for SignedInModel<A>
Source§fn check(&self, kind: &EffectKind) -> Vec<UnsupportedOption>
fn check(&self, kind: &EffectKind) -> Vec<UnsupportedOption>
What the model leaves out, from the unsigned model: a check is a dry run, which needs no credential.
Source§type Family = Completion
type Family = Completion
The family this handler serves, or
Dynamic.Source§fn descriptor(&self) -> HandlerDescriptor
fn descriptor(&self) -> HandlerDescriptor
What this handler is: the family-keyed description a typed view
checks at bind time and a scene serializes.
Source§async fn serve(&self, kind: EffectKind, dispatch: Dispatch) -> Reply
async fn serve(&self, kind: EffectKind, dispatch: Dispatch) -> Reply
Prepare an outcome or an owned stream for the driver to consume.
Source§fn key(&self) -> HandlerKey
fn key(&self) -> HandlerKey
The descriptor’s key. A handler whose
descriptor is costly to build, such as a tool’s argument schema,
says it without building one.
Source§fn footprint(&self, kind: &EffectKind) -> Option<Touches>
fn footprint(&self, kind: &EffectKind) -> Option<Touches>
What dispatching
kind may read and change, for a tool’s handler
(Tool::footprint); None when it
cannot say, such as for arguments that do not parse.Auto Trait Implementations§
impl<A> !Freeze for SignedInModel<A>
impl<A> !RefUnwindSafe for SignedInModel<A>
impl<A> !UnwindSafe for SignedInModel<A>
impl<A> Send for SignedInModel<A>where
A: Send,
impl<A> Sync for SignedInModel<A>where
A: Sync,
impl<A> Unpin for SignedInModel<A>where
A: Unpin,
impl<A> UnsafeUnpin for SignedInModel<A>where
A: UnsafeUnpin,
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
Converts
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> ⓘ
Converts
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