Giter Site home page Giter Site logo

uprootiny / aider Goto Github PK

View Code? Open in Web Editor NEW

This project forked from paul-gauthier/aider

0.0 0.0 0.0 4.38 MB

aider is GPT powered coding in your terminal

Home Page: https://aider.chat/

License: Apache License 2.0

Python 96.95% HTML 2.23% SCSS 0.82%

aider's Introduction

aider is GPT powered coding in your terminal

aider is a command-line chat tool that allows you to write and edit code with gpt-4 or gpt-3.5-turbo. You can ask GPT to help you start a new project, or modify code in your existing git repo. Aider makes it easy to git commit, diff & undo changes proposed by GPT without copy/pasting. It also has features that help GPT-4 understand and modify larger codebases.

aider screencast

Getting started

$ pip install aider-chat
$ export OPENAI_API_KEY=your-key-goes-here
$ aider myapp.py

Using git repo: .git
Added myapp.py to the chat.

myapp.py> change the fibonacci function from recursion to iteration

Example chat transcripts

Here are some example transcripts that show how you can chat with aider to write and edit code with GPT-4.

You can find more chat transcripts on the examples page.

Features

  • Chat with GPT about your code by launching aider from the command line with set of source files to discuss and edit together. Aider lets GPT see and edit the content of those files.
  • Request new features, changes, improvements, or bug fixes to your code. Ask for new test cases, updated documentation or code refactors.
  • Aider will apply the edits suggested by GPT directly to your source files.
  • Aider will automatically commit each changeset to your local git repo with a descriptive commit message. These frequent, automatic commits provide a safety net. It's easy to undo changes or use standard git workflows to manage longer sequences of changes.
  • You can use aider with multiple source files at once, so GPT can make coordinated code changes across all of them in a single changeset/commit.
  • Aider can give GPT-4 a map of your entire git repo, which helps it understand and modify large codebases.
  • You can also edit files by hand using your editor while chatting with aider. Aider will notice these out-of-band edits and ask if you'd like to commit them. This lets you bounce back and forth between the aider chat and your editor, to collaboratively code with GPT.

GPT-4 vs GPT-3.5

Aider supports gpt-4, gpt-3.5-turbo, gpt-4-32k and the the brand new gpt-3.5-turbo-16k model. You will probably get the best results with GPT-4, because of its large context window and greater competance at code editing.

The GPT-3.5 models are less able to follow instructions for returning code edits in a diff-like format. So aider needs to send GPT-3.5 the original code and ask it to return a full copy of the modified code. Both the original and modified copies of the code count towards the context window token limit. In practice, this means you can only use gpt-3.5-turbo to edit files that are smaller than about 2k tokens (8k bytes). The new gpt-3.5-turbo-16k model should be able to edit code up to 8k tokens (32k bytes).

Aider disables the repository map feature when used with either of GPT-3.5 models. The gpt-3.5-turbo context window is too small to include a repo map. Evaluation is needed to see if gpt-3.5-turbo-16k can make use of a repo map.

To use gpt-3.5-turbo-16k, install from GitHub per the instructions below. For now, aider just treats gpt-3.5-turbo-16k like the original gpt-3.5-turbo with a larger context window.

Installation

  1. Install the package:
  • PyPI: pip install aider-chat
  • GitHub: pip install git+https://github.com/paul-gauthier/aider.git
  • Local clone: pip install -e .
  1. Set up your OpenAI API key:
  • As an environment variable: export OPENAI_API_KEY=sk-...
  • Or, by including openai-api-key: sk-... in an .aider.config.yml file
  1. Optionally, install universal ctags. This is helpful if you plan to use aider and GPT-4 with repositories that have more than a handful of files. This allows aider to build a map of your entire git repo and share it with GPT to help it better understand and modify large codebases.

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. These files will be added to the chat session.

You can also just launch aider anywhere in a git repo without naming files on the command line. It will discover all the files in the repo. You can then add and remove individual files in the chat session with the /add and /drop chat commands described below. If you or GPT mention one of the repo's filenames in the conversation, aider will ask if you'd like to add it to the chat.

You can also use additional command-line options, environment variables or configuration file to set many options. See aider --help for details.

In-chat commands

Aider supports commands from within the chat, which all start with /. Here are some of the most useful in-chat commands:

  • /add <file>: Add matching files to the chat session.
  • /drop <file>: Remove matching files from the chat session.
  • /undo: Undo the last git commit if it was done by aider.
  • /diff: Display the diff of the last aider commit.
  • /run <command>: Run a shell command and optionally add the output to the chat.
  • /help: Show help about all commands.

Tips

  • Large changes are best performed as a sequence of thoughtful bite sized steps, where you plan out the approach and overall design. Walk GPT through changes like you might with a junior dev. Ask for a refactor to prepare, then ask for the actual change. Spend the time to ask for code quality/structure improvements.
  • 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 to GPT with more information or direction.
  • Use the /run command to run tests, linters, etc and show the output to GPT so it can fix any issues.
  • Enter a multiline chat message by entering { alone on the first line. End the multiline message with } alone on the last line.
  • If your code is throwing an error, share the error output with GPT using /run or by pasting it into the chat. Let GPT figure out and fix the bug.
  • GPT knows about a lot of standard tools and libraries, but may get some of the fine details wrong about APIs and function arguments. You can paste doc snippets into the chat to resolve these issues.
  • Aider will notice if you launch it on a git repo with uncommitted changes and offer to commit them before proceeding.
  • GPT can only see the content of the files you specifically "add to the chat". Aider also sends GPT-4 a map of your entire git repo. So GPT may ask to see additional files if it feels that's needed for your requests.
  • I also shared some general GPT coding tips on Hacker News.

Kind words from users

  • "Aider ... has easily quadrupled my coding productivity." -- SOLAR_FIELDS
  • "What an amazing tool. It's incredible." -- valyagolev
  • "It was WAY faster than I would be getting off the ground and making the first few working versions." -- Daniel Feldman

Limitations

You can only use aider to edit code that fits in the GPT context window. For GPT-4 that is 8k tokens, and for GPT-3.5 that is 4k tokens. Aider lets you manage the context window by being selective about how many source files you discuss with aider at one time. You might consider refactoring your code into more, smaller files (which is usually a good idea anyway). You can use aider to help perform such refactorings, if you start before the files get too large.

If you have access to gpt-4-32k, I would be curious to hear how it works with aider.

aider's People

Contributors

jevon avatar mobyvb avatar paul-gauthier avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.