-
-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add status emojis to system messages #429
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Looks good to me! Reviewed everything up to 05f8220 in 1 minute and 5 seconds
More details
- Looked at
230
lines of code in8
files - Skipped
0
files when reviewing. - Skipped posting
8
drafted comments based on config settings.
1. gptme/message.py:46
- Draft comment:
Thestatus
attribute is added to theMessage
class, but the class docstring is not updated to reflect this new attribute. Consider updating the docstring to includestatus
and its possible values. - Reason this comment was not posted:
Confidence changes required:50%
The PR introduces a new 'status' attribute to the Message class, which is used to add status emojis to system messages. This is a good feature addition, but there are some areas that need attention.
2. gptme/message.py:89
- Draft comment:
Theto_dict
method now includes thestatus
attribute. Ensure that any consumers of this dictionary representation are aware of the newstatus
field to avoid potential issues. - Reason this comment was not posted:
Confidence changes required:30%
The PR introduces a new 'status' attribute to the Message class, which is used to add status emojis to system messages. This is a good feature addition, but there are some areas that need attention.
3. gptme/message.py:226
- Draft comment:
The use of the walrus operator:=
is Python 3.8+. Ensure that the project supports this version or higher. If not, consider using a different approach to maintain compatibility. - Reason this comment was not posted:
Confidence changes required:50%
The PR introduces a new 'status' attribute to the Message class, which is used to add status emojis to system messages. This is a good feature addition, but there are some areas that need attention.
4. gptme/tools/base.py:300
- Draft comment:
The comment# this works
is unnecessary and should be removed to maintain code cleanliness. This applies to similar comments in other files as well. - Reason this comment was not posted:
Confidence changes required:20%
The PR introduces a new 'status' attribute to the Message class, which is used to add status emojis to system messages. This is a good feature addition, but there are some areas that need attention.
5. gptme/tools/patch.py:261
- Draft comment:
The message 'No patch provided by the assistant' is marked withstatus="error"
. Consider if this should be aninfo
status instead, as it might not be an error condition but rather a lack of input. - Reason this comment was not posted:
Confidence changes required:30%
The PR introduces a new 'status' attribute to the Message class, which is used to add status emojis to system messages. This is a good feature addition, but there are some areas that need attention.
6. gptme/tools/python.py:119
- Draft comment:
The message 'Execution aborted: user chose not to run this code.' is marked withstatus="info"
. Ensure this is the intended status level, as it might be more appropriate as awarning
. - Reason this comment was not posted:
Confidence changes required:30%
The PR introduces a new 'status' attribute to the Message class, which is used to add status emojis to system messages. This is a good feature addition, but there are some areas that need attention.
7. gptme/tools/save.py:100
- Draft comment:
The message 'Save aborted: user refused to overwrite the file.' is marked withstatus="error"
. Consider if this should be awarning
status instead, as it might not be a critical error but a user decision. - Reason this comment was not posted:
Confidence changes required:30%
The PR introduces a new 'status' attribute to the Message class, which is used to add status emojis to system messages. This is a good feature addition, but there are some areas that need attention.
8. gptme/tools/shell.py:306
- Draft comment:
The print statements for debugging purposes (e.g.,print(f"expecting non-zero return code: {returncode}")
) should be removed or replaced with proper logging to maintain code cleanliness and performance. - Reason this comment was not posted:
Confidence changes required:40%
The PR introduces a new 'status' attribute to the Message class, which is used to add status emojis to system messages. This is a good feature addition, but there are some areas that need attention.
Workflow ID: wflow_eA21jIrCmMrzV4QH
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can do this without adding msg.status
gptme/message.py
Outdated
# Add status emoji for system messages | ||
if msg.role == "system" and msg.status: | ||
status_emoji = { | ||
"success": "✅", | ||
"error": "❌", | ||
"info": "ℹ️", | ||
} | ||
if emoji := status_emoji.get(msg.status): | ||
userprefix = f"{userprefix} {emoji}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In gptme-webui I simply check the first line with:
first_line = msg.content.split("\n", 1)[0].lower()
isSuccess = first_line.startswith(["saved", "success", "patch successfully"])
isError = first_line.startswith(["error", "failed"])
Since it's just a design thing, I think such a lightweight approach makes more sense.
The "info" emoji also doesn't make much sense to me (how is it different from no status?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "info" emoji also doesn't make much sense to me (how is it different from no status?)
The info emoji was suggested by gptme yeah, I should just scrap it.
06357e1
to
e02e119
Compare
gptme/message.py
Outdated
@@ -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", "executed", "ran", "appended", "patch successfully")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"executed", "ran"
I think these do not actually signal success explicitly? (could have non-zero exit codes)
gptme/message.py
Outdated
if msg.role == "system": | ||
first_line = msg.content.split("\n", 1)[0].lower() | ||
isSuccess = first_line.startswith(("saved", "executed", "ran", "appended", "patch successfully")) | ||
isError = first_line.startswith(("error", "failed","missing arguments", "unknown command", "no patch")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see tmux gives "missing arguments", the message should probably be changed to "Error: Missing arguments" so the detection can be simplified.
Same for "unknown command" and "no patch".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
ffa7f04
to
b9fe104
Compare
gptme/message.py
Outdated
isSuccess = first_line.startswith(("saved", "executed", "ran", "appended", "patch successfully")) | ||
isError = first_line.startswith(("error", "failed","missing arguments", "unknown command", "no patch")) | ||
isSuccess = first_line.startswith(("saved", "appended", "patch successfully")) | ||
isError = first_line.startswith(("error", "failed")) or "Return code" in msg.content[-16:] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a shell command exits with a non-zero code the code is part of the message. Only captures unsuccessful commands. Could change the code to append the return code for each command and strip the zero return codes before displaying the message.
78bb536
to
b1410c1
Compare
gptme/tools/shell.py
Outdated
) | ||
+ "\n\n" | ||
_format_block_smart( | ||
f"{'Failed to run' if returncode else 'Ran'} " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think "failed to run" might be bad prompting. We should be careful to not infer too much from a non-zero exit code I think. I'd just keep the "Ran" and not try to infer a success/error status for shell commands, for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the shell.py changes.
b1410c1
to
712d686
Compare
Nice, lets go! |
Important
Add status emojis to system messages by introducing a
status
attribute in theMessage
class and updating related functions to handle this attribute.status
attribute toMessage
class inmessage.py
to represent message status as "success", "error", "info", orNone
.format_msgs()
inmessage.py
to append status emojis to system messages based on thestatus
attribute.execute()
inbase.py
,execute_patch_impl()
inpatch.py
,execute_python()
inpython.py
,execute_save_impl()
andexecute_append_impl()
insave.py
,execute_shell_impl()
inshell.py
, andexecute_tmux()
intmux.py
to set thestatus
attribute inMessage
instances.to_dict()
andfrom_toml()
inmessage.py
to handle thestatus
attribute.execute_with_confirmation()
inask_execute.py
.This description was created by for 05f8220. It will automatically update as commits are pushed.