Coverage for src / lilbee / providers / local_servers / spec.py: 100%
19 statements
« prev ^ index » next coverage.py v7.13.4, created at 2026-06-28 01:01 +0000
« prev ^ index » next coverage.py v7.13.4, created at 2026-06-28 01:01 +0000
1"""The LocalServerSpec type: identity and capabilities of one local server."""
3from __future__ import annotations
5from dataclasses import dataclass
7from lilbee.providers.backend_names import BackendName
10@dataclass(frozen=True)
11class LocalServerSpec:
12 """Identity and capabilities of one local model server.
14 ``key`` doubles as the model-source string: ``ModelSource(spec.key)`` is
15 the source these models report as (asserted by an invariant test). The
16 type lives in ``lilbee.catalog`` and is not imported here to keep this
17 module light for the routing layer.
18 """
20 key: str # routing key, ref-prefix stem, and ModelSource value ("ollama")
21 display_name: BackendName # human-facing backend name
22 wire_prefix: str # litellm provider/ prefix ("ollama/")
23 default_base_url: str # URL the server listens on out of the box
24 url_patterns: tuple[str, ...] # lowercase substrings that identify it in a URL
25 appends_latest_tag: bool # bare name gets a ":latest" tag (Ollama)
26 supports_pull: bool # exposes an HTTP model-pull endpoint
27 supports_show: bool # exposes an HTTP model-metadata endpoint
29 def qualify(self, name: str) -> str:
30 """Render *name* as a canonical ``<wire_prefix><name>`` ref."""
31 return f"{self.wire_prefix}{name}"
33 def normalize_name(self, name: str) -> str:
34 """Apply the server's bare-name convention (Ollama's ``:latest``)."""
35 if self.appends_latest_tag and ":" not in name:
36 return f"{name}:latest"
37 return name