Private
Public Access
0
0

feat(capability_matrix): populate v2 fields per-model; add runtime local override

Updates per-model registry entries to populate the 12 v2
fields where the capability is genuinely supported:

  minimax-M2.5/M2.7: reasoning=True (uses reasoning_details)
  grok-2-vision:      web_search=True, x_search=True (Live Search)
  grok-2:             web_search=True, x_search=True
  grok-beta:          web_search=True, x_search=True
  llama-3.1-405b:     reasoning=True (explicitly in model name)
  qwen-long:          caching=True (custom long-context chunking)
  qwen-audio:         audio=True (was 'deferred' in v1 notes)

Adds the runtime override helper:
  _apply_runtime_caps_override(app, caps)
  -> caps with local=True if app.current_provider=='llama'
     AND _llama_base_url contains 'localhost' or '127.0.0.1'

The 'local' flag is the only v2 field that is runtime-state,
not a static per-model property (OpenRouter llama is cloud;
Ollama llama is local — same model name, different backend).
The override uses dataclasses.replace() to mutate the
frozen dataclass. Implemented in src/gui_2.py (per the
HARD RULE on no new src/*.py files).

The override is wired into App._get_active_capabilities()
so the GUI sees caps.local=True when the active backend
is Ollama and caps.local=False otherwise.

Also: cost panel in src/gui_2.py (per-tier + session-total
columns) now renders 'Free (local)' when caps.local=True
(both the per-tier cost column and the session-total line).
This is t3_7 (moved from Phase 3 per the user's request;
naturally belongs after t4_1 which adds caps.local).

Tests:
- 3 new tests in tests/test_vendor_capabilities.py:
  * per-model population (reasoning, audio, caching, vision)
  * runtime override for llama+localhost
  * runtime override does NOT touch other vendors
- 107/107 vendor+tool+provider+import-isolation tests pass
  (no regressions; +4 new tests this commit)
- 3 audit scripts pass
This commit is contained in:
2026-06-11 21:04:36 -04:00
parent 6b28d15575
commit 7d60e8f5ab
3 changed files with 93 additions and 13 deletions
+60
View File
@@ -70,3 +70,63 @@ def test_v2_local_flag_does_not_affect_other_vendors() -> None:
register(VendorCapabilities(vendor='qwen', model='*'))
caps = get_capabilities('qwen', 'qwen-turbo')
assert caps.local is False
def test_runtime_caps_override_sets_local_for_llama_localhost() -> None:
from dataclasses import replace
base = VendorCapabilities(vendor='llama', model='llama-3.1-70b-versatile')
assert base.local is False
overridden = replace(base, local=True)
assert overridden.local is True
overridden2 = replace(overridden, local=False)
assert overridden2.local is False
def test_v2_per_model_population() -> None:
caps = get_capabilities('minimax', 'MiniMax-M2.5')
assert caps.reasoning is True
caps_old = get_capabilities('minimax', 'MiniMax-M2')
assert caps_old.reasoning is False
caps_grok_v = get_capabilities('grok', 'grok-2-vision')
assert caps_grok_v.web_search is True
assert caps_grok_v.x_search is True
assert caps_grok_v.vision is True
caps_qwen_audio = get_capabilities('qwen', 'qwen-audio')
assert caps_qwen_audio.audio is True
caps_qwen_long = get_capabilities('qwen', 'qwen-long')
assert caps_qwen_long.caching is True
caps_llama_reasoning = get_capabilities('llama', 'llama-3.1-405b-reasoning')
assert caps_llama_reasoning.reasoning is True
caps_llama_plain = get_capabilities('llama', 'llama-3.1-8b-instant')
assert caps_llama_plain.reasoning is False
def test_runtime_caps_override_helper_for_llama_localhost() -> None:
from src import gui_2
from src import ai_client
original_url = ai_client._llama_base_url
try:
class MockApp:
current_provider = 'llama'
mock = MockApp()
caps = VendorCapabilities(vendor='llama', model='llama-3.1-70b-versatile')
ai_client._llama_base_url = 'https://openrouter.ai/api/v1'
result = gui_2._apply_runtime_caps_override(mock, caps)
assert result.local is False
ai_client._llama_base_url = 'http://localhost:11434/v1'
result = gui_2._apply_runtime_caps_override(mock, caps)
assert result.local is True
finally:
ai_client._llama_base_url = original_url
def test_runtime_caps_override_helper_does_not_touch_other_vendors() -> None:
from src import gui_2
from src import ai_client
original_url = ai_client._llama_base_url
try:
class MockApp:
current_provider = 'qwen'
mock = MockApp()
caps = VendorCapabilities(vendor='qwen', model='qwen-turbo')
ai_client._llama_base_url = 'http://localhost:11434/v1'
result = gui_2._apply_runtime_caps_override(mock, caps)
assert result.local is False
finally:
ai_client._llama_base_url = original_url