AutoGPT
AutoGPT copied to clipboard
fix: use a modern prompt to avoid ^[[D char when using arrow left and…
Background
This PR aims to fix an issue with the input prompt where arrow keys would generate unwanted characters (^[[D
) in the input when using arrows.
We also want to ensure that the colored output works correctly with the new input method.
prompt_toolkit also support history with up and down arrow which could be useful if we plan to have more user interaction with the agent in the futur
Changes
- Replaced the
input()
function withprompt_toolkit
'sPromptSession
to prevent unwanted characters when using arrow keys. - Adjusted all
clean_input
calls to useprompt_toolkit
'sHTML
formatting instead ofcolorama
ANSI escape codes. - Added the
prompt_toolkit
package to therequirements.txt
file.
Documentation
The changes are documented in the form of in-code comments and by updating the clean_input
function to accept FormattedText
from prompt_toolkit
.
Test Plan
Tested the changes by running the script and interacting with the modified prompts. Verified that the arrow keys no longer produce unwanted characters and that the colored output is displayed correctly.
PR Quality Checklist
- [x] My pull request is atomic and focuses on a single change.
- [x] I have thoroughly tested my changes with multiple different prompts.
- [x] I have considered potential risks and mitigations for my changes.
- [x] I have documented my changes clearly and comprehensively.
- [x] I have not snuck in any "extra" small tweaks changes
There is an another PR regarding this with readline. Why this is better than that?
Check #2558
This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.
Conflicts have been resolved! 🎉 A maintainer will review the pull request shortly.
There is an another PR regarding this with readline. Why this is better than that?
Check #2558
Hi @hdkiller
realine is already a good improvement but i believe that we will have much more interaction with auto-GPT using the terminal in the futur and readline is really basic.
prompt_toolkit allows:
- multi-line editing
- syntax highlighting
- input validation (which can be really neat using gtp 3.5 turbo)
- auto-completion
- creating complex user interfaces with colors, styles and widget like progress bars, menus, dialog box, html tags ect..
- mouse interaction
Which i believe will make the terminal UX much better.
I kept this PR small to know if you guys are willing to use prompt_toolkit. But i can create an other PR if this one is merged to show case how we can improve the current UI.
Some cool improvement could be to have options when auto-GPT want to execute a task, for example you want to do a web search Auto Gpt prompt display 3 option (BIng / google / duckduck go), you could use the arrow to choose between those 3 choices.
I think it will push the terminal interaction to an other level
@ntindle
Added tests, fixed the linter issue and add colors as constants to the utils file
This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.
Conflicts have been resolved! 🎉 A maintainer will review the pull request shortly.
This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
docs | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Apr 28, 2023 3:26am |
Conflicts have been resolved! 🎉 A maintainer will review the pull request shortly.
This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.
Conflicts have been resolved! 🎉 A maintainer will review the pull request shortly.
This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.
This is a mass message from the AutoGPT core team. Our apologies for the ongoing delay in processing PRs. This is because we are re-architecting the AutoGPT core!
For more details (and for infor on joining our Discord), please refer to: https://github.com/Significant-Gravitas/Auto-GPT/wiki/Architecting
prompt_toolkit also support history with up and down arrow which could be useful if we plan to have more user interaction with the agent in the futur
FYI: early experiments using prompt-toolkit (the idea was to easily reuse/edit previous commands again, and to have autocomplete for directories and file names inside the workspace): #4078
I'm getting this ^[[D
issue when I press left arrow key. Hope this gets fixed soon.
Simplest implementation to fix issue in #4649
Simplest implementation to fix issue in #4649
You are the man, thank you will merge this.
Closing as fixed in #4649