Skip to content

Commit dc95a4c

Browse files
committed
feat: the scope of the content field is local
Signed-off-by: Louis Mandel <[email protected]>
1 parent 7fdf002 commit dc95a4c

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

src/pdl/pdl_interpreter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ def process_block_body(
783783
if state.yield_result and not iteration_state.yield_result:
784784
yield_result(result, block.kind)
785785
case MessageBlock():
786-
content, _, scope, trace = process_block_of(
786+
content, _, _, trace = process_block_of(
787787
block,
788788
"content",
789789
state,

tests/test_messages.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,48 @@ def test_messages5():
147147
"pdl__defsite": "array.0.message",
148148
}
149149
]
150+
151+
152+
def test_messages6():
153+
prog_str = """
154+
description: Message block scope
155+
defs:
156+
x: 1
157+
array:
158+
- content:
159+
defs:
160+
x: 2
161+
text: ${ x }
162+
- content:
163+
text: ${ x }
164+
"""
165+
result = exec_str(prog_str, output="all")
166+
context = result["scope"]["pdl_context"]
167+
assert [m.serialize(SerializeMode.LITELLM) for m in result["result"]] == [
168+
[
169+
{
170+
"role": "user",
171+
"content": "2",
172+
"pdl__defsite": "array.0.message",
173+
}
174+
],
175+
[
176+
{
177+
"role": "user",
178+
"content": "1",
179+
"pdl__defsite": "array.1.message",
180+
}
181+
],
182+
]
183+
assert context.serialize(SerializeMode.LITELLM) == [
184+
{
185+
"role": "user",
186+
"content": "2",
187+
"pdl__defsite": "array.0.message",
188+
},
189+
{
190+
"role": "user",
191+
"content": "1",
192+
"pdl__defsite": "array.1.message",
193+
},
194+
]

0 commit comments

Comments
 (0)