Skip to content

Commit c632ebb

Browse files
committed
fix: handle missing id and task attributes in logs
1 parent 6fa0b4a commit c632ebb

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

nemoguardrails/logging/verbose.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ def emit(self, record) -> None:
5454
skip_print = True
5555
if verbose_llm_calls:
5656
console.print("")
57-
console.print(f"[cyan]LLM {title} ({record.id[:5]}..)[/]")
57+
console.print(
58+
f"[cyan]LLM {title} ({getattr(record, 'id', 'unknown')[:5]}..)[/]"
59+
)
5860
for line in body.split("\n"):
5961
text = Text(line, style="black on #006600", end="\n")
6062
text.pad_right(console.width)
@@ -67,7 +69,7 @@ def emit(self, record) -> None:
6769
skip_print = True
6870
console.print("")
6971
console.print(
70-
f"[cyan]LLM Prompt ({record.id[:5]}..) - {record.task}[/]"
72+
f"[cyan]LLM Prompt ({getattr(record, 'id', 'unknown')[:5]}..) - {getattr(record, 'task', 'unknown')}[/]"
7173
)
7274

7375
for line in body.split("\n"):

0 commit comments

Comments
 (0)