Skip to content

Commit

Permalink
Add installation instruction (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
ProKil committed May 23, 2024
1 parent 0efe3eb commit fc9d110
Show file tree
Hide file tree
Showing 6 changed files with 220 additions and 12 deletions.
Binary file modified docs/bun.lockb
Binary file not shown.
56 changes: 56 additions & 0 deletions docs/components/ui/accordion.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import * as React from "react"
import * as AccordionPrimitive from "@radix-ui/react-accordion"
import { ChevronDown } from "lucide-react"

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

const Accordion = AccordionPrimitive.Root

const AccordionItem = React.forwardRef<
React.ElementRef<typeof AccordionPrimitive.Item>,
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item>
>(({ className, ...props }, ref) => (
<AccordionPrimitive.Item
ref={ref}
className={cn("border-b", className)}
{...props}
/>
))
AccordionItem.displayName = "AccordionItem"

const AccordionTrigger = React.forwardRef<
React.ElementRef<typeof AccordionPrimitive.Trigger>,
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger>
>(({ className, children, ...props }, ref) => (
<AccordionPrimitive.Header className="flex">
<AccordionPrimitive.Trigger
ref={ref}
className={cn(
"flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",
className
)}
{...props}
>
{children}
<ChevronDown className="h-4 w-4 shrink-0 transition-transform duration-200" />
</AccordionPrimitive.Trigger>
</AccordionPrimitive.Header>
))
AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName

const AccordionContent = React.forwardRef<
React.ElementRef<typeof AccordionPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Content>
>(({ className, children, ...props }, ref) => (
<AccordionPrimitive.Content
ref={ref}
className="overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down"
{...props}
>
<div className={cn("pb-4 pt-0", className)}>{children}</div>
</AccordionPrimitive.Content>
))

AccordionContent.displayName = AccordionPrimitive.Content.displayName

export { Accordion, AccordionItem, AccordionTrigger, AccordionContent }
3 changes: 2 additions & 1 deletion docs/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ const nextConfig = {

const withNextra = require('nextra')({
theme: 'nextra-theme-docs',
themeConfig: './theme.config.jsx'
themeConfig: './theme.config.jsx',
defaultShowCopyCode: true,
})

module.exports = withNextra(nextConfig)
1 change: 1 addition & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"lint": "next lint"
},
"dependencies": {
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-checkbox": "^1.0.4",
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-dropdown-menu": "^2.0.6",
Expand Down
6 changes: 1 addition & 5 deletions docs/pages/_meta.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
{
"index": {
"type": "page",
"title": "Home",
"theme": {
"timestamp": false,
"layout": "full"
}
"title": "Home"
},
"contribution_menu": {
"title": "Documentation",
Expand Down
166 changes: 160 additions & 6 deletions docs/pages/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,165 @@ import Link from 'next/link'
import { Lumiflex } from 'uvcanvas'
import { Button } from "../components/ui/button"
import { MoveRight } from "lucide-react"
import { Accordion, AccordionItem, AccordionContent, AccordionTrigger } from "../components/ui/accordion"
import { Steps } from 'nextra/components'

export default function Home() {
return (
<img src="https://github.com/sotopia-lab/sotopia/raw/main/figs/title.png" />
)
}

<Home />
# Sotopia - Getting Started
https://github.com/sotopia-lab/sotopia


## Simulate social interactions between AIs and humans

* Enables human-AI interaction
- use `LLMAgent` to create LLM-based social agents,
- REST API-based interface for humans.
* Preset social tasks, characters, and interactions
- more than 200 social tasks, 40 characters, and 10k interaction episodes,
- interactions between agents backed by both closed-source and open-source LLMs, and human participants,
- evaluation of the performance based on multiple social dimensions.
* Realistic social interaction
- agents can talk, do non-verbal communication and performance physical actions,
- characters have different personalities, backgrounds, and relationships,
- agents can have different goals and motivations.
* Create your own
- modular design for easy extension,
- subclass `BaseAgent`, `ParallelSotopiaEnv`, `Evaluator` to create your own agents, environments, and evaluators,
- add your customized social tasks and characters.

## Installation

<div className='mt-3 space-x-3 flex flex-row items-center'>
<Link target="_blank" href="https://colab.research.google.com/drive/14hJOfzpA37PRUzdlFgiqVzUGIhhngqnz?usp=sharing">
<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>

### Basic Usage

This package supports Python 3.11 and above.



#### Install the package

```bash
pip install sotopia
```

<Accordion type="single" collapsible className="w-full">
<AccordionItem value="item-1">
<AccordionTrigger>Using Conda?</AccordionTrigger>
<AccordionContent>
Create a new environment with conda and install the package with pip:
```bash
conda create -n sotopia python=3.11;
conda activate sotopia;
```
</AccordionContent>
</AccordionItem>
<AccordionItem value="item-2">
<AccordionTrigger>Want to use the nightly version?</AccordionTrigger>
<AccordionContent>
<p>Install the nightly version with:</p>
```bash
curl -sSL https://install.python-poetry.org | python3;
poetry install;
```
</AccordionContent>
</AccordionItem>
<AccordionItem>
<AccordionTrigger>Where to put my OpenAI/TogetherAI/Groq/Replicate API keys?</AccordionTrigger>
<AccordionContent>
Although API keys are not required for all the experiments, you need to use these keys when you use LLMs from these providers.
For example, set the environment variable `OPENAI_API_KEY` to your key. The recommend way is to add the key to the conda environment:
```bash
conda env config vars set OPENAI_API_KEY=your_key
```
</AccordionContent>
</AccordionItem>
</Accordion>

#### Set up Redis stack

Redis stack is a required dependency for using Sotopia. There are two ways to set up Redis stack:

<Accordion type="single" collapsible className="w-full">
<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.

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"
```
</AccordionContent>
</AccordionItem>
<AccordionItem value="item-2">
<AccordionTrigger>No, I don't want to use Docker.</AccordionTrigger>
<AccordionContent>
<Steps>
### Download the Redis stack
```bash
# if you are using Ubunutu 20.04
curl -fsSL https://packages.redis.io/redis-stack/redis-stack-server-7.2.0-v10.focal.x86_64.tar.gz -o redis-stack-server.tar.gz
tar -xvzf redis-stack-server.tar.gz
export PATH=$(pwd)/redis-stack-server-7.2.0-v10/bin:$PATH
# 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
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
```

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:
```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>
</AccordionContent>
</AccordionItem>
</Accordion>

#### Set up the log folder

Just make a folder to store the logs:
```bash
mkdir logs
```



## Quick Start

You can view an episode demo with default parameters with the following:
```python
import asyncio
from sotopia.samplers import UniformSampler
from sotopia.server import run_async_server

asyncio.run(
run_async_server(
model_dict={
"env": "gpt-4",
"agent1": "gpt-3.5-turbo",
"agent2": "gpt-3.5-turbo",
},
sampler=UniformSampler(),
)
)
```
or if you have cloned the repo, run
```bash
python examples/minimalist_demo.py
```

0 comments on commit fc9d110

Please sign in to comment.