Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
ProKil committed Jun 27, 2024
2 parents fa1a410 + 701f2a8 commit d34115b
Show file tree
Hide file tree
Showing 37 changed files with 1,621 additions and 856 deletions.
23 changes: 23 additions & 0 deletions .github/.codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
codecov:
notify:
wait_for_ci: true

coverage:
status:
patch:
default:
threshold: 100% # allow patch coverage to be lower than project coverage by any amount
project:
default:
threshold: 5% # allow project coverage to drop at most 5%

comment: # this is a top-level key
layout: " diff, flags, files"
behavior: default
require_changes: false # if true: only post the comment if coverage changes
require_base: false # [true :: must have a base report to post]
require_head: true # [true :: must have a head report to post]
hide_project_coverage: false # [true :: only show coverage on the git diff]

github_checks:
annotations: false
20 changes: 16 additions & 4 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 All @@ -38,4 +46,8 @@ jobs:
REDIS_OM_URL: ${{ secrets.REDIS_OM_URL }}
TOGETHER_API_KEY: ${{ secrets.TOGETHER_API_KEY }}
run: |
poetry run pytest
poetry run pytest --cov=. --cov-report=xml
- name: Upload coverage report to Codecov
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
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/*
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
[![pypi](https://img.shields.io/pypi/v/sotopia.svg)](https://pypi.python.org/pypi/sotopia)
[![versions](https://img.shields.io/pypi/pyversions/sotopia.svg)](https://github.com/sotopia/sotopia)
[![CI](https://img.shields.io/github/actions/workflow/status/sotopia-lab/sotopia/tests.yml?branch=main&logo=github&label=CI)](https://github.com/sotopia-lab/sotopia/actions?query=branch%3Amain)
[![codecov](https://codecov.io/github/sotopia-lab/sotopia/graph/badge.svg?token=00LRQFX0QR)](https://codecov.io/github/sotopia-lab/sotopia)
[![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/14hJOfzpA37PRUzdlFgiqVzUGIhhngqnz?usp=sharing)

[![Project Page](https://img.shields.io/badge/Project-Page-green.svg)](https://www.sotopia.world/projects/sotopia)
Expand Down Expand Up @@ -81,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 @@ -155,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
Binary file modified docs/bun.lockb
Binary file not shown.
53 changes: 53 additions & 0 deletions docs/components/ui/tabs.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import * as React from "react"
import * as TabsPrimitive from "@radix-ui/react-tabs"

import { cn } from "@/lib/utils"

const Tabs = TabsPrimitive.Root

const TabsList = React.forwardRef<
React.ElementRef<typeof TabsPrimitive.List>,
React.ComponentPropsWithoutRef<typeof TabsPrimitive.List>
>(({ className, ...props }, ref) => (
<TabsPrimitive.List
ref={ref}
className={cn(
"inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",
className
)}
{...props}
/>
))
TabsList.displayName = TabsPrimitive.List.displayName

const TabsTrigger = React.forwardRef<
React.ElementRef<typeof TabsPrimitive.Trigger>,
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>
>(({ className, ...props }, ref) => (
<TabsPrimitive.Trigger
ref={ref}
className={cn(
"inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",
className
)}
{...props}
/>
))
TabsTrigger.displayName = TabsPrimitive.Trigger.displayName

const TabsContent = React.forwardRef<
React.ElementRef<typeof TabsPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Content>
>(({ className, ...props }, ref) => (
<TabsPrimitive.Content
ref={ref}
className={cn(
"mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
className
)}
{...props}
/>
))
TabsContent.displayName = TabsPrimitive.Content.displayName

export { Tabs, TabsList, TabsTrigger, TabsContent }
1 change: 1 addition & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"@radix-ui/react-popover": "^1.0.7",
"@radix-ui/react-separator": "^1.0.3",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-tabs": "^1.0.4",
"@tanstack/react-table": "^8.16.0",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
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.
50 changes: 41 additions & 9 deletions docs/pages/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { Button } from "../components/ui/button"
import { MoveRight } from "lucide-react"
import { Accordion, AccordionItem, AccordionContent, AccordionTrigger } from "../components/ui/accordion"
import { Steps, Callout } from 'nextra/components'
import { Tabs, TabsContent, TabsList, TabsTrigger } from "../components/ui/tabs"



# Sotopia - Getting Started
Expand Down Expand Up @@ -34,17 +36,14 @@ https://github.com/sotopia-lab/sotopia

<div className='space-x-3 flex flex-row items-center'>
<span className='font-bold'> Check out </span>
<Link target="_blank" href="https://colab.research.google.com/drive/14hJOfzpA37PRUzdlFgiqVzUGIhhngqnz?usp=sharing">
<Link target="_blank" href="https://colab.research.google.com/github/sotopia-lab/sotopia/blob/main/notebooks/tutorials/1.1-setup.ipynb">
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open in Colab"/> </Link>
<span className='font-bold'> for a quick tutorial </span>
</div>

This package supports Python 3.10 and above.
</Callout>

### Basic Usage

This package supports Python 3.10 and above. Tested on Ubuntu 22.04 with python 3.11.



#### Install the package
Expand Down Expand Up @@ -108,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 All @@ -119,6 +118,14 @@ Redis stack is a required dependency for using Sotopia. There are two ways to se
<AccordionItem value="item-2">
<AccordionTrigger>No, I don't want to use Docker.</AccordionTrigger>
<AccordionContent>
<Tabs defaultValue="linux" className="w-full">
<TabsList>
<TabsTrigger value="linux">Linux</TabsTrigger>
<TabsTrigger value="mac">MacOS</TabsTrigger>
<TabsTrigger value="windows">Windows</TabsTrigger>
</TabsList>
<TabsContent value="linux">

<Steps>
### Download the Redis stack
```bash
Expand All @@ -129,24 +136,49 @@ Redis stack is a required dependency for using Sotopia. There are two ways to se
# if you are using Ubunutu 22.04, please do an extra step
wget http://nz2.archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2.22_amd64.deb
sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2.22_amd64.deb
# if you are using macOs
```

### Start the server
```bash
./redis-stack-server-7.2.0-v10/bin/redis-stack-server --daemonize yes
```



### The `REDIS_OM_URL` need to be set before loading and saving agents:
```bash
conda env config vars set REDIS_OM_URL="redis://user:password@host:port"
```
If you are using the default settings, you can set the `REDIS_OM_URL` to `redis://localhost:6379`.
</Steps>
</TabsContent>
<TabsContent value="mac">
<Steps>
### Download the Redis stack
```bash
brew tap redis-stack/redis-stack
brew install redis-stack
```

### Start the server
```bash
./redis-stack-server-7.2.0-v10/bin/redis-stack-server --daemonize yes
redis-stack-server --daemonize yes
```

For other platforms, please check the [instruction](https://redis.io/docs/latest/operate/oss_and_stack/install/install-stack/).

### The `REDIS_OM_URL` need to be set before loading and saving agents:
### Set the environment variable:
The `REDIS_OM_URL` need to be set before loading and saving agents
```bash
conda env config vars set REDIS_OM_URL="redis://user:password@host:port"
```
If you are using the default settings, you can set the `REDIS_OM_URL` to `redis://localhost:6379`.
</Steps>
</TabsContent>
<TabsContent value="windows">
For Windows, unfortunately only docker is supported. Check the [official documentation](https://redis.io/docs/latest/operate/oss_and_stack/install/install-stack/windows/).
</TabsContent>
</Tabs>
</AccordionContent>
</AccordionItem>
</Accordion>
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
1 change: 1 addition & 0 deletions docs/tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const config = {
'./app/**/*.{ts,tsx}',
'./src/**/*.{ts,tsx}',
],
safelist: ['dark'],
prefix: "",
theme: {
container: {
Expand Down
6 changes: 3 additions & 3 deletions examples/generate_specific_envs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import numpy as np
from datasets import DatasetDict, load_dataset

from sotopia.generation_utils.generate import StrOutputParser, generate
from sotopia.generation_utils.generate import StrOutputParser, agenerate


async def generate_mutual_friend_envs() -> tuple[str, list[str]]:
Expand Down Expand Up @@ -78,7 +78,7 @@ async def generate_craigslist_bargains_envs() -> tuple[str, list[str]]:
all_data = craigslist_bargains_dataset["train"]
# sample one datum from all data
datum = np.random.choice(all_data)
scenario = generate(
scenario = await agenerate(
model_name="gpt-4",
template="The following sentence is automatically generated with the following"
'template: "One person is selling <item> for <price>, another person is'
Expand All @@ -100,7 +100,7 @@ async def generate_craigslist_bargains_envs() -> tuple[str, list[str]]:
datum["agent_info"]["Target"][i] = datum["items"]["Price"][0] / (
1 + markup_ratio
)
goal = generate(
goal = await agenerate(
model_name="gpt-4",
template="The following sentence is automatically generated with the following"
'template: "You want to <role> this item. Your target price '
Expand Down
Loading

0 comments on commit d34115b

Please sign in to comment.