Skip to content

Commit

Permalink
Update dependency list and move optional ones to extra dependencies (#80
Browse files Browse the repository at this point in the history
)

* cut 5 dependencies: datasets, scipy, names, torch, and transformers

* remove jinja2

* change minimalist demo back

* update dependency by adding extra options

* 👷 add "chat" extra to intall

* add install types for sotopia-chat

* add sotopia-chat to mypy

* 👷 add multiple python versions

* 👷 widen python versions

* 💚 add poetry lock to update the lock file

* remove 3.9

* update raise syntax to adapt more python versions

* add poetry lock to pytest

* use wait for for python < 3.11

* add relase to pypi github action

* docs: Update Python version support to include Python 3.10, and include instructions to install extra dependencies

* added callout components
  • Loading branch information
ProKil authored May 26, 2024
1 parent 2227503 commit 184d1ca
Show file tree
Hide file tree
Showing 27 changed files with 1,439 additions and 2,250 deletions.
14 changes: 10 additions & 4 deletions .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,26 @@ jobs:
runs-on: ubuntu-latest
strategy:
max-parallel: 5
matrix:
python-version: ["3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: 3.11.2
python-version: ${{ matrix.python-version }}
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install dependencies
run: |
curl -sSL https://install.python-poetry.org | python3
poetry install --all-extras
poetry lock
poetry install --with test -E chat
- name: Type-checking package with mypy
run: |
# Run this mypy instance against our main package.
poetry run pip install types-protobuf==4.24.0.4
poetry run mypy --install-types --non-interactive sotopia
poetry run mypy --install-types --non-interactive sotopia-chat
poetry run mypy --strict .
38 changes: 38 additions & 0 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Upload Python Package

on:
release:
types: [published]

permissions:
contents: read

jobs:
release:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11.2
- name: Install dependencies
run: |
curl -sSL https://install.python-poetry.org | python3
- name: Get release version
run: echo "RELEASE_VERSION=$(poetry version | awk '{print $2}')" >> $GITHUB_ENV

- name: Build and publish Python package
run: poetry publish --build
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
3 changes: 2 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ jobs:
- name: Install dependencies
run: |
curl -sSL https://install.python-poetry.org | python3
poetry install --all-extras
poetry lock
poetry install --with test -E chat
- name: Test with pytest
env: # Or as an environment variable
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
Expand Down
6 changes: 5 additions & 1 deletion docs/pages/examples.md → docs/pages/examples.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { Callout } from 'nextra/components'

# Example Scripts For Using The Library

## Example 1: Evaluating existing episodes
<Callout type="info" emoji="ℹ️">
Before running examples, please install extra dependencies with `pip install sotopia[examples]` or `poetry install -E examples` if you are using poetry.
</Callout>

```python
python examples/evaluate_existing_episodes.py --tag=<tag to upload to the database> --model=<the model used to re-evaluate the existing episodes> --batch_size=<batch size used for evaluation> --push-to-db
Expand Down
24 changes: 21 additions & 3 deletions docs/pages/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ 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'
import { Steps, Callout } from 'nextra/components'


# Sotopia - Getting Started
Expand All @@ -30,15 +30,20 @@ https://github.com/sotopia-lab/sotopia

## Installation

<div className='mt-3 space-x-3 flex flex-row items-center'>
<Callout>

<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">
<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>

</Callout>

### Basic Usage

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



Expand Down Expand Up @@ -80,6 +85,19 @@ pip install sotopia
```
</AccordionContent>
</AccordionItem>
<AccordionItem value="item-4">
<AccordionTrigger>What if I want to run examples and sotopia-chat?</AccordionTrigger>
<AccordionContent>
<p>Install the package with the following command:</p>
```bash
pip install sotopia[examples, chat]
```
if you are using poetry, you can install the package with:
```bash
poetry install -E examples -E chat
```
</AccordionContent>
</AccordionItem>
</Accordion>

#### Set up Redis stack
Expand Down
2 changes: 2 additions & 0 deletions examples/generate_scenarios.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
from sotopia.database.persistent_profile import RelationshipType
from sotopia.generation_utils import (
LLM_Name,
)
from .generate_specific_envs import ( # type:ignore[import-untyped]
generate_craigslist_bargains_envs,
generate_mutual_friend_envs,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
Here are the datasets we have so far:
1. Mutual-Friend (https://huggingface.co/datasets/mutual_friends)
2. Craigslist-Bargains (https://huggingface.co/datasets/craigslist_bargains)
You will have to install the datasets library to use this file.
"""

import names
import numpy as np
from datasets import DatasetDict, load_dataset

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


async def generate_mutual_friend_envs() -> tuple[str, list[str]]:
Expand Down
Empty file removed lmlib/__init__.py
Empty file.
Empty file removed lmlib/api_service/__init__.py
Empty file.
197 changes: 0 additions & 197 deletions lmlib/api_service/chat_model.py

This file was deleted.

Loading

0 comments on commit 184d1ca

Please sign in to comment.