Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

to_regex does not support type to be a list of types anymore. #126

Open
LorrinWWW opened this issue Dec 17, 2024 · 0 comments
Open

to_regex does not support type to be a list of types anymore. #126

LorrinWWW opened this issue Dec 17, 2024 · 0 comments
Labels
bug Something isn't working json schema

Comments

@LorrinWWW
Copy link

Describe the issue as clearly as possible:

In the outlines repo, there was method to_regex & build_regex_from_schema that can correctly parse type being a list of types. Recently outlines opted to use outlines-core's implementation and it cannot parse this anymore.

Steps/code to reproduce the bug:

##### outlines==0.1.8 works

import json
from outlines.fsm.json_schema import build_regex_from_schema

schema = {
    "properties": {
        "text": {"type": ["string", "number"]},
    }
}

regex = build_regex_from_schema(json.dumps(schema))

#####

import json
from outlines_core.fsm.json_schema import build_regex_from_schema

schema = {
    "properties": {
        "text": {"type": ["string", "number"]},
    }
}

regex = build_regex_from_schema(json.dumps(schema))

---> 11 regex = build_regex_from_schema(json.dumps(schema))

ValueError: 'type' must be a string

Expected result:

It should be able to parse `dtype` as a list.

Error message:

---> 11 regex = build_regex_from_schema(json.dumps(schema))

ValueError: 'type' must be a string

Outlines/Python version information:

Version information

``` 0.1.8 ```

outlines.fsm.json_schema.build_regex_from_schema was removed in outlines>=0.1.9

Context for the issue:

No response

@LorrinWWW LorrinWWW added the bug Something isn't working label Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working json schema
Projects
None yet
Development

No branches or pull requests

2 participants