diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index d3f42fb1..8e3f75d3 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.8", "3.9", "3.10"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} diff --git a/.github/workflows/pytestmac.yml b/.github/workflows/pytestmac.yml new file mode 100644 index 00000000..09392b7b --- /dev/null +++ b/.github/workflows/pytestmac.yml @@ -0,0 +1,35 @@ +name: Test on Macos-14 M1 + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: macos-14 + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python 3.11.7 + uses: actions/setup-python@v5 + with: + python-version: 3.11.7 + + - name: Install Poetry + uses: snok/install-poetry@v1 + with: + virtualenvs-create: true + virtualenvs-in-project: true + installer-parallel: true + + - name: Install dependencies + run: | + poetry install + + - name: Run tests + run: | + poetry run pytest \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index baaadfc8..6b175ce2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,9 +19,7 @@ jobs: - "3.9" - "3.10" - "3.11" - test_type: - - "core" - - "extended" + steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} @@ -29,48 +27,26 @@ jobs: with: python-version: ${{ matrix.python-version }} poetry-version: "1.4.2" - cache-key: ${{ matrix.test_type }} install-command: - if [ "${{ matrix.test_type }}" == "core" ]; then - echo "Running core tests, installing dependencies with poetry..." - poetry install - else - echo "Running extended tests, installing dependencies with poetry..." - poetry install -E extended_testing - fi - - name: Run ${{matrix.test_type}} tests - run: | - if [ "${{ matrix.test_type }}" == "core" ]; then - make test - else - make extended_tests - fi + echo "Running core tests, installing dependencies with poetry..." + poetry install + - name: Run core tests + run: pytest shell: bash - name: Python ${{ matrix.python-version }} ${{ matrix.test_type }} - steps: - - uses: actions/checkout@v4 + - name: Python ${{ matrix.python-version }} core + uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: "./.github/actions/poetry_setup" + uses: "actions/setup-python@v2" with: python-version: ${{ matrix.python-version }} poetry-version: "1.4.2" - cache-key: ${{ matrix.test_type }} install-command: | - if [ "${{ matrix.test_type }}" == "core" ]; then - echo "Running core tests, installing dependencies with poetry..." - poetry install - else - echo "Running extended tests, installing dependencies with poetry..." - poetry install -E extended_testing - fi - - name: Run ${{matrix.test_type}} tests - run: | - if [ "${{ matrix.test_type }}" == "core" ]; then - make test - else - make extended_tests - fi + echo "Running core tests, installing dependencies with poetry..." + poetry install + - name: Run core tests + run: pytest shell: bash + build: runs-on: ubuntu-latest strategy: @@ -80,31 +56,17 @@ jobs: - "3.9" - "3.10" - "3.11" - test_type: - - "core" - - "extended" - name: Python ${{ matrix.python-version }} ${{ matrix.test_type }} + name: Python ${{ matrix.python-version }} core steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: "./.github/actions/poetry_setup" + uses: "actions/setup-python@v2" with: python-version: ${{ matrix.python-version }} poetry-version: "1.4.2" - cache-key: ${{ matrix.test_type }} install-command: | - if [ "${{ matrix.test_type }}" == "core" ]; then - echo "Running core tests, installing dependencies with poetry..." - poetry install - else - echo "Running extended tests, installing dependencies with poetry..." - poetry install -E extended_testing - fi - - name: Run ${{matrix.test_type}} tests - run: | - if [ "${{ matrix.test_type }}" == "core" ]; then - make test - else - make extended_tests - fi + echo "Running core tests, installing dependencies with poetry..." + poetry install + - name: Run core tests + run: pytest shell: bash \ No newline at end of file diff --git a/example.py b/example.py index 33c3bef1..05ff27e8 100644 --- a/example.py +++ b/example.py @@ -1,3 +1,4 @@ +""" Example of using the OpenAIChat model to generate a blog post. """ import os from dotenv import load_dotenv diff --git a/playground/agents/mm_agent_example.py b/playground/agents/mm_agent_example.py index 6cedcb29..10bacefb 100644 --- a/playground/agents/mm_agent_example.py +++ b/playground/agents/mm_agent_example.py @@ -1,8 +1,10 @@ -from swarms.agents import MultiModalAgent +""" Example of using the MultiModalAgent """ + +from swarms.agents import OmniModalAgent load_dict = {"ImageCaptioning": "cuda"} -node = MultiModalAgent(load_dict) +node = OmniModalAgent(load_dict) text = node.run_text( "What is your name? Generate a picture of yourself" diff --git a/pyproject.toml b/pyproject.toml index 6e3cdc7f..a2b23854 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,7 @@ classifiers = [ [tool.poetry.dependencies] -python = "^3.6.1" +python = ">=3.9.1,<3.12" torch = "2.1.1" transformers = "4.37.1" openai = "0.28.0" @@ -33,6 +33,7 @@ einops = "0.7.0" google-generativeai = "0.3.1" langchain-experimental = "0.0.10" tensorflow = "*" +tensorflow-io = "*" weaviate-client = "3.25.3" opencv-python-headless = "4.8.1.78" faiss-cpu = "1.7.4" @@ -74,6 +75,7 @@ supervision = "*" scikit-image = "*" pinecone-client = "*" roboflow = "*" +python-dotenv = "*" diff --git a/requirements.txt b/requirements.txt index 00c92023..ce25dc57 100644 --- a/requirements.txt +++ b/requirements.txt @@ -18,6 +18,7 @@ PyPDF2==3.0.1 accelerate==0.22.0 chromadb==0.4.14 tensorflow +tensorflow-io optimum toml tiktoken==0.4.0 @@ -51,4 +52,5 @@ supervision scikit-image anthropic pinecone-client -roboflow \ No newline at end of file +roboflow +python-dotenv \ No newline at end of file diff --git a/swarms/__init__.py b/swarms/__init__.py index 2a682f5b..aaa6cc83 100644 --- a/swarms/__init__.py +++ b/swarms/__init__.py @@ -1,3 +1,4 @@ +""" init file for swarms package. """ # from swarms.telemetry.main import Telemetry # noqa: E402, F403 from swarms.telemetry.bootup import bootup # noqa: E402, F403 from swarms.telemetry.user_utils import ( @@ -6,15 +7,15 @@ from swarms.telemetry.user_utils import ( bootup() -get_user_device_data() +from swarms.agents import * # noqa: E402, F403, C0413 +from swarms.structs import * # noqa: E402, F403, C0413 +from swarms.models import * # noqa: E402, F403, C0413 +from swarms.telemetry import * # noqa: E402, F403, C0413 +from swarms.utils import * # noqa: E402, F403, C0413 +from swarms.prompts import * # noqa: E402, F403, C0413 +from swarms.tokenizers import * # noqa: E402, F403, C0413 +from swarms.loaders import * # noqa: E402, F403, C0413 +from swarms.artifacts import * # noqa: E402, F403, C0413 +from swarms.chunkers import * # noqa: E402, F403, C0413 -from swarms.agents import * # noqa: E402, F403 -from swarms.structs import * # noqa: E402, F403 -from swarms.models import * # noqa: E402, F403 -from swarms.telemetry import * # noqa: E402, F403 -from swarms.utils import * # noqa: E402, F403 -from swarms.prompts import * # noqa: E402, F403 -from swarms.tokenizers import * # noqa: E402, F403 -from swarms.loaders import * # noqa: E402, F403 -from swarms.artifacts import * # noqa: E402, F403 -from swarms.chunkers import * # noqa: E402, F403 +get_user_device_data() diff --git a/swarms/agents/__init__.py b/swarms/agents/__init__.py index 461baa16..5d17ce84 100644 --- a/swarms/agents/__init__.py +++ b/swarms/agents/__init__.py @@ -1,3 +1,4 @@ +""" init file for swarms/agents module. """ from swarms.agents.base import AbstractAgent from swarms.agents.omni_modal_agent import OmniModalAgent from swarms.agents.simple_agent import SimpleAgent diff --git a/swarms/agents/agent_wrapper.py b/swarms/agents/agent_wrapper.py index 738f599d..5855c7c8 100644 --- a/swarms/agents/agent_wrapper.py +++ b/swarms/agents/agent_wrapper.py @@ -1,3 +1,5 @@ +""" This module provides a function to wrap a class to inherit from 'Agent'. """ + from swarms.structs.agent import Agent @@ -14,7 +16,8 @@ def agent_wrapper(ClassToWrap): type: The new class that inherits from both 'ClassToWrap' and 'Agent'. """ - class WrappedClass(ClassToWrap, Agent): + class WrappedClass(ClassToWrap, Agent): # noqa C0103 + """ A class that inherits from both 'ClassToWrap' and 'Agent'. """ def __init__(self, *args, **kwargs): try: Agent.__init__(self, *args, **kwargs) diff --git a/swarms/agents/base.py b/swarms/agents/base.py index 22c0addc..5ce53510 100644 --- a/swarms/agents/base.py +++ b/swarms/agents/base.py @@ -1,3 +1,5 @@ +""" Base class for AI agents. """ + from typing import Dict, List diff --git a/swarms/agents/omni_modal_agent.py b/swarms/agents/omni_modal_agent.py index 113ec461..3d25debc 100644 --- a/swarms/agents/omni_modal_agent.py +++ b/swarms/agents/omni_modal_agent.py @@ -1,3 +1,5 @@ +""" OmniModalAgent """ + from langchain.base_language import BaseLanguageModel from langchain_experimental.autonomous_agents.hugginggpt.repsonse_generator import ( load_response_generator, @@ -72,11 +74,11 @@ class OmniModalAgent: # self.task_executor = TaskExecutor self.history = [] - def run(self, input: str) -> str: + def run(self, inputtoagent: str) -> str: """Run the OmniAgent""" plan = self.chat_planner.plan( inputs={ - "input": input, + "input": inputtoagent, "hf_tools": self.tools, } )