cohere-ai/SWE-agent
forked from SWE-agent/SWE-agent
Captured source
source ↗cohere-ai/SWE-agent
Description: SWE-agent takes a GitHub issue and tries to automatically fix it, using GPT-4, or your LM of choice. It solves 12.29% of bugs in the SWE-bench evaluation set and takes just 1.5 minutes to run.
Language: Python
License: MIT
Stars: 3
Forks: 0
Open issues: 2
Created: 2024-04-10T14:12:53Z
Pushed: 2024-07-06T02:03:49Z
Default branch: main
Fork: yes
Parent repository: SWE-agent/SWE-agent
Archived: no
README:
Website & Demo | Discord | Preprint
👋 Overview
SWE-agent turns LMs (e.g. GPT-4) into software engineering agents that can fix bugs and issues in real GitHub repositories.
On SWE-bench, SWE-agent resolves 12.29% of issues, achieving the state-of-the-art performance on the full test set.
We accomplish our results by designing simple LM-centric commands and feedback formats to make it easier for the LM to browse the repository, view, edit and execute code files. We call this an 🤖 Agent-Computer Interface (ACI). Read more about it in our paper!
SWE-agent is built and maintained by researchers from Princeton University.
If you found this work helpful, please consider using the following citation:
@misc{yang2024sweagent,
title={SWE-agent: Agent-Computer Interfaces Enable Automated Software Engineering},
author={John Yang and Carlos E. Jimenez and Alexander Wettig and Kilian Lieret and Shunyu Yao and Karthik Narasimhan and Ofir Press},
year={2024},
}✨ Use SWE-agent as a dev tool
We provide a command line tool and a graphical web interface:
🚀 Installation
☁️ Run from your browser
🔎 Watch the video
https://github.com/princeton-nlp/SWE-agent/assets/13602468/44d60674-59ca-4986-9b22-7052a45cbed9
1. Click  2. Add your API keys to keys.cfg (find the file in the left sidebar and fill out the template) 3. Make sure to wait until the postCreateCommand in the terminal window at the bottom is finished 4. Enter your SWE-agent command ([see below](#real-life))
Install from source
> [!WARNING] > Expect some issues with Windows (we're working on them). > In the meantime, use Docker (see below).
1. Install Docker, then start Docker locally. 2. For the web interface only: Install [nodejs][nodejs-install]. 3. Clone this repository. 4. Run pip install --editable . at the repository root (as with any python setup, it's recommended to use [conda][] or [virtual environments][] to manage dependencies). 5. Run ./setup.sh to create the swe-agent docker image. 6. Create a keys.cfg file at the root of this repository ([see below](#tokens)).
[nodejs-install]: https://docs.npmjs.com/downloading-and-installing-node-js-and-npm
> [!TIP] > If you run into docker issues, see the [installation issues section](#more-installation-tips) for more help
[conda]: https://docs.conda.io/en/latest/ [virtual environments]: https://realpython.com/python-virtual-environments-a-primer/
Fallback: Run with docker
> [!warning] > The latest containerized version does not yet provide the web interface.
Instead of installing SWE-agent from source, you can also run the software directly using Docker.
1. Install Docker, then start Docker locally. 2. Run docker pull sweagent/swe-agent:latest 3. Add your API tokens to a file keys.cfg as explained [below](#tokens)
Then run
# NOTE: # This assumes that keys.cfg is in your current directory (else fix the path below) # This command is equivalent to the script shown in the quickstart docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock \ -v $(pwd)/keys.cfg:/app/keys.cfg \ sweagent/swe-agent-run:latest \ python run.py --image_name=sweagent/swe-agent:latest \ --model_name gpt4 \ --data_path https://github.com/pvlib/pvlib-python/issues/1603 \ --config_file config/default_from_url.yaml --skip_existing=False
> [!TIP] > * For more information on the different API keys/tokens, see [below](#tokens). > * If you're using docker on Windows, use -v //var/run/docker.sock:/var/run/docker.sock > (double slash) to escape it (more information). > * See the [installation issues section](#more-installation-tips) for more help if you run into > trouble.
🔑 Add your API keys/tokens
Create a keys.cfg file at the root of this repository and populate it with your API keys.
GITHUB_TOKEN: 'GitHub Token Here (optional)' OPENAI_API_KEY: 'OpenAI API Key Here if using OpenAI Model (optional)'
🔎 More options for different keys (click to unfold)
All keys are optional.
GITHUB_TOKEN: 'GitHub Token for access to private repos' # See the following links for tutorials on obtaining [Anthropic](https://docs.anthropic.com/claude/reference/getting-started-with-the-api), [OpenAI](https://platform.openai.com/docs/quickstart/step-2-set-up-your-api-key), and [Github](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) tokens. ### More installation tips If you seem to be having issues with running docker * Make sure that you allow the use of the Docker socket. In Docker desktop, click *Settings* > *Advanced* > *Allow the default Docker socket to be used (requires password)* * If your docker installation uses a different socket, you might have to symlink them, see [this command for example](https://github.com/princeton-nlp/SWE-agent/issues/20#issuecomment-2047506005) Any remaining issues? Please [open a GitHub issue](https://github.com/princeton-nlp/SWE-agent/issues/new/choose)! ## 🔥 Solve real GitHub issues! To start our web UI, simply run
./start_web_ui.sh
If the user interface doesn't automatically open in your browser, please open it at `http://localhost:3000`. Currently, the web interface only has a subset of the options of the command line interface (CLI). For the CLI, use the `run.py` script:
python run.py --model_name gpt4 \ --data_path https://github.com/pvlib/pvlib-python/issues/1603 \ --config_file config/default_from_url.yaml \ --per_instance_cost_limit 2.00
You can also apply to it to a local repository:
Excerpt shown — open the source for the full document.