Skip to content

Commit

Permalink
fix: catch rich.print() errors and fall back to builtins.print() when…
Browse files Browse the repository at this point in the history
… printing messages
  • Loading branch information
ErikBjare committed Sep 5, 2024
1 parent 8a7fb5c commit 8698bef
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion gptme/message.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import base64
import builtins
import io
import logging
import shutil
Expand Down Expand Up @@ -264,7 +265,11 @@ def print_msg(
if m.hide and not show_hidden:
skipped_hidden += 1
continue
print(s)
try:
print(s)
except Exception:
# rich can throw errors, if so then print the raw message
builtins.print(s)
if skipped_hidden:
print(
f"[grey30]Skipped {skipped_hidden} hidden system messages, show with --show-hidden[/]"
Expand Down

0 comments on commit 8698bef

Please sign in to comment.