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 · 1 comment · May be fixed by #138
Open

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

LorrinWWW opened this issue Dec 17, 2024 · 1 comment · May be fixed by #138
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
@Dsantra92
Copy link

Can I work on this?

bnjjj added a commit to bnjjj/outlines-core that referenced this issue Jan 21, 2025
Signed-off-by: Benjamin <5719034+bnjjj@users.noreply.github.com>
@bnjjj bnjjj linked a pull request Jan 21, 2025 that will close this issue
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

Successfully merging a pull request may close this issue.

3 participants