-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into release
- Loading branch information
Showing
69 changed files
with
7,522 additions
and
6,525 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM mcr.microsoft.com/devcontainers/python:1-3.12-bullseye | ||
|
||
RUN pip install uv\ | ||
&& uv venv /workspaces/.venv\ | ||
&& export UV_PROJECT_ENVIRONMENT=/workspaces/.venv\ | ||
&& echo export UV_PROJECT_ENVIRONMENT=/workspaces/.venv >> /root/.bashrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM ghcr.io/ggerganov/llama.cpp:server | ||
|
||
# Install curl and other necessary utilities | ||
RUN apt-get update && \ | ||
apt-get install -y curl && \ | ||
rm -rf /var/lib/apt/lists/* && \ | ||
curl -L https://huggingface.co/unsloth/Llama-3.2-1B-Instruct-GGUF/resolve/main/Llama-3.2-1B-Instruct-Q8_0.gguf --output Llama-3.2.gguf | ||
|
||
CMD ["-m", "Llama-3.2.gguf", "--port", "8000"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/python | ||
{ | ||
"name": "Sotopia Place", | ||
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile | ||
|
||
"dockerComposeFile": "docker-compose.yml", | ||
"service": "devcontainer", | ||
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", | ||
|
||
// Features to add to the dev container. More info: https://containers.dev/features. | ||
// "features": {}, | ||
|
||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [], | ||
|
||
// Use 'postCreateCommand' to run commands after the container is created. | ||
"postCreateCommand": "uv sync --all-extras", | ||
|
||
// Configure tool-specific properties. | ||
// "customizations": {}, | ||
|
||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. | ||
"remoteUser": "root" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
services: | ||
devcontainer: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
depends_on: | ||
llamacpp: | ||
condition: service_started | ||
redis: | ||
condition: service_healthy | ||
volumes: | ||
- ../..:/workspaces:cached | ||
command: sleep infinity | ||
network_mode: "host" | ||
|
||
llamacpp: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile.llamacpp | ||
container_name: llamacpp | ||
network_mode: "host" | ||
|
||
redis: | ||
image: redis/redis-stack-server:latest | ||
healthcheck: | ||
test: [ "CMD", "redis-cli", "--raw", "incr", "ping" ] | ||
network_mode: "host" | ||
|
||
networks: | ||
sotopia: | ||
external: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
uv run --extra test --extra chat pytest --ignore tests/cli --cov=. --cov-report=xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Pytest in docker | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- release | ||
- dev | ||
pull_request: | ||
branches: | ||
- main | ||
- release | ||
|
||
jobs: | ||
Pytest: | ||
strategy: | ||
max-parallel: 5 | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Docker Compose | ||
run: docker compose -f .devcontainer/docker-compose.yml up -d | ||
- name: Run tests | ||
run: docker compose -f .devcontainer/docker-compose.yml run --rm -u root -v /home/runner/work/sotopia/sotopia:/workspaces/sotopia devcontainer /bin/sh -c "cd /workspaces/sotopia; ls; uv sync --extra test --extra chat; uv run pytest --ignore tests/cli --cov=. --cov-report=xml" | ||
- name: Upload coverage report to Codecov | ||
uses: codecov/codecov-action@v4.0.1 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# Welcome to the documentation for the Sotopia | ||
import os | ||
import openai | ||
import rich | ||
from tqdm import tqdm | ||
|
||
|
||
def generate_api_docs(source_dir: str, output_dir: str) -> None: | ||
# Create the output directory if it doesn't exist | ||
os.makedirs(output_dir, exist_ok=True) | ||
|
||
# Walk through the source directory | ||
total_files = sum( | ||
[ | ||
len(files) | ||
for r, d, files in os.walk(source_dir) | ||
if any(f.endswith(".py") and not f.startswith("__") for f in files) | ||
] | ||
) | ||
with tqdm(total=total_files, desc="Generating API docs") as pbar: | ||
for root, dirs, files in os.walk(source_dir): | ||
for file in files: | ||
if file.endswith(".py") and not file.startswith("__"): | ||
file_path = os.path.join(root, file) | ||
|
||
# Read the Python file | ||
with open(file_path, "r") as f: | ||
code = f.read() | ||
|
||
# Write the documentation to a file | ||
doc_content = generate_doc_for_node(code) | ||
rich.print(f"doc_content: {doc_content}") | ||
relative_path = os.path.relpath(root, source_dir) | ||
output_path = os.path.join( | ||
output_dir, relative_path, f"{file[:-3]}.md" | ||
) | ||
os.makedirs(os.path.dirname(output_path), exist_ok=True) | ||
|
||
with open(output_path, "w") as f: | ||
f.write(doc_content) | ||
pbar.update(1) | ||
|
||
|
||
def generate_doc_for_node(code: str) -> str: | ||
prompt = f""" | ||
Please provide a brief documentation for the following Python code: | ||
```python | ||
{code} | ||
``` | ||
Include a short description, parameters (if any), and return value (if any) as well as usage examples. Try to prettify the markdown content as much as possible. | ||
Please only return the markdown content and do not include any other text. | ||
""" | ||
|
||
response = openai.chat.completions.create( | ||
model="gpt-4o", | ||
messages=[ | ||
{ | ||
"role": "system", | ||
"content": "You are a helpful assistant that generates Python documentation. You only return the markdown content and do not include any other text.", | ||
}, | ||
{"role": "user", "content": prompt}, | ||
], | ||
) | ||
|
||
doc = response.choices[0].message.content | ||
assert isinstance(doc, str) | ||
|
||
return doc | ||
|
||
|
||
if __name__ == "__main__": | ||
openai.api_key = os.getenv("OPENAI_API_KEY") | ||
if not openai.api_key: | ||
raise ValueError("Please set the OPENAI_API_KEY environment variable") | ||
|
||
source_dir = "sotopia/samplers" | ||
output_dir = "docs/pages/python_API/samplers" | ||
generate_api_docs(source_dir, output_dir) | ||
|
||
print("API documentation generated successfully.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"agents": { | ||
"title": "Agents" | ||
}, | ||
"environments": { | ||
"title": "Environments" | ||
}, | ||
"database": { | ||
"title": "Database" | ||
}, | ||
"generation": { | ||
"title": "Generation Utilities" | ||
}, | ||
"renderers": { | ||
"title": "Renderers" | ||
} | ||
} |
Oops, something went wrong.