Merge pull request #36 from gabrii/35-handle-model-generating-invalid-json-gracefully

Fix #35: logging crashes when model provides invalid json
This commit is contained in:
Gabriel Gavilan
2025-09-15 12:42:03 +02:00
committed by GitHub
+5 -1
View File
@@ -232,7 +232,11 @@ def log_request(req: Request) -> str:
)
)
if arguments:
console.print(Padding(JSON(arguments), (0, 8)))
try:
console.print(Padding(JSON(arguments), (0, 8)))
except json.JSONDecodeError:
console.print("[red]Invalid JSON generated by the model:[/red]")
print(arguments)
console.print(Padding("[bold])[/bold]", (0, 4)))
if tool_calls:
console.print()