Skip to content

Commit 636d6a7

Browse files
authored
Structured decoding bug fix for watsonx, ollama + traceback for python code blocks (#708)
* structure decoding support for watsonx, ollama, traceback for code blocks Signed-off-by: Mandana Vaziri <[email protected]> * cleanup Signed-off-by: Mandana Vaziri <[email protected]> --------- Signed-off-by: Mandana Vaziri <[email protected]>
1 parent 104c75e commit 636d6a7

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
text:
2+
- role: system
3+
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.
4+
contribute: [context]
5+
- "\nWhat is the color of the sky?\n"
6+
- model: ollama_chat/granite3.2:2b
7+
#model: watsonx/ibm/granite-34b-code-instruct
8+
parser: json
9+
spec: { color: str }

src/pdl/pdl_ast.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -860,8 +860,11 @@ def set_structured_decoding_parameters(
860860
parameters["guided_json"] = schema
861861
parameters["response_format"] = {
862862
"type": "json_schema",
863-
"json_schema": schema,
864-
"strict": True,
863+
"json_schema": {
864+
"name": "schema",
865+
"schema": schema,
866+
"strict": True,
867+
},
865868
}
866869
return parameters
867870

src/pdl/pdl_interpreter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import subprocess # nosec
66
import sys
77
import time
8+
import traceback
89
import types
910

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

0 commit comments

Comments
 (0)