https://www.boundaryml.com logo
Error parsing
# help
a
Good morning! 😃 I attached a picture with the error. I added some chain of thought to the response with Mercury Coder via OpenRouter, but the parser fails to capture the object
lines
even though the syntax it's correct. The error is replicable in a test case. I'm also attaching the same test with another model that doesn't add CoT to the output, and in this case the parsing works. In the past, when adding CoT to the output, the parser still worked so I'm confused why isn't this working. Let me know if you need additional info, thanks!! https://cdn.discordapp.com/attachments/1428425171491885167/1428425171722703001/image.png?ex=68f2741b&is=68f1229b&hm=3b572ea76f4ae6c58cc12d1bcf5267192ddf7867d60d78e0c89e99a42fb6352a& https://cdn.discordapp.com/attachments/1428425171491885167/1428425172079214663/image.png?ex=68f2741b&is=68f1229b&hm=eada2d73c196ab6725edd77d0dc320baecfadb03daeeabad82df841b64378283&
a
thank you for the bug report, we take parsing issues very high priority so we'll be taking a look at this tomorrow
can you paste your data model here?
the baml output type
a
Sure! I was able to add it to Prompt Fiddle, the failing test case its here: https://www.promptfiddle.com/Order-state-gUMqN
v
thanks for this report @afr2903
i've confirmed this is a bug!
when i parse it as a
OrderLine[]
it fails
in case you're curious what i did was:
Copy code
python
from baml_client import b

raw_text = """
To reconstruct the order based on the provided instructions and menu, we will follow these steps:

1. **Start with an empty order**.
2. **Execute each instruction sequentially**.
3. **Build the final order state step by step**.
4. **Add to the previous state without overwriting**.

---

### Step-by-Step Execution:

**1. Instruction 1: “Cliente pidió Combo con Todo y eligió 2 empanadas de carne con queso”**
→ Create a combo with `combo_id` “combo_con_todo”
→ Add 2 items of `carne_con_queso` to the combo’s components array.

**2. Instruction 2: “Cliente quiere agregar chimichurri”**
→ Add the modifier `aderezos:bolsa_chimichurri` to the combo’s modifiers array.

---

### Final Order State:

``json
{
  "lines": [
    {
      "item": {
        "combo_id": "combo_con_todo",
        "components": [
          { "id": "carne_con_queso", "name": "Carne con Queso" },
          { "id": "carne_con_queso", "name": "Carne con Queso" }
        ],
        "modifiers": [
          "aderezos:bolsa_chimichurri"
        ]
      },
      "notes": null,
      "quantity": 1
    }
  ]
}
``

---

### Explanation:

* **Instruction 1:** Created a combo with `combo_id` “combo_con_todo” and added 2 items of `carne_con_queso` to the components array.
* **Instruction 2:** Added the modifier `aderezos:bolsa_chimichurri` to the combo’s modifiers array.

"""

result = b.parse.UpdateOrderState(raw_text)
print(result)
and then just kept tweaking the function signature to evaluate it
a small thing you can do right away to improve quality is to just change the function's return type to:
Copy code
OrderLine[]?
instead of:
Copy code
OrderState
which only has 1 field anyways
that will work better! Meanwhile I'll see if we can diagnore what this failure is
alternatively, you can add this key:
Copy code
diff
class OrderState {
+    key "order_state"
    lines OrderLine[]? @description("Current order lines accumulated so far")
}
top-level single key containers are the most likely to misbehave (in both the parser and llm)
a
thank you so much for the tips and the attention! I used the static key and it's working now 😃