https://www.boundaryml.com logo
Parsing escaped quotations
# help
l
I'm returning structured json, including a field with ft/in measurements, like [1] below, which is unfortunately being parsed weirdly as [2] below. Since it's returning JSON, it's kindly escaping the inches symbol ("), but this messes up the parser somehow. One weird additional thing is the parser seems to get it right in the testing tab, but not with actual use. I'm on baml-py 0.210.0
Copy code
---LLM REPLY---
    json
    [
      {
        "number": "1S1B",
        "mark": "1S1B",
        "location": "STAIR 1",
        "room": "STAIR 1",
        "dimensions": "3' - 6\" x 8' - 0\"",
        "width": "3' - 6\"",
        "height": "8' - 0\"",
        "thickness": "1 3/4\"",
        "leaf": "F",
        "type": "F",
        "material": "HM",
        "finish": "PTD",
        "num_of_leaves": "1",
        "frame": "1",
        "glazing": null,
        "oitc": null,
        "stc": null,
        "details": "10/A9.16, 3/A9.16, 9/A9.16",
        "head": "10/A9.16",
        "sill": "3/A9.16",
        "jamb": "9/A9.16",
        "hardware": "true",
        "latch": "true",
        "closer": "true",
        "card_reader": null,
        "exit_device": null,
        "hold_open": null,
        "set_num": "11",
        "fire_rating": "3/4 HR",
        "comments": null
      },
Copy code
---Parsed Response (list<class ScheduleRow>)---
    [
      {
        "number": "1S1B",
        "mark": "1S1B",
        "location": "STAIR 1",
        "room": "STAIR 1",
        "dimensions": "3' - 6\" x 8' - 0\"",
        "width": "3' - 6\"\",\n    \"height\": \"8' - 0\"",
        "height": "8' - 0\"\",\n    \"thickness\": \"1 3/4\"",
        "thickness": "1 3/4\"\",\n    \"leaf\": \"F\",\n    \"type\": \"F\",\n    \"material\": \"HM\",\n    \"finish\": \"PTD\",\n    \"num_of_leaves\": \"1\",\n    \"frame\": \"1\",\n    \"glazing\": null,\n    \"oitc\": null,\n    \"stc\": null,\n    \"details\": \"10/A9.16, 3/A9.16, 9/A9.16\",\n    \"head\": \"10/A9.16\",\n    \"sill\": \"3/A9.16\",\n    \"jamb\": \"9/A9.16\",\n    \"hardware\": \"true\",\n    \"latch\": \"true\",\n    \"closer\": \"true\",\n    \"card_reader\": null,\n    \"exit_device\": null,\n    \"hold_open\": null,\n    \"set_num\": \"11\",\n    \"fire_rating\": \"3/4 HR\",\n    \"comments\": null\n  },\n  {\n    \"number\": \"1S2\",\n    \"mark\": \"1S2\",\n    \"location\": \"STAIR 2\",\n    \"room\": \"STAIR 2\",\n    \"dimensions\": \"3' - 0\" x 8' - 0\"\",\n    \"width\": \"3' - 0\"",
        "leaf": "F",
        "type": "F",
        "material": "HM",
        "finish": "PTD",
        "num_of_leaves": "1",
        "frame": "1",
        "glazing": null,
        "oitc": null,
        "stc": null,
        "details": "10/A9.16, 3/A9.16, 9/A9.16",
        "head": "10/A9.16",
        "sill": "3/A9.16",
        "jamb": "9/A9.16",
        "hardware": "true",
        "latch": "true",
        "closer": "true",
        "card_reader": null,
        "exit_device": null,
        "hold_open": null,
        "set_num": "16",
        "fire_rating": "3/4 HR",
        "comments": null
      },
v
Great catch. We actually run a simple json.parse before we run any of the parsing algorithms. So there likely is something downstream at the model messed up that is not valid json. That said it looks like \”” could be better detected!
Oops I meant backslash \””
l
Interesting, you mean the model might have messed up the json structure somewhere else in the reply? It looks above like the raw reply is correct and the parsed reply is duplicating information somehow.
v
Hmm can you post the full result
l
Honestly don't know why but it stopped being an issue
Thanks for listening to my concerns lol