Skip to main content

ProviderRegistry

Struct ProviderRegistry 

Source
pub struct ProviderRegistry { /* private fields */ }
Expand description

Resolves model ids of the form <provider><separator><model>.

Implementations§

Source§

impl ProviderRegistry

Source

pub fn builder() -> ProviderRegistryBuilder

Starts building a registry.

Source

pub fn provider_ids(&self) -> impl Iterator<Item = &str> + '_

The registered provider ids.

Source

pub fn provider(&self, id: &str) -> Option<&ProviderRef>

Looks up a provider by id.

Source

pub fn files(&self, provider_id: &str) -> Result<FilesRef, Error>

Resolves a file service by provider ID.

§Errors

Returns Error::NoSuchProvider for an unknown provider or a provider ProviderError::UnsupportedFunctionality when file uploads are unavailable.

Source

pub fn skills(&self, provider_id: &str) -> Result<SkillsRef, Error>

Resolves a skill service by provider ID.

§Errors

Returns Error::NoSuchProvider for an unknown provider or a provider ProviderError::UnsupportedFunctionality when skills are unavailable.

Source

pub fn register_provider( &mut self, id: impl Into<String>, provider: ProviderRef, )

Registers or replaces a provider for subsequent model resolutions.

Source

pub fn language_model(&self, id: &str) -> Result<LanguageModelRef, Error>

Resolves a language model, applying the registry middleware.

§Errors

Error::NoSuchProvider for unknown providers, Error::Provider (NoSuchModel) for malformed ids or unknown models.

Source

pub fn embedding_model(&self, id: &str) -> Result<EmbeddingModelRef, Error>

Resolves an embedding model, applying the registry middleware.

§Errors

See ProviderRegistry::language_model.

Source

pub fn image_model(&self, id: &str) -> Result<ImageModelRef, Error>

Resolves an image model, applying the registry middleware.

§Errors

See ProviderRegistry::language_model.

Source

pub fn transcription_model( &self, id: &str, ) -> Result<TranscriptionModelRef, Error>

Resolves a transcription model.

§Errors

See ProviderRegistry::language_model.

Source

pub fn speech_model(&self, id: &str) -> Result<SpeechModelRef, Error>

Resolves a speech model.

§Errors

See ProviderRegistry::language_model.

Source

pub fn reranking_model(&self, id: &str) -> Result<RerankingModelRef, Error>

Resolves a reranking model.

§Errors

See ProviderRegistry::language_model.

Source

pub fn video_model(&self, id: &str) -> Result<VideoModelRef, Error>

Resolves a video model.

§Errors

See ProviderRegistry::language_model.

Source

pub fn speech_translation_model( &self, id: &str, ) -> Result<SpeechTranslationModelRef, Error>

Resolves a speech translation model.

§Errors

See ProviderRegistry::language_model.

Source

pub fn realtime_model(&self, id: &str) -> Result<RealtimeModelRef, Error>

Resolves a realtime model through the provider’s realtime factory.

§Errors

See ProviderRegistry::language_model; providers without realtime support yield a NoSuchModel error.

Trait Implementations§

Source§

impl Clone for ProviderRegistry

Source§

fn clone(&self) -> ProviderRegistry

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ProviderRegistry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Provider for ProviderRegistry

Source§

fn provider_id(&self) -> &ProviderId

Provider identifier, for example openai.
Source§

fn language_model( &self, model_id: &str, ) -> Result<LanguageModelRef, NoSuchModelError>

Returns the language model with model_id. Read more
Source§

fn embedding_model( &self, model_id: &str, ) -> Result<EmbeddingModelRef, NoSuchModelError>

Returns the embedding model with model_id. Read more
Source§

fn image_model(&self, model_id: &str) -> Result<ImageModelRef, NoSuchModelError>

Returns the image model with model_id. Read more
Source§

fn transcription_model( &self, model_id: &str, ) -> Result<TranscriptionModelRef, NoSuchModelError>

Returns the transcription model with model_id. Read more
Source§

fn speech_model( &self, model_id: &str, ) -> Result<SpeechModelRef, NoSuchModelError>

Returns the speech model with model_id. Read more
Source§

fn reranking_model( &self, model_id: &str, ) -> Result<RerankingModelRef, NoSuchModelError>

Returns the reranking model with model_id. Read more
Source§

fn video_model(&self, model_id: &str) -> Result<VideoModelRef, NoSuchModelError>

Returns the video model with model_id. Read more
Source§

fn speech_translation_model( &self, model_id: &str, ) -> Result<SpeechTranslationModelRef, NoSuchModelError>

Returns the speech translation model with model_id. Read more
Source§

fn realtime(&self) -> Option<ServiceRef<dyn DynRealtimeFactory>>

Returns the realtime factory, if the provider supports realtime sessions.
Source§

fn files(&self) -> Option<ServiceRef<dyn DynFiles>>

Returns the files service, if the provider supports file storage.
Source§

fn skills(&self) -> Option<ServiceRef<dyn DynSkills>>

Returns the skills service, if the provider supports skills.
Source§

fn batch(&self) -> Option<ServiceRef<dyn DynBatch>>

Returns the batch service, if the provider supports batch jobs.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more