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
3 changes: 2 additions & 1 deletion examples/demo/8-tools.pdl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ text:
text: You are Granite, developed by IBM. You are a helpful AI assistant with access to the following tools. When a tool is required to answer the user's query, respond with <|tool_call|> followed by a JSON list of tools used. If a tool does not exist in the provided list of tools, notify the user that you do not have the ability to fulfill the request.
contribute: [context]
- role: tools
text: ${ tools }
content:
text: ${ tools }
contribute: [context]
- "Out of 1400 participants, 400 passed the test. What percentage is that?\n"
- def: actions
Expand Down
3 changes: 2 additions & 1 deletion examples/demo/9-react.pdl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ text:
text: You are Granite, developed by IBM. You are a helpful AI assistant with access to the following tools. When a tool is required to answer the user's query, respond with <|tool_call|> followed by a JSON list of tools used. If a tool does not exist in the provided list of tools, notify the user that you do not have the ability to fulfill the request.
contribute: [context]
- role: tools
text: ${ tools }
content:
text: ${ tools }
contribute: [context]
- text:
|
Expand Down
3 changes: 2 additions & 1 deletion examples/react/demo.pdl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ text:
text: You are Granite, developed by IBM. You are a helpful AI assistant with access to the following tools. When a tool is required to answer the user's query, respond with <|tool_call|> followed by a JSON list of tools used. If a tool does not exist in the provided list of tools, notify the user that you do not have the ability to fulfill the request.
contribute: [context]
- role: tools
text: ${ tools }
content:
text: ${ tools }
contribute: [context]
- text:
|
Expand Down
3 changes: 2 additions & 1 deletion examples/tools/calc.pdl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ text:
text: You are Granite, developed by IBM. You are a helpful AI assistant with access to the following tools. When a tool is required to answer the user's query, respond with <|tool_call|> followed by a JSON list of tools used. If a tool does not exist in the provided list of tools, notify the user that you do not have the ability to fulfill the request.
contribute: [context]
- role: tools
text: ${ tools }
content:
text: ${ tools }
contribute: [context]
- "Out of 1400 participants, 400 passed the test. What percentage is that?\n"
- def: actions
Expand Down
14 changes: 5 additions & 9 deletions src/pdl/pdl_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,12 @@ def process_block(
trace=ErrorBlock(msg=exc.message, pdl__location=loc, program=block),
) from exc
result = PdlConst(v)
stringified_result = lazy_apply(stringify, result)
background = PdlList(
[
PdlDict( # type: ignore
{
"role": state.role,
"content": stringified_result,
"content": result,
"defsite": ".".join(
state.id_stack
), # Warning: defsite for a literal value
Expand All @@ -268,7 +267,7 @@ def process_block(
)
trace = DataBlock(
data=expr,
pdl__result=stringified_result,
pdl__result=result,
pdl__timing=PdlTiming(start_nanos=start, end_nanos=time.time_ns()),
pdl__id=".".join(state.id_stack),
)
Expand Down Expand Up @@ -475,9 +474,8 @@ def process_block_body(
loc=exc.loc or loc,
trace=ErrorBlock(msg=exc.message, pdl__location=loc, program=block),
) from exc
stringified_result = lazy_apply(stringify, result)
background = PdlList(
[PdlDict({"role": state.role, "content": stringified_result})] # type: ignore
[PdlDict({"role": state.role, "content": result})] # type: ignore
)
trace = block.model_copy()
if state.yield_result:
Expand All @@ -492,9 +490,8 @@ def process_block_body(
else:
v, trace = process_expr_of(block, "data", scope, loc)
result = PdlConst(v)
stringified_result = stringify(v)
background = PdlList(
[PdlDict({"role": state.role, "content": stringified_result})] # type: ignore
[PdlDict({"role": state.role, "content": result})] # type: ignore
)
if state.yield_result:
yield_result(result.result(), block.kind)
Expand Down Expand Up @@ -1601,9 +1598,8 @@ def process_call_code(
case "pdl":
try:
result = call_pdl(code_s, scope)
stringified_result = lazy_apply(stringify, result)
background = PdlList(
[PdlDict({"role": state.role, "content": stringified_result, "defsite": block.pdl__id})] # type: ignore
[PdlDict({"role": state.role, "content": result, "defsite": block.pdl__id})] # type: ignore
)
except Exception as exc:
raise PDLRuntimeError(
Expand Down
Loading