Revert "[WIP] Get CI Passing V2"

revert-388-fix-ci-2
Eternal Reclaimer 11 months ago committed by GitHub
parent ff29a6b816
commit 415a5cf644
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1,11 +0,0 @@
[flake8]
max-line-length = 127
extend-ignore = E203
per-file-ignores =
# Most of this is just long strings
./swarms/prompts/**.py: E501 W293 W291
./swarms/__init__.py: F401
exclude =
./playground
./tests
./scripts

@ -1,5 +1,6 @@
--- ---
# These are supported funding model platforms # These are supported funding model platforms
github: [kyegomez] github: [kyegomez]
# patreon: # Replace with a single Patreon username # patreon: # Replace with a single Patreon username
# open_collective: # Replace with a single Open Collective username # open_collective: # Replace with a single Open Collective username

37
.github/action.yml vendored

@ -0,0 +1,37 @@
name: "Init Environment"
description: "Initialize environment for tests"
runs:
using: "composite"
steps:
- name: Checkout actions
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root --with test --with dev --all-extras
shell: bash
- name: Activate venv
run: |
source .venv/bin/activate
echo PATH=$PATH >> $GITHUB_ENV
shell: bash

@ -1,11 +1,13 @@
--- ---
# https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/configuration-options-for-dependency-updates # https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/configuration-options-for-dependency-updates
version: 2 version: 2
updates: updates:
- package-ecosystem: "github-actions" - package-ecosystem: "github-actions"
directory: "/" directory: "/"
schedule: schedule:
interval: "weekly" interval: "weekly"
- package-ecosystem: "pip" - package-ecosystem: "pip"
directory: "/" directory: "/"
schedule: schedule:

@ -1,52 +1,14 @@
--- ---
documentation: # this is a config file for the github action labeler
- changed-files:
- any-glob-to-any-file: ["docs/**", "*.md"] # Add 'label1' to any changes within 'example' folder or any subfolders
tests: example_change:
- changed-files: - example/**
- any-glob-to-any-file: "tests/**"
agents: # Add 'label2' to any file changes within 'example2' folder
- changed-files: example2_change: example2/*
- any-glob-to-any-file: "swarms/agents/**"
artifacts: # Add label3 to any change to .txt files within the entire repository.
- changed-files: # Quotation marks are required for the leading asterisk
- any-glob-to-any-file: "swarms/artifacts/**" text_files:
chunkers: - '**/*.txt'
- changed-files:
- any-glob-to-any-file: "swarms/chunkers/**"
cli:
- changed-files:
- any-glob-to-any-file: "swarms/cli/**"
loaders:
- changed-files:
- any-glob-to-any-file: "swarms/loaders/**"
memory:
- changed-files:
- any-glob-to-any-file: "swarms/memory/**"
models:
- changed-files:
- any-glob-to-any-file: "swarms/models/**"
prompts:
- changed-files:
- any-glob-to-any-file: "swarms/prompts/**"
structs:
- changed-files:
- any-glob-to-any-file: "swarms/structs/**"
telemetry:
- changed-files:
- any-glob-to-any-file: "swarms/telemetry/**"
tokenizers:
- changed-files:
- any-glob-to-any-file: "swarms/tokenizers/**"
tools:
- changed-files:
- any-glob-to-any-file: "swarms/tools/**"
utils:
- changed-files:
- any-glob-to-any-file: "swarms/utils/**"
workers:
- changed-files:
- any-glob-to-any-file: "swarms/workers/**"
rust:
- changed-files:
- any-glob-to-any-file: "**/*.rs"

@ -1,44 +0,0 @@
---
name: "Setup"
description: Setup the environment for the project
inputs:
python-version:
description: "Python version to use"
required: false
default: "3.10"
runs:
using: "composite"
steps:
- name: Free up disk space
run: |
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL
sudo docker image prune --all --force
shell: bash
- name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python-version }}
- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
installer-parallel: true
- name: Cache Poetry cache
uses: actions/cache@v4
with:
path: ~/.cache/pypoetry
key: poetry-cache
-${{ runner.os }}
-${{ steps.setup_python.outputs.python-version }}
-${{ env.POETRY_VERSION }}
- name: Cache Packages
uses: actions/cache@v4
with:
path: ~/.local
key: poetry-local
-${{ runner.os }}
-${{ steps.setup_python.outputs.python-version }}
-${{ hashFiles('**/poetry.lock')}}
-${{ hashFiles('.github/workflows/*.yml') }}
- name: Install dependencies
run: POETRY_VIRTUALENVS_CREATE=false poetry install
shell: bash

@ -1,5 +1,5 @@
---
name: release name: release
on: on:
pull_request: pull_request:
types: types:
@ -7,18 +7,26 @@ on:
branches: branches:
- master - master
paths: paths:
- "pyproject.toml" - 'pyproject.toml'
env: env:
POETRY_VERSION: "1.4.2" POETRY_VERSION: "1.4.2"
jobs: jobs:
if_release: if_release:
if: | if: |
${{ github.event.pull_request.merged == true }} ${{ github.event.pull_request.merged == true }}
&& ${{ contains(github.event.pull_request.labels.*.name, 'release') }} && ${{ contains(github.event.pull_request.labels.*.name, 'release') }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: ./.github/library/setup - name: Install poetry
run: pipx install poetry==$POETRY_VERSION
- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: "3.9"
cache: "poetry"
- name: Build project for distribution - name: Build project for distribution
run: poetry build run: poetry build
- name: Check Version - name: Check Version
@ -37,5 +45,5 @@ jobs:
- name: Publish to PyPI - name: Publish to PyPI
env: env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }} POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }}
run: |- run: |
poetry publish poetry publish

@ -1,4 +1,3 @@
---
# This workflow uses actions that are not certified by GitHub. # This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by # They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support # separate terms of service, privacy policy, and support
@ -11,38 +10,39 @@
# https://github.com/codacy/codacy-analysis-cli-action. # https://github.com/codacy/codacy-analysis-cli-action.
# For more information on Codacy Analysis CLI in general, see # For more information on Codacy Analysis CLI in general, see
# https://github.com/codacy/codacy-analysis-cli. # https://github.com/codacy/codacy-analysis-cli.
name: Codacy Security Scan name: Codacy Security Scan
on: on:
push: push:
branches: ["master"] branches: [ "master" ]
pull_request: pull_request:
# The branches below must be a subset of the branches above # The branches below must be a subset of the branches above
branches: ["master"] branches: [ "master" ]
schedule: schedule:
- cron: '18 23 * * 4' - cron: '18 23 * * 4'
permissions: permissions:
contents: read contents: read
jobs: jobs:
codacy-security-scan: codacy-security-scan:
permissions: permissions:
# for actions/checkout to fetch code contents: read # for actions/checkout to fetch code
contents: read security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
# for github/codeql-action/upload-sarif to upload SARIF results actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
security-events: write
# only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
actions: read
name: Codacy Security Scan name: Codacy Security Scan
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
# Checkout the repository to the GitHub Actions runner # Checkout the repository to the GitHub Actions runner
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
# Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis # Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis
- name: Run Codacy Analysis CLI - name: Run Codacy Analysis CLI
uses: codacy/codacy-analysis-cli-action@33d455949345bddfdb845fba76b57b70cc83754b uses: codacy/codacy-analysis-cli-action@33d455949345bddfdb845fba76b57b70cc83754b
with: with:
# Check https://github.com/codacy/codacy-analysis-cli#project-token # Check https://github.com/codacy/codacy-analysis-cli#project-token to get your project token from your Codacy repository
# to get your project token from your Codacy repository
# You can also omit the token and run the tools that support default configurations # You can also omit the token and run the tools that support default configurations
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
verbose: true verbose: true
@ -53,6 +53,7 @@ jobs:
# Force 0 exit code to allow SARIF file generation # Force 0 exit code to allow SARIF file generation
# This will handover control about PR rejection to the GitHub side # This will handover control about PR rejection to the GitHub side
max-allowed-issues: 2147483647 max-allowed-issues: 2147483647
# Upload the SARIF file generated in the previous step # Upload the SARIF file generated in the previous step
- name: Upload SARIF results file - name: Upload SARIF results file
uses: github/codeql-action/upload-sarif@v3 uses: github/codeql-action/upload-sarif@v3

@ -1,4 +1,3 @@
---
# For most projects, this workflow file will not need changing; you simply need # For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository. # to commit it to your repository.
# #
@ -11,14 +10,16 @@
# supported CodeQL languages. # supported CodeQL languages.
# #
name: "CodeQL" name: "CodeQL"
on: on:
push: push:
branches: ["master"] branches: [ "master" ]
pull_request: pull_request:
# The branches below must be a subset of the branches above # The branches below must be a subset of the branches above
branches: ["master"] branches: [ "master" ]
schedule: schedule:
- cron: '33 12 * * 5' - cron: '33 12 * * 5'
jobs: jobs:
analyze: analyze:
name: Analyze name: Analyze
@ -33,42 +34,49 @@ jobs:
actions: read actions: read
contents: read contents: read
security-events: write security-events: write
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
language: ['python'] language: [ 'python' ]
# CodeQL supports [ 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' ] # CodeQL supports [ 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' ]
# Use only 'java-kotlin' to analyze code written in Java, Kotlin or both # Use only 'java-kotlin' to analyze code written in Java, Kotlin or both
# Use only 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both # Use only 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL # Initializes the CodeQL tools for scanning.
uses: github/codeql-action/init@v3 - name: Initialize CodeQL
with: uses: github/codeql-action/init@v3
languages: ${{ matrix.language }} with:
# If you wish to specify custom queries, you can do so here or in a config file. languages: ${{ matrix.language }}
# By default, queries listed here will override any specified in a config file. # If you wish to specify custom queries, you can do so here or in a config file.
# Prefix the list here with "+" to use these queries and those in the config file. # By default, queries listed here will override any specified in a config file.
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift). # Prefix the list here with "+" to use these queries and those in the config file.
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# For more details on CodeQL's query packs, refer to:
# https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality # queries: security-extended,security-and-quality
uses: github/codeql-action/autobuild@v3
# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh
- name: Perform CodeQL Analysis
# Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
# If the Autobuild fails above, remove it and uncomment the following three lines. # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. # If this step fails, then you should remove it and run the build manually (see below)
uses: github/codeql-action/analyze@v3 - name: Autobuild
with: uses: github/codeql-action/autobuild@v3
category: "/language:${{matrix.language}}"
# Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"

@ -1,5 +1,5 @@
---
name: Docs WorkAgent name: Docs WorkAgent
on: on:
push: push:
branches: branches:
@ -11,8 +11,10 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: ./.github/library/setup - uses: actions/setup-python@v5
with:
python-version: 3.x
- run: pip install mkdocs-material - run: pip install mkdocs-material
- run: pip install mkdocs-glightbox - run: pip install mkdocs-glightbox
- run: pip install "mkdocstrings[python]" - run: pip install "mkdocstrings[python]"
- run: mkdocs gh-deploy --force - run: mkdocs gh-deploy --force

@ -1,20 +1,22 @@
---
# This workflow will triage pull requests and apply a label based on the # This workflow will triage pull requests and apply a label based on the
# paths that are modified in the pull request. # paths that are modified in the pull request.
# #
# To use this workflow, you will need to set up a .github/labeler.yml # To use this workflow, you will need to set up a .github/labeler.yml
# file with configuration. For more information, see: # file with configuration. For more information, see:
# https://github.com/actions/labeler # https://github.com/actions/labeler
name: Labeler name: Labeler
on: [pull_request_target] on: [pull_request_target]
jobs: jobs:
label: label:
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
contents: read contents: read
pull-requests: write pull-requests: write
steps: steps:
- uses: actions/labeler@v5 - uses: actions/labeler@v5
with: with:
repo-token: "${{ secrets.GITHUB_TOKEN }}" repo-token: "${{ secrets.GITHUB_TOKEN }}"
sync-labels: true

@ -1,42 +1,27 @@
---
name: Lint name: Lint
on: [push, pull_request]
on: [push, pull_request] # yamllint disable-line rule:truthy
jobs: jobs:
yaml-lint: yaml-lint:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - name: Check out source repository
- uses: ./.github/library/setup uses: actions/checkout@v4
- name: yaml Lint - name: yaml Lint
uses: ibiqlik/action-yamllint@v3 uses: ibiqlik/action-yamllint@v3
with:
file_or_dir: ${{ github.workspace }}
flake8-lint: flake8-lint:
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: flake8 Lint name: flake8 Lint
steps: steps:
- uses: actions/checkout@v4 - name: Check out source repository
- uses: ./.github/library/setup uses: actions/checkout@v4
- name: Set up Python environment - name: Set up Python environment
uses: py-actions/flake8@v2 uses: py-actions/flake8@v2
with:
args: --verbose
ruff-lint: ruff-lint:
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: ruff Lint name: ruff Lint
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: ./.github/library/setup
- uses: chartboost/ruff-action@v1 - uses: chartboost/ruff-action@v1
pylint-lint:
runs-on: ubuntu-latest
name: pylint Lint
steps:
- uses: actions/checkout@v4
- uses: ./.github/library/setup
- name: Install dependencies
run: |
pip install pylint
- name: Analysing the code with pylint
run: |
pylint $(git ls-files '*.py')

@ -0,0 +1,15 @@
name: "PR Labeler"
on:
pull_request_target:
types: ["opened", "reopened", "ready_for_review"]
jobs:
triage:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v5
if: ${{ github.event.pull_request.draft == false }}

@ -0,0 +1,30 @@
name: Pull Request Checks
on:
pull_request:
branches:
- master
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install dependencies
run: |
pip install -r requirements.txt
pip install swarms
pip install pytest
- name: Run tests and checks
run: |
pytest
pylint swarms

@ -1,4 +1,3 @@
---
name: readthedocs/actions name: readthedocs/actions
on: on:
pull_request_target: pull_request_target:
@ -6,12 +5,14 @@ on:
- opened - opened
paths: paths:
- "docs/**" - "docs/**"
permissions: permissions:
pull-requests: write pull-requests: write
jobs: jobs:
pull-request-links: pull-request-links:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: readthedocs/actions/preview@v1 - uses: readthedocs/actions/preview@v1
with: with:
project-slug: swarms project-slug: swarms

@ -0,0 +1,23 @@
name: Pylint
on: [push]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint
- name: Analysing the code with pylint
run: |
pylint $(git ls-files '*.py')

@ -0,0 +1,39 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Python application
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest swarms
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest

@ -0,0 +1,41 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Python package
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade swarms
python -m pip install flake8 pytest swarms
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest

@ -1,16 +1,27 @@
---
name: Upload Python Package name: Upload Python Package
on:
on: # yamllint disable-line rule:truthy
release: release:
types: [published] types: [published]
permissions: permissions:
contents: read contents: read
jobs: jobs:
deploy: deploy:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: ./.github/library/setup - name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package - name: Build package
run: python -m build run: python -m build
- name: Publish package - name: Publish package

@ -1,49 +1,27 @@
---
# This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time. # This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time.
# #
# You can adjust the behavior by modifying this file. # You can adjust the behavior by modifying this file.
# For more information, see: # For more information, see:
# https://github.com/actions/stale # https://github.com/actions/stale
name: Mark stale issues and pull requests name: Mark stale issues and pull requests
on: on:
schedule: schedule:
# Scheduled to run at 1.30 UTC everyday - cron: '26 12 * * *'
- cron: "30 1 * * *"
jobs: jobs:
stale: stale:
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
issues: write issues: write
pull-requests: write pull-requests: write
steps:
- uses: actions/stale@v9
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
days-before-issue-stale: 14
days-before-issue-close: 14
stale-issue-label: "status:stale"
close-issue-reason: not_planned
any-of-labels: "status:awaiting user response,status:more data needed"
stale-issue-message: >
Marking this issue as stale since it has been open for 14 days with no activity. This issue
will be closed if no further activity occurs.
close-issue-message: > steps:
This issue was closed because it has been inactive for 28 days. Please post a new issue if - uses: actions/stale@v9
you need further assistance. Thanks! with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
days-before-pr-stale: 14 stale-issue-message: 'Stale issue message'
days-before-pr-close: 14 stale-pr-message: 'Stale pull request message'
stale-pr-label: "status:stale" stale-issue-label: 'no-issue-activity'
stale-pr-message: > stale-pr-label: 'no-pr-activity'
Marking this pull request as stale since it has been open for 14 days with no activity. This
PR will be closed if no further activity occurs.
close-pr-message: >
This pull request was closed because it has been inactive for 28 days. Please open a new
pull request if you need furtherassistance. Thanks!
# Label that can be assigned to issues to exclude them from being marked as stale
exempt-issue-labels: "override-stale"
# Label that can be assigned to PRs to exclude them from being marked as stale
exempt-pr-labels: "override-stale"

@ -0,0 +1,49 @@
# This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time.
#
# You can adjust the behavior by modifying this file.
# For more information, see:
# https://github.com/actions/stale
name: Mark stale issues and pull requests
on:
schedule:
# Scheduled to run at 1.30 UTC everyday
- cron: '30 1 * * *'
jobs:
stale:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/stale@v9
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
days-before-issue-stale: 14
days-before-issue-close: 14
stale-issue-label: "status:stale"
close-issue-reason: not_planned
any-of-labels: "status:awaiting user response,status:more data needed"
stale-issue-message: >
Marking this issue as stale since it has been open for 14 days with no activity.
This issue will be closed if no further activity occurs.
close-issue-message: >
This issue was closed because it has been inactive for 28 days.
Please post a new issue if you need further assistance. Thanks!
days-before-pr-stale: 14
days-before-pr-close: 14
stale-pr-label: "status:stale"
stale-pr-message: >
Marking this pull request as stale since it has been open for 14 days with no activity.
This PR will be closed if no further activity occurs.
close-pr-message: >
This pull request was closed because it has been inactive for 28 days.
Please open a new pull request if you need further assistance. Thanks!
# Label that can be assigned to issues to exclude them from being marked as stale
exempt-issue-labels: 'override-stale'
# Label that can be assigned to PRs to exclude them from being marked as stale
exempt-pr-labels: "override-stale"

@ -1,16 +1,110 @@
--- name: test
name: build
on: [push, pull_request] on:
push:
branches: [master]
pull_request:
workflow_dispatch:
env:
POETRY_VERSION: "1.4.2"
jobs: jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
test_type:
- "core"
- "extended"
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: "snok/install-poetry@v1"
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
shell: bash
name: Python ${{ matrix.python-version }} ${{ matrix.test_type }}
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: "./.github/actions/poetry_setup"
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
shell: bash
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
test_type:
- "core"
- "extended"
name: Python ${{ matrix.python-version }} ${{ matrix.test_type }}
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: ./.github/library/setup - name: Set up Python ${{ matrix.python-version }}
- name: Install dependencies uses: "./.github/actions/poetry_setup"
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: | run: |
pip install pytest if [ "${{ matrix.test_type }}" == "core" ]; then
- name: Run Python unit tests make test
run: pytest else
- name: Verify that the Docker image for the action builds make extended_tests
run: docker build . --file Dockerfile fi
shell: bash

@ -1,28 +1,81 @@
---
# Notebook-related checks # Notebook-related checks
name: Presubmit checks name: Presubmit checks
on: [push, pull_request]
on:
# Relevant PRs
pull_request:
paths:
- "swarms/**"
- "tests/**"
# Allow manual runs
workflow_dispatch:
jobs: jobs:
# Disabled until google/pytype/issues/151 is resolved test3_11:
# pytype3_10: name: Test Py3.11
# name: pytype 3.10 runs-on: ubuntu-latest
# runs-on: ubuntu-latest steps:
# steps: - uses: actions/checkout@v4
# - uses: actions/checkout@v4 - uses: actions/setup-python@v5
# - uses: ./.github/library/setup with:
# - name: Install pytype python-version: '3.11'
# run: pip install -q pytype - name: Run tests
# - name: Run pytype run: |
# run: pytype ./swarms python --version
pip install .[dev]
python -m pytest
test3_10:
name: Test Py3.10
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Run tests
run: |
python --version
pip install -q .[dev]
python -m pytest
test3_9:
name: Test Py3.9
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Run tests
run: |
python --version
pip install .[dev]
python -m pytest
pytype3_10:
name: pytype 3.10
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Run pytype
run: |
python --version
pip install .[dev]
pip install -q gspread ipython
pytype
format: format:
name: Check format with black name: Check format with black
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: ./.github/library/setup - uses: actions/setup-python@v5
- name: Check format with:
run: | python-version: '3.11'
python --version - name: Check format
pip install -q . run: |
pip install -q black python --version
black . --check pip install -q .
pip install -q black
black . --check

@ -0,0 +1,27 @@
name: Unit Tests
on:
push:
branches:
- master
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
run: |
pip install -r requirements.txt
pip install pytest
- name: Run unit tests
run: pytest

@ -0,0 +1,36 @@
name: build
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Install dependencies
run: |
pip install -r requirements.txt
pip install pytest
pip install swarms
- name: Run Python unit tests
run: pytest
- name: Verify that the Docker image for the action builds
run: docker build . --file Dockerfile
- name: Verify integration test results
run: pytest

@ -1,10 +1,11 @@
---
name: Welcome WorkAgent name: Welcome WorkAgent
on: on:
issues: issues:
types: [opened] types: [opened]
pull_request_target: pull_request_target:
types: [opened] types: [opened]
jobs: jobs:
build: build:
name: 👋 Welcome name: 👋 Welcome
@ -14,10 +15,5 @@ jobs:
- uses: actions/first-interaction@v1.3.0 - uses: actions/first-interaction@v1.3.0
with: with:
repo-token: ${{ secrets.GITHUB_TOKEN }} repo-token: ${{ secrets.GITHUB_TOKEN }}
issue-message: > issue-message: "Hello there, thank you for opening an Issue ! 🙏🏻 The team was notified and they will get back to you asap."
Hello there, thank you for opening an Issue ! 🙏🏻 The team was notified and they will get back pr-message: "Hello there, thank you for opening an PR ! 🙏🏻 The team was notified and they will get back to you asap."
to you asap.
pr-message: >-
Hello there, thank you for opening an PR ! 🙏🏻 The team was notified and they will get back
to you asap.

@ -1,19 +1,18 @@
---
repos: repos:
- repo: https://github.com/ambv/black - repo: https://github.com/ambv/black
rev: 22.3.0 rev: 22.3.0
hooks: hooks:
- id: black - id: black
- repo: https://github.com/charliermarsh/ruff-pre-commit - repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.255' rev: 'v0.0.255'
hooks: hooks:
- id: ruff - id: ruff
args: ['----unsafe-fixes'] args: [----unsafe-fixes]
- repo: https://github.com/nbQA-dev/nbQA - repo: https://github.com/nbQA-dev/nbQA
rev: 1.6.3 rev: 1.6.3
hooks: hooks:
- id: nbqa-black - id: nbqa-black
additional_dependencies: [ipython==8.12, black] additional_dependencies: [ipython==8.12, black]
- id: nbqa-ruff - id: nbqa-ruff
args: ["--ignore=I001"] args: ["--ignore=I001"]
additional_dependencies: [ipython==8.12, ruff] additional_dependencies: [ipython==8.12, ruff]

@ -1,11 +1,13 @@
---
version: 2 version: 2
build: build:
os: ubuntu-22.04 os: ubuntu-22.04
tools: tools:
python: "3.11" python: "3.11"
mkdocs: mkdocs:
configuration: mkdocs.yml configuration: mkdocs.yml
python: python:
install: install:
- requirements: requirements.txt - requirements: requirements.txt

@ -1,6 +0,0 @@
---
formatter:
type: basic
include_document_start: true
max_line_length: 100
pad_line_comments: 2

@ -1,14 +0,0 @@
---
extends: default
rules:
line-length:
max: 127
truthy:
# GitHub Actions
check-keys: false
ignore:
# GH Actions
- lib
- .venv

@ -30,7 +30,6 @@ This guide is intended for developers and contributors to the `swarms` project w
## Prerequisites ## Prerequisites
Before you begin, ensure you have: Before you begin, ensure you have:
- A GitHub account - A GitHub account
- Git installed on your machine - Git installed on your machine
- Basic command-line proficiency - Basic command-line proficiency
@ -116,13 +115,14 @@ docker run -it --rm swarms-dev
- Introduce Docker Compose and its role in simplifying multi-container setups. - Introduce Docker Compose and its role in simplifying multi-container setups.
- Create a `docker-compose.yml` file for the `swarms` project. - Create a `docker-compose.yml` file for the `swarms` project.
## Dockerfile ## Dockerfile
Creating a Dockerfile for deploying the `swarms` framework to the cloud involves setting up the necessary environment to run your Python application, ensuring all dependencies are installed, and configuring the container to execute the desired tasks. Here's an example Dockerfile that sets up such an environment: Creating a Dockerfile for deploying the `swarms` framework to the cloud involves setting up the necessary environment to run your Python application, ensuring all dependencies are installed, and configuring the container to execute the desired tasks. Here's an example Dockerfile that sets up such an environment:
```Dockerfile ```Dockerfile
# Use an official Python runtime as a parent image # Use an official Python runtime as a parent image
FROM python:3.10-slim FROM python:3.9-slim
# Set environment variables # Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONDONTWRITEBYTECODE 1
@ -194,4 +194,4 @@ For deploying to the cloud, you'll need to push your Docker image to a container
- Setting up networking, storage, and other cloud resources. - Setting up networking, storage, and other cloud resources.
- Monitoring, logging, and potentially scaling your containers. - Monitoring, logging, and potentially scaling your containers.
Remember to secure sensitive data, use tagged releases for your images, and follow best practices for operating in the cloud. Remember to secure sensitive data, use tagged releases for your images, and follow best practices for operating in the cloud.

@ -19,7 +19,7 @@ python -m pip install --upgrade revChatGPT
``` ```
**Supported Python Versions:** **Supported Python Versions:**
- Minimum: Python3.10 - Minimum: Python3.9
- Recommended: Python3.11+ - Recommended: Python3.11+
### Initial Setup and Configuration <a name="initial-setup"></a> ### Initial Setup and Configuration <a name="initial-setup"></a>

@ -16,7 +16,7 @@ Swarms provides you with all the building blocks you need to build reliable, pro
## 💻 Install ## 💻 Install
You can install `swarms` with pip in a You can install `swarms` with pip in a
[**Python>=3.10**](https://www.python.org/) environment. [**Python>=3.8**](https://www.python.org/) environment.
!!! example "pip install (recommended)" !!! example "pip install (recommended)"

@ -1,6 +1,6 @@
from swarms import Agent, OpenAIChat from swarms import Agent, OpenAIChat
# Initialize the workflow ## Initialize the workflow
agent = Agent( agent = Agent(
llm=OpenAIChat(), llm=OpenAIChat(),
max_loops=1, max_loops=1,

@ -1,4 +1,3 @@
---
site_name: Swarms Docs site_name: Swarms Docs
plugins: plugins:
- glightbox - glightbox
@ -17,15 +16,15 @@ extra:
- icon: fontawesome/brands/python - icon: fontawesome/brands/python
link: https://pypi.org/project/Swarms/ link: https://pypi.org/project/Swarms/
theme: theme:
name: material name: material
custom_dir: docs/overrides custom_dir: docs/overrides
logo: assets/img/SwarmsLogoIcon.png logo: assets/img/SwarmsLogoIcon.png
palette: palette:
# Palette toggle for light mode # Palette toggle for light mode
- scheme: default - scheme: default
primary: black primary: black
toggle: toggle:
icon: material/brightness-7 icon: material/brightness-7
name: Switch to dark mode name: Switch to dark mode
# Palette toggle for dark mode # Palette toggle for dark mode
- scheme: slate - scheme: slate
@ -33,14 +32,14 @@ theme:
toggle: toggle:
icon: material/brightness-4 icon: material/brightness-4
name: Switch to light mode name: Switch to light mode
features: features:
- content.code.copy - content.code.copy
- content.code.annotate - content.code.annotate
- navigation.tabs - navigation.tabs
- navigation.sections - navigation.sections
- navigation.expand - navigation.expand
- navigation.top - navigation.top
- announce.dismiss - announce.dismiss
markdown_extensions: markdown_extensions:
- pymdownx.highlight: - pymdownx.highlight:
anchor_linenums: true anchor_linenums: true
@ -56,126 +55,127 @@ markdown_extensions:
- def_list - def_list
- footnotes - footnotes
nav: nav:
- Home: - Home:
- Overview: "index.md" - Overview: "index.md"
- Contributing: "contributing.md" - Contributing: "contributing.md"
- Swarms: - Limitations of Individual Agents: "limits_of_individual_agents.md"
- Overview: "swarms/index.md" - Swarms:
- swarms.agents: - Overview: "swarms/index.md"
- Agents: - swarms.agents:
- WorkerAgent: "swarms/agents/workeragent.md" - Agents:
- OmniAgent: "swarms/agents/omni_agent.md" - WorkerAgent: "swarms/agents/workeragent.md"
- AbstractAgent: "swarms/agents/abstractagent.md" - OmniAgent: "swarms/agents/omni_agent.md"
- ToolAgent: "swarms/agents/toolagent.md" - AbstractAgent: "swarms/agents/abstractagent.md"
- swarms.models: - ToolAgent: "swarms/agents/toolagent.md"
- Language: - swarms.models:
- BaseLLM: "swarms/models/base_llm.md" - Language:
- Overview: "swarms/models/index.md" - BaseLLM: "swarms/models/base_llm.md"
- HuggingFaceLLM: "swarms/models/huggingface.md" - Overview: "swarms/models/index.md"
- Anthropic: "swarms/models/anthropic.md" - HuggingFaceLLM: "swarms/models/huggingface.md"
- OpenAI: "swarms/models/openai.md" - Anthropic: "swarms/models/anthropic.md"
- Zephyr: "swarms/models/zephyr.md" - OpenAI: "swarms/models/openai.md"
- BioGPT: "swarms/models/biogpt.md" - Zephyr: "swarms/models/zephyr.md"
- vLLM: "swarms/models/vllm.md" - BioGPT: "swarms/models/biogpt.md"
- MPT7B: "swarms/models/mpt.md" - vLLM: "swarms/models/vllm.md"
- Mistral: "swarms/models/mistral.md" - MPT7B: "swarms/models/mpt.md"
- Mixtral: "swarms/models/mixtral.md" - Mistral: "swarms/models/mistral.md"
- MultiModal: - Mixtral: "swarms/models/mixtral.md"
- BaseMultiModalModel: "swarms/models/base_multimodal_model.md" - MultiModal:
- Fuyu: "swarms/models/fuyu.md" - BaseMultiModalModel: "swarms/models/base_multimodal_model.md"
- Vilt: "swarms/models/vilt.md" - Fuyu: "swarms/models/fuyu.md"
- Idefics: "swarms/models/idefics.md" - Vilt: "swarms/models/vilt.md"
- BingChat: "swarms/models/bingchat.md" - Idefics: "swarms/models/idefics.md"
- Kosmos: "swarms/models/kosmos.md" - BingChat: "swarms/models/bingchat.md"
- Nougat: "swarms/models/nougat.md" - Kosmos: "swarms/models/kosmos.md"
- Dalle3: "swarms/models/dalle3.md" - Nougat: "swarms/models/nougat.md"
- GPT4V: "swarms/models/gpt4v.md" - Dalle3: "swarms/models/dalle3.md"
- LayoutLMDocumentQA: "swarms/models/layoutlm_document_qa.md" - GPT4V: "swarms/models/gpt4v.md"
- DistilWhisperModel: "swarms/models/distilled_whisperx.md" - LayoutLMDocumentQA: "swarms/models/layoutlm_document_qa.md"
- ElevenLabsText2SpeechTool: "swarms/models/elevenlabs.md" - DistilWhisperModel: "swarms/models/distilled_whisperx.md"
- OpenAITTS: "swarms/models/openai_tts.md" - ElevenLabsText2SpeechTool: "swarms/models/elevenlabs.md"
- Gemini: "swarms/models/gemini.md" - OpenAITTS: "swarms/models/openai_tts.md"
- ZeroscopeTTV: "swarms/models/zeroscope.md" - Gemini: "swarms/models/gemini.md"
- swarms.structs: - ZeroscopeTTV: "swarms/models/zeroscope.md"
- Foundational Structures: - swarms.structs:
- agent: "swarms/structs/agent.md" - Foundational Structures:
- basestructure: "swarms/structs/basestructure.md" - agent: "swarms/structs/agent.md"
- artifactupload: "swarms/structs/artifactupload.md" - basestructure: "swarms/structs/basestructure.md"
- taskinput: "swarms/structs/taskinput.md" - artifactupload: "swarms/structs/artifactupload.md"
- stepinput: "swarms/structs/stepinput.md" - taskinput: "swarms/structs/taskinput.md"
- artifact: "swarms/structs/artifact.md" - stepinput: "swarms/structs/stepinput.md"
- task: "swarms/structs/task.md" - artifact: "swarms/structs/artifact.md"
- Task Queue Base: "swarms/structs/taskqueuebase.md" - task: "swarms/structs/task.md"
- Workflows: - Task Queue Base: "swarms/structs/taskqueuebase.md"
- recursiveworkflow: "swarms/structs/recursiveworkflow.md" - Workflows:
- concurrentworkflow: "swarms/structs/concurrentworkflow.md" - recursiveworkflow: "swarms/structs/recursiveworkflow.md"
- nonlinearworkflow: "swarms/structs/nonlinearworkflow.md" - concurrentworkflow: "swarms/structs/concurrentworkflow.md"
- sequential_workflow: "swarms/structs/sequential_workflow.md" - nonlinearworkflow: "swarms/structs/nonlinearworkflow.md"
- workflow: "swarms/structs/workflow.md" - sequential_workflow: "swarms/structs/sequential_workflow.md"
- baseworkflow: "swarms/structs/baseworkflow.md" - workflow: "swarms/structs/workflow.md"
- Multi Agent Architectures: - baseworkflow: "swarms/structs/baseworkflow.md"
- conversation: "swarms/structs/conversation.md" - Multi Agent Architectures:
- groupchat: "swarms/structs/groupchat.md" - conversation: "swarms/structs/conversation.md"
- swarmnetwork: "swarms/structs/swarmnetwork.md" - groupchat: "swarms/structs/groupchat.md"
- groupchatmanager: "swarms/structs/groupchatmanager.md" - swarmnetwork: "swarms/structs/swarmnetwork.md"
- MajorityVoting: "swarms/structs/majorityvoting.md" - groupchatmanager: "swarms/structs/groupchatmanager.md"
- swarms.tokenizers: - MajorityVoting: "swarms/structs/majorityvoting.md"
- Language: - swarms.tokenizers:
- Tokenizer: "swarms/tokenizers/tokenizer.md" - Language:
- CohereTokenizer: "swarms/tokenizers/coheretokenizer.md" - Tokenizer: "swarms/tokenizers/tokenizer.md"
- BaseTokenizer: "swarms/tokenizers/basetokenizer.md" - CohereTokenizer: "swarms/tokenizers/coheretokenizer.md"
- HuggingfaceTokenizer: "swarms/tokenizers/huggingfacetokenizer.md" - BaseTokenizer: "swarms/tokenizers/basetokenizer.md"
- SentencepieceTokenizer: "swarms/tokenizers/sentencepiecetokenizer.md" - HuggingfaceTokenizer: "swarms/tokenizers/huggingfacetokenizer.md"
- AnthropicTokenizer: "swarms/tokenizers/anthropictokenizer.md" - SentencepieceTokenizer: "swarms/tokenizers/sentencepiecetokenizer.md"
- OpenaiTokenizer: "swarms/tokenizers/openaitokenizer.md" - AnthropicTokenizer: "swarms/tokenizers/anthropictokenizer.md"
- swarms.memory: - OpenaiTokenizer: "swarms/tokenizers/openaitokenizer.md"
- Vector Databases: - swarms.memory:
- Weaviate: "swarms/memory/weaviate.md" - Vector Databases:
- PineconeDB: "swarms/memory/pinecone.md" - Weaviate: "swarms/memory/weaviate.md"
- PGVectorStore: "swarms/memory/pg.md" - PineconeDB: "swarms/memory/pinecone.md"
- ShortTermMemory: "swarms/memory/short_term_memory.md" - PGVectorStore: "swarms/memory/pg.md"
- swarms.utils: - ShortTermMemory: "swarms/memory/short_term_memory.md"
- Misc: - swarms.utils:
- pdf_to_text: "swarms/utils/pdf_to_text.md" - Misc:
- load_model_torch: "swarms/utils/load_model_torch.md" - pdf_to_text: "swarms/utils/pdf_to_text.md"
- metrics_decorator: "swarms/utils/metrics_decorator.md" - load_model_torch: "swarms/utils/load_model_torch.md"
- prep_torch_inference: "swarms/utils/prep_torch_inference.md" - metrics_decorator: "swarms/utils/metrics_decorator.md"
- find_image_path: "swarms/utils/find_image_path.md" - prep_torch_inference: "swarms/utils/prep_torch_inference.md"
- print_class_parameters: "swarms/utils/print_class_parameters.md" - find_image_path: "swarms/utils/find_image_path.md"
- extract_code_from_markdown: "swarms/utils/extract_code_from_markdown.md" - print_class_parameters: "swarms/utils/print_class_parameters.md"
- check_device: "swarms/utils/check_device.md" - extract_code_from_markdown: "swarms/utils/extract_code_from_markdown.md"
- display_markdown_message: "swarms/utils/display_markdown_message.md" - check_device: "swarms/utils/check_device.md"
- phoenix_tracer: "swarms/utils/phoenix_tracer.md" - display_markdown_message: "swarms/utils/display_markdown_message.md"
- limit_tokens_from_string: "swarms/utils/limit_tokens_from_string.md" - phoenix_tracer: "swarms/utils/phoenix_tracer.md"
- math_eval: "swarms/utils/math_eval.md" - limit_tokens_from_string: "swarms/utils/limit_tokens_from_string.md"
- Guides: - math_eval: "swarms/utils/math_eval.md"
- Overview: "examples/index.md" - Guides:
- Agents: - Overview: "examples/index.md"
- Agent: "examples/flow.md" - Agents:
- OmniAgent: "examples/omni_agent.md" - Agent: "examples/flow.md"
- Swarms: - OmniAgent: "examples/omni_agent.md"
- SequentialWorkflow: "examples/reliable_autonomous_agents.md" - Swarms:
- 2O+ Autonomous Agent Blogs: "examples/ideas.md" - SequentialWorkflow: "examples/reliable_autonomous_agents.md"
- Applications: - 2O+ Autonomous Agent Blogs: "examples/ideas.md"
- CustomerSupport: - Applications:
- Overview: "applications/customer_support.md" - CustomerSupport:
- Marketing: - Overview: "applications/customer_support.md"
- Overview: "applications/marketing_agencies.md" - Marketing:
- Corporate: - Overview: "applications/marketing_agencies.md"
- FAQ: "corporate/faq.md" - Corporate:
- Purpose: "corporate/purpose.md" - FAQ: "corporate/faq.md"
- Roadmap: "corporate/roadmap.md" - Purpose: "corporate/purpose.md"
- Weaknesses: "corporate/failures.md" - Roadmap: "corporate/roadmap.md"
- Design: "corporate/design.md" - Weaknesses: "corporate/failures.md"
- Flywheel: "corporate/flywheel.md" - Design: "corporate/design.md"
- Bounties: "corporate/bounties.md" - Flywheel: "corporate/flywheel.md"
- Metric: "corporate/metric.md" - Bounties: "corporate/bounties.md"
- Distribution: "corporate/distribution" - Metric: "corporate/metric.md"
- Research: "corporate/research.md" - Distribution: "corporate/distribution"
- Demos: "corporate/demos.md" - Research: "corporate/research.md"
- Architecture: "corporate/architecture.md" - Demos: "corporate/demos.md"
- Checklist: "corporate/checklist.md" - Architecture: "corporate/architecture.md"
- Hiring: "corporate/hiring.md" - Checklist: "corporate/checklist.md"
- SwarmCloud: "corporate/swarm_cloud.md" - Hiring: "corporate/hiring.md"
- SwarmMemo: "corporate/swarm_memo.md" - SwarmCloud: "corporate/swarm_cloud.md"
- Data Room: "corporate/data_room.md" - SwarmMemo: "corporate/swarm_memo.md"
- Data Room: "corporate/data_room.md"

@ -2,12 +2,10 @@ import pandas as pd
from swarms import dataframe_to_text from swarms import dataframe_to_text
# # Example usage: # # Example usage:
df = pd.DataFrame( df = pd.DataFrame({
{ 'A': [1, 2, 3],
"A": [1, 2, 3], 'B': [4, 5, 6],
"B": [4, 5, 6], 'C': [7, 8, 9],
"C": [7, 8, 9], })
}
)
print(dataframe_to_text(df)) print(dataframe_to_text(df))

6085
poetry.lock generated

File diff suppressed because it is too large Load Diff

@ -10,37 +10,30 @@ description = "Swarms - Pytorch"
license = "MIT" license = "MIT"
authors = ["Kye Gomez <kye@apac.ai>"] authors = ["Kye Gomez <kye@apac.ai>"]
homepage = "https://github.com/kyegomez/swarms" homepage = "https://github.com/kyegomez/swarms"
documentation = "https://swarms.apac.ai" documentation = "https://swarms.apac.ai"
readme = "README.md" readme = "README.md" # Assuming you have a README.md
repository = "https://github.com/kyegomez/swarms" repository = "https://github.com/kyegomez/swarms"
keywords = [ keywords = ["artificial intelligence", "deep learning", "optimizers", "Prompt Engineering", "swarms", "agents"]
"artificial intelligence",
"deep learning",
"optimizers",
"Prompt Engineering",
"swarms",
"agents",
]
classifiers = [ classifiers = [
"Development Status :: 4 - Beta", "Development Status :: 4 - Beta",
"Intended Audience :: Developers", "Intended Audience :: Developers",
"Topic :: Scientific/Engineering :: Artificial Intelligence", "Topic :: Scientific/Engineering :: Artificial Intelligence",
"License :: OSI Approved :: MIT License", "License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.10"
] ]
[tool.poetry.dependencies] [tool.poetry.dependencies]
python = ">=3.10,<3.12" python = "^3.6.1"
torch = "2.1.1" torch = "2.1.1"
transformers = "4.38.1" transformers = "4.37.1"
openai = "1.3.0" openai = "0.28.0"
langchain = "0.0.333" langchain = "0.0.333"
asyncio = "3.4.3" asyncio = "3.4.3"
einops = "0.7.0" einops = "0.7.0"
google-generativeai = "0.3.1" google-generativeai = "0.3.1"
langchain-experimental = "0.0.10" langchain-experimental = "0.0.10"
tensorflow = "^2.15.0" tensorflow = "*"
weaviate-client = "3.25.3" weaviate-client = "3.25.3"
opencv-python-headless = "4.8.1.78" opencv-python-headless = "4.8.1.78"
faiss-cpu = "1.7.4" faiss-cpu = "1.7.4"
@ -62,7 +55,7 @@ cohere = "4.24"
huggingface-hub = "*" huggingface-hub = "*"
pydantic = "1.10.12" pydantic = "1.10.12"
tenacity = "8.2.2" tenacity = "8.2.2"
Pillow = "10.2.0" Pillow = "9.4.0"
chromadb = "*" chromadb = "*"
termcolor = "2.2.0" termcolor = "2.2.0"
black = "23.3.0" black = "23.3.0"
@ -93,12 +86,9 @@ types-chardet = "^5.0.4.6"
mypy-protobuf = "^3.0.0" mypy-protobuf = "^3.0.0"
[tool.poetry.group.test.dependencies]
pytest = "^8.0.2"
[tool.autopep8] [tool.autopep8]
max_line_length = 70 max_line_length = 70
ignore = "E501,W6" # or ["E501", "W6"] ignore = "E501,W6" # or ["E501", "W6"]
in-place = true in-place = true
recursive = true recursive = true
aggressive = 3 aggressive = 3
@ -113,4 +103,4 @@ preview = true
[tool.poetry.scripts] [tool.poetry.scripts]
swarms = 'swarms.cli._cli:main' swarms = 'swarms.cli._cli:main'

@ -1,2 +0,0 @@
[pytest]
testpaths = tests

@ -1,10 +0,0 @@
exclude = ["./playground", "./tests", "./scripts"]
line-length = 127
[lint]
ignore = ["E203"]
select = ["E", "F", "W"]
[lint.per-file-ignores]
"./swarms/prompts/**.py" = ["E501", "W291", "W293"]
"./swarms/__init__.py" = ["F401"]

@ -23,12 +23,9 @@ class TextArtifact(BaseArtifact):
Methods: Methods:
__add__(self, other: BaseArtifact) -> TextArtifact: Concatenates the text value of the artifact with another artifact. __add__(self, other: BaseArtifact) -> TextArtifact: Concatenates the text value of the artifact with another artifact.
__bool__(self) -> bool: Checks if the text value of the artifact is non-empty. __bool__(self) -> bool: Checks if the text value of the artifact is non-empty.
generate_embedding(self, driver: BaseEmbeddingModel) -> Optional[list[float]]: generate_embedding(self, driver: BaseEmbeddingModel) -> Optional[list[float]]: Generates the embedding of the text artifact using a given embedding model.
Generates the embedding of the text artifact using a given embedding model. token_count(self, tokenizer: BaseTokenizer) -> int: Counts the number of tokens in the text artifact using a given tokenizer.
token_count(self, tokenizer: BaseTokenizer) -> int: to_bytes(self) -> bytes: Converts the text value of the artifact to bytes using the specified encoding and error handler.
Counts the number of tokens in the text artifact using a given tokenizer.
to_bytes(self) -> bytes:
Converts the text value of the artifact to bytes using the specified encoding and error handler.
""" """
value: str value: str

@ -7,8 +7,7 @@ class InternalMemoryBase(ABC):
"""Abstract base class for internal memory of agents in the swarm.""" """Abstract base class for internal memory of agents in the swarm."""
def __init__(self, n_entries): def __init__(self, n_entries):
"""Initialize the internal memory. """Initialize the internal memory. In the current architecture the memory always consists of a set of soltuions or evaluations.
In the current architecture the memory always consists of a set of soltuions or evaluations.
During the operation, the agent should retrivie best solutions from it's internal memory based on the score. During the operation, the agent should retrivie best solutions from it's internal memory based on the score.
Moreover, the project is designed around LLMs for the proof of concepts, so we treat all entry content as a string. Moreover, the project is designed around LLMs for the proof of concepts, so we treat all entry content as a string.
@ -29,8 +28,7 @@ class InternalMemoryBase(ABC):
class DictInternalMemory(InternalMemoryBase): class DictInternalMemory(InternalMemoryBase):
def __init__(self, n_entries: int): def __init__(self, n_entries: int):
""" """
Initialize the internal memory. Initialize the internal memory. In the current architecture the memory always consists of a set of solutions or evaluations.
In the current architecture the memory always consists of a set of solutions or evaluations.
Simple key-value store for now. Simple key-value store for now.
Args: Args:

@ -16,15 +16,13 @@ class DictSharedMemory:
Methods: Methods:
__init__(self, file_loc: str = None) -> None: Initializes the shared memory. __init__(self, file_loc: str = None) -> None: Initializes the shared memory.
add_entry(self, score: float, agent_id: str, agent_cycle: int, entry: Any) -> bool: add_entry(self, score: float, agent_id: str, agent_cycle: int, entry: Any) -> bool: Adds an entry to the internal memory.
Adds an entry to the internal memory.
get_top_n(self, n: int) -> None: Gets the top n entries from the internal memory. get_top_n(self, n: int) -> None: Gets the top n entries from the internal memory.
write_to_file(self, data: Dict[str, Dict[str, Any]]) -> bool: Writes the internal memory to a file. write_to_file(self, data: Dict[str, Dict[str, Any]]) -> bool: Writes the internal memory to a file.
""" """
def __init__(self, file_loc: str = None) -> None: def __init__(self, file_loc: str = None) -> None:
"""Initialize the shared memory. """Initialize the shared memory. In the current architecture the memory always consists of a set of soltuions or evaluations.
In the current architecture the memory always consists of a set of soltuions or evaluations.
Moreover, the project is designed around LLMs for the proof of concepts, so we treat all entry content as a string. Moreover, the project is designed around LLMs for the proof of concepts, so we treat all entry content as a string.
""" """
if file_loc is not None: if file_loc is not None:

@ -153,8 +153,7 @@ class LangchainChromaVectorMemory:
query (str): The query to search for. query (str): The query to search for.
k (int): The number of results to return. k (int): The number of results to return.
type (str): The type of search to perform: "cos" or "mmr". type (str): The type of search to perform: "cos" or "mmr".
distance_threshold (float): distance_threshold (float): The similarity threshold to use for the search. Results with distance > similarity_threshold will be dropped.
The similarity threshold to use for the search. Results with distance > similarity_threshold will be dropped.
Returns: Returns:
list[str]: A list of the top k results. list[str]: A list of the top k results.

@ -24,31 +24,13 @@ class PineconeDB(AbstractVectorDatabase):
index (pinecone.Index, optional): The Pinecone index to use. Defaults to None. index (pinecone.Index, optional): The Pinecone index to use. Defaults to None.
Methods: Methods:
upsert_vector( upsert_vector(vector: list[float], vector_id: Optional[str] = None, namespace: Optional[str] = None, meta: Optional[dict] = None, **kwargs) -> str:
vector: list[float],
vector_id: Optional[str] = None,
namespace: Optional[str] = None,
meta: Optional[dict] = None,
**kwargs
) -> str:
Upserts a vector into the index. Upserts a vector into the index.
load_entry( load_entry(vector_id: str, namespace: Optional[str] = None) -> Optional[BaseVectorStore.Entry]:
vector_id: str,
namespace: Optional[str] = None
) -> Optional[BaseVectorStore.Entry]:
Loads a single vector from the index. Loads a single vector from the index.
load_entries( load_entries(namespace: Optional[str] = None) -> list[BaseVectorStore.Entry]:
namespace: Optional[str] = None
) -> list[BaseVectorStore.Entry]:
Loads all vectors from the index. Loads all vectors from the index.
query( query(query: str, count: Optional[int] = None, namespace: Optional[str] = None, include_vectors: bool = False, include_metadata=True, **kwargs) -> list[BaseVectorStore.QueryResult]:
query: str,
count: Optional[int] = None,
namespace: Optional[str] = None,
include_vectors: bool = False,
include_metadata=True,
**kwargs
) -> list[BaseVectorStore.QueryResult]:
Queries the index for vectors similar to the given query string. Queries the index for vectors similar to the given query string.
create_index(name: str, **kwargs) -> None: create_index(name: str, **kwargs) -> None:
Creates a new index. Creates a new index.

@ -12,10 +12,8 @@ from swarms.models.clipq import CLIPQ # noqa: E402
# from swarms.models.whisperx_model import WhisperX # noqa: E402 # from swarms.models.whisperx_model import WhisperX # noqa: E402
# from swarms.models.kosmos_two import Kosmos # noqa: E402 # from swarms.models.kosmos_two import Kosmos # noqa: E402
# from swarms.models.cog_agent import CogAgent # noqa: E402 # from swarms.models.cog_agent import CogAgent # noqa: E402
# Function calling models ## Function calling models
from swarms.models.fire_function import ( from swarms.models.fire_function import FireFunctionCaller
FireFunctionCaller,
)
from swarms.models.fuyu import Fuyu # noqa: E402 from swarms.models.fuyu import Fuyu # noqa: E402
from swarms.models.gemini import Gemini # noqa: E402 from swarms.models.gemini import Gemini # noqa: E402
from swarms.models.gigabind import Gigabind # noqa: E402 from swarms.models.gigabind import Gigabind # noqa: E402
@ -52,7 +50,7 @@ from swarms.models.timm import TimmModel # noqa: E402
# ) # noqa: E402 # ) # noqa: E402
from swarms.models.together import TogetherLLM # noqa: E402 from swarms.models.together import TogetherLLM # noqa: E402
# Types ############## Types
from swarms.models.types import ( # noqa: E402 from swarms.models.types import ( # noqa: E402
AudioModality, AudioModality,
ImageModality, ImageModality,

@ -46,7 +46,7 @@ class AzureOpenAI(BaseOpenAI):
deployment_name: str | None = Field( deployment_name: str | None = Field(
default=None, alias="azure_deployment" default=None, alias="azure_deployment"
) )
"""A model deployment. """A model deployment.
If given sets the base client URL to include `/deployments/{azure_deployment}`. If given sets the base client URL to include `/deployments/{azure_deployment}`.
Note: this means you won't be able to use non-deployment endpoints. Note: this means you won't be able to use non-deployment endpoints.
@ -62,7 +62,7 @@ class AzureOpenAI(BaseOpenAI):
Automatically inferred from env var `AZURE_OPENAI_AD_TOKEN` if not provided. Automatically inferred from env var `AZURE_OPENAI_AD_TOKEN` if not provided.
For more: For more:
https://www.microsoft.com/en-us/security/business/identity-access/microsoft-entra-id. https://www.microsoft.com/en-us/security/business/identity-access/microsoft-entra-id.
""" # noqa: E501 """ # noqa: E501
azure_ad_token_provider: Callable[[], str] | None = None azure_ad_token_provider: Callable[[], str] | None = None
@ -73,7 +73,7 @@ class AzureOpenAI(BaseOpenAI):
openai_api_type: str = "" openai_api_type: str = ""
"""Legacy, for openai<1.0.0 support.""" """Legacy, for openai<1.0.0 support."""
validate_base_url: bool = True validate_base_url: bool = True
"""For backwards compatibility. If legacy val openai_api_base is passed in, try to """For backwards compatibility. If legacy val openai_api_base is passed in, try to
infer if it is a base_url or azure_endpoint and update accordingly. infer if it is a base_url or azure_endpoint and update accordingly.
""" """

@ -40,30 +40,14 @@ class BaseMultiModalModel:
Examples: Examples:
>>> from swarms.models.base_multimodal_model import BaseMultiModalModel >>> from swarms.models.base_multimodal_model import BaseMultiModalModel
>>> model = BaseMultiModalModel() >>> model = BaseMultiModalModel()
>>> link = "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png"
>>> model.run("Generate a summary of this text") >>> model.run("Generate a summary of this text")
>>> model.run("Generate a summary of this text", link) >>> model.run("Generate a summary of this text", "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png")
>>> model.run_batch(["Generate a summary of this text", "Generate a summary of this text"]) >>> model.run_batch(["Generate a summary of this text", "Generate a summary of this text"])
>>> model.run_batch([ >>> model.run_batch([("Generate a summary of this text", "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png"), ("Generate a summary of this text", "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png")])
("Generate a summary of this text", link), >>> model.run_batch_async(["Generate a summary of this text", "Generate a summary of this text"])
("Generate a summary of this text", link) >>> model.run_batch_async([("Generate a summary of this text", "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png"), ("Generate a summary of this text", "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png")])
]) >>> model.run_batch_async_with_retries(["Generate a summary of this text", "Generate a summary of this text"])
>>> model.run_batch_async([ >>> model.run_batch_async_with_retries([("Generate a summary of this text", "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png"), ("Generate a summary of this text", "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png")])
"Generate a summary of this text",
"Generate a summary of this text"
])
>>> model.run_batch_async([
("Generate a summary of this text", link),
("Generate a summary of this text", link)
])
>>> model.run_batch_async_with_retries([
"Generate a summary of this text",
"Generate a summary of this text"
])
>>> model.run_batch_async_with_retries([
("Generate a summary of this text", link),
("Generate a summary of this text", link)
])
>>> model.generate_summary("Generate a summary of this text") >>> model.generate_summary("Generate a summary of this text")
>>> model.set_temperature(0.5) >>> model.set_temperature(0.5)
>>> model.set_max_tokens(500) >>> model.set_max_tokens(500)
@ -364,9 +348,9 @@ class BaseMultiModalModel:
_type_: _description_ _type_: _description_
""" """
META_PROMPT = """ META_PROMPT = """
For any labels or markings on an image that you reference in your response, please For any labels or markings on an image that you reference in your response, please
enclose them in square brackets ([]) and list them explicitly. Do not use ranges; for enclose them in square brackets ([]) and list them explicitly. Do not use ranges; for
example, instead of '1 - 4', list as '[1], [2], [3], [4]'. These labels could be example, instead of '1 - 4', list as '[1], [2], [3], [4]'. These labels could be
numbers or letters and typically correspond to specific segments or parts of the image. numbers or letters and typically correspond to specific segments or parts of the image.
""" """
return META_PROMPT return META_PROMPT

@ -2,8 +2,7 @@ r"""
BioGPT BioGPT
Pre-trained language models have attracted increasing attention in the biomedical domain, Pre-trained language models have attracted increasing attention in the biomedical domain,
inspired by their great success in the general natural language domain. inspired by their great success in the general natural language domain.
Among the two main branches of pre-trained language models in the general language domain, Among the two main branches of pre-trained language models in the general language domain, i.e. BERT (and its variants) and GPT (and its variants),
i.e. BERT (and its variants) and GPT (and its variants),
the first one has been extensively studied in the biomedical domain, such as BioBERT and PubMedBERT. the first one has been extensively studied in the biomedical domain, such as BioBERT and PubMedBERT.
While they have achieved great success on a variety of discriminative downstream biomedical tasks, While they have achieved great success on a variety of discriminative downstream biomedical tasks,
the lack of generation ability constrains their application scope. the lack of generation ability constrains their application scope.
@ -25,6 +24,7 @@ advantage of BioGPT on biomedical literature to generate fluent descriptions for
number = {6}, number = {6},
year = {2022}, year = {2022},
month = {09}, month = {09},
abstract = "{Pre-trained language models have attracted increasing attention in the biomedical domain, inspired by their great success in the general natural language domain. Among the two main branches of pre-trained language models in the general language domain, i.e. BERT (and its variants) and GPT (and its variants), the first one has been extensively studied in the biomedical domain, such as BioBERT and PubMedBERT. While they have achieved great success on a variety of discriminative downstream biomedical tasks, the lack of generation ability constrains their application scope. In this paper, we propose BioGPT, a domain-specific generative Transformer language model pre-trained on large-scale biomedical literature. We evaluate BioGPT on six biomedical natural language processing tasks and demonstrate that our model outperforms previous models on most tasks. Especially, we get 44.98\%, 38.42\% and 40.76\% F1 score on BC5CDR, KD-DTI and DDI end-to-end relation extraction tasks, respectively, and 78.2\% accuracy on PubMedQA, creating a new record. Our case study on text generation further demonstrates the advantage of BioGPT on biomedical literature to generate fluent descriptions for biomedical terms.}",
issn = {1477-4054}, issn = {1477-4054},
doi = {10.1093/bib/bbac409}, doi = {10.1093/bib/bbac409},
url = {https://doi.org/10.1093/bib/bbac409}, url = {https://doi.org/10.1093/bib/bbac409},

@ -161,8 +161,7 @@ class CogVLMMultiModal(BaseMultiModalModel):
Methods: Methods:
run: Generates a response using the CogVLM model. run: Generates a response using the CogVLM model.
generate_stream_cogvlm: Generates a stream of responses using the CogVLM model in inference mode. generate_stream_cogvlm: Generates a stream of responses using the CogVLM model in inference mode.
process_history_and_images: Processes history messages to extract text, identify the last user query, process_history_and_images: Processes history messages to extract text, identify the last user query, and convert base64 encoded image URLs to PIL images.
and convert base64 encoded image URLs to PIL images.
Example: Example:
>>> model = CogVLMMultiModal() >>> model = CogVLMMultiModal()

@ -257,7 +257,7 @@ class Dalle3:
"""Print the Dalle3 dashboard""" """Print the Dalle3 dashboard"""
print( print(
colored( colored(
f"""Dalle3 Dashboard: f"""Dalle3 Dashboard:
-------------------- --------------------
Model: {self.model} Model: {self.model}
@ -271,8 +271,8 @@ class Dalle3:
Save Folder: {self.save_folder} Save Folder: {self.save_folder}
Image Format: {self.image_format} Image Format: {self.image_format}
-------------------- --------------------
""", """,
"green", "green",
) )

@ -37,8 +37,7 @@ class ElevenLabsText2SpeechTool(BaseTool):
Defaults to ElevenLabsModel.MULTI_LINGUAL. Defaults to ElevenLabsModel.MULTI_LINGUAL.
name (str): The name of the tool. Defaults to "eleven_labs_text2speech". name (str): The name of the tool. Defaults to "eleven_labs_text2speech".
description (str): The description of the tool. description (str): The description of the tool.
Defaults to "A wrapper around Eleven Labs Text2Speech. Useful for when you need to convert text to speech. Defaults to "A wrapper around Eleven Labs Text2Speech. Useful for when you need to convert text to speech. It supports multiple languages, including English, German, Polish, Spanish, Italian, French, Portuguese, and Hindi."
It supports multiple languages, including English, German, Polish, Spanish, Italian, French, Portuguese, and Hindi."
Usage: Usage:

@ -132,13 +132,13 @@ class Gemini(BaseMultiModalModel):
system_prompt (str, optional): _description_. Defaults to None. system_prompt (str, optional): _description_. Defaults to None.
""" """
PROMPT = f""" PROMPT = f"""
{self.system_prompt} {self.system_prompt}
###### ######
{task} {task}
""" """
return PROMPT return PROMPT

@ -11,8 +11,7 @@ from swarms.utils.supervision_visualizer import MarkVisualizer
class GPT4VSAM(BaseMultiModalModel): class GPT4VSAM(BaseMultiModalModel):
""" """
GPT4VSAM class represents a multi-modal model that combines the capabilities of GPT-4 and SegmentAnythingMarkGenerator. GPT4VSAM class represents a multi-modal model that combines the capabilities of GPT-4 and SegmentAnythingMarkGenerator.
It takes an instance of BaseMultiModalModel (vlm) It takes an instance of BaseMultiModalModel (vlm) and a device as input and provides methods for loading images and making predictions.
and a device as input and provides methods for loading images and making predictions.
Args: Args:
vlm (BaseMultiModalModel): An instance of BaseMultiModalModel representing the visual language model. vlm (BaseMultiModalModel): An instance of BaseMultiModalModel representing the visual language model.

@ -203,9 +203,8 @@ class GPT4VisionAPI(BaseMultiModalModel):
""" """
PROMPT = f""" PROMPT = f"""
These are frames from a video that I want to upload. These are frames from a video that I want to upload. Generate a compelling description that I can upload along with the video:
Generate a compelling description that I can upload along with the video:
{frames} {frames}
""" """
return PROMPT return PROMPT

@ -63,8 +63,7 @@ class Idefics(BaseMultiModalModel):
response = model.chat(user_input) response = model.chat(user_input)
print(response) print(response)
user_input = "User: And who is that? \ user_input = "User: And who is that? https://static.wikia.nocookie.net/asterix/images/2/25/R22b.gif/revision/latest?cb=20110815073052"
https://static.wikia.nocookie.net/asterix/images/2/25/R22b.gif/revision/latest?cb=20110815073052"
response = model.chat(user_input) response = model.chat(user_input)
print(response) print(response)

@ -26,8 +26,7 @@ class MedicalSAM:
Methods: Methods:
__post_init__(): Initializes the MedicalSAM object. __post_init__(): Initializes the MedicalSAM object.
download_model_weights(model_path: str): download_model_weights(model_path: str): Downloads the model weights from the specified URL and saves them to the given file path.
Downloads the model weights from the specified URL and saves them to the given file path.
preprocess(img): Preprocesses the input image. preprocess(img): Preprocesses the input image.
run(img, box): Runs the semantic segmentation on the input image within the specified bounding box. run(img, box): Runs the semantic segmentation on the input image within the specified bounding box.

@ -1,7 +1,6 @@
from typing import Any, Dict, List, Optional, Union from typing import Any, Dict, List, Optional, Union
from openai import OpenAI import openai
import requests import requests
from pydantic import BaseModel, validator from pydantic import BaseModel, validator
from tenacity import ( from tenacity import (
@ -148,7 +147,6 @@ class OpenAIFunctionCaller:
self.user = user self.user = user
self.messages = messages if messages is not None else [] self.messages = messages if messages is not None else []
self.timeout_sec = timeout_sec self.timeout_sec = timeout_sec
self.client = OpenAI(api_key=self.openai_api_key)
def add_message(self, role: str, content: str): def add_message(self, role: str, content: str):
self.messages.append({"role": role, "content": content}) self.messages.append({"role": role, "content": content})
@ -165,7 +163,7 @@ class OpenAIFunctionCaller:
): ):
headers = { headers = {
"Content-Type": "application/json", "Content-Type": "application/json",
"Authorization": "Bearer " + self.openai_api_key, "Authorization": "Bearer " + openai.api_key,
} }
json_data = {"model": self.model, "messages": messages} json_data = {"model": self.model, "messages": messages}
if tools is not None: if tools is not None:
@ -237,7 +235,7 @@ class OpenAIFunctionCaller:
) )
def call(self, task: str, *args, **kwargs) -> Dict: def call(self, task: str, *args, **kwargs) -> Dict:
return self.client.completions.create( return openai.Completion.create(
engine=self.model, engine=self.model,
prompt=task, prompt=task,
max_tokens=self.max_tokens, max_tokens=self.max_tokens,

@ -37,6 +37,9 @@ from tenacity import (
stop_after_attempt, stop_after_attempt,
wait_exponential, wait_exponential,
) )
logger = logging.getLogger(__name__)
from importlib.metadata import version from importlib.metadata import version
from packaging.version import parse from packaging.version import parse
@ -174,11 +177,11 @@ def _create_retry_decorator(
import openai import openai
errors = [ errors = [
openai.Timeout, openai.error.Timeout,
openai.APIError, openai.error.APIError,
openai.APIConnectionError, openai.error.APIConnectionError,
openai.RateLimitError, openai.error.RateLimitError,
openai.ServiceUnavailableError, openai.error.ServiceUnavailableError,
] ]
return create_base_retry_decorator( return create_base_retry_decorator(
error_types=errors, error_types=errors,
@ -349,13 +352,7 @@ class BaseOpenAI(BaseLLM):
try: try:
import openai import openai
values["client"] = openai.OpenAI( values["client"] = openai.Completion
api_key=values["openai_api_key"],
api_base=values["openai_api_base"] or None,
organization=values["openai_organization"] or None,
# TODO: Reenable this when openai package supports proxy
# proxy=values["openai_proxy"] or None,
)
except ImportError: except ImportError:
raise ImportError( raise ImportError(
"Could not import openai python package. " "Could not import openai python package. "
@ -648,11 +645,9 @@ class BaseOpenAI(BaseLLM):
"organization": self.openai_organization, "organization": self.openai_organization,
} }
if self.openai_proxy: if self.openai_proxy:
pass import openai
# TODO: The 'openai.proxy' option isn't read in the client API. You will need to pass it when you instantiate the openai.proxy = {"http": self.openai_proxy, "https": self.openai_proxy} # type: ignore[assignment] # noqa: E501
# client, e.g. 'OpenAI(proxy={"http": self.openai_proxy, "https": self.openai_proxy})'
# openai.proxy = {"http": self.openai_proxy, "https": self.openai_proxy} # type: ignore[assignment] # noqa: E501
return {**openai_creds, **self._default_params} return {**openai_creds, **self._default_params}
@property @property
@ -938,36 +933,44 @@ class OpenAIChat(BaseLLM):
@root_validator() @root_validator()
def validate_environment(cls, values: dict) -> dict: def validate_environment(cls, values: dict) -> dict:
"""Validate that api key and python package exists in environment.""" """Validate that api key and python package exists in environment."""
# openai_api_key = get_from_dict_or_env( openai_api_key = get_from_dict_or_env(
# values, "openai_api_key", "OPENAI_API_KEY" values, "openai_api_key", "OPENAI_API_KEY"
# ) )
# openai_api_base = get_from_dict_or_env( openai_api_base = get_from_dict_or_env(
# values, values,
# "openai_api_base", "openai_api_base",
# "OPENAI_API_BASE", "OPENAI_API_BASE",
# default="", default="",
# ) )
# openai_proxy = get_from_dict_or_env( openai_proxy = get_from_dict_or_env(
# values, values,
# "openai_proxy", "openai_proxy",
# "OPENAI_PROXY", "OPENAI_PROXY",
# default="", default="",
# ) )
# openai_organization = get_from_dict_or_env( openai_organization = get_from_dict_or_env(
# values, values,
# "openai_organization", "openai_organization",
# "OPENAI_ORGANIZATION", "OPENAI_ORGANIZATION",
# default="", default="",
# ) )
try: try:
import openai import openai
openai.api_key = openai_api_key
if openai_api_base:
openai.api_base = openai_api_base
if openai_organization:
openai.organization = openai_organization
if openai_proxy:
openai.proxy = {"http": openai_proxy, "https": openai_proxy} # type: ignore[assignment] # noqa: E501
except ImportError: except ImportError:
raise ImportError( raise ImportError(
"Could not import openai python package. " "Could not import openai python package. "
"Please install it with `pip install openai`." "Please install it with `pip install openai`."
) )
try: try:
values["client"] = openai.OpenAI values["client"] = openai.ChatCompletion
except AttributeError: except AttributeError:
raise ValueError( raise ValueError(
"`openai` has no `ChatCompletion` attribute, this is" "`openai` has no `ChatCompletion` attribute, this is"

@ -27,8 +27,7 @@ class SAM:
processor (SamProcessor): The processor for the SAM model. processor (SamProcessor): The processor for the SAM model.
Methods: Methods:
run(task=None, img=None, *args, **kwargs): run(task=None, img=None, *args, **kwargs): Runs the SAM model on the given image and returns the segmentation scores and masks.
Runs the SAM model on the given image and returns the segmentation scores and masks.
process_img(img: str = None, *args, **kwargs): Processes the input image and returns the processed image. process_img(img: str = None, *args, **kwargs): Processes the input image and returns the processed image.
""" """

@ -2,29 +2,18 @@
SpeechT5 (TTS task) SpeechT5 (TTS task)
SpeechT5 model fine-tuned for speech synthesis (text-to-speech) on LibriTTS. SpeechT5 model fine-tuned for speech synthesis (text-to-speech) on LibriTTS.
This model was introduced in SpeechT5: Unified-Modal Encoder-Decoder Pre-Training for Spoken Language Processing by This model was introduced in SpeechT5: Unified-Modal Encoder-Decoder Pre-Training for Spoken Language Processing by Junyi Ao, Rui Wang, Long Zhou, Chengyi Wang, Shuo Ren, Yu Wu, Shujie Liu, Tom Ko, Qing Li, Yu Zhang, Zhihua Wei, Yao Qian, Jinyu Li, Furu Wei.
Junyi Ao, Rui Wang, Long Zhou, Chengyi Wang, Shuo Ren, Yu Wu,
Shujie Liu, Tom Ko, Qing Li, Yu Zhang, Zhihua Wei, Yao Qian, Jinyu Li, Furu Wei.
SpeechT5 was first released in this repository, original weights. The license used is MIT. SpeechT5 was first released in this repository, original weights. The license used is MIT.
Model Description Model Description
Motivated by the success of T5 (Text-To-Text Transfer Transformer) in pre-trained natural language processing models, Motivated by the success of T5 (Text-To-Text Transfer Transformer) in pre-trained natural language processing models, we propose a unified-modal SpeechT5 framework that explores the encoder-decoder pre-training for self-supervised speech/text representation learning. The SpeechT5 framework consists of a shared encoder-decoder network and six modal-specific (speech/text) pre/post-nets. After preprocessing the input speech/text through the pre-nets, the shared encoder-decoder network models the sequence-to-sequence transformation, and then the post-nets generate the output in the speech/text modality based on the output of the decoder.
we propose a unified-modal SpeechT5 framework that explores the encoder-decoder pre-training for self-supervised speech/text
representation learning. The SpeechT5 framework consists of a shared encoder-decoder network and six modal-specific
(speech/text) pre/post-nets. After preprocessing the input speech/text through the pre-nets, the shared encoder-decoder network
models the sequence-to-sequence transformation,and then the post-nets generate the output in the speech/text modality based on
the output of the decoder.
Leveraging large-scale unlabeled speech and text data, we pre-train SpeechT5 to learn a unified-modal representation,
hoping to improve the modeling capability for both speech and text. To align the textual and speech information into
this unified semantic space, we propose a cross-modal vector quantization approach that randomly mixes up speech/text
states with latent units as the interface between encoder and decoder.
Extensive evaluations show the superiority of the proposed SpeechT5 framework on a wide variety of spoken language processing
tasks, including automatic speech recognition, speech synthesis, speech translation, voice conversion, speech enhancement,
and speaker identification.
Leveraging large-scale unlabeled speech and text data, we pre-train SpeechT5 to learn a unified-modal representation, hoping to improve the modeling capability for both speech and text. To align the textual and speech information into this unified semantic space, we propose a cross-modal vector quantization approach that randomly mixes up speech/text states with latent units as the interface between encoder and decoder.
Extensive evaluations show the superiority of the proposed SpeechT5 framework on a wide variety of spoken language processing tasks, including automatic speech recognition, speech synthesis, speech translation, voice conversion, speech enhancement, and speaker identification.
Developed by: Junyi Ao, Rui Wang, Long Zhou, Chengyi Wang, Shuo Ren, Yu Wu, Shujie Liu, Tom Ko, Qing Li, Yu Zhang, Zhihua Wei, Yao Qian, Jinyu Li, Furu Wei.
Shared by [optional]: Matthijs Hollemans Shared by [optional]: Matthijs Hollemans
Model type: text-to-speech Model type: text-to-speech
Language(s) (NLP): [More Information Needed] Language(s) (NLP): [More Information Needed]

@ -49,7 +49,7 @@ class SSD1B:
max_time_seconds: int = 60 max_time_seconds: int = 60
save_folder: str = "images" save_folder: str = "images"
image_format: str = "png" image_format: str = "png"
device: str = "cuda" if torch.cuda.is_available() else "cpu" device: str = "cuda"
dashboard: bool = False dashboard: bool = False
cache = TTLCache(maxsize=100, ttl=3600) cache = TTLCache(maxsize=100, ttl=3600)
pipe = StableDiffusionXLPipeline.from_pretrained( pipe = StableDiffusionXLPipeline.from_pretrained(
@ -171,7 +171,7 @@ class SSD1B:
"""Print the SSD1B dashboard""" """Print the SSD1B dashboard"""
print( print(
colored( colored(
f"""SSD1B Dashboard: f"""SSD1B Dashboard:
-------------------- --------------------
Model: {self.model} Model: {self.model}
@ -185,8 +185,8 @@ class SSD1B:
Save Folder: {self.save_folder} Save Folder: {self.save_folder}
Image Format: {self.image_format} Image Format: {self.image_format}
-------------------- --------------------
""", """,
"green", "green",
) )

@ -34,7 +34,7 @@ commands: {
""" """
# FEW SHOT EXAMPLES # ########### FEW SHOT EXAMPLES ################
SCENARIOS = """ SCENARIOS = """
commands: { commands: {
"tools": { "tools": {

@ -62,6 +62,6 @@ def worker_tools_sop_promp(name: str, memory: str, time=time):
[{memory}] [{memory}]
Human: Determine which next command to use, and respond using the format specified above: Human: Determine which next command to use, and respond using the format specified above:
""".format(name=name, time=time, memory=memory) # noqa: F521 """.format(name=name, time=time, memory=memory)
return str(out) return str(out)

@ -447,7 +447,7 @@ class Agent:
Name: {self.agent_name} Name: {self.agent_name}
Description: {self.agent_description} Description: {self.agent_description}
Standard Operating Procedure: {self.sop} Standard Operating Procedure: {self.sop}
System Prompt: {self.system_prompt} System Prompt: {self.system_prompt}
Task: {task} Task: {task}
Max Loops: {self.max_loops} Max Loops: {self.max_loops}
Stopping Condition: {self.stopping_condition} Stopping Condition: {self.stopping_condition}
@ -778,7 +778,7 @@ class Agent:
Follow this standard operating procedure (SOP) to complete tasks: Follow this standard operating procedure (SOP) to complete tasks:
{self.sop} {self.sop}
{history} {history}
""" """
return agent_history_prompt return agent_history_prompt
@ -786,7 +786,7 @@ class Agent:
system_prompt = self.system_prompt system_prompt = self.system_prompt
agent_history_prompt = f""" agent_history_prompt = f"""
System : {system_prompt} System : {system_prompt}
{history} {history}
""" """
return agent_history_prompt return agent_history_prompt

@ -98,8 +98,7 @@ class AsyncWorkflow:
# if self.dashboard: # if self.dashboard:
# self.display() # self.display()
# Add a stopping condition to stop the workflow, # Add a stopping condition to stop the workflow, if provided but stopping_condition takes in a parameter s for string
# if provided but stopping_condition takes in a parameter s for string
if self.stopping_condition: if self.stopping_condition:
if self.stopping_condition(self.results): if self.stopping_condition(self.results):
break break

@ -86,6 +86,10 @@ class AbstractSwarm(ABC):
def step(self): def step(self):
"""Step the swarm""" """Step the swarm"""
# @abstractmethod
def add_agent(self, agent: "Agent"):
"""Add a agent to the swarm"""
# @abstractmethod # @abstractmethod
def remove_agent(self, agent: "Agent"): def remove_agent(self, agent: "Agent"):
"""Remove a agent from the swarm""" """Remove a agent from the swarm"""

@ -195,16 +195,7 @@ class BaseWorkflow(BaseStructure):
>>> workflow.add("Create a report on these metrics", llm) >>> workflow.add("Create a report on these metrics", llm)
>>> workflow.delete_task("What's the weather in miami") >>> workflow.delete_task("What's the weather in miami")
>>> workflow.tasks >>> workflow.tasks
[ [Task(description='Create a report on these metrics', agent=Agent(llm=OpenAIChat(openai_api_key=''), max_loops=1, dashboard=False), args=[], kwargs={}, result=None, history=[])]
Task(
description='Create a report on these metrics',
agent=Agent(llm=OpenAIChat(openai_api_key=''), max_loops=1, dashboard=False),
args=[],
kwargs={},
result=None,
history=[]
)
]
""" """
try: try:
for task in self.tasks: for task in self.tasks:

@ -15,8 +15,7 @@ class ConcurrentWorkflow(BaseStructure):
Args: Args:
max_workers (int): The maximum number of workers to use for the ThreadPoolExecutor. max_workers (int): The maximum number of workers to use for the ThreadPoolExecutor.
autosave (bool): Whether to save the state of the workflow to a file. Default is False. autosave (bool): Whether to save the state of the workflow to a file. Default is False.
saved_state_filepath (str): saved_state_filepath (str): The filepath to save the state of the workflow to. Default is "runs/concurrent_workflow.json".
The filepath to save the state of the workflow to. Default is "runs/concurrent_workflow.json".
print_results (bool): Whether to print the results of each task. Default is False. print_results (bool): Whether to print the results of each task. Default is False.
return_results (bool): Whether to return the results of each task. Default is False. return_results (bool): Whether to return the results of each task. Default is False.
use_processes (bool): Whether to use processes instead of threads. Default is False. use_processes (bool): Whether to use processes instead of threads. Default is False.

@ -19,8 +19,7 @@ class DebatePlayer(Agent):
Args: Args:
model_name(str): model name model_name(str): model name
name (str): name of this player name (str): name of this player
temperature (float): temperature (float): higher values make the output more random, while lower values make it more focused and deterministic
higher values make the output more random, while lower values make it more focused and deterministic
openai_api_key (str): As the parameter name suggests openai_api_key (str): As the parameter name suggests
sleep_time (float): sleep because of rate limits sleep_time (float): sleep because of rate limits
""" """
@ -32,8 +31,7 @@ class Debate:
Args: Args:
model_name (str): openai model name model_name (str): openai model name
temperature (float): temperature (float): higher values make the output more random, while lower values make it more focused and deterministic
higher values make the output more random, while lower values make it more focused and deterministic
num_players (int): num of players num_players (int): num of players
save_file_dir (str): dir path to json file save_file_dir (str): dir path to json file
openai_api_key (str): As the parameter name suggests openai_api_key (str): As the parameter name suggests
@ -361,13 +359,6 @@ class Debate:
# with open(prompts_path, 'w') as file: # with open(prompts_path, 'w') as file:
# json.dump(config, file, ensure_ascii=False, indent=4) # json.dump(config, file, ensure_ascii=False, indent=4)
# debate = Debate( # debate = Debate(save_file_dir=save_file_dir, num_players=3, openai_api_key=openai_api_key, prompts_path=prompts_path, temperature=0, sleep_time=0)
# save_file_dir=save_file_dir,
# num_players=3,
# openai_api_key=openai_api_key,
# prompts_path=prompts_path,
# temperature=0,
# sleep_time=0
# )
# debate.run() # debate.run()
# debate.save_file_to_json(id) # debate.save_file_to_json(id)

@ -17,8 +17,7 @@ class GraphWorkflow(BaseStructure):
connect(from_node, to_node): Connects two nodes in the graph. connect(from_node, to_node): Connects two nodes in the graph.
set_entry_point(node_name): Sets the entry point node for the workflow. set_entry_point(node_name): Sets the entry point node for the workflow.
add_edge(from_node, to_node): Adds an edge between two nodes in the graph. add_edge(from_node, to_node): Adds an edge between two nodes in the graph.
add_conditional_edges(from_node, condition, edge_dict): add_conditional_edges(from_node, condition, edge_dict): Adds conditional edges from a node to multiple nodes based on a condition.
Adds conditional edges from a node to multiple nodes based on a condition.
run(): Runs the workflow and returns the graph. run(): Runs the workflow and returns the graph.
Examples: Examples:

@ -51,23 +51,23 @@ class LongContextSwarmLeader:
- prompt (str): The formatted string containing the agent metadata. - prompt (str): The formatted string containing the agent metadata.
""" """
prompt = f""" prompt = f"""
You need to recruit a team of members to solve a You need to recruit a team of members to solve a
task. Select the appropriate member based on the task. Select the appropriate member based on the
task description: task description:
# Task Description # Task Description
{task} {task}
# Members # Members
Your output must follow this JSON schema below in markdown format: Your output must follow this JSON schema below in markdown format:
{{ {{
"agent_id": "string", "agent_id": "string",
"agent_name": "string", "agent_name": "string",
"agent_description": "string" "agent_description": "string"
}} }}
""" """
for agent in self.agents: for agent in self.agents:
prompt += ( prompt += (
@ -83,7 +83,7 @@ class LongContextSwarmLeader:
You are the leader of a team of {len(self.agents)} You are the leader of a team of {len(self.agents)}
members. Your team will need to collaborate to members. Your team will need to collaborate to
solve a task. The rule is: solve a task. The rule is:
1. Only you know the task description and task 1. Only you know the task description and task
objective; the other members do not. objective; the other members do not.
2. But they will receive different documents that 2. But they will receive different documents that
@ -95,13 +95,13 @@ class LongContextSwarmLeader:
explicitly include the task objective. explicitly include the task objective.
4. Finally, you need to complete the task based on 4. Finally, you need to complete the task based on
the query results they return. the query results they return.
# Task Description: # Task Description:
{task_description} {task_description}
# Task Objective: # Task Objective:
{task} {task}
# Generate Instruction for Members: # Generate Instruction for Members:
Now, you need to generate an instruction for all Now, you need to generate an instruction for all
team members. You can ask them to answer a team members. You can ask them to answer a
@ -110,7 +110,7 @@ class LongContextSwarmLeader:
Your output must following the JSON Your output must following the JSON
format: {{"type": "instruction", "content": format: {{"type": "instruction", "content":
"your_instruction_content"}} "your_instruction_content"}}
""" """
return prompt return prompt

@ -129,8 +129,7 @@ class MajorityVoting:
multithreaded (bool, optional): Whether to run the agents using multithreading. Defaults to False. multithreaded (bool, optional): Whether to run the agents using multithreading. Defaults to False.
multiprocess (bool, optional): Whether to run the agents using multiprocessing. Defaults to False. multiprocess (bool, optional): Whether to run the agents using multiprocessing. Defaults to False.
asynchronous (bool, optional): Whether to run the agents asynchronously. Defaults to False. asynchronous (bool, optional): Whether to run the agents asynchronously. Defaults to False.
output_parser (callable, optional): A callable function to parse the output output_parser (callable, optional): A callable function to parse the output of the majority voting system. Defaults to None.
of the majority voting system. Defaults to None.
Examples: Examples:
>>> from swarms.structs.agent import Agent >>> from swarms.structs.agent import Agent

@ -3,7 +3,7 @@ from time import time_ns
from typing import Callable, List, Optional, Sequence, Union from typing import Callable, List, Optional, Sequence, Union
from swarms.structs.agent import Agent from swarms.structs.agent import Agent
from swarms.structs.base_swarm import AbstractSwarm from swarms.structs.base_swarm import BaseSwarm
from swarms.utils.loguru_logger import logger from swarms.utils.loguru_logger import logger
@ -43,7 +43,7 @@ def msg_hash(
) )
class MessagePool(AbstractSwarm): class MessagePool(BaseSwarm):
""" """
A class representing a message pool for agents in a swarm. A class representing a message pool for agents in a swarm.
@ -68,17 +68,11 @@ class MessagePool(AbstractSwarm):
>>> message_pool.add(agent=agent2, content="Hello, agent1!", turn=1) >>> message_pool.add(agent=agent2, content="Hello, agent1!", turn=1)
>>> message_pool.add(agent=agent3, content="Hello, agent1!", turn=1) >>> message_pool.add(agent=agent3, content="Hello, agent1!", turn=1)
>>> message_pool.get_all_messages() >>> message_pool.get_all_messages()
[{'agent': Agent(agent_name='agent1'), 'content': 'Hello, agent2!', 'turn': 1, 'visible_to': 'all', 'logged': True}, [{'agent': Agent(agent_name='agent1'), 'content': 'Hello, agent2!', 'turn': 1, 'visible_to': 'all', 'logged': True}, {'agent': Agent(agent_name='agent2'), 'content': 'Hello, agent1!', 'turn': 1, 'visible_to': 'all', 'logged': True}, {'agent': Agent(agent_name='agent3'), 'content': 'Hello, agent1!', 'turn': 1, 'visible_to': 'all', 'logged': True}]
{'agent': Agent(agent_name='agent2'), 'content': 'Hello, agent1!', 'turn': 1, 'visible_to': 'all', 'logged': True}, >>> message_pool.get_visible_messages(agent=agent1, turn=1)
{'agent': Agent(agent_name='agent3'), 'content': 'Hello, agent1!', 'turn': 1, 'visible_to': 'all', 'logged': True}] [{'agent': Agent(agent_name='agent1'), 'content': 'Hello, agent2!', 'turn': 1, 'visible_to': 'all', 'logged': True}, {'agent': Agent(agent_name='agent2'), 'content': 'Hello, agent1!', 'turn': 1, 'visible_to': 'all', 'logged': True}, {'agent': Agent(agent_name='agent3'), 'content': 'Hello, agent1!', 'turn': 1, 'visible_to': 'all', 'logged': True}]
>>> message_pool.get_visible_messages(agent=agent2, turn=1) >>> message_pool.get_visible_messages(agent=agent2, turn=1)
[{'agent': Agent(agent_name='agent1'), 'content': 'Hello, agent2!', 'turn': 1, 'visible_to': 'all', 'logged': True}, [{'agent': Agent(agent_name='agent1'), 'content': 'Hello, agent2!', 'turn': 1, 'visible_to': 'all', 'logged': True}, {'agent': Agent(agent_name='agent2'), 'content': 'Hello, agent1!', 'turn': 1, 'visible_to': 'all', 'logged': True}, {'agent': Agent(agent_name='agent3'), 'content': 'Hello, agent1!', 'turn': 1, 'visible_to': 'all', 'logged': True}]
{'agent': Agent(agent_name='agent2'), 'content': 'Hello, agent1!', 'turn': 1, 'visible_to': 'all', 'logged': True},
{'agent': Agent(agent_name='agent3'), 'content': 'Hello, agent1!', 'turn': 1, 'visible_to': 'all', 'logged': True}]
>>> message_pool.get_visible_messages(agent=agent2, turn=1)
[{'agent': Agent(agent_name='agent1'), 'content': 'Hello, agent2!', 'turn': 1, 'visible_to': 'all', 'logged': True},
{'agent': Agent(agent_name='agent2'), 'content': 'Hello, agent1!', 'turn': 1, 'visible_to': 'all', 'logged': True},
{'agent': Agent(agent_name='agent3'), 'content': 'Hello, agent1!', 'turn': 1, 'visible_to': 'all', 'logged': True}]
""" """
def __init__( def __init__(

@ -1,7 +1,7 @@
import importlib.util import importlib.util
import sys import sys
from importlib.metadata import version as pkg_version import pkg_resources
import requests import requests
from packaging import version from packaging import version
@ -35,7 +35,7 @@ def check_for_update():
latest_version = response.json()["info"]["version"] latest_version = response.json()["info"]["version"]
# Get the current version using pkg_resources # Get the current version using pkg_resources
current_version = pkg_version("swarms") current_version = pkg_resources.get_distribution("swarms").version
return version.parse(latest_version) > version.parse( return version.parse(latest_version) > version.parse(
current_version current_version

@ -1,8 +1,8 @@
import platform import platform
import subprocess import subprocess
import pkg_resources
import psutil import psutil
import importlib.metadata as metadata
import toml import toml
@ -31,7 +31,9 @@ def get_swarms_verison():
) )
except Exception as e: except Exception as e:
swarms_verison_cmd = str(e) swarms_verison_cmd = str(e)
swarms_verison_pkg = metadata.version("swarms") swarms_verison_pkg = pkg_resources.get_distribution(
"swarms"
).version
swarms_verison = swarms_verison_cmd, swarms_verison_pkg swarms_verison = swarms_verison_cmd, swarms_verison_pkg
return swarms_verison return swarms_verison
@ -65,7 +67,7 @@ def get_package_mismatches(file_path="pyproject.toml"):
dependencies.update(dev_dependencies) dependencies.update(dev_dependencies)
installed_packages = { installed_packages = {
pkg.key: pkg.version for pkg in metadata.distributions() pkg.key: pkg.version for pkg in pkg_resources.working_set
} }
mismatches = [] mismatches = []

@ -12,8 +12,7 @@ def scrape_tool_func_docs(fn: Callable) -> str:
fn (Callable): The function to scrape. fn (Callable): The function to scrape.
Returns: Returns:
str: A string containing the function's name, documentation string, and a list of its parameters. str: A string containing the function's name, documentation string, and a list of its parameters. Each parameter is represented as a line containing the parameter's name, default value, and annotation.
Each parameter is represented as a line containing the parameter's name, default value, and annotation.
""" """
try: try:
# If the function is a tool, get the original function # If the function is a tool, get the original function

@ -85,7 +85,7 @@ def tools_prompt_prep(docs: str = None, scenarios: str = SCENARIOS):
You will be provided with a list of APIs. These APIs will have a You will be provided with a list of APIs. These APIs will have a
description and a list of parameters and return types for each tool. Your description and a list of parameters and return types for each tool. Your
task involves creating varied, complex, and detailed user scenarios task involves creating varied, complex, and detailed user scenarios
that require to call API calls. You must select what api to call based on that require to call API calls. You must select what api to call based on
the context of the task and the scenario. the context of the task and the scenario.
For instance, given the APIs: SearchHotels, BookHotel, CancelBooking, For instance, given the APIs: SearchHotels, BookHotel, CancelBooking,
@ -116,14 +116,14 @@ def tools_prompt_prep(docs: str = None, scenarios: str = SCENARIOS):
different combination of APIs for each scenario. All APIs must be used in different combination of APIs for each scenario. All APIs must be used in
at least one scenario. You can only use the APIs provided in the APIs at least one scenario. You can only use the APIs provided in the APIs
section. section.
Note that API calls are not explicitly mentioned and their uses are Note that API calls are not explicitly mentioned and their uses are
included in parentheses. This behaviour should be mimicked in your included in parentheses. This behaviour should be mimicked in your
response. response.
Output the tool usage in a strict json format with the function name and input to Output the tool usage in a strict json format with the function name and input to
the function. For example, Deliver your response in this format: the function. For example, Deliver your response in this format:
{scenarios} {scenarios}

@ -83,7 +83,7 @@ class TestResult:
prompt = f""" prompt = f"""
This function has been executed for {self.visit_times} times. Last execution: This function has been executed for {self.visit_times} times. Last execution:
1.Status: {self.runtime_status.name} 1.Status: {self.runtime_status.name}
2.Input: 2.Input:
{self.input_data} {self.input_data}
3.Output: 3.Output:
@ -108,7 +108,7 @@ class Action:
def to_json(self): def to_json(self):
try: try:
tool_output = json.loads(self.tool_output) tool_output = json.loads(self.tool_output)
except json.JSONDecodeError: except:
tool_output = self.tool_output tool_output = self.tool_output
return { return {
"thought": self.thought, "thought": self.thought,

@ -18,8 +18,7 @@ def load_model_torch(
model_path (str): Path to the saved model file. model_path (str): Path to the saved model file.
device (torch.device): Device to move the model to. device (torch.device): Device to move the model to.
model (nn.Module): The model architecture, if the model file only contains the state dictionary. model (nn.Module): The model architecture, if the model file only contains the state dictionary.
strict (bool): Whether to strictly enforce that the keys in the state dictionary match the keys returned by the model's strict (bool): Whether to strictly enforce that the keys in the state dictionary match the keys returned by the model's `state_dict()` function.
`state_dict()` function.
map_location (callable): A function to remap the storage locations of the loaded model. map_location (callable): A function to remap the storage locations of the loaded model.
*args: Additional arguments to pass to `torch.load`. *args: Additional arguments to pass to `torch.load`.
**kwargs: Additional keyword arguments to pass to `torch.load`. **kwargs: Additional keyword arguments to pass to `torch.load`.

@ -14,7 +14,7 @@ def dataframe_to_text(
Returns: Returns:
str: The string representation of the DataFrame. str: The string representation of the DataFrame.
Example: Example:
>>> df = pd.DataFrame({ >>> df = pd.DataFrame({
... 'A': [1, 2, 3], ... 'A': [1, 2, 3],

@ -1,7 +1,7 @@
# TESTING # TESTING
# -================== # -==================
# Use an official Python runtime as a parent image # Use an official Python runtime as a parent image
FROM python:3.10-slim FROM python:3.9-slim
# Set environment variables to make Python output unbuffered and disable the PIP cache # Set environment variables to make Python output unbuffered and disable the PIP cache
ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONDONTWRITEBYTECODE 1

@ -6,9 +6,7 @@ from swarms.structs.agent import Agent
from swarms.structs.groupchat import GroupChat, GroupChatManager from swarms.structs.groupchat import GroupChat, GroupChatManager
llm = OpenAIChat() llm = OpenAIChat()
# llm2 = Anthropic() llm2 = Anthropic()
# TODO: Mock anthropic class
llm2 = OpenAIChat()
# Mock the OpenAI class for testing # Mock the OpenAI class for testing

@ -0,0 +1,73 @@
# JSON
# Contents of test_json.py, which must be placed in the `tests/` directory.
import json
import pytest
from swarms.tokenizers import JSON
# Fixture for reusable JSON schema file paths
@pytest.fixture
def valid_schema_path(tmp_path):
d = tmp_path / "sub"
d.mkdir()
p = d / "schema.json"
p.write_text(
'{"type": "object", "properties": {"name": {"type":'
' "string"}}}'
)
return str(p)
@pytest.fixture
def invalid_schema_path(tmp_path):
d = tmp_path / "sub"
d.mkdir()
p = d / "invalid_schema.json"
p.write_text("this is not a valid JSON")
return str(p)
# This test class must be subclassed as JSON class is abstract
class TestableJSON(JSON):
def validate(self, data):
# Here must be a real validation implementation for testing
pass
# Basic tests
def test_initialize_json(valid_schema_path):
json_obj = TestableJSON(valid_schema_path)
assert json_obj.schema_path == valid_schema_path
assert "name" in json_obj.schema["properties"]
def test_load_schema_failure(invalid_schema_path):
with pytest.raises(json.JSONDecodeError):
TestableJSON(invalid_schema_path)
# Mocking tests
def test_validate_calls_method(monkeypatch):
# Mock the validate method to check that it is being called
pass
# Exception tests
def test_initialize_with_nonexistent_schema():
with pytest.raises(FileNotFoundError):
TestableJSON("nonexistent_path.json")
# Tests on different Python versions if applicable
# ...
# Grouping tests marked as slow if they perform I/O operations
@pytest.mark.slow
def test_loading_large_schema():
# Test with a large json file
pass

@ -15,7 +15,7 @@ custom_config = {
"verbose": True, "verbose": True,
} }
huggingface_llm = HuggingfaceLLM( huggingface_llm = HuggingfaceLLM(
model_id="liuhaotian/llava-v1.6-mistral-7b", model_id="NousResearch/Nous-Hermes-2-Vision-Alpha",
**custom_config, **custom_config,
) )
mixtral = Mixtral(load_in_4bit=True, use_flash_attention_2=True) mixtral = Mixtral(load_in_4bit=True, use_flash_attention_2=True)

Loading…
Cancel
Save