Skip to content

armgit / camel

Public Imported from GitHub
0

🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org

Fix dependencies in `pyproject.toml` (#242)

Tianqi Xu416400fca7ee
diff --git a/.github/workflows/documentation.yaml b/.github/workflows/documentation.yaml
index f30034512..bd3793562 100644
--- a/.github/workflows/documentation.yaml
+++ b/.github/workflows/documentation.yaml
@@ -9,23 +9,38 @@ permissions:
contents: write
jobs:
docs:
+
runs-on: ubuntu-latest
+
steps:
- - uses: actions/checkout@v3
- - uses: actions/setup-python@v3
- - name: Install dependencies
- run: |
- pip install -e .
- pip install sphinx sphinx_book_theme recommonmark
- - name: Sphinx build
- run: |
- cd docs
- make html
- - name: Deploy
- uses: peaceiris/actions-gh-pages@v3
- if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master'}}
- with:
- publish_branch: gh-pages
- github_token: ${{ secrets.GITHUB_TOKEN }}
- publish_dir: docs/_build/html/
- force_orphan: true
+ - uses: actions/checkout@v3
+ - name: Set up Python 3.8
+ uses: actions/setup-python@v3
+ with:
+ python-version: "3.8"
+ - name: Install poetry
+ uses: abatilo/actions-poetry@v2
+ - name: Setup poetry virtual environment
+ run: |
+ poetry config virtualenvs.create true --local
+ poetry config virtualenvs.in-project true --local
+ - uses: actions/cache@v3
+ name: Cache for the virtual environment based on pyproject.toml
+ with:
+ path: ./.venv
+ key: ${{ runner.os }}-venv-docs-${{ hashFiles('pyproject.toml') }}
+ restore-keys: ${{ runner.os }}-venv-docs
+ - name: Install the project dependencies
+ run: poetry install --with docs
+ - name: Sphinx build
+ run: |
+ cd docs
+ poetry run make html
+ - name: Deploy
+ uses: peaceiris/actions-gh-pages@v3
+ if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master'}}
+ with:
+ publish_branch: gh-pages
+ github_token: ${{ secrets.GITHUB_TOKEN }}
+ publish_dir: docs/_build/html/
+ force_orphan: true
diff --git a/.github/workflows/pytest_apps.yml b/.github/workflows/pytest_apps.yml
index e625e34f8..f3e6c93c6 100644
--- a/.github/workflows/pytest_apps.yml
+++ b/.github/workflows/pytest_apps.yml
@@ -23,24 +23,24 @@ jobs:
uses: actions/setup-python@v3
with:
python-version: "3.8"
+ - name: Install poetry
+ uses: abatilo/actions-poetry@v2
+ - name: Setup poetry virtual environment
+ run: |
+ poetry config virtualenvs.create true --local
+ poetry config virtualenvs.in-project true --local
- uses: actions/cache@v3
- id: cache
+ name: Cache for the virtual environment based on pyproject.toml
with:
- path: ~/.cache/pip
- key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.*') }}
- restore-keys: |
- ${{ runner.os }}-pip-
- - name: Install dependencies
- run: |
- python -m pip install --upgrade pip
- pip install flake8 pytest mock
- pip install gradio
- pip install -e .
- - name: Test with pytest
+ path: ./.venv
+ key: ${{ runner.os }}-venv-${{ hashFiles('pyproject.toml') }}
+ restore-keys: ${{ runner.os }}-venv
+ - name: Install the project dependencies
+ run: poetry install --with dev
+ - name: Run pytest
env:
OPENAI_API_KEY: "${{ secrets.OPENAI_API_KEY }}"
- run: |
- pytest apps/
+ run: poetry run pytest -v apps/
pytest_examples:
@@ -52,20 +52,21 @@ jobs:
uses: actions/setup-python@v3
with:
python-version: "3.8"
+ - name: Install poetry
+ uses: abatilo/actions-poetry@v2
+ - name: Setup poetry virtual environment
+ run: |
+ poetry config virtualenvs.create true --local
+ poetry config virtualenvs.in-project true --local
- uses: actions/cache@v3
- id: cache
+ name: Cache for the virtual environment based on pyproject.toml
with:
- path: ~/.cache/pip
- key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.*') }}
- restore-keys: |
- ${{ runner.os }}-pip-
- - name: Install dependencies
- run: |
- python -m pip install --upgrade pip
- pip install flake8 pytest mock
- pip install -e .
- - name: Test with pytest
+ path: ./.venv
+ key: ${{ runner.os }}-venv-${{ hashFiles('pyproject.toml') }}
+ restore-keys: ${{ runner.os }}-venv
+ - name: Install the project dependencies
+ run: poetry install --with dev
+ - name: Run pytest
env:
OPENAI_API_KEY: "${{ secrets.OPENAI_API_KEY }}"
- run: |
- pytest examples/
+ run: poetry run pytest -v examples/
diff --git a/.github/workflows/pytest_package.yml b/.github/workflows/pytest_package.yml
index 664943a78..38a155015 100644
--- a/.github/workflows/pytest_package.yml
+++ b/.github/workflows/pytest_package.yml
@@ -23,24 +23,26 @@ jobs:
uses: actions/setup-python@v3
with:
python-version: "3.8"
+ - name: Install poetry
+ uses: abatilo/actions-poetry@v2
+ - name: Setup poetry virtual environment
+ run: |
+ poetry config virtualenvs.create true --local
+ poetry config virtualenvs.in-project true --local
- uses: actions/cache@v3
- id: cache
+ name: Cache for the virtual environment based on pyproject.toml
with:
- path: ~/.cache/pip
- key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.*') }}
- restore-keys: |
- ${{ runner.os }}-pip-
- - name: Install dependencies
- run: |
- python -m pip install --upgrade pip
- pip install flake8 pytest
- pip install -e .
- - name: Test with pytest
+ path: ./.venv
+ key: ${{ runner.os }}-venv-${{ hashFiles('pyproject.toml') }}
+ restore-keys: ${{ runner.os }}-venv
+ - name: Install the project dependencies
+ run: poetry install --with dev
+ - name: Run pytest
env:
OPENAI_API_KEY: "${{ secrets.OPENAI_API_KEY }}"
- run: |
- pytest test/
-
+ run: poetry run pytest test/
+
+
pytest_package_full_test:
runs-on: ubuntu-latest
@@ -51,23 +53,25 @@ jobs:
uses: actions/setup-python@v3
with:
python-version: "3.8"
+ - name: Install poetry
+ uses: abatilo/actions-poetry@v2
+ - name: Setup poetry virtual environment
+ run: |
+ poetry config virtualenvs.create true --local
+ poetry config virtualenvs.in-project true --local
- uses: actions/cache@v3
- id: cache
+ name: Cache for the virtual environment based on pyproject.toml
with:
- path: ~/.cache/pip
- key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.*') }}
- restore-keys: |
- ${{ runner.os }}-pip-
- - name: Install dependencies
- run: |
- python -m pip install --upgrade pip
- pip install flake8 pytest
- pip install -e .
- - name: Test with pytest
+ path: ./.venv
+ key: ${{ runner.os }}-venv-${{ hashFiles('pyproject.toml') }}
+ restore-keys: ${{ runner.os }}-venv
+ - name: Install the project dependencies
+ run: poetry install --with dev
+ - name: Run pytest
env:
OPENAI_API_KEY: "${{ secrets.OPENAI_API_KEY }}"
- run: |
- pytest --full-test-mode test/
+ run: poetry run pytest --full-test-mode test/
+
pytest_package_fast_test:
@@ -79,20 +83,21 @@ jobs:
uses: actions/setup-python@v3
with:
python-version: "3.8"
+ - name: Install poetry
+ uses: abatilo/actions-poetry@v2
+ - name: Setup poetry virtual environment
+ run: |
+ poetry config virtualenvs.create true --local
+ poetry config virtualenvs.in-project true --local
- uses: actions/cache@v3
- id: cache
+ name: Cache for the virtual environment based on pyproject.toml
with:
- path: ~/.cache/pip
- key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.*') }}
- restore-keys: |
- ${{ runner.os }}-pip-
- - name: Install dependencies
- run: |
- python -m pip install --upgrade pip
- pip install flake8 pytest
- pip install -e .
- - name: Test with pytest
+ path: ./.venv
+ key: ${{ runner.os }}-venv-${{ hashFiles('pyproject.toml') }}
+ restore-keys: ${{ runner.os }}-venv
+ - name: Install the project dependencies
+ run: poetry install --with dev
+ - name: Run pytest
env:
OPENAI_API_KEY: "${{ secrets.OPENAI_API_KEY }}"
- run: |
- pytest --fast-test-mode test/
+ run: poetry run pytest --fast-test-mode test/
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index cc89d5d9b..8610f26a3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -104,7 +104,7 @@ ipython_config.py
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
-#poetry.lock
+poetry.lock
# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 97d877cb5..d083d6116 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -44,25 +44,31 @@ In line with this, we do have specific guidelines for code linting, formatting,
To get started with CAMEL, follow these steps:
-```bash
-# Create a conda virtual environment
-conda create --name camel python=3.10
-
-# Activate the camel conda environment
-conda activate camel
-
-# Clone the GitHub repo
+```sh
+# Clone github repo
git clone https://github.com/camel-ai/camel.git
-# Change to the project directory
+# Change directory into project directory
cd camel
-# Install CAMEL from source
-pip install -e .
+# Activate camel virtual environment
+poetry shell
+
+# Install camel from source
+# It takes about 75s to resolve dependencies and 10s to install them, depending on your hardware and network,
+poetry install --with dev,docs
-# Install pre-commit within the camel environment (only needed for opening pull requests)
-pip install pre-commit
+# Or if you want to use "huggingface agent"
+poetry install --with dev,docs -E huggingface-agent # (Optional)
+
+# The following command installs a pre-commit hook into the local git repo,
+$ so every commit gets auto-formatted and linted.
pre-commit install
+
+# do something with camel
+
+# Exit the virtual environment
+exit
```
These commands will install all the necessary dependencies for running the package, examples, linting, formatting, tests, and coverage.
diff --git a/README.md b/README.md
index e15fb6ad9..65c7f071f 100644
--- a/README.md
+++ b/README.md
@@ -64,8 +64,36 @@ We provide a [![Google Colab](https://colab.research.google.com/assets/colab-bad
[CAMEL package documentation pages](https://camel-ai.github.io/camel/)
## Installation
-Install `CAMEL` from source with conda:
+
+Install `CAMEL` from source with poetry (Recommended):
+```sh
+# Clone github repo
+# For the latest code:
+git clone https://github.com/camel-ai/camel.git
+# Or for the stable code:
+git clone -b v0.1.0 https://github.com/camel-ai/camel.git
+
+# Change directory into project directory
+cd camel
+
+# Activate camel virtual environment
+poetry shell
+
+# Install camel from source
+# It takes about 90 seconds to resolve dependencies
+poetry install
+
+# Or if you want to use "huggingface agent"
+poetry install -E huggingface-agent # (Optional)
+
+# do something with camel
+
+# Exit the virtual environment
+exit
```
+
+Install `CAMEL` from source with conda and pip:
+```sh
# Create a conda virtual environment
conda create --name camel python=3.10
@@ -81,9 +109,8 @@ cd camel
# Install camel from source
pip install -e .
-# Install pre-commmit within camel env (only needed for opening pull requests)
-pip install pre-commit
-pre-commit install
+# Or if you want to use "huggingface agent"
+pip install -e .[huggingface-agent] # (Optional)
```
## Example
You can find a list of tasks for different set of assistant and user role pairs [here](https://drive.google.com/file/d/194PPaSTBR07m-PzjS-Ty6KlPLdFIPQDd/view?usp=share_link)
diff --git a/install_env.sh b/install_env.sh
deleted file mode 100644
index 3a7ceb487..000000000
--- a/install_env.sh
+++ /dev/null
@@ -1,6 +0,0 @@
-conda create --name camel python=3.10
-conda activate camel
-conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia
-pip install -r requirements.txt
-pre-commit install
-pip install -e .
\ No newline at end of file
diff --git a/pyproject.toml b/pyproject.toml
index 3c81395c7..47aa5b5a5 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -3,13 +3,12 @@ requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
[tool.poetry]
-name="camel"
-version="0.1.0"
-authors=["CAMEL-AI.org"]
-description="Communicative Agents for AI Society Study"
-readme="README.md"
-requires-python=">=3.7"
-keywords=[
+name = "camel"
+version = "0.1.0"
+authors = ["CAMEL-AI.org"]
+description = "Communicative Agents for AI Society Study"
+readme = "README.md"
+keywords = [
"communicative-ai",
"ai-societies",
"artificial-intelligence",
@@ -19,13 +18,13 @@ keywords=[
"natural-language-processing",
"large-language-models",
]
-license="Apache License 2.0"
-homepage="https://www.camel-ai.org/"
-repository="https://github.com/camel-ai/camel"
-documentation="https://docs.camel-ai.org"
+license = "Apache License 2.0"
+homepage = "https://www.camel-ai.org/"
+repository = "https://github.com/camel-ai/camel"
+documentation = "https://docs.camel-ai.org"
[tool.poetry.dependencies]
-python = "^3.7"
+python = "^3.8.1"
numpy = "^1"
openai = "^0"
tenacity = "^8"
@@ -34,21 +33,58 @@ colorama = "^0"
jsonschema = "^4"
types-colorama = "^0"
types-requests = "^2"
+bs4 = "^0"
+
+transformers = { version = "^4", optional = true }
+diffusers = { version = "^0", optional = true }
+accelerate = { version = "^0", optional = true }
+datasets = { version = "^2", optional = true }
+torch = { version = "^1", optional = true }
+soundfile = { version = "^0", optional = true }
+sentencepiece = { version = "^0", optional = true }
+opencv-python = { version = "^4", optional = true }
+
+[tool.poetry.extras]
+huggingface-agent = [
+ "transformers",
+ "diffusers",
+ "accelerate",
+ "datasets",
+ "torch",
+ "soundfile",
+ "sentencepiece",
+ "opencv-python",
+]
+
+all = [
+ "transformers",
+ "diffusers",
+ "accelerate",
+ "datasets",
+ "torch",
+ "soundfile",
+ "sentencepiece",
+ "opencv-python",
+]
+
+[tool.poetry.group.dev]
+optional = true
+[tool.poetry.group.dev.dependencies]
yapf = "^0"
isort = "^5"
flake8 = "^6"
pre-commit = "^3"
pytest = "^7"
pytest-cov = "^4"
-bs4 = {version = "^0", optional = true}
-transformers = {version = "^4", optional = true}
-diffusers = {version = "^0", optional = true}
-accelerate = {version = "^0", optional = true}
-datasets = {version = "^2", optional = true}
-torch = {version = "^1", optional = true}
-soundfile = {version = "^0", optional = true}
-sentencepiece = {version = "^0", optional = true}
-opencv-python = {version = "^4", optional = true}
+gradio = "^3"
+mock = "^5"
+
+[tool.poetry.group.docs]
+optional = true
+[tool.poetry.group.docs.dependencies]
+sphinx = "^6"
+sphinx_book_theme = "*"
+recommonmark = "*"
[tool.yapf]
based_on_style = "pep8"
diff --git a/requirements.txt b/requirements.txt
deleted file mode 100644
index c3c48bc75..000000000
--- a/requirements.txt
+++ /dev/null
@@ -1,28 +0,0 @@
-# Packages for core
-numpy
-openai
-tenacity
-tiktoken
-colorama
-jsonschema
-
-# Packages for development
-yapf
-isort
-flake8
-pre-commit
-
-# Packages for testing
-pytest
-pytest-cov
-
-# Packages for huggingface tools
-bs4
-transformers[agent]
-diffusers==0.16.1
-accelerate==0.19.0
-datasets==2.12.0
-torch==2.0.0
-soundfile==0.12.1
-sentencepiece==0.1.97
-opencv-python==4.7.0.72
\ No newline at end of file