Skip to content

Commit 3a4618a

Browse files
committed
Upgrade outlines_core and update imports
1 parent 39af590 commit 3a4618a

File tree

4 files changed

+43
-44
lines changed

4 files changed

+43
-44
lines changed

outlines/backends/outlines_core.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
from typing import Callable, Dict
44

55
from outlines_core import Guide, Index, Vocabulary
6-
# TODO: change this once the import issue is fixed in outlines_core
7-
from outlines_core import outlines_core
6+
from outlines_core.json_schema import build_regex_from_schema
87

98
from outlines.backends.base import BaseBackend
109
from outlines.models import SteerableModel
@@ -248,7 +247,7 @@ def get_json_schema_logits_processor(
248247
The logits processor to use to constrain the generation.
249248
250249
"""
251-
regex = outlines_core.json_schema.build_regex_from_schema(json_schema)
250+
regex = build_regex_from_schema(json_schema)
252251
return self.get_regex_logits_processor(regex)
253252

254253
def get_regex_logits_processor(self, regex: str):

outlines/types/dsl.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
)
3030
import jsonschema
3131
from genson import SchemaBuilder
32-
# TODO: change this once the import issue is fixed in outlines_core
33-
from outlines_core import outlines_core
3432
from pydantic import (
3533
BaseModel,
3634
GetCoreSchemaHandler,
@@ -39,6 +37,7 @@
3937
)
4038
from pydantic.json_schema import JsonSchemaValue
4139
from pydantic_core import core_schema as cs
40+
from outlines_core.json_schema import build_regex_from_schema
4241

4342
import outlines.types as types
4443
from outlines import grammars
@@ -916,7 +915,7 @@ def to_regex(term: Term) -> str:
916915
elif isinstance(term, Regex):
917916
return f"({term.pattern})"
918917
elif isinstance(term, JsonSchema):
919-
regex_str = outlines_core.json_schema.build_regex_from_schema(term.schema, term.whitespace_pattern)
918+
regex_str = build_regex_from_schema(term.schema, term.whitespace_pattern)
920919
return f"({regex_str})"
921920
elif isinstance(term, Choice):
922921
regexes = [to_regex(python_types_to_terms(item)) for item in term.items]

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ dependencies = [
3131
"jsonschema",
3232
"pillow",
3333
"typing_extensions",
34-
"outlines_core==0.2.11",
34+
"outlines_core==0.2.14",
3535
"genson",
3636
"jsonpath_ng",
3737
]

0 commit comments

Comments
 (0)