pub struct Provider { /* private fields */ }Expand description
Cloneable opaque provider handle.
Provider and Model clones share one lifecycle. Shutdown seals model admission, drains accepted work, and publishes one terminal result to every waiter; cancelling a waiter cannot cancel owned cleanup. Models have no independent shutdown. Caller implementations retain their concrete associated children directly.
§Examples
use providers_kit::{Provider, ProviderBackend, ProviderConfig, ModelBackend, ModelId, config::{ProviderKind, OllamaConfig, TransportConfig}};
let provider = Provider::from_config(ProviderConfig::new(ProviderKind::Ollama(OllamaConfig::local()), TransportConfig::default()))?;
let model = provider.model(ModelId::new("exact-model")?)?;
assert_eq!(model.model_id().as_str(), "exact-model");
provider.shutdown().await?;
Implementations§
Source§impl Provider
impl Provider
Sourcepub fn from_config(config: ProviderConfig) -> Result<Self, KitError>
pub fn from_config(config: ProviderConfig) -> Result<Self, KitError>
Constructs a built-in provider from validated configuration.
Construction creates clients locally and does not probe credentials or model availability.
§Errors
Returns a configuration or client-construction error for invalid endpoints, transport settings, or HTTP/TLS client setup. Service authentication is checked by subsequent operations.
§Examples
use providers_kit::{Provider, ProviderBackend, ProviderConfig, ModelBackend, ModelId, config::{ProviderKind, OllamaConfig, TransportConfig}};
let provider = Provider::from_config(ProviderConfig::new(ProviderKind::Ollama(OllamaConfig::local()), TransportConfig::default()))?;
let model = provider.model(ModelId::new("exact-model")?)?;
assert_eq!(model.model_id().as_str(), "exact-model");
provider.shutdown().await?;
Trait Implementations§
Source§impl ProviderBackend for Provider
impl ProviderBackend for Provider
Source§fn model(&self, id: ModelId) -> Result<Model, KitError>
fn model(&self, id: ModelId) -> Result<Model, KitError>
Selects one exact provider-local model. Read more
Source§async fn list_models(
&self,
request: ModelListRequest,
) -> Result<ModelPage, KitError>
async fn list_models( &self, request: ModelListRequest, ) -> Result<ModelPage, KitError>
Lists provider-visible models. Read more
Source§async fn model_info(&self, id: ModelId) -> Result<ModelSummary, KitError>
async fn model_info(&self, id: ModelId) -> Result<ModelSummary, KitError>
Fetches descriptive metadata for one exact provider-local model. Read more
Source§async fn upload_file(
&self,
request: FileUploadRequest,
) -> Result<FileObject, KitError>
async fn upload_file( &self, request: FileUploadRequest, ) -> Result<FileObject, KitError>
Uploads one provider-managed file. Read more
Source§async fn list_files(
&self,
request: FileListRequest,
) -> Result<FilePage, KitError>
async fn list_files( &self, request: FileListRequest, ) -> Result<FilePage, KitError>
Lists provider-managed files. Read more
Source§async fn file_info(&self, id: String) -> Result<FileObject, KitError>
async fn file_info(&self, id: String) -> Result<FileObject, KitError>
Fetches metadata for one provider-managed file. Read more
Source§async fn delete_file(&self, id: String) -> Result<(), KitError>
async fn delete_file(&self, id: String) -> Result<(), KitError>
Deletes one provider-managed file. Read more
Source§async fn download_file(
&self,
id: String,
max_bytes: NonZeroUsize,
) -> Result<Vec<u8>, KitError>
async fn download_file( &self, id: String, max_bytes: NonZeroUsize, ) -> Result<Vec<u8>, KitError>
Downloads one provider-managed file under the caller’s byte limit. Read more
Source§async fn batch_status(&self, id: String) -> Result<BatchJob, KitError>
async fn batch_status(&self, id: String) -> Result<BatchJob, KitError>
Fetches one batch job. Read more
Source§async fn cancel_batch(&self, id: String) -> Result<BatchJob, KitError>
async fn cancel_batch(&self, id: String) -> Result<BatchJob, KitError>
Cancels one batch job. Read more
Source§async fn batch_results(
&self,
id: String,
max_bytes: NonZeroUsize,
) -> Result<Vec<BatchResult<GenerationContinuation>>, KitError>
async fn batch_results( &self, id: String, max_bytes: NonZeroUsize, ) -> Result<Vec<BatchResult<GenerationContinuation>>, KitError>
Downloads and normalizes batch result rows under the caller’s byte limit. Read more
Source§async fn list_batches(
&self,
request: BatchListRequest,
) -> Result<BatchPage, KitError>
async fn list_batches( &self, request: BatchListRequest, ) -> Result<BatchPage, KitError>
Lists provider batch jobs. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for Provider
impl !UnwindSafe for Provider
impl Freeze for Provider
impl Send for Provider
impl Sync for Provider
impl Unpin for Provider
impl UnsafeUnpin for Provider
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