Skip to content

Commit 4fdd7c4

Browse files
committed
Fixes
Signed-off-by: Louis Mandel <[email protected]>
1 parent 655eb17 commit 4fdd7c4

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

src/pdl/pdl_llms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def generate_text_stream(
183183

184184

185185
def set_structured_decoding_parameters(
186-
spec: PdlTypeType,
186+
spec: Optional[PdlTypeType],
187187
parameters: Optional[dict[str, Any]],
188188
) -> dict[str, Any]:
189189
if parameters is None:

src/pdl/pdl_schema_utils.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,13 @@ def pdltype_to_jsonschema(
7373
else:
7474
details = constraints.model_dump(exclude_defaults=True)
7575
schema = {"type": "integer", **details}
76-
case ListPdlType(list=ListPdlTypeConstraints()):
77-
items_type = PdlTypeParser.model_validate(
78-
pdl_type.list.__pydantic_extra__
79-
).root
76+
case ListPdlType(list=ListPdlTypeConstraints() as cstr):
77+
items_type = PdlTypeParser.model_validate(cstr.__pydantic_extra__).root
8078
details = {}
81-
if pdl_type.list.minItems is not None:
82-
details["minItems"] = pdl_type.list.minItems
83-
if pdl_type.list.maxItems is not None:
84-
details["maxItems"] = pdl_type.list.maxItems
79+
if cstr.minItems is not None:
80+
details["minItems"] = cstr.minItems
81+
if cstr.maxItems is not None:
82+
details["maxItems"] = cstr.maxItems
8583
schema = {
8684
"type": "array",
8785
"items": pdltype_to_jsonschema(items_type, additional_properties),

tests/test_type_checking.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from pdl.pdl import exec_dict
55
from pdl.pdl_interpreter import PDLRuntimeError
6+
from pdl.pdl_parser import PDLParseError
67
from pdl.pdl_schema_utils import pdltype_to_jsonschema
78

89
_PDLTYPE_TO_JSONSCHEMA_TESTS = [
@@ -314,7 +315,7 @@ def test_function_call7():
314315

315316

316317
def test_function_call8():
317-
with pytest.raises(PDLRuntimeError):
318+
with pytest.raises(PDLParseError):
318319
exec_dict(function_call8)
319320

320321

0 commit comments

Comments
 (0)