Skip to content

Commit 1d62fc7

Browse files
apply lint to pdl_interpreter.py
Signed-off-by: hirokuni-kitahara <[email protected]>
1 parent 538b28d commit 1d62fc7

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/pdl/pdl_interpreter.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -804,14 +804,19 @@ def process_block_body(
804804
retry_count += 1
805805
error = f"Retry on error is triggered in a repeat block. Error detail: {repr(exc)} "
806806
print(f"\n\033[0;31m{error}\033[0m\n")
807-
if (
808-
background
809-
and background.data
810-
and background.data[-1]["content"].endswith(error)
811-
):
807+
repeating_same_error = False
808+
if background and background.data:
809+
bg_data = background.data
810+
if isinstance(bg_data, list):
811+
last_error = bg_data[-1]["content"]
812+
if isinstance(last_error, str):
813+
if last_error.endswith(error):
814+
repeating_same_error = True
815+
if repeating_same_error:
812816
error = "The previous error occurs multiple times."
813817
background = lazy_messages_concat(
814-
background, [{"role": "assistant", "content": error}]
818+
background,
819+
PdlList([{"role": "assistant", "content": error}]),
815820
)
816821
else:
817822
raise PDLRuntimeError(

0 commit comments

Comments
 (0)