gptme
gptme copied to clipboard
refactor: attempt to refactor & simplify chat.py
Mostly vibecoding. Some things are broken but some good ideas here too.
[!IMPORTANT] Refactor
chat.pyfor improved readability, introducepaths.pyfor path handling, and enhance interrupt handling ininterrupt.py.
- Refactor
chat.py:
- Split
chat()into smaller functions:_init_chat(),_process_prompt(),_handle_non_interactive_exit(), etc.- Introduced
_init_terminal(),_init_model(),_init_log_manager(),_init_tool_format(),_init_and_setup_workspace(),_print_log()for initialization tasks.- Added
_prepare_message(),_is_executable_command(),_get_response_messages(),_process_response_messages()for message processing.- Improved interrupt handling with
Interruptiblecontext manager.- New
paths.pymodule:
- Added
find_potential_paths(),is_url(),resolve_path(),read_text_file(),process_url()for path and URL handling.- Interrupt handling in
interrupt.py:
- Replaced
interruptiblewith_interruptible_state.- Added
Interruptiblecontext manager for consistent interrupt handling.- Makefile:
- Added
clean-pyctarget to remove.pycfiles and__pycache__directories.This description was created by
for 2db20b05a7aff5b8ecd007557a24aff6f8f7fb47. It will automatically update as commits are pushed.
:x: 1 Tests Failed:
| Tests completed | Failed | Passed | Skipped |
|---|---|---|---|
| 171 | 1 | 170 | 3 |
View the top 1 failed test(s) by shortest run time
tests.test_browser::test_search_ddgStack Traces | 6.62s run time
@pytest.mark.slow def test_search_ddg(): results = search("test", "duckduckgo") > assert "1." in results, f"{results=}" E AssertionError: results='Error: something went wrong with the search.' E assert '1.' in 'Error: something went wrong with the search.' tests/test_browser.py:14: AssertionError
To view more test analytics, go to the Test Analytics Dashboard 📋 Got 3 mins? Take this short survey to help us improve Test Analytics.
Looks like I created a bunch of conflicts in https://github.com/ErikBjare/gptme/pull/454
This handles GitHub URLs specially which is something we want, but this has diverged significantly from master and would be difficult to resolve the conflicts.
Ellipsis has also highlighted some changes we made which might be good ideas. Splitting up the chat function which is one of the most complex in the codebase and has some quirks would be nice.