gptme
gptme copied to clipboard
fix: fixed behavior for keyboard interrupts and user commands
Has some similarities to https://github.com/ErikBjare/gptme/pull/371
[!IMPORTANT] Refactor keyboard interrupt and user command handling in
chat.pyandcommands.pyfor consistent behavior.
- Behavior:
- Refactor keyboard interrupt handling in
chat.pyandcommands.pyto use a consistentinterrupt_msg.- Modify
execute_cmdincommands.pyto check both user role and command prefix.- Functions:
- Update
step()inchat.pyto yieldinterrupt_msgonKeyboardInterrupt.- Adjust
handle_cmd()incommands.pyto handle/helpcommand separately.- Misc:
- Remove redundant assertions in
execute_cmd()incommands.py.- Minor refactoring in
chat.pyto streamline message handling logic.This description was created by
for e3d04d279f406ce6998cd5a3c4ad9be712f39e08. It will automatically update as commits are pushed.
:x: 5 Tests Failed:
| Tests completed | Failed | Passed | Skipped |
|---|---|---|---|
| 160 | 5 | 155 | 3 |
View the top 3 failed tests by shortest run time
tests.test_cli::test_block[ipython]Stack Traces | 0.125s run time
args = ['--name', 'test-62770-test_block[ipython]', '/impersonate ```ipython\ndef test():\n print("start") # start\n\n print("after empty line")\n```'] lang = 'ipython', runner = <click.testing.CliRunner object at 0x7fd62571a1a0> @pytest.mark.slow @pytest.mark.parametrize("lang", blocks.keys()) def test_block(args: list[str], lang: str, runner: CliRunner): # tests that shell codeblocks are formatted correctly such that whitespace and newlines are preserved code = blocks[lang] code = f"""```{lang} {code.strip()} ```""" assert "'" not in code args.append(f"/impersonate {code}") print(f"running: gptme {' '.join(args)}") result = runner.invoke(gptme.cli.main, args) output = result.output print(f"output: {output}\nEND") # check everything after the second '# start' # (get not the user impersonation command, but the assistant message and everything after) output = output.split("# start", 2)[-1] printcmd = "print" if lang == "ipython" else "echo" > assert f"\n\n {printcmd}" in output E AssertionError: assert '\n\n print' in '[12:58:40] Using logdir .../gptme/logs/test-62770-test_block \n' .../gptme/tests/test_cli.py:243: AssertionError
tests.test_cli::test_command_tokensStack Traces | 0.177s run time
args = ['--name', 'test-68912-test_command_tokens', '/tokens'] runner = <click.testing.CliRunner object at 0x7f9a3df39f30> def test_command_tokens(args: list[str], runner: CliRunner): args.append("/tokens") result = runner.invoke(gptme.cli.main, args) > assert "/tokens" in result.output E AssertionError: assert '/tokens' in '[12:58:32] Using logdir \n .../gptme/logs/test-68912-test_command_tokens \n' E + where '[12:58:32] Using logdir \n .../gptme/logs/test-68912-test_command_tokens \n' = <Result FileExistsError(17, 'File exists')>.output .../gptme/tests/test_cli.py:80: AssertionError
tests.test_cli::test_command_toolsStack Traces | 3.82s run time
args = ['--name', 'test-93637-test_command_tools', '/tools'] runner = <click.testing.CliRunner object at 0x7f4c22c4b160> def test_command_tools(args: list[str], runner: CliRunner): args.append("/tools") result = runner.invoke(gptme.cli.main, args) > assert "/tools" in result.output E AssertionError: assert '/tools' in '[12:58:35] Using logdir \n .../gptme/logs/test-93637-test_command_tools \n' E + where '[12:58:35] Using logdir \n .../gptme/logs/test-93637-test_command_tools \n' = <Result FileExistsError(17, 'File exists')>.output .../gptme/tests/test_cli.py:95: AssertionError
To view more test analytics, go to the Test Analytics Dashboard :loudspeaker: Thoughts on this report? Let us know!
I need to break this apart to figure out why it isn't working