-
-
Notifications
You must be signed in to change notification settings - Fork 210
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
fix: fixed behavior for keyboard interrupts and user commands #384
base: master
Are you sure you want to change the base?
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 450a0e5 in 57 seconds
More details
- Looked at
148
lines of code in2
files - Skipped
0
files when reviewing. - Skipped posting
3
drafted comments based on config settings.
1. gptme/chat.py:141
- Draft comment:
interrupt_msg
is used before it is defined, which can lead to aNameError
. Defineinterrupt_msg
before its first use. - Reason this comment was not posted:
Comment looked like it was already resolved.
2. gptme/commands.py:63
- Draft comment:
The checkmsg.role == "user" and msg.content.startswith("/")
is repeated in multiple places. Consider refactoring this into a helper function for clarity and efficiency. - Reason this comment was not posted:
Confidence changes required:50%
Theexecute_cmd
function ingptme/commands.py
checks if a message is a command by verifying if it starts with a "/" and if the role is "user". This check is repeated in multiple places, which can be refactored for clarity and efficiency.
3. gptme/commands.py:159
- Draft comment:
Thehelp()
function is called but not defined in the provided code, which can lead to aNameError
. Ensure that thehelp()
function is defined or imported correctly. - Reason this comment was not posted:
Comment did not seem useful.
Workflow ID: wflow_CZu6xC7lCVe7l8DA
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
❌ 5 Tests Failed:
View the top 3 failed tests by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
450a0e5
to
e3d04d2
Compare
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! Incremental review on e3d04d2 in 55 seconds
More details
- Looked at
143
lines of code in2
files - Skipped
0
files when reviewing. - Skipped posting
2
drafted comments based on config settings.
1. gptme/chat.py:222
- Draft comment:
The checkmsg.content.startswith("/") and msg.role == "user"
is redundant here sinceexecute_cmd
already performs this check. Consider removing it for clarity. - Reason this comment was not posted:
Decided after close inspection that this draft comment was likely wrong and/or not actionable:
The check is actually not redundant. execute_cmd returns a boolean indicating if it handled a command, but this code needs to prevent further processing of commands by returning early. The check and return on line 222-223 serves a different purpose than execute_cmd - it prevents command messages from being added to the log and processed further. Without this check, commands would be processed twice.
I could be wrong about the command processing flow. Maybe there's another mechanism preventing double processing that I'm missing.
Looking at the full context, I'm confident this check is needed. The code structure shows commands need special handling to prevent them from being treated as regular messages.
The comment is incorrect - this check is not redundant and serves an important purpose in preventing command messages from being processed as regular messages.
2. gptme/commands.py:64
- Draft comment:
The checkmsg.role == "user" and msg.content.startswith("/")
is redundant sinceexecute_cmd
is only called when these conditions are met. Consider simplifying the logic. - Reason this comment was not posted:
Marked as duplicate.
Workflow ID: wflow_disyq8FgF6gQ0cVt
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
e3d04d2
to
c7301e5
Compare
Has some similarities to #371
Important
Refactor keyboard interrupt and user command handling in
chat.py
andcommands.py
for consistent behavior.chat.py
andcommands.py
to use a consistentinterrupt_msg
.execute_cmd
incommands.py
to check both user role and command prefix.step()
inchat.py
to yieldinterrupt_msg
onKeyboardInterrupt
.handle_cmd()
incommands.py
to handle/help
command separately.execute_cmd()
incommands.py
.chat.py
to streamline message handling logic.This description was created by for e3d04d2. It will automatically update as commits are pushed.