Skip to content

Commit

Permalink
Setup everything for sotopia in one script (#122)
Browse files Browse the repository at this point in the history
* git ignore

* add nextra site

* change path to docs

* Add installation instruction (#76)

* fix an accordion bug

* Add tabs for choosing platform in Redis Instructions

* add platform tab

* updated open in colab instruction

* add agents.md/environments.md rename all_the_issues to troubleshooting

* add auto set script

* add more dataset choices

* adding download data menu and protection when the path exists

* Unify benchmark and install into `sotopia` cli command

* move install and benchmark in to folders

* make flow more rigorious and add tests

* update linux direction

* add restart directions

* remove _renderer

* add use docker test

* call -> run

* add shell=True

* mkdir when the dirctory doesn't exist

* remove docker test due to memory limit

* add prompt mocking

* add install cli

* add a sleep to make sure that the redis is launched before stopping

* add matrix os in pytest

* add poetry to path on macos

* Use install poetry action

* make redis directory on mac

* avoid permission issue on mac

* update macos test

* test docker

* install docker with brew

* set up docker

* give up testing docker on mac

* check if docker daemon is up and brew update

* improve prompts

* update prompt tests

---------

Co-authored-by: XuhuiZhou <[email protected]>
Co-authored-by: Ruiyi Wang <[email protected]>
  • Loading branch information
3 people authored Jun 26, 2024
1 parent 5818a89 commit 701f2a8
Show file tree
Hide file tree
Showing 22 changed files with 1,017 additions and 286 deletions.
14 changes: 11 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,27 @@ on:

jobs:
Pytest:
runs-on: ubuntu-latest
strategy:
max-parallel: 5
matrix:
os: [ubuntu-latest, macos-13]

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11.2
- name: Set up Docker
if: runner.os == 'ubuntu-latest'
uses: docker-practice/actions-setup-docker@master
timeout-minutes: 12
- name: Install Poetry
uses: abatilo/actions-poetry@v2
- name: Install dependencies
run: |
curl -sSL https://install.python-poetry.org | python3
poetry lock
poetry install --with test -E chat
- name: Test with pytest
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,5 @@ backup/*
node_modules/*
docs/.next/*
docs/node_modules/*

redis-data/*
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ For some experiments, TogetherAI key is required to run the code. Please set the
conda env config vars set TOGETHER_API_KEY=your_key
```

A redis-stack server is required to run the code. Please follow the [instruction](https://redis.io/docs/stack/get-started/install/docker/) to start a redis-stack server or use an existing server. You can also check [Q&A](/docs/all_the_issues.md) to initiate the redis server with the Sotopia data.
A redis-stack server is required to run the code. Please follow the [instruction](https://redis.io/docs/stack/get-started/install/docker/) to start a redis-stack server or use an existing server. You can also check [Q&A](/docs/troubleshooting.md) to initiate the redis server with the Sotopia data.

The `REDIS_OM_URL` need to be set before loading and saving agents:
```bash
Expand Down Expand Up @@ -156,7 +156,7 @@ To run a large batch of environments, you can change the `ENV_IDS` parameter in
## Getting access to your simulation
After running experiments, you can go to the `examples/redis_stats.ipynb` notebook to check the existing episodes (Episode Log section), as well as calculate the performance.

For the original Sotopia simulation in our paper's experiments, you can find how to get them in the [Q&A](/docs/all_the_issues.md) section in the `./docs` folder.
For the original Sotopia simulation in our paper's experiments, you can find how to get them in the [Q&A](/docs/troubleshooting.md) section in the `./docs` folder.

## Adding new characters and environments
You can use the following function with the `**kwargs` being the properties of the `AgentProfile` class. This is the same for the scenarios/environments.
Expand Down
8 changes: 8 additions & 0 deletions docs/pages/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
"title": "Documentation",
"type": "menu",
"items": {
"agents": {
"title": "Agents",
"href": "/agents"
},
"environments": {
"title": "Environments",
"href": "/environments"
},
"examples": {
"title": "Examples",
"href": "/examples"
Expand Down
Empty file added docs/pages/agents.md
Empty file.
Empty file added docs/pages/environments.md
Empty file.
2 changes: 1 addition & 1 deletion docs/pages/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Redis stack is a required dependency for using Sotopia. There are two ways to se
<AccordionItem value="item-1">
<AccordionTrigger>Docker is my thing.</AccordionTrigger>
<AccordionContent>
Please follow the [instruction](https://redis.io/docs/stack/get-started/install/docker/) to start a redis-stack server or use an existing server. You can also check [Q&A](/docs/all_the_issues.md) to initiate the redis server with the Sotopia data.
Please follow the [instruction](https://redis.io/docs/stack/get-started/install/docker/) to start a redis-stack server or use an existing server. You can also check [Q&A](/docs/troubleshooting.md) to initiate the redis server with the Sotopia data.

The `REDIS_OM_URL` need to be set before loading and saving agents:
```bash
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Q&A
# Troubleshooting
## Missing episodes

Large batch size may cause some episodes to be skipped. This is due to the fact that the server may not be able to handle the load. Try reducing the batch size. But you can also use the script in `examples/fix_missing_episodes.py` to fix the missing episodes.
Expand Down
573 changes: 306 additions & 267 deletions poetry.lock

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ langchain = "~0.2.5"
rich = "^13.6.0"
PettingZoo = "1.24.3"
redis-om = "^0.2.1"
types-tqdm = "*"
gin-config = "^0.5.0"
absl-py = "^2.0.0"
together = "^0.2.4"
Expand All @@ -42,6 +41,8 @@ pandas = { version = "^2.1.1", optional = true }
pre-commit = "*"
nbmake = "*"
types-setuptools = "*"
types-requests = "*"
types-tqdm = "*"
ruff = "*"

[tool.poetry.group.test.dependencies]
Expand Down Expand Up @@ -79,4 +80,4 @@ testpaths = ["tests"]
python_files = "test_*.py"

[tool.poetry.scripts]
sotopia_benchmark = "sotopia.benchmark:app"
sotopia = "sotopia.cli:app"
3 changes: 0 additions & 3 deletions sotopia/benchmark/__init__.py

This file was deleted.

5 changes: 5 additions & 0 deletions sotopia/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .app import app
from .install import install
from .benchmark import benchmark

__all__ = ["app", "install", "benchmark"]
3 changes: 3 additions & 0 deletions sotopia/cli/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from typer import Typer

app = Typer()
3 changes: 3 additions & 0 deletions sotopia/cli/benchmark/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .benchmark import benchmark

__all__ = ["benchmark"]
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@

import typer
from pathlib import Path

app = typer.Typer()
from ..app import app


def check_existing_episodes(
Expand Down Expand Up @@ -264,7 +263,7 @@ def _set_up_logs(


@app.command()
def cli(
def benchmark(
model: str = typer.Option(..., help="The language model you want to benchmark."),
partner_model: str = typer.Option(
"together_ai/meta-llama/Llama-3-70b-chat-hf",
Expand Down Expand Up @@ -297,7 +296,3 @@ def cli(
verbose=False,
push_to_db=True,
)


if __name__ == "__main__":
app()
3 changes: 3 additions & 0 deletions sotopia/cli/install/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .install import install

__all__ = ["install"]
Loading

0 comments on commit 701f2a8

Please sign in to comment.