pub struct ModelRef<D: ?Sized>(/* private fields */);Expand description
A reference to a model: either a resolved instance or a provider:model
id that the application layer resolves through its registry.
D is the object-safe trait object type (dyn DynLanguageModel, …).
Provider implementations always return resolved references; the id form
exists so that entry points can accept impl Into<LanguageModelRef> for
both model instances and strings.
Implementations§
Source§impl<D: ?Sized> ModelRef<D>
impl<D: ?Sized> ModelRef<D>
Sourcepub fn from_id(id: impl Into<String>) -> Self
pub fn from_id(id: impl Into<String>) -> Self
Creates an unresolved reference by id (for example openai:gpt-5).
Sourcepub fn unresolved_id(&self) -> Option<&str>
pub fn unresolved_id(&self) -> Option<&str>
Returns the id when the reference is unresolved.
Sourcepub fn is_resolved(&self) -> bool
pub fn is_resolved(&self) -> bool
Returns true when the reference holds a model instance.
Sourcepub fn into_model(self) -> Result<Arc<D>, String>
pub fn into_model(self) -> Result<Arc<D>, String>
Unwraps the model, or returns the unresolved id as the error.
§Errors
Returns the id when the reference was created with ModelRef::from_id.
Trait Implementations§
Auto Trait Implementations§
impl<D> Freeze for ModelRef<D>
impl<D> RefUnwindSafe for ModelRef<D>where
Inner<D>: RefUnwindSafe,
D: ?Sized,
impl<D> Send for ModelRef<D>
impl<D> Sync for ModelRef<D>
impl<D> Unpin for ModelRef<D>
impl<D> UnsafeUnpin for ModelRef<D>where
Inner<D>: UnsafeUnpin,
D: ?Sized,
impl<D> UnwindSafe for ModelRef<D>where
Inner<D>: UnwindSafe,
D: ?Sized,
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