pub struct ProviderRef { /* private fields */ }Expand description
A nonempty model identifier paired with a credential-free provider selection. Construction validates the identifier; both fields are read-only.
use rig_core::providers::registry::ProviderRef;
let Ok(mut reference) = ProviderRef::parse("deepseek:deepseek-chat") else { return; };
reference.model.clear(); // the validated identifier is privateProvider data is also read-only, so credentials cannot be inserted afterwards:
use rig_core::providers::registry::ProviderRef;
let Ok(mut reference) = ProviderRef::parse("deepseek:deepseek-chat") else { return; };
reference.provider = reference.provider().clone();Implementations§
Source§impl ProviderRef
impl ProviderRef
Sourcepub fn registered(
id: ProviderId,
model: impl Into<String>,
) -> Result<Self, RefError>
pub fn registered( id: ProviderId, model: impl Into<String>, ) -> Result<Self, RefError>
A reference to a non-empty model on a registered selection.
Returns RefError::EmptyModel for an empty identifier.
Sourcepub fn configured(
config: ProviderConfig,
model: impl Into<String>,
) -> Result<Self, RefError>
pub fn configured( config: ProviderConfig, model: impl Into<String>, ) -> Result<Self, RefError>
A reference to a non-empty model on an explicit configuration.
Removes the credential: references are persistent recipes, and the
host supplies credentials through config at construction time.
The host stays fixed, even if it is a preset’s default. For Copilot,
use a registered reference to follow the resolved token’s proxy endpoint,
or configure the intended endpoint before creating this reference.
Returns RefError::EmptyModel for an empty identifier.
Sourcepub fn parse(text: &str) -> Result<Self, RefError>
pub fn parse(text: &str) -> Result<Self, RefError>
Parse vendor[/format]:model.
The first : separates the selection from the model, so a model
identifier may contain : and / freely.
Sourcepub fn id(&self) -> Option<ProviderId>
pub fn id(&self) -> Option<ProviderId>
The catalog selection this reference names, if its dialect is registered.
Sourcepub fn config(&self, api_key: impl Into<Secret>) -> ProviderConfig
pub fn config(&self, api_key: impl Into<Secret>) -> ProviderConfig
The configuration to build from, credentialed with api_key: the
registry’s preset, or the explicit configuration rehydrated.
Source§impl ProviderRef
impl ProviderRef
Sourcepub fn completion_model(&self) -> Result<DynModel<Completion>, EnvError>
Available on crate feature reqwest only.
pub fn completion_model(&self) -> Result<DynModel<Completion>, EnvError>
reqwest only.A completion model for this reference, credentials from the environment, on the shared reqwest client. A registered selection reads every variable its dialect names; an explicit configuration keeps its host and options and reads only its vendor’s credential.
Sourcepub fn completion_model_with(
&self,
api_key: impl Into<Secret>,
http: impl HttpClientExt + 'static,
) -> DynModel<Completion>
pub fn completion_model_with( &self, api_key: impl Into<Secret>, http: impl HttpClientExt + 'static, ) -> DynModel<Completion>
A completion model for this reference, credentialed with api_key,
sending through http.
Trait Implementations§
Source§impl Clone for ProviderRef
impl Clone for ProviderRef
Source§impl Debug for ProviderRef
impl Debug for ProviderRef
Source§impl<'de> Deserialize<'de> for ProviderRef
Deserialize strings as registered references and maps as explicit configurations.
Requires a self-describing format and preserves configuration field errors.
impl<'de> Deserialize<'de> for ProviderRef
Deserialize strings as registered references and maps as explicit configurations. Requires a self-describing format and preserves configuration field errors.
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Source§impl Display for ProviderRef
Display vendor/format:model for registered and configured references.
This label omits hosts and options; use serialization to preserve them.
impl Display for ProviderRef
Display vendor/format:model for registered and configured references.
This label omits hosts and options; use serialization to preserve them.
Source§impl FromStr for ProviderRef
impl FromStr for ProviderRef
Source§impl PartialEq for ProviderRef
impl PartialEq for ProviderRef
Source§impl Serialize for ProviderRef
Serialize registered references as canonical strings and configured references
as {config, model} objects to preserve their hosts and options.
impl Serialize for ProviderRef
Serialize registered references as canonical strings and configured references
as {config, model} objects to preserve their hosts and options.
impl StructuralPartialEq for ProviderRef
Auto Trait Implementations§
impl Freeze for ProviderRef
impl RefUnwindSafe for ProviderRef
impl Send for ProviderRef
impl Sync for ProviderRef
impl Unpin for ProviderRef
impl UnsafeUnpin for ProviderRef
impl UnwindSafe for ProviderRef
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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> ⓘ
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> ⓘ
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 moreSource§impl<T> IntoToolOutput for Twhere
T: Serialize + 'static,
impl<T> IntoToolOutput for Twhere
T: Serialize + 'static,
Source§fn into_tool_output(self) -> Result<ToolOutput, ToolExecutionError>
fn into_tool_output(self) -> Result<ToolOutput, ToolExecutionError>
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.