Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Faster install #431

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
542 changes: 341 additions & 201 deletions LICENSE

Large diffs are not rendered by default.

381 changes: 50 additions & 331 deletions README.md

Large diffs are not rendered by default.

17 changes: 0 additions & 17 deletions Transcript Generator_state.json

This file was deleted.

66 changes: 66 additions & 0 deletions docs/corporate/monthly_formula.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
def calculate_monthly_charge(
development_time_hours: float,
hourly_rate: float,
amortization_months: int,
api_calls_per_month: int,
cost_per_api_call: float,
monthly_maintenance: float,
additional_monthly_costs: float,
profit_margin_percentage: float,
) -> float:
"""
Calculate the monthly charge for a service based on various cost factors.

Parameters:
- development_time_hours (float): The total number of hours spent on development and setup.
- hourly_rate (float): The rate per hour for development and setup.
- amortization_months (int): The number of months over which to amortize the development and setup costs.
- api_calls_per_month (int): The number of API calls made per month.
- cost_per_api_call (float): The cost per API call.
- monthly_maintenance (float): The monthly maintenance cost.
- additional_monthly_costs (float): Any additional monthly costs.
- profit_margin_percentage (float): The desired profit margin as a percentage.

Returns:
- monthly_charge (float): The calculated monthly charge for the service.
"""

# Calculate Development and Setup Costs (amortized monthly)
development_and_setup_costs_monthly = (
development_time_hours * hourly_rate
) / amortization_months

# Calculate Operational Costs per Month
operational_costs_monthly = (
(api_calls_per_month * cost_per_api_call)
+ monthly_maintenance
+ additional_monthly_costs
)

# Calculate Total Monthly Costs
total_monthly_costs = (
development_and_setup_costs_monthly
+ operational_costs_monthly
)

# Calculate Pricing with Profit Margin
monthly_charge = total_monthly_costs * (
1 + profit_margin_percentage / 100
)

return monthly_charge


# Example usage:
monthly_charge = calculate_monthly_charge(
development_time_hours=100,
hourly_rate=500,
amortization_months=12,
api_calls_per_month=500000,
cost_per_api_call=0.002,
monthly_maintenance=1000,
additional_monthly_costs=300,
profit_margin_percentage=10000,
)

print(f"Monthly Charge: ${monthly_charge:.2f}")
25 changes: 2 additions & 23 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "swarms"
version = "4.6.0"
version = "4.6.1"
description = "Swarms - Pytorch"
license = "MIT"
authors = ["Kye Gomez <kye@apac.ai>"]
Expand All @@ -26,49 +26,28 @@ classifiers = [
[tool.poetry.dependencies]
python = ">=3.9,<4.0"
torch = ">=2.1.1,<3.0"
transformers = "4.39.0"
transformers = ">= 4.39.0, <5.0.0"
asyncio = ">=3.4.3,<4.0"
einops = "0.7.0"
google-generativeai = "0.3.1"
langchain = "0.1.13"
langchain-core = "0.1.33"
langchain-community = "0.0.29"
langchain-experimental = "0.0.55"
faiss-cpu = "1.7.4"
backoff = "2.2.1"
datasets = "*"
optimum = "1.15.0"
supervision = "0.19.0"
opencv-python = "4.9.0.80"
diffusers = "*"
anthropic = "0.21.3"
toml = "*"
pypdf = "4.1.0"
accelerate = "*"
sentencepiece = "0.1.98"
httpx = "0.24.1"
tiktoken = "0.5.2"
ratelimit = "2.2.1"
loguru = "0.7.2"
huggingface-hub = "*"
pydantic = "2.6.4"
tenacity = "8.2.3"
Pillow = "10.2.0"
chromadb = "0.4.24"
termcolor = "2.2.0"
torchvision = "0.16.1"
rich = "13.5.2"
bitsandbytes = "*"
sentence-transformers = "*"
peft = "*"
psutil = "*"
timm = "*"
sentry-sdk = "*"

[tool.poetry.dev-dependencies]
black = "23.3.0"


[tool.poetry.group.lint.dependencies]
ruff = ">=0.0.249,<0.3.5"
types-toml = "^0.10.8.1"
Expand Down
48 changes: 15 additions & 33 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,40 +1,22 @@
torch==2.1.1
transformers
pandas
langchain==0.1.13
mkdocs
mkdocs-material
mkdocs-glightbox
torch>=2.1.1,<3.0
transformers==4.39.0
asyncio>=3.4.3,<4.0
einops==0.7.0
langchain-core==0.1.33
langchain-community==0.0.29
langsmith==0.1.17
langchain-openai==0.0.5
httpx==0.24.1
Pillow==9.4.0
datasets==2.14.5
pydantic==2.6.4
huggingface-hub
requests_mock
pypdf==4.0.1
accelerate==0.22.0
loguru==0.7.2
optimum
diffusers
toml
tiktoken==0.5.2
colored
addict
langchain-experimental==0.0.55
backoff==2.2.1
toml
pypdf==4.1.0
httpx==0.24.1
ratelimit==2.2.1
loguru==0.7.2
pydantic==2.6.4
tenacity==8.2.3
Pillow==10.2.0
termcolor==2.2.0
opencv-python==4.9.0.80
timm
torchvision==0.16.1
rich==13.5.2
mkdocs
mkdocs-material
anthropic==0.2.5
mkdocs-glightbox
pre-commit==3.6.2
psutil
black
tenacity
supervision
sentry-sdk
2 changes: 1 addition & 1 deletion swarms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
from swarms.prompts import * # noqa: E402, F403
from swarms.structs import * # noqa: E402, F403
from swarms.telemetry import * # noqa: E402, F403
from swarms.tokenizers import * # noqa: E402, F403
from swarms.tools import * # noqa: E402, F403
from swarms.utils import * # noqa: E402, F403
from swarms.schedulers import * # noqa: E402, F403
3 changes: 2 additions & 1 deletion swarms/agents/omni_modal_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
load_chat_planner,
)
from transformers import load_tool
from swarms.utils.loguru_logger import logger

from swarms.structs.agent import Agent
from swarms.utils.loguru_logger import logger


class OmniModalAgent(Agent):
Expand Down
26 changes: 5 additions & 21 deletions swarms/agents/worker_agent.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import os
from typing import List

import faiss
from langchain.docstore import InMemoryDocstore
from langchain.embeddings import OpenAIEmbeddings
from langchain.vectorstores import FAISS
from langchain_experimental.autonomous_agents import AutoGPT

from swarms.structs.agent import Agent
from swarms.tools.tool import BaseTool
from swarms.utils.decorators import error_decorator, timing_decorator


class Worker:
class Worker(Agent):
"""
The Worker class represents an autonomous agent that can perform tassks through
function calls or by running a chat.
Expand Down Expand Up @@ -53,6 +49,7 @@ def __init__(
embedding_size: int = 1536,
search_kwargs: dict = {"k": 8},
verbose: bool = False,
memory: callable = None,
*args,
**kwargs,
):
Expand All @@ -67,6 +64,7 @@ def __init__(
self.embedding_size = embedding_size
self.search_kwargs = search_kwargs
self.verbose = verbose
self.memory = memory

self.setup_tools(external_tools)
self.setup_memory()
Expand Down Expand Up @@ -121,22 +119,8 @@ def setup_memory(self):
"""
Set up memory for the worker.
"""
openai_api_key = (
os.getenv("OPENAI_API_KEY") or self.openai_api_key
)
try:
embeddings_model = OpenAIEmbeddings(
openai_api_key=openai_api_key
)
embedding_size = self.embedding_size
index = faiss.IndexFlatL2(embedding_size)

self.vectorstore = FAISS(
embeddings_model.embed_query,
index,
InMemoryDocstore({}),
{},
)
self.vectorstore = self.memory

except Exception as error:
raise RuntimeError(
Expand Down
5 changes: 0 additions & 5 deletions swarms/chunkers/__init__.py

This file was deleted.