pub struct ModelFactoryRegistry { /* private fields */ }Expand description
Every wire protocol this process can construct.
Implementations§
Source§impl ModelFactoryRegistry
impl ModelFactoryRegistry
pub fn new() -> Self
Sourcepub fn register(
&mut self,
factory: Arc<dyn ModelFactory>,
) -> Option<Arc<dyn ModelFactory>>
pub fn register( &mut self, factory: Arc<dyn ModelFactory>, ) -> Option<Arc<dyn ModelFactory>>
Add a factory, replacing any previous one for the same api and
returning it.
Replacing is allowed on purpose: a host that wants its own client
behind anthropic — a proxy, a recording layer, a different retry
policy — should not have to invent a new api its users then
have to write in their settings.
Sourcepub fn with_credentials(self, source: Arc<dyn CredentialSource>) -> Self
pub fn with_credentials(self, source: Arc<dyn CredentialSource>) -> Self
Ask source for every credential instead of reading settings.json.
One source for the whole registry, not one per protocol: “where do this deployment’s credentials come from” is a property of the deployment, and letting it vary per protocol would mean a host could secure one and forget the other.
Sourcepub fn with_network(self, network: Arc<dyn Network>) -> Self
pub fn with_network(self, network: Arc<dyn Network>) -> Self
Send every model’s requests through network. One for the whole
registry, for the reason credentials are.
pub fn get(&self, api_type: &str) -> Option<&Arc<dyn ModelFactory>>
Sourcepub fn api_types(&self) -> Vec<&str>
pub fn api_types(&self) -> Vec<&str>
The registered api values, sorted — for error messages, so what
the user is told they may write is generated from what actually works.
pub fn is_empty(&self) -> bool
Sourcepub fn missing_credential(
&self,
provider_id: &str,
config: &ProviderConfig,
) -> Option<String>
pub fn missing_credential( &self, provider_id: &str, config: &ProviderConfig, ) -> Option<String>
Why the credential source has no usable key for this provider, when it has none.
Sourcepub fn build(
&self,
provider_id: &str,
config: &ProviderConfig,
) -> Result<Arc<dyn Model>, String>
pub fn build( &self, provider_id: &str, config: &ProviderConfig, ) -> Result<Arc<dyn Model>, String>
Build the model one provider config describes.
An absent api means anthropic. An empty key from the source
is no key: the factory is not asked to build a client that would send
requests with it.