Skip to content

Commit 4ea3dde

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

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
@@ -792,14 +792,19 @@ def process_block_body(
792792
retry_count += 1
793793
error = f"Retry on error is triggered in a repeat block. Error detail: {repr(exc)} "
794794
print(f"\n\033[0;31m{error}\033[0m\n")
795-
if (
796-
background
797-
and background.data
798-
and background.data[-1]["content"].endswith(error)
799-
):
795+
repeating_same_error = False
796+
if background and background.data:
797+
bg_data = background.data
798+
if isinstance(bg_data, list):
799+
last_error = bg_data[-1]["content"]
800+
if isinstance(last_error, str):
801+
if last_error.endswith(error):
802+
repeating_same_error = True
803+
if repeating_same_error:
800804
error = "The previous error occurs multiple times."
801805
background = lazy_messages_concat(
802-
background, [{"role": "assistant", "content": error}]
806+
background,
807+
PdlList([{"role": "assistant", "content": error}]),
803808
)
804809
else:
805810
raise PDLRuntimeError(

0 commit comments

Comments
 (0)