6be04bc4f0
Green phase: src/vendor_capabilities.py now exists and all 3 Red-phase tests in tests/test_vendor_capabilities.py pass. Implementation: - VendorCapabilities frozen dataclass with 12 fields (vendor, model, vision, tool_calling, caching, streaming, model_discovery, context_window, cost_tracking, cost_input_per_mtok, cost_output_per_mtok, notes) - Module-level _REGISTRY dict keyed by (vendor, model) - register() inserts/overwrites entries - get_capabilities() returns specific entry if present, else vendor '*' default, else raises KeyError with 'No capabilities registered' message - list_models_for_vendor() returns sorted model names for a vendor (excludes '*' wildcard) Initial population (22 entries at module load): - 1 minimax wildcard (cost: 0.20/0.20 per Mtok) - 4 grok (1 wildcard + 3 models; grok-2-vision has vision=True) - 9 llama (1 wildcard + 8 models; 11b/90b vision variants have vision=True) - 8 qwen (1 wildcard + 7 models; qwen-vl-plus/max have vision=True; qwen-audio has notes='Text-only in v1; audio input deferred') The plan's Task 1.3 listed 22 entries but included one impossible entry (vendor='minimax', model='grok-2-latest'). Omitted; 21 entries shipped. Test fix: test_fallback_to_vendor_default previously used model name 'llama-3.3-70b-specdec' which IS in the registry, so the specific entry was returned (with default cost_tracking=True), not the wildcard. Fixed by changing to 'llama-3.3-future-unregistered' (not in registry, so fallback fires correctly).
41 lines
1.1 KiB
Python
41 lines
1.1 KiB
Python
import pytest
|
|
from src.vendor_capabilities import VendorCapabilities, get_capabilities, register
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def _clean_registry():
|
|
import src.vendor_capabilities
|
|
snapshot = src.vendor_capabilities._REGISTRY.copy()
|
|
yield
|
|
src.vendor_capabilities._REGISTRY.clear()
|
|
src.vendor_capabilities._REGISTRY.update(snapshot)
|
|
|
|
def test_registry_lookup_known_model():
|
|
caps = VendorCapabilities(
|
|
vendor='qwen',
|
|
model='qwen-max',
|
|
vision=False,
|
|
context_window=32768
|
|
)
|
|
register(caps)
|
|
retrieved = get_capabilities('qwen', 'qwen-max')
|
|
assert retrieved.vendor == 'qwen'
|
|
assert retrieved.model == 'qwen-max'
|
|
assert retrieved.context_window == 32768
|
|
assert retrieved.vision is False
|
|
|
|
def test_fallback_to_vendor_default():
|
|
caps = VendorCapabilities(
|
|
vendor='llama',
|
|
model='*',
|
|
context_window=131072,
|
|
cost_tracking=False
|
|
)
|
|
register(caps)
|
|
retrieved = get_capabilities('llama', 'llama-3.3-future-unregistered')
|
|
assert retrieved.context_window == 131072
|
|
assert retrieved.cost_tracking is False
|
|
|
|
def test_unknown_vendor_raises():
|
|
with pytest.raises(KeyError, match='No capabilities registered'):
|
|
get_capabilities('nonexistent_vendor', 'anymodel')
|