Skip to content

Commit

Permalink
feat: add status emojis to system messages (#429)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xbrayo authored Feb 2, 2025
1 parent a6109c7 commit 69c5f01
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
9 changes: 9 additions & 0 deletions gptme/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,15 @@ def format_msgs(
if highlight:
color = ROLE_COLOR[msg.role]
userprefix = f"[bold {color}]{userprefix}[/bold {color}]"
if msg.role == "system":
first_line = msg.content.split("\n", 1)[0].lower()
isSuccess = first_line.startswith(("saved", "appended", "patch successfully", "ran"))
isError = first_line.startswith(("error", "failed"))
if isSuccess:
userprefix = f"{userprefix} ✅"
elif isError:
userprefix = f"{userprefix} ❌"

# get terminal width
max_len = shutil.get_terminal_size().columns - len(userprefix)
output = ""
Expand Down
2 changes: 1 addition & 1 deletion gptme/tools/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def execute_patch(
code = kwargs.get("patch", code)

if not code:
yield Message("system", "No patch provided by the assistant")
yield Message("system", "Error: No patch provided by the assistant")
return

yield from execute_with_confirmation(
Expand Down
4 changes: 2 additions & 2 deletions gptme/tools/tmux.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def execute_tmux(
continue

if len(parts) < 2:
yield Message("system", f"Missing arguments for command: {command}")
yield Message("system", f"Error: Missing arguments for command: {command}")
continue

_args = parts[1]
Expand All @@ -237,7 +237,7 @@ def execute_tmux(
elif command == "kill_session":
yield kill_session(_args)
else:
yield Message("system", f"Unknown command: {command}")
yield Message("system", f"Error: Unknown command: {command}")


instructions = """
Expand Down

0 comments on commit 69c5f01

Please sign in to comment.