Skip to content

Commit 1614b26

Browse files
authored
fix: remove some type: ignore (#837)
--------- Signed-off-by: Louis Mandel <[email protected]>
1 parent aebe635 commit 1614b26

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

src/pdl/pdl_interpreter.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -577,18 +577,18 @@ def process_block_body(
577577
scope,
578578
loc,
579579
)
580-
d = {
580+
message = {
581581
"role": state.role,
582582
"content": content,
583583
"defsite": block.pdl__id,
584584
}
585585
if block.name is not None:
586586
name, block = process_expr_of(block, "name", scope, loc)
587-
d["name"] = name
587+
message["name"] = name
588588
if block.tool_call_id is not None:
589589
tool_call_id, block = process_expr_of(block, "tool_call_id", scope, loc)
590-
d["tool_call_id"] = tool_call_id
591-
result = PdlDict(d)
590+
message["tool_call_id"] = tool_call_id
591+
result = PdlDict(message)
592592
background = PdlList([result])
593593
case IfBlock():
594594
b, if_trace = process_condition_of(block, "condition", scope, loc, "if")

tests/test_messages.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,34 @@ def test_message4():
106106
"defsite": "message",
107107
},
108108
]
109+
110+
111+
def test_messages5():
112+
prog_str = """
113+
description: Messages block
114+
array:
115+
- role: tool
116+
content: 42
117+
name: f
118+
tool_call_id: id
119+
"""
120+
result = exec_str(prog_str, output="all")
121+
context = result["scope"]["pdl_context"]
122+
assert result["result"] == [
123+
{
124+
"role": "tool",
125+
"content": 42,
126+
"name": "f",
127+
"tool_call_id": "id",
128+
"defsite": "array.0.message",
129+
},
130+
]
131+
assert context == [
132+
{
133+
"role": "tool",
134+
"content": 42,
135+
"name": "f",
136+
"tool_call_id": "id",
137+
"defsite": "array.0.message",
138+
}
139+
]

0 commit comments

Comments
 (0)