Skip to content

SWE-agent takes a GitHub issue and tries to automatically fix it, using your LM of choice. It can also be employed for offensive cybersecurity or competitive coding challenges. [NeurIPS 2024]

Doc: Updates left and right

Kilian Lieretc083c3ef341d
diff --git a/docs/assets/open_port_default.png b/docs/assets/open_port_default.png
new file mode 100644
index 00000000..16f1c97f
Binary files /dev/null and b/docs/assets/open_port_default.png differ
diff --git a/docs/assets/open_port_in_browser.png b/docs/assets/open_port_in_browser.png
new file mode 100644
index 00000000..c34d1655
Binary files /dev/null and b/docs/assets/open_port_in_browser.png differ
diff --git a/docs/faq.md b/docs/faq.md
index 13ba8a62..9d196a4a 100644
--- a/docs/faq.md
+++ b/docs/faq.md
@@ -14,5 +14,4 @@ We're open to merge simple fixes to make the [development setup](installation/so
> Which LMs do you support?
-Currently our model support is limited, mostly focused on GPT-4 and Claude 3. SWE-agent will not perform well with small or local models.
-[More information on models](usage/usage_faq.md).
+See [models](installation/keys.md).
\ No newline at end of file
diff --git a/docs/installation/codespaces.md b/docs/installation/codespaces.md
new file mode 100644
index 00000000..919ccb1c
--- /dev/null
+++ b/docs/installation/codespaces.md
@@ -0,0 +1,40 @@
+# Running SWE-agent in your browser
+
+Running SWE-agent in your browser is the easiest way to try out our project.
+
+<video controls>
+<source src=" https://github.com/princeton-nlp/SWE-agent/assets/13602468/44d60674-59ca-4986-9b22-7052a45cbed9" type="video/mp4">
+</video>
+
+1. Click [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/princeton-nlp/SWE-agent)
+2. Add your language modelAPI keys to `.env` (find the file in the left sidebar and fill out the template). More information on the keys [here](keys.md).
+3. Make sure to wait until the `postCreateCommand` in the terminal window at the bottom is finished
+4. Enter your SWE-agent command, see, see [using the command line](../usage/cl_tutorial.md).
+
+## Running the Web UI
+
+!!! warning "Web UI"
+ We're currently working on updating the web UI to be compatible with the latest version of SWE-agent.
+ Please use the [using the command line](../usage/cl_tutorial.md) until this is fixed.
+
+Go to the terminal and enter
+
+```bash
+./start_web_ui.sh
+```
+
+After a while, you should see a popup offering you to forward port `3000`. Click `Open in Browser`.
+
+![port 3000 forwarding popup](../assets/open_port_default.png)
+
+If you instead only see the offer to forward port `8000`, do not click it (this is the port that's being used by the backend).
+
+Instead, click on the `Ports` tab, and click on the globe next to port `3000`:
+
+![port 3000 forwarding manual](../assets/open_port_in_browser.png)
+
+!!! tip "More information"
+ See [running the web UI](../usage/web_ui.md) for more information about the
+ web UI and additional hints for how to solve problems with the starting it.
+
+{% include-markdown "../_footer.md" %}
\ No newline at end of file
diff --git a/docs/installation/index.md b/docs/installation/index.md
index b3e9441c..c8c0ac95 100644
--- a/docs/installation/index.md
+++ b/docs/installation/index.md
@@ -21,13 +21,13 @@
[:octicons-arrow-right-24: Get started](source.md)
-- :material-docker:{ .lg .middle } __Run in docker__
+- :material-docker:{ .lg .middle } __Coming soon: Run in docker__
---
Pull a docker container and directly run SWE-agent. This is our fallback solution if the local installation does not work for you.
- [:octicons-arrow-right-24: Get started](docker.md)
+ :octicons-arrow-right-24: Coming soon
- :material-newspaper:{ .lg .middle } __Changelog__
diff --git a/docs/installation/keys.md b/docs/installation/keys.md
index e1f54abf..10dad215 100644
--- a/docs/installation/keys.md
+++ b/docs/installation/keys.md
@@ -1,25 +1,21 @@
-# Adding your API keys
+# Models and API keys
In order to access the LM of your choice (and to access private GitHub repositories), you need to supply the corresponding keys.
There are two options to do this:
1. Set the corresponding [environment variables](https://www.cherryservers.com/blog/how-to-set-list-and-manage-linux-environment-variables).
-2. Create a `keys.cfg` file at the root of this repository.
+2. Create a `.env` file at the root of this repository. All of the variables defined there will take the place of environment variables.
-The following `keys.cfg` example shows you how the keys are named:
+
+Here's an example
```
# Remove the comment '#' in front of the line for all keys that you have set
-# GITHUB_TOKEN: 'GitHub Token for access to private repos'
-# OPENAI_API_KEY: 'OpenAI API Key Here if using OpenAI Model'
-# ANTHROPIC_API_KEY: 'Anthropic API Key Here if using Anthropic Model'
-# TOGETHER_API_KEY: 'Together API Key Here if using Together Model'
-# AZURE_OPENAI_API_KEY: 'Azure OpenAI API Key Here if using Azure OpenAI Model'
-# AZURE_OPENAI_ENDPOINT: 'Azure OpenAI Endpoint Here if using Azure OpenAI Model'
-# AZURE_OPENAI_DEPLOYMENT: 'Azure OpenAI Deployment Here if using Azure OpenAI Model'
-# AZURE_OPENAI_API_VERSION: 'Azure OpenAI API Version Here if using Azure OpenAI Model'
-# OPENAI_API_BASE_URL: 'LM base URL here if using Local or alternative api Endpoint'
+# GITHUB_TOKEN='GitHub Token for access to private repos'
+# OPENAI_API_KEY='OpenAI API Key Here if using OpenAI Model'
+# ANTHROPIC_API_KEY='Anthropic API Key Here if using Anthropic Model'
+# TOGETHER_API_KEY='Together API Key Here if using Together Model'
```
See the following links for tutorials on obtaining [Anthropic](https://docs.anthropic.com/en/api/getting-started), [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.
diff --git a/docs/installation/source.md b/docs/installation/source.md
index f2aead3e..283f359e 100644
--- a/docs/installation/source.md
+++ b/docs/installation/source.md
@@ -2,27 +2,24 @@
Installation from source is the preferred way to set up SWE-agent on your machine.
-!!! warning "Issues on Windows"
- Expect some issues with Windows (we're working on them).
- In the meantime, [use Docker](docker.md).
-
-1. Install Docker ([follow the docs](https://github.com/docker/docker-install) or use the [get-docker.sh script for linux](https://github.com/docker/docker-install)), then start Docker locally. Problems? See [docker issues](tips.md#docker).
-2. If you plan on using the web-based GUI: Install [`nodejs`][nodejs-install].
-3. Clone the repository, for example with
+1. Clone the repository, for example with
```bash
git clone https://github.com/princeton-nlp/SWE-agent.git
```
-4. Run
+2. Run
```
python -m pip install --upgrade pip && 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
- ```bash
- docker pull sweagent/swe-agent:latest
- ```
- Errors? See [docker issues](tips.md#docker). Alternatively, you can run `./setup.sh` to create your own `swe-agent` docker image.
-6. Set up your LM API keys as explained [here](keys.md).
+3. Set up your language model of choice as explained [here](keys.md).
+
+**Optional:**
+
+1. The default backend for SWE-agent is docker, so we recommend to install Docker
+ ([follow the docs](https://github.com/docker/docker-install) or use the [get-docker.sh script for linux](https://github.com/docker/docker-install)),
+ then start Docker locally. Problems? See [docker issues](tips.md#docker).
+ If you do not want to use docker, you can still use SWE-agent with code evaluation in the cloud.
+2. If you plan on using the web-based GUI: Install [`nodejs`][nodejs-install].
[nodejs-install]: https://docs.npmjs.com/downloading-and-installing-node-js-and-npm
diff --git a/docs/installation/tips.md b/docs/installation/tips.md
index 6a09ea86..b25bd1ad 100644
--- a/docs/installation/tips.md
+++ b/docs/installation/tips.md
@@ -1,4 +1,4 @@
-# More installation tips
+# Installation troubleshooting
## Docker issues <a name="docker"></a>
@@ -11,7 +11,8 @@ docker run hello-world
If you get an error like
```
-docker: permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Head "http://%2Fvar%2Frun%2Fdocker.sock/_ping": dial unix /var/run/docker.sock: connect: permission denied.
+docker: permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock:
+Head "http://%2Fvar%2Frun%2Fdocker.sock/_ping": dial unix /var/run/docker.sock: connect: permission denied.
```
* 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)*.
diff --git a/docs/usage/coding_challenges.md b/docs/usage/coding_challenges.md
index 877c4181..85444b69 100644
--- a/docs/usage/coding_challenges.md
+++ b/docs/usage/coding_challenges.md
@@ -56,12 +56,12 @@ Now, we can let SWE-agent solve the problem:
```bash
python run.py \
- --data_path problem.md \
- --repo_path /path/to/empty \
- --config_file config/coding_challenge.yaml \
- --model gpt4 \
- --per_instance_cost_limit 3.0 \
- --apply_patch_locally
+ --config config/coding_challenge.yaml \
+ --problem_statement.path=problem.md \
+ --repo.path=/path/to/empty \
+ --agent.model.name=gpt4 \
+ --agent.model.per_instance_cost_limit 3.0 \
+ --action.apply_patch_locally=True
```
<details>
diff --git a/docs/usage/trajectories.md b/docs/usage/trajectories.md
index 397fb8c9..764d6f8b 100644
--- a/docs/usage/trajectories.md
+++ b/docs/usage/trajectories.md
@@ -62,11 +62,9 @@ Here are a few more files that are generated with `sweagent run-batch`:
!!! tip "Viewing trajectories"
We provide a [trajectory viewer](inspector.md) for an easy viewing of trajectories.
-## How an Experiment Folder is Generated
-
!!! tip
* Evaluation is not completed by `run.py`, it is a separate step (see [benchmarking](benchmarking.md))
- * `all_preds.jsonl` can be referenced directly into SWE-bench to run evaluation (see [benchmarking](benchmarking.md))
+ * `preds.json` can be referenced directly into SWE-bench to run evaluation (see [benchmarking](benchmarking.md))
* Trajectories can be turned into custom demonstrations for SWE-agent ([more information](../config/demonstrations.md)).
{% include-markdown "../_footer.md" %}
diff --git a/mkdocs.yml b/mkdocs.yml
index 5beaa37f..44950f35 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -53,11 +53,15 @@ markdown_extensions:
nav:
- Getting Started:
- index.md
- - "Installation": "installation/index.md"
+ - "Installation":
+ - "installation/index.md"
+ - "In browser": "installation/codespaces.md"
+ - "From source": "installation/source.md"
+ - "API keys": "installation/keys.md"
+ - "Troubleshooting": "installation/tips.md"
- "Tutorials":
- "Command line basics": "usage/cl_tutorial.md"
- "Solving coding challenges": "usage/coding_challenges.md"
- - "API keys": "installation/keys.md"
- "FAQ": "usage/usage_faq.md"
- User Guide:
- "usage/index.md"
diff --git a/sweagent/environment/swe_env.py b/sweagent/environment/swe_env.py
index 8b2cfd0b..ad609f38 100644
--- a/sweagent/environment/swe_env.py
+++ b/sweagent/environment/swe_env.py
@@ -107,8 +107,7 @@ class SWEEnv:
self._chook.on_copy_repo_started(repo=self.repo)
self.repo.copy(self.deployment)
- # todo: Get rid of return type here?
- def reset(self) -> tuple[str | None, dict]:
+ def reset(self):
"""Reset the environment to a clean state.
Gets called by `start`, but can also be called independently to reset the
environment to a clean state before a new attempt.
@@ -117,12 +116,10 @@ class SWEEnv:
observation: output from container
info: additional information (e.g. debugging information)
"""
- info = {}
self.communicate(input="cd /", check="raise")
self._copy_repo()
self._reset_repository()
self._chook.on_environment_startup()
- return None, info
def _reset_repository(self) -> None:
"""Clean repository of any modifications + Checkout base commit"""