Skip to content

Commit 008e0ec

Browse files
apply lint to pdl_interpreter.py
Signed-off-by: hirokuni-kitahara <[email protected]>
1 parent 69fdddb commit 008e0ec

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
@@ -799,14 +799,19 @@ def process_block_body(
799799
retry_count += 1
800800
error = f"Retry on error is triggered in a repeat block. Error detail: {repr(exc)} "
801801
print(f"\n\033[0;31m{error}\033[0m\n")
802-
if (
803-
background
804-
and background.data
805-
and background.data[-1]["content"].endswith(error)
806-
):
802+
repeating_same_error = False
803+
if background and background.data:
804+
bg_data = background.data
805+
if isinstance(bg_data, list):
806+
last_error = bg_data[-1]["content"]
807+
if isinstance(last_error, str):
808+
if last_error.endswith(error):
809+
repeating_same_error = True
810+
if repeating_same_error:
807811
error = "The previous error occurs multiple times."
808812
background = lazy_messages_concat(
809-
background, [{"role": "assistant", "content": error}]
813+
background,
814+
PdlList([{"role": "assistant", "content": error}]),
810815
)
811816
else:
812817
raise PDLRuntimeError(

0 commit comments

Comments
 (0)