Skip to content
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

Using arrow keys to edit question prints escape characters #50

Closed
hyp-er opened this issue Apr 1, 2023 · 2 comments
Closed

Using arrow keys to edit question prints escape characters #50

hyp-er opened this issue Apr 1, 2023 · 2 comments

Comments

@hyp-er
Copy link
Contributor

hyp-er commented Apr 1, 2023

When trying to edit my query, you can't use your arrow keys to traverse the prompt - one extremely necessary feature when working with the TTY. It gets especially annoying when you have to delete half your prompt to fix one simple spelling mistake, which can yield incorrect responses.

@signebedi
Copy link
Owner

Oh, sure. We can add this. Here's a few references for using the prompt_toolkit (which is, admittedly, just another dependency for us to manage... ugh).

  1. https://stackoverflow.com/questions/75807664/issues-handling-chatgpt-streaming-response-in-terminal-using-openai-api-using
  2. https://stackoverflow.com/a/56181822/13301284

So this would look something like:

from prompt_toolkit import PromptSession

...
# this is used when we run the `chat` command
async def create_chat_room(configs=get_config_data(), log_responses:bool=True, config_path=None, verbose:bool=False):
...

    session = PromptSession()
    # Continuously send and receive messages
    while True:
...
        i = await session.prompt_async(f"{CYAN}> ")

@signebedi
Copy link
Owner

Added @hyp-er! Thank you for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants