pub struct ModelCatalog { /* private fields */ }Expand description
Shared, refreshable view of the fixed models.dev["opencode"] catalog.
Implementations§
Source§impl ModelCatalog
impl ModelCatalog
Sourcepub async fn initialize() -> Result<Self, ModelCatalogError>
pub async fn initialize() -> Result<Self, ModelCatalogError>
Load the disk cache and refresh it when needed. A fresh cache returns immediately. A stale cache remains usable while one background refresh runs; with no usable cache, the network fetch is awaited and required.
Sourcepub async fn refresh(&self) -> Result<(), ModelCatalogError>
pub async fn refresh(&self) -> Result<(), ModelCatalogError>
Force a refresh. Concurrent callers share a single in-flight fetch.
Sourcepub async fn resolve(
&self,
request: ModelRequestConfig,
wire_protocol: WireProtocol,
) -> Result<ResolvedModelConfig, ModelCatalogError>
pub async fn resolve( &self, request: ModelRequestConfig, wire_protocol: WireProtocol, ) -> Result<ResolvedModelConfig, ModelCatalogError>
Resolve and validate a short model id for one of the three wire
protocols. Exact id match wins; a path-like id may also match by a
unique basename. Contains/fuzzy matches are suggestions only. An id
with no match at all does not error: it resolves against
[default_capabilities]-style conservative limits marked
LimitsSource::Default (see the module docs for the validation
split that follows from that).
Sourcepub async fn capabilities(
&self,
model: &str,
) -> Result<ModelCapabilities, ModelCatalogError>
pub async fn capabilities( &self, model: &str, ) -> Result<ModelCapabilities, ModelCatalogError>
Look up one model’s capabilities without validating a request. Lets
callers clamp max_output_tokens or drop unsupported temperature /
reasoning knobs before Self::resolve, instead of recovering
from InvalidRequest errors after the fact.
Sourcepub fn from_json(bytes: &[u8]) -> Result<Self, ModelCatalogError>
pub fn from_json(bytes: &[u8]) -> Result<Self, ModelCatalogError>
Build a catalog from a models.dev-shaped JSON payload — no network fetch, no disk cache. For embedding a fixed catalog: tests, air-gapped deployments, and custom gateways whose model ids are absent from models.dev[“opencode”].
pub async fn model_count(&self) -> usize
Trait Implementations§
Source§impl Clone for ModelCatalog
impl Clone for ModelCatalog
Source§fn clone(&self) -> ModelCatalog
fn clone(&self) -> ModelCatalog
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more