fix(heretic2-nvfp4): parse tool_call arguments string->dict for Qwen3.6 template
render-verify caught it: Dvalin's calib tool_calls carry OpenAI wire-form JSON string arguments, but the Qwen3.6 chat template does .items() on arguments (needs a dict) → jinja TypeError. Parse string->dict in render_verify + the quant's load_calib_chat. Confirmed: renders the exact qwen3_coder XML the seat emits (prefixed bifrost.soong-lab.*, v0.3.13 generate_portrait, <think>, <tool_response>).
This commit is contained in:
@@ -61,6 +61,14 @@ def load_calib_chat(path, tokenizer, seqlen):
|
||||
rows = [json.loads(l) for l in open(path) if l.strip()]
|
||||
out = []
|
||||
for r in rows:
|
||||
# Tool_call arguments arrive as OpenAI wire-form JSON *strings*; the Qwen3.6
|
||||
# template does .items() on them → needs a dict. Parse string→dict so the
|
||||
# forward-pass sees the qwen3_coder XML the seat emits. (render_verify finding.)
|
||||
for m in r["messages"]:
|
||||
for tc in (m.get("tool_calls") or []):
|
||||
a = tc.get("function", {}).get("arguments")
|
||||
if isinstance(a, str):
|
||||
tc["function"]["arguments"] = json.loads(a)
|
||||
text = tokenizer.apply_chat_template(
|
||||
r["messages"], tools=r.get("tools"),
|
||||
tokenize=False, add_generation_prompt=False, enable_thinking=True,
|
||||
|
||||
Reference in New Issue
Block a user