Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions examples/hello/hello-structured-decoding.pdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
text:
- role: system
text: You are an AI language model developed by IBM Research. You are a cautious assistant. You carefully follow instructions. You are helpful and harmless and you follow ethical guidelines and promote positive behavior.
contribute: [context]
- "\nWhat is the color of the sky?\n"
- model: ollama_chat/granite3.2:2b
#model: watsonx/ibm/granite-34b-code-instruct
parser: json
spec: { color: str }
7 changes: 5 additions & 2 deletions src/pdl/pdl_ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -860,8 +860,11 @@ def set_structured_decoding_parameters(
parameters["guided_json"] = schema
parameters["response_format"] = {
"type": "json_schema",
"json_schema": schema,
"strict": True,
"json_schema": {
"name": "schema",
"schema": schema,
"strict": True,
},
}
return parameters

Expand Down
3 changes: 2 additions & 1 deletion src/pdl/pdl_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import subprocess # nosec
import sys
import time
import traceback
import types

# TODO: temporarily disabling warnings to mute a pydantic warning from liteLLM
Expand Down Expand Up @@ -1445,7 +1446,7 @@ def process_call_code(
)
except Exception as exc:
raise PDLRuntimeError(
f"Python Code error: {repr(exc)}",
f"Python Code error: {traceback.format_exc()}",
loc=loc,
trace=block.model_copy(
update={"code": code_s, "defsite": block.pdl__id}
Expand Down