pull/377/merge
evelynmitchell 1 year ago committed by GitHub
commit 855104fe94
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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 }}

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

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

@ -1,3 +1,4 @@
""" Example of using the OpenAIChat model to generate a blog post. """
import os
from dotenv import load_dotenv

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

@ -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 = "*"

@ -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
@ -52,3 +53,4 @@ scikit-image
anthropic
pinecone-client
roboflow
python-dotenv

@ -1,15 +1,16 @@
""" init file for swarms package. """
# from swarms.telemetry.main import Telemetry # noqa: E402, F403
from swarms.telemetry.bootup import bootup # noqa: E402, F403
bootup()
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
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

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

@ -1,7 +1,9 @@
""" This module provides a function to wrap a class to inherit from 'Agent'. """
from swarms.structs.agent import Agent
def agent_wrapper(ClassToWrap):
def agent_wrapper(ClassToWrap): # noqa C0103
"""
This function takes a class 'ClassToWrap' and returns a new class that
inherits from both 'ClassToWrap' and 'Agent'. The new class overrides
@ -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)

@ -1,3 +1,5 @@
""" Base class for AI agents. """
from typing import Dict, List

@ -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, input_to_agent: str) -> str:
"""Run the OmniAgent"""
plan = self.chat_planner.plan(
inputs={
"input": input,
"input": input_to_agent,
"hf_tools": self.tools,
}
)

@ -1,8 +1,10 @@
from swarms.structs.conversation import Conversation
from swarms.models.base_llm import AbstractLLM
from typing import Any
import importlib
import pkgutil
from swarms.structs.conversation import Conversation
from swarms.models.base_llm import AbstractLLM
import swarms.models
@ -16,7 +18,7 @@ def get_llm_by_name(name: str):
Returns:
type: The class with the given name, or None if no such class is found.
"""
for importer, modname, ispkg in pkgutil.iter_modules(
for importer, modname, ispkg in pkgutil.iter_modules( # noqa: W0612
swarms.models.__path__
):
module = importlib.import_module(f"swarms.models.{modname}")
@ -26,7 +28,7 @@ def get_llm_by_name(name: str):
# Run the language model in a loop for n iterations
def SimpleAgent(
def SimpleAgent( #noqa: C0103
llm: AbstractLLM = None, iters: Any = "automatic", *args, **kwargs
):
"""
@ -39,21 +41,21 @@ def SimpleAgent(
**kwargs: Additional keyword arguments to pass to the language model.
Raises:
Exception: If the language model is not defined or cannot be found.
AttributeError: If the language model is not defined or cannot be found.
Returns:
None
"""
try:
if llm is None:
raise Exception("Language model not defined")
raise AttributeError("Language model not defined")
if isinstance(llm, str):
llm = get_llm_by_name(llm)
if llm is None:
raise Exception(f"Language model {llm} not found")
raise AttributeError(f"Language model {llm} not found")
llm = llm(*args, **kwargs)
except Exception as error:
except AttributeError as error:
print(f"[ERROR][SimpleAgent] {error}")
raise error
@ -98,7 +100,7 @@ def SimpleAgent(
print(f"[ERROR][SimpleAgentConversation] {error}")
raise error
except KeyboardInterrupt:
except KeyboardInterrupt as exc:
print("[INFO][SimpleAgentConversation] Keyboard interrupt")
conv.export_conversation("conversation.txt")
raise KeyboardInterrupt
raise KeyboardInterrupt from exc

Loading…
Cancel
Save