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§
Sourcefn provider_id(&self) -> &ProviderId
fn provider_id(&self) -> &ProviderId
Provider identifier, for example openai.
Sourcefn language_model(
&self,
model_id: &str,
) -> Result<LanguageModelRef, NoSuchModelError>
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.
Sourcefn embedding_model(
&self,
model_id: &str,
) -> Result<EmbeddingModelRef, NoSuchModelError>
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.
Sourcefn image_model(&self, model_id: &str) -> Result<ImageModelRef, NoSuchModelError>
fn image_model(&self, model_id: &str) -> Result<ImageModelRef, NoSuchModelError>
Provided Methods§
Sourcefn transcription_model(
&self,
model_id: &str,
) -> Result<TranscriptionModelRef, NoSuchModelError>
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.
Sourcefn speech_model(
&self,
model_id: &str,
) -> Result<SpeechModelRef, NoSuchModelError>
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.
Sourcefn reranking_model(
&self,
model_id: &str,
) -> Result<RerankingModelRef, NoSuchModelError>
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.
Sourcefn video_model(&self, model_id: &str) -> Result<VideoModelRef, NoSuchModelError>
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.
Sourcefn speech_translation_model(
&self,
model_id: &str,
) -> Result<SpeechTranslationModelRef, NoSuchModelError>
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.
Sourcefn realtime(&self) -> Option<RealtimeFactoryRef>
fn realtime(&self) -> Option<RealtimeFactoryRef>
Returns the realtime factory, if the provider supports realtime sessions.
Sourcefn files(&self) -> Option<FilesRef>
fn files(&self) -> Option<FilesRef>
Returns the files service, if the provider supports file storage.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".