Skip to content

[Bug] require latest 0.54.1 json-repair to respect python style number notation (underscore format number) #9078

@BoluoZz

Description

@BoluoZz

What happened?

Issue

My LLM starts to output numbers in underscore format like '{"value": 82_461_110}'.
When ChatAdapter call parse to handle the LLM completion, the parse_value function inside uses candidate = json_repair.loads(value), which will return {'value': 82}.

Fix in json-repair

Thanks to @mangiucugna, the author of json-repair, a new version 0.54.1 has released to fix this problem.
https://github.com/mangiucugna/json_repair/issues/169
https://github.com/mangiucugna/json_repair/releases/tag/v0.54.1

I think if you can update the dependency that will help. Thanks!

Steps to reproduce

with json-repair==0.54.0

text = '{"value": 82_461_110}'
fixed = json_repair.loads(text)
fixed
{'value': 82}

with json-repair==0.54.1

text = '{"value": 82_461_110}'
fixed = json_repair.loads(text)
fixed
{'value': 82461110}

In dspy.adapters.utils, parse_value requires value and annotation.
If my annotation is a pydantic.Basemodel, json-repair will be called later candidate = json_repair.loads(value).

I think simply upgrade to 0.54.1 of json-repair will fix this issue.

DSPy version

3.0.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions