aider is AI pair programming in your terminal https://aider.chat/
Find a file
Paul Gauthier 659ce00c40 aider: Add typing simulation to get_input function.
# Context:
USER: in this case, have it still print the "> " followed by the inputted line. but write and flush one character at a time, with small random delays in between so it looks like typing
ASSISTANT: To achieve this, you can use the `time` module to introduce small random delays and print the characters one by one. Here's the change you need to make in the `get_input` function:

```python
aider/getinput.py
<<<<<<< ORIGINAL
import sys

def get_input(history_file, fnames):
    if not sys.stdin.isatty():
        return input()
=======
import sys
import time
import random

def get_input(history_file, fnames):
    if not sys.stdin.isatty():
        input_line = input()
        print("> ", end="")
        for char in input_line:
            print(char, end="", flush=True)
            time.sleep(random.uniform(0.05, 0.2))
        print()
        return input_line
>>>>>>> UPDATED
```

This change imports the `time` and `random` modules. When the input is coming from a file, it reads the input line, prints the "> " prompt, and then prints each character in the input line with a small random delay between 0.05 and 0.2 seconds, simulating typing.
2023-05-09 14:16:47 -07:00
aider aider: Add typing simulation to get_input function. 2023-05-09 14:16:47 -07:00
.flake8 debug 2023-05-08 22:55:55 -07:00
.pre-commit-config.yaml lint 2023-05-09 13:10:38 -07:00
README.md updated readme 2023-05-09 14:01:15 -07:00
requirements.txt initial 2023-05-09 10:55:05 -07:00
setup.py Add setup.py file that reads requirements.txt for dependencies and sets up CLI script. 2023-05-09 10:57:56 -07:00

Aider

Aider is a command-line tool that allows you to chat with GPT-4 about your code. It can make changes, improvements, and bug fixes to your code on your local. Each change is automatically committed to git with a sensible commit message.

asciicast

Features

  • Chat with GPT about your code by specifying a set of source files to discuss.
  • Request changes, improvements, and bug fixes to your code.
  • Aider will apply the edits suggested by GPT.
  • Aider will automatically commit each change to git with a sensible commit message to provide safety, change history and easy undo with normal git tools.
  • Aider can make coordinated code changes across multiple source files at once.
  • Aider will notice if you edit the files outside the chat:
    • It will ask if you'd like to commit these out-of-band changes.
    • It will make GPT aware of the updated file content.
    • You can bounce back and forth between your aider chat and your editor, to fluidly collaborate with GPT.
  • Live, colorized, human friendly output.
  • Readline style chat input history, with autocompletion of tokens found in the source files being discussed (via prompt_toolkit)

Installation

  1. Install the package: pip install git+https://github.com/paul-gauthier/aider.git
  2. Set up your OpenAI API key as an environment variable OPENAI_API_KEY or by including it in a .env file.

Usage

Run the Aider tool by executing the following command:

aider <file1> <file2> ...

Replace <file1>, <file2>, etc., with the paths to the source code files you want to work on.

You can also use additional command-line options to customize the behavior of the tool. For more information, run aider --help. Many defaults can be set with .env or environment variables, see the help output.

Tips

  • Large changes are best performed as a sequence of bite sized steps. Same as if you were undertaking them yourself.
  • GPT-4 knows about a lot of standard tools and libraries, but may get some of the fine details wrong about APIs. You can paste doc snippets into the chat with the {} multiline syntax described below.
  • Use Control-C to safely interrupt GPT if it isn't providing a useful response. The partial response remains in the conversation, so you can refer to it when you reply with more information or direction.
  • Provide a multiline chat message by entering { alone on the first line. End the multiline message with } alone on the last line.
  • Aider will notice if you ask it to discuss files with uncommitted changes and offer to commit them before proceeding.
  • GPT can only see the content of the files you specify, but it also gets a list of all the files in the repo. It may ask to see additional files if it feels that's needed for your requests. Relaunch with the additional files on the command line.

Limitations

Aider basically requires GPT-4. You can invoke it with aider -3 to try using gpt-3.5-turbo, but it will almost certainly fail to function correctly. GPT-3.5 is unable to follow directions and generate code changes in a stable, parsable format.

Aider also can only edit code that can fit in the context window. For GPT-4 that is 8k tokens. It helps to be selective about which of your source files you give to aider. It can also help to refactor your code into more, smaller files. Aider can help with such refactorings if you start them before the files hit the context window limit. If you have access to gpt-4-32k, I would be curious to hear how it works with aider.