pub struct ProviderRegistry { /* private fields */ }Expand description
A “provider directory” that is materialized at assembly time. The session holds an
Arc<ProviderRegistry>.
Implementations§
Source§impl ProviderRegistry
impl ProviderRegistry
Sourcepub fn single(
provider: Arc<dyn LlmProvider>,
default_model: ModelInfo,
) -> Arc<Self> ⓘ
pub fn single( provider: Arc<dyn LlmProvider>, default_model: ModelInfo, ) -> Arc<Self> ⓘ
A convenience constructor for a single provider with a single model.
Used by tests, EchoProvider, and the provider() builder entry point.
This is the minimal form that satisfies the invariants checked by
ProviderRegistry::new (non-empty + default_model must belong to an entry).
Sourcepub fn new(
entries: Vec<ProviderEntry>,
default_provider: &str,
default_model: &str,
) -> Result<Self, ProviderRegistryError>
pub fn new( entries: Vec<ProviderEntry>, default_provider: &str, default_model: &str, ) -> Result<Self, ProviderRegistryError>
Constructs a registry from a list of entries and a default (provider vendor, model id) pair. The pair must appear in the (vendor, models) list of some
entry.
The same model id may be declared by multiple entries with different vendors
(multiple gateways sharing a model) — the selection key is (vendor, model). Only
a duplicate (vendor, model) pair is a configuration error.
§Errors
ProviderRegistryError::Empty: entries is emptyProviderRegistryError::DuplicateSelection: the same(vendor, model)pair appears twiceProviderRegistryError::UnknownDefaultModel: the default(vendor, model)pair is not present in any entry
Sourcepub fn default_entry(&self) -> &ProviderEntry
pub fn default_entry(&self) -> &ProviderEntry
The default entry used to initialize the current provider/model when a session starts.
Sourcepub fn default_model(&self) -> &str
pub fn default_model(&self) -> &str
The default model ID.
Sourcepub fn entry_for(&self, vendor: &str, model_id: &str) -> Option<&ProviderEntry>
pub fn entry_for(&self, vendor: &str, model_id: &str) -> Option<&ProviderEntry>
Look up the entry for a given (vendor, model id) pair. Returns None if the
registry does not declare this pair.
Sourcepub fn first_entry_for_model(&self, model_id: &str) -> Option<&ProviderEntry>
pub fn first_entry_for_model(&self, model_id: &str) -> Option<&ProviderEntry>
Look up the first entry that declares the given bare model ID (in assembly order).
Used by legacy paths that lack a vendor dimension, such as the model field in
prompt hooks — when there are multiple matches, the first one is returned.
Sourcepub fn entries(&self) -> &[ProviderEntry]
pub fn entries(&self) -> &[ProviderEntry]
Returns all entries in assembly order.
Sourcepub fn list_candidates(&self) -> Vec<ModelCandidate>
pub fn list_candidates(&self) -> Vec<ModelCandidate>
Flatten all (provider_info, model) pairs. ACP list_models uses this to build
SessionModelState::available_models.
Sourcepub fn candidate_for(
&self,
vendor: &str,
model_id: &str,
) -> Option<ModelCandidate>
pub fn candidate_for( &self, vendor: &str, model_id: &str, ) -> Option<ModelCandidate>
Look up a candidate by model ID; used by the ACP layer to render the description.