pub struct Registry { /* private fields */ }Expand description
A registry mapping model-name patterns to Factory functions.
Safe for concurrent use.
Implementations§
Source§impl Registry
impl Registry
Sourcepub fn register(&self, pattern: &str, f: Factory) -> Result<(), RegistryError>
pub fn register(&self, pattern: &str, f: Factory) -> Result<(), RegistryError>
Associates a model-name pattern with a Factory.
pattern is a regular expression matched against candidate names with an
unanchored, partial match; anchor it with ^ and $ to match a name exactly.
Registration order is not significant, so patterns must not overlap for names a
caller intends to resolve.
Returns RegistryError::InvalidPattern if pattern does not compile and
RegistryError::DuplicatePattern if the same pattern string is already
registered.
Sourcepub async fn new_llm(&self, name: &str) -> Result<Arc<dyn Llm>, RegistryError>
pub async fn new_llm(&self, name: &str) -> Result<Arc<dyn Llm>, RegistryError>
Builds an Llm for name using the single registration whose pattern matches.
Returns RegistryError::NoMatch if no pattern matches,
RegistryError::Ambiguous if two or more match, and
RegistryError::Factory if the matching factory fails. The registry lock is
not held while the factory runs.