feat(moa): support per-slot reasoning effort

This commit is contained in:
Justin Schille 2026-07-09 17:24:42 -06:00 committed by Teknium
parent 6997dc81cd
commit 3dca75b45c
8 changed files with 279 additions and 16 deletions

View file

@ -60,6 +60,12 @@ def _pick_slot(current: dict[str, str] | None = None) -> dict[str, str]:
return {"provider": str(provider.get("slug") or ""), "model": str(model)}
def _format_slot(slot: dict[str, Any]) -> str:
label = f"{slot['provider']}:{slot['model']}"
effort = str(slot.get("reasoning_effort") or "").strip()
return f"{label} [reasoning={effort}]" if effort else label
def _print_config(config: dict[str, Any]) -> None:
cfg = normalize_moa_config(config.get("moa") if isinstance(config, dict) else {})
print("Mixture of Agents presets")
@ -71,9 +77,9 @@ def _print_config(config: dict[str, Any]) -> None:
print(f"\n{marker} {name}")
print(" Reference models:")
for idx, slot in enumerate(preset["reference_models"], start=1):
print(f" {idx}. {slot['provider']}:{slot['model']}")
print(f" {idx}. {_format_slot(slot)}")
agg = preset["aggregator"]
print(f" Aggregator: {agg['provider']}:{agg['model']}")
print(f" Aggregator: {_format_slot(agg)}")
def cmd_moa(args) -> None:

View file

@ -73,7 +73,23 @@ def _coerce_fanout(value: Any) -> str:
return mode if mode in {"per_iteration", "user_turn"} else "per_iteration"
def _clean_slot(slot: Any) -> dict[str, str] | None:
def _clean_reasoning_effort(value: Any) -> str | None:
"""Return a canonical per-slot reasoning effort, or None when unset/invalid."""
if value is None or value is True:
return None
if value is False:
return "none"
text = str(value or "").strip().lower()
if not text:
return None
if text in {"none", "false", "disabled"}:
return "none"
if text in {"minimal", "low", "medium", "high", "xhigh", "max"}:
return text
return None
def _clean_slot(slot: Any) -> dict[str, Any] | None:
if not isinstance(slot, dict):
return None
provider = str(slot.get("provider") or "").strip()
@ -87,7 +103,11 @@ def _clean_slot(slot: Any) -> dict[str, str] | None:
# an invalid slot is dropped, falling back to the preset's defaults.
if provider.lower() == "moa":
return None
return {"provider": provider, "model": model}
clean: dict[str, Any] = {"provider": provider, "model": model}
effort = _clean_reasoning_effort(slot.get("reasoning_effort"))
if effort:
clean["reasoning_effort"] = effort
return clean
def _default_preset() -> dict[str, Any]: