Skip to main content

Provider

Trait Provider 

Source
pub trait Provider:
    Send
    + Sync
    + 'static {
Show 13 methods // Required methods fn provider_id(&self) -> &ProviderId; fn language_model( &self, model_id: &str, ) -> Result<LanguageModelRef, NoSuchModelError>; fn embedding_model( &self, model_id: &str, ) -> Result<EmbeddingModelRef, NoSuchModelError>; fn image_model( &self, model_id: &str, ) -> Result<ImageModelRef, NoSuchModelError>; // Provided methods fn transcription_model( &self, model_id: &str, ) -> Result<TranscriptionModelRef, NoSuchModelError> { ... } fn speech_model( &self, model_id: &str, ) -> Result<SpeechModelRef, NoSuchModelError> { ... } fn reranking_model( &self, model_id: &str, ) -> Result<RerankingModelRef, NoSuchModelError> { ... } fn video_model( &self, model_id: &str, ) -> Result<VideoModelRef, NoSuchModelError> { ... } fn speech_translation_model( &self, model_id: &str, ) -> Result<SpeechTranslationModelRef, NoSuchModelError> { ... } fn realtime(&self) -> Option<RealtimeFactoryRef> { ... } fn files(&self) -> Option<FilesRef> { ... } fn skills(&self) -> Option<SkillsRef> { ... } fn batch(&self) -> Option<BatchRef> { ... }
}
Expand description

A provider: creates model instances by id and exposes provider services.

Implement language_model, embedding_model and image_model; return NoSuchModelError::unsupported_kind for kinds the provider does not offer. The remaining lookups default to that error, and the service accessors default to None.

Required Methods§

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.

§Errors

Returns NoSuchModelError when the model is unknown.

Source

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

Returns the embedding model with model_id.

§Errors

Returns NoSuchModelError when the model is unknown.

Source

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

Returns the image model with model_id.

§Errors

Returns NoSuchModelError when the model is unknown.

Provided Methods§

Source

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

Returns the transcription model with model_id.

§Errors

Returns NoSuchModelError when the model is unknown or the provider has no transcription models.

Source

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

Returns the speech model with model_id.

§Errors

Returns NoSuchModelError when the model is unknown or the provider has no speech models.

Source

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

Returns the reranking model with model_id.

§Errors

Returns NoSuchModelError when the model is unknown or the provider has no reranking models.

Source

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

Returns the video model with model_id.

§Errors

Returns NoSuchModelError when the model is unknown or the provider has no video models.

Source

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

Returns the speech translation model with model_id.

§Errors

Returns NoSuchModelError when the model is unknown or the provider has no speech translation models.

Source

fn realtime(&self) -> Option<RealtimeFactoryRef>

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

Source

fn files(&self) -> Option<FilesRef>

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

Source

fn skills(&self) -> Option<SkillsRef>

Returns the skills service, if the provider supports skills.

Source

fn batch(&self) -> Option<BatchRef>

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

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§