fix(moa): parse JSON string reference_models in _normalize_preset
When reference_models is stored as a JSON string (e.g. from hermes moa configure or hand-edited config.yaml), _normalize_preset silently falls back to hardcoded defaults because the string fails both isinstance(x, list) and isinstance(x, dict) checks. Add json.loads() parsing before the type checks so both formats work.
This commit is contained in:
parent
c1f5f0f911
commit
3638abfbf9
|
|
@ -207,6 +207,12 @@ def _normalize_preset(raw: Any) -> dict[str, Any]:
|
|||
raw = {}
|
||||
|
||||
raw_refs = raw.get("reference_models")
|
||||
# reference_models may be a JSON string (hand-edited config.yaml) or a list.
|
||||
if isinstance(raw_refs, str):
|
||||
try:
|
||||
raw_refs = json.loads(raw_refs)
|
||||
except (json.JSONDecodeError, ValueError):
|
||||
raw_refs = []
|
||||
if not isinstance(raw_refs, list):
|
||||
# A hand-edited scalar / single mapping (or a bad type) must degrade to
|
||||
# defaults instead of crashing the iteration, mirroring the tolerance
|
||||
|
|
|
|||
Loading…
Reference in New Issue