feat(ai_review): route per-repo model override through PRICES provider field
This commit is contained in:
+17
-4
@@ -483,11 +483,15 @@ def _resolve_display_model(base_model: str, config: dict | None) -> str:
|
||||
|
||||
Precedence (highest first):
|
||||
1. `OPENCODE_MODEL` env var — operator override, used as-is (already a
|
||||
provider-prefixed opencode ref).
|
||||
provider-prefixed opencode ref like `headroom/MiniMax-M2.7`).
|
||||
2. `.pr-review.json:model` — per-repo override. Already validated
|
||||
against `cost_model.PRICES` by `parse_repo_config`, so a bare key
|
||||
like `claude-sonnet-5` is safe to use as the opencode ref AND the
|
||||
REVIEW_HEADER label.
|
||||
like `claude-sonnet-5` or `qwen3.8-27b` is safe. Re-prefixed with
|
||||
the model's `provider` field from `cost_model.Price` (default
|
||||
`headroom`) so the opencode subprocess routes correctly — e.g.
|
||||
`qwen3.8-27b` → `local/qwen3.8-27b` (local AI workstation on
|
||||
192.168.1.79:18020), `claude-sonnet-5` → `headroom/claude-sonnet-5`
|
||||
(Anthropic pricing proxy).
|
||||
3. Default — `f"headroom/{base_model}"` where `base_model` is the bare
|
||||
`OLLAMA_MODEL` (e.g. `"MiniMax-M2.7" → "headroom/MiniMax-M2.7"`).
|
||||
|
||||
@@ -500,7 +504,16 @@ def _resolve_display_model(base_model: str, config: dict | None) -> str:
|
||||
return env
|
||||
cfg_model = (config or {}).get("model")
|
||||
if isinstance(cfg_model, str) and cfg_model.strip():
|
||||
return cfg_model.strip()
|
||||
# Look up the provider from PRICES so the opencode subprocess routes
|
||||
# through the right provider block (local vs headroom). Lazy import —
|
||||
# the ollama path doesn't touch cost_model.
|
||||
from cost_model import PRICES
|
||||
provider = PRICES.get(cfg_model.strip())
|
||||
if provider is not None:
|
||||
return f"{provider.provider}/{cfg_model.strip()}"
|
||||
# parse_repo_config already drops unknowns, but stay defensive: fall
|
||||
# back to headroom so the review still runs rather than crash.
|
||||
return f"headroom/{cfg_model.strip()}"
|
||||
return f"headroom/{base_model}"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user