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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user