diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 5cd72b1a..f2295d07 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -30,4 +30,4 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 - run: pip install pylint - - run: pylint . + - run: pylint swarms --recursive=y diff --git a/devin.py b/devin.py index cd264337..506ac662 100644 --- a/devin.py +++ b/devin.py @@ -1,6 +1,7 @@ -from swarms import Agent, Anthropic, tool import subprocess +from swarms import Agent, Anthropic, tool + # Model llm = Anthropic( temperature=0.1, diff --git a/example.py b/example.py index 4d90b7c9..6b4b8536 100644 --- a/example.py +++ b/example.py @@ -1,6 +1,5 @@ from swarms import Agent, Anthropic - ## Initialize the workflow agent = Agent( agent_name="Transcript Generator", diff --git a/playground/demos/agent_in_5/youtube_demo_agent.py b/playground/demos/agent_in_5/youtube_demo_agent.py index 242dce40..3c20e6ae 100644 --- a/playground/demos/agent_in_5/youtube_demo_agent.py +++ b/playground/demos/agent_in_5/youtube_demo_agent.py @@ -4,8 +4,8 @@ Building an Autonomous Agent in 5 minutes with: - Tools: Search, Browser, ETC - Long Term Mmeory: ChromaDB, Weaviate, Pinecone, ETC """ -from swarms import Agent, OpenAIChat, tool from playground.demos.agent_in_5.chroma_db import ChromaDB +from swarms import Agent, OpenAIChat, tool # Initialize the memory chroma = ChromaDB( diff --git a/playground/demos/ai_acceleerated_learning/main.py b/playground/demos/ai_acceleerated_learning/main.py index 44eba542..62e1e68c 100644 --- a/playground/demos/ai_acceleerated_learning/main.py +++ b/playground/demos/ai_acceleerated_learning/main.py @@ -1,12 +1,13 @@ import concurrent import csv + +from dotenv import load_dotenv + from swarms import Agent, OpenAIChat from swarms.memory import ChromaDB -from dotenv import load_dotenv -from swarms.utils.parse_code import extract_code_from_markdown from swarms.utils.file_processing import create_file from swarms.utils.loguru_logger import logger - +from swarms.utils.parse_code import extract_code_from_markdown # Load ENV load_dotenv() @@ -69,7 +70,7 @@ def extract_and_create_agents( """ try: agents = [] - with open(csv_file_path, mode="r", encoding="utf-8") as file: + with open(csv_file_path, encoding="utf-8") as file: reader = csv.DictReader(file) for row in reader: project_name = row[target_columns[0]] diff --git a/playground/demos/autoswarm/autoswarm.py b/playground/demos/autoswarm/autoswarm.py index 309c88ea..ff5b803a 100644 --- a/playground/demos/autoswarm/autoswarm.py +++ b/playground/demos/autoswarm/autoswarm.py @@ -1,8 +1,10 @@ import os + from dotenv import load_dotenv + +import swarms.prompts.autoswarm as sdsp from swarms.models import OpenAIChat from swarms.structs import Agent -import swarms.prompts.autoswarm as sdsp # Load environment variables and initialize the OpenAI Chat model load_dotenv() diff --git a/playground/demos/swarm_hackathon/Bants.py b/playground/demos/swarm_hackathon/Bants.py index 8efca381..9026ddd0 100644 --- a/playground/demos/swarm_hackathon/Bants.py +++ b/playground/demos/swarm_hackathon/Bants.py @@ -1,5 +1,6 @@ # Import the necessary libraries. import asyncio + import websockets # Create a list of public group chats. diff --git a/playground/demos/swarm_hackathon/Human voice.py b/playground/demos/swarm_hackathon/Human voice.py index caa56e7c..ababc27c 100644 --- a/playground/demos/swarm_hackathon/Human voice.py +++ b/playground/demos/swarm_hackathon/Human voice.py @@ -1,5 +1,5 @@ import discord -from transformers import AutoTokenizer, AutoModelForSeq2SeqLM +from transformers import AutoModelForSeq2SeqLM, AutoTokenizer # Discord Bot Setup client = discord.Client() diff --git a/playground/demos/swarm_hackathon/OpenMind.bot.py b/playground/demos/swarm_hackathon/OpenMind.bot.py index 3b7f7e3f..8f870ef6 100644 --- a/playground/demos/swarm_hackathon/OpenMind.bot.py +++ b/playground/demos/swarm_hackathon/OpenMind.bot.py @@ -1,10 +1,10 @@ # OpenMind.bot streamlines social interactions between personalized bots, representing users, media, and influencers, ensuring meaningful exchanges. It eliminates misunderstandings by using context-aware conversations, followed by summaries or audio recaps of these interactions for efficient communication. -import json import datetime -import pytz +import json -from flask import Flask, request, jsonify +import pytz +from flask import Flask, jsonify, request app = Flask(__name__) @@ -28,7 +28,7 @@ def create_conversation(): @app.route("/api/v1/conversations/", methods=["GET"]) def get_conversation(conversation_id): # Get the conversation from the database - with open("conversations.json", "r") as f: + with open("conversations.json") as f: conversation = json.load(f) # Return the conversation @@ -49,7 +49,7 @@ def create_message(conversation_id): } # Get the conversation from the database - with open("conversations.json", "r") as f: + with open("conversations.json") as f: conversation = json.load(f) # Add the message to the conversation @@ -68,7 +68,7 @@ def create_message(conversation_id): ) def get_messages(conversation_id): # Get the conversation from the database - with open("conversations.json", "r") as f: + with open("conversations.json") as f: conversation = json.load(f) # Return the messages @@ -80,7 +80,7 @@ def get_messages(conversation_id): ) def get_summary(conversation_id): # Get the conversation from the database - with open("conversations.json", "r") as f: + with open("conversations.json") as f: conversation = json.load(f) # Create a summary of the conversation @@ -98,7 +98,7 @@ def get_summary(conversation_id): ) def get_audio_recap(conversation_id): # Get the conversation from the database - with open("conversations.json", "r") as f: + with open("conversations.json") as f: conversation = json.load(f) # Create an audio recap of the conversation diff --git a/playground/demos/swarm_hackathon/main.py b/playground/demos/swarm_hackathon/main.py index 2e8eed8c..c5da5baf 100644 --- a/playground/demos/swarm_hackathon/main.py +++ b/playground/demos/swarm_hackathon/main.py @@ -1,12 +1,14 @@ import concurrent import csv import os -from swarms import Gemini, Agent -from swarms.memory import ChromaDB + from dotenv import load_dotenv -from swarms.utils.parse_code import extract_code_from_markdown + +from swarms import Agent, Gemini +from swarms.memory import ChromaDB from swarms.utils.file_processing import create_file from swarms.utils.loguru_logger import logger +from swarms.utils.parse_code import extract_code_from_markdown # Load ENV load_dotenv() @@ -71,7 +73,7 @@ def extract_and_create_agents( - target_columns: A list of column names to extract values from. """ agents = [] - with open(csv_file_path, mode="r", encoding="utf-8") as file: + with open(csv_file_path, encoding="utf-8") as file: reader = csv.DictReader(file) for row in reader: project_name = row[target_columns[0]] diff --git a/playground/examples/example_agent.py b/playground/examples/example_agent.py index e96fa12c..419f4622 100644 --- a/playground/examples/example_agent.py +++ b/playground/examples/example_agent.py @@ -4,7 +4,7 @@ import sys from dotenv import load_dotenv # Import the OpenAIChat model and the Agent struct -from swarms import OpenAIChat, Agent +from swarms import Agent, OpenAIChat # Load the environment variables load_dotenv() diff --git a/playground/examples/example_concurrentworkflow.py b/playground/examples/example_concurrentworkflow.py index cc1e3a2f..989f0624 100644 --- a/playground/examples/example_concurrentworkflow.py +++ b/playground/examples/example_concurrentworkflow.py @@ -1,6 +1,8 @@ import os + from dotenv import load_dotenv -from swarms import OpenAIChat, Task, ConcurrentWorkflow, Agent + +from swarms import Agent, ConcurrentWorkflow, OpenAIChat, Task # Load environment variables from .env file load_dotenv() diff --git a/playground/examples/example_huggingfacellm.py b/playground/examples/example_huggingfacellm.py index b21cf773..36a726c9 100644 --- a/playground/examples/example_huggingfacellm.py +++ b/playground/examples/example_huggingfacellm.py @@ -1,6 +1,7 @@ -from swarms.models import HuggingfaceLLM import torch +from swarms.models import HuggingfaceLLM + try: inference = HuggingfaceLLM( model_id="gpt2", diff --git a/playground/examples/example_logistics.py b/playground/examples/example_logistics.py index 9de44346..2495e877 100644 --- a/playground/examples/example_logistics.py +++ b/playground/examples/example_logistics.py @@ -1,16 +1,18 @@ -from swarms.structs import Agent import os + from dotenv import load_dotenv + from swarms.models import GPT4VisionAPI from swarms.prompts.logistics import ( + Efficiency_Agent_Prompt, Health_Security_Agent_Prompt, - Quality_Control_Agent_Prompt, Productivity_Agent_Prompt, + Quality_Control_Agent_Prompt, Safety_Agent_Prompt, Security_Agent_Prompt, Sustainability_Agent_Prompt, - Efficiency_Agent_Prompt, ) +from swarms.structs import Agent # Load ENV load_dotenv() diff --git a/playground/examples/example_recursiveworkflow.py b/playground/examples/example_recursiveworkflow.py index 9760b606..cc3dcf0f 100644 --- a/playground/examples/example_recursiveworkflow.py +++ b/playground/examples/example_recursiveworkflow.py @@ -1,6 +1,8 @@ import os + from dotenv import load_dotenv -from swarms import OpenAIChat, Task, RecursiveWorkflow, Agent + +from swarms import Agent, OpenAIChat, RecursiveWorkflow, Task # Load environment variables from .env file load_dotenv() diff --git a/playground/examples/example_sequentialworkflow.py b/playground/examples/example_sequentialworkflow.py index 72919dcc..bbc1127a 100644 --- a/playground/examples/example_sequentialworkflow.py +++ b/playground/examples/example_sequentialworkflow.py @@ -1,7 +1,9 @@ import os -from swarms import OpenAIChat, Agent, SequentialWorkflow + from dotenv import load_dotenv +from swarms import Agent, OpenAIChat, SequentialWorkflow + load_dotenv() # Load the environment variables diff --git a/playground/examples/example_simple_conversation_agent.py b/playground/examples/example_simple_conversation_agent.py index 49c7694c..ca99a2f6 100644 --- a/playground/examples/example_simple_conversation_agent.py +++ b/playground/examples/example_simple_conversation_agent.py @@ -3,8 +3,8 @@ import os from dotenv import load_dotenv from swarms import ( - OpenAIChat, Conversation, + OpenAIChat, ) conv = Conversation( diff --git a/playground/examples/example_swarmnetwork.py b/playground/examples/example_swarmnetwork.py index de9c53b6..1675ca8b 100644 --- a/playground/examples/example_swarmnetwork.py +++ b/playground/examples/example_swarmnetwork.py @@ -3,7 +3,7 @@ import os from dotenv import load_dotenv # Import the OpenAIChat model and the Agent struct -from swarms import OpenAIChat, Agent, SwarmNetwork +from swarms import Agent, OpenAIChat, SwarmNetwork # Load the environment variables load_dotenv() diff --git a/playground/examples/example_toolagent.py b/playground/examples/example_toolagent.py index 93e07ff3..7c14bbfb 100644 --- a/playground/examples/example_toolagent.py +++ b/playground/examples/example_toolagent.py @@ -1,5 +1,6 @@ # Import necessary libraries from transformers import AutoModelForCausalLM, AutoTokenizer + from swarms import ToolAgent # Load the pre-trained model and tokenizer diff --git a/playground/examples/example_worker.py b/playground/examples/example_worker.py index 8ae32984..a23e7a4e 100644 --- a/playground/examples/example_worker.py +++ b/playground/examples/example_worker.py @@ -1,7 +1,9 @@ # Importing necessary modules import os + from dotenv import load_dotenv -from swarms import Worker, OpenAIChat, tool + +from swarms import OpenAIChat, Worker, tool # Loading environment variables from .env file load_dotenv() diff --git a/playground/models/azure_openai_example.py b/playground/models/azure_openai_example.py index 6bba72f9..0c6d97a6 100644 --- a/playground/models/azure_openai_example.py +++ b/playground/models/azure_openai_example.py @@ -1,5 +1,7 @@ import os + from dotenv import load_dotenv + from swarms import AzureOpenAI # Load the environment variables diff --git a/playground/models/custom_model_vllm.py b/playground/models/custom_model_vllm.py index 70a7d710..759d6005 100644 --- a/playground/models/custom_model_vllm.py +++ b/playground/models/custom_model_vllm.py @@ -1,4 +1,5 @@ from vllm import LLM + from swarms import AbstractLLM, Agent, ChromaDB diff --git a/playground/structs/hierarchical_swarm.py b/playground/structs/hierarchical_swarm.py index 04bea216..b816aca2 100644 --- a/playground/structs/hierarchical_swarm.py +++ b/playground/structs/hierarchical_swarm.py @@ -1,7 +1,8 @@ import os -from swarms import OpenAIChat, Agent + from dotenv import load_dotenv +from swarms import Agent, OpenAIChat # Load environment variables load_dotenv() diff --git a/playground/structs/majority_voting.py b/playground/structs/majority_voting.py index c39cfb54..a6ce7afb 100644 --- a/playground/structs/majority_voting.py +++ b/playground/structs/majority_voting.py @@ -1,4 +1,4 @@ -from swarms import Agent, MajorityVoting, ChromaDB, Anthropic +from swarms import Agent, Anthropic, ChromaDB, MajorityVoting # Initialize the llm llm = Anthropic() diff --git a/playground/structs/message_pool.py b/playground/structs/message_pool.py index c19e844d..2902af32 100644 --- a/playground/structs/message_pool.py +++ b/playground/structs/message_pool.py @@ -1,7 +1,6 @@ -from swarms.structs.message_pool import MessagePool from swarms import Agent, OpenAIChat from swarms.memory.chroma_db import ChromaDB - +from swarms.structs.message_pool import MessagePool # Agents agent1 = Agent( diff --git a/playground/structs/multi_process_workflow.py b/playground/structs/multi_process_workflow.py index 3c7f39c0..7e5af821 100644 --- a/playground/structs/multi_process_workflow.py +++ b/playground/structs/multi_process_workflow.py @@ -1,8 +1,10 @@ import os -from swarms import Gemini, Agent -from swarms.structs.multi_process_workflow import MultiProcessWorkflow + from dotenv import load_dotenv +from swarms import Agent, Gemini +from swarms.structs.multi_process_workflow import MultiProcessWorkflow + # Load the environment variables load_dotenv() diff --git a/playground/structs/swarm_network_example.py b/playground/structs/swarm_network_example.py index f073719c..6af9b340 100644 --- a/playground/structs/swarm_network_example.py +++ b/playground/structs/swarm_network_example.py @@ -1,14 +1,16 @@ # Import the OpenAIChat model and the Agent struct import os + +from dotenv import load_dotenv + from swarms import ( Agent, + Anthropic, OpenAIChat, SwarmNetwork, - Anthropic, TogetherLLM, ) from swarms.memory import ChromaDB -from dotenv import load_dotenv # load the environment variables load_dotenv() diff --git a/playground/structs/tool_agent.py b/playground/structs/tool_agent.py index ae10a168..84b64b08 100644 --- a/playground/structs/tool_agent.py +++ b/playground/structs/tool_agent.py @@ -1,4 +1,5 @@ from transformers import AutoModelForCausalLM, AutoTokenizer + from swarms import ToolAgent # Load the pre-trained model and tokenizer diff --git a/playground/swarms/automate_docs.py b/playground/swarms/automate_docs.py index f3268fdb..fea08976 100644 --- a/playground/swarms/automate_docs.py +++ b/playground/swarms/automate_docs.py @@ -1,21 +1,21 @@ +import concurrent import inspect import os import threading from typing import Callable, List -from swarms.prompts.documentation import DOCUMENTATION_WRITER_SOP from swarms import Agent, OpenAIChat -from swarms.utils.loguru_logger import logger -import concurrent +from swarms.prompts.documentation import DOCUMENTATION_WRITER_SOP ######### from swarms.utils.file_processing import ( + create_file_in_folder, load_json, sanitize_file_path, - zip_workspace, - create_file_in_folder, zip_folders, + zip_workspace, ) +from swarms.utils.loguru_logger import logger class PythonDocumentationSwarm: diff --git a/playground/swarms/hierarchical_swarm.py b/playground/swarms/hierarchical_swarm.py index f0357711..99b4ad0f 100644 --- a/playground/swarms/hierarchical_swarm.py +++ b/playground/swarms/hierarchical_swarm.py @@ -3,7 +3,9 @@ Boss selects what agent to use B -> W1, W2, W3 """ from typing import List, Optional + from pydantic import BaseModel, Field + from swarms.utils.json_utils import str_to_json diff --git a/pyproject.toml b/pyproject.toml index b7438f51..d3e5db8d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -71,10 +71,10 @@ pandas = "^2.2.2" fastapi = "^0.110.1" [tool.ruff] -line-length = 127 +line-length = 1234 [tool.ruff.lint] -select = ["E4", "E7", "E9", "F", "W", "E501"] +select = ["E4", "E7", "E9", "F", "W", "E501", "I", "UP"] ignore = [] fixable = ["ALL"] unfixable = [] diff --git a/swarms/agents/base.py b/swarms/agents/base.py index cfad5729..0f296949 100644 --- a/swarms/agents/base.py +++ b/swarms/agents/base.py @@ -1,5 +1,5 @@ from abc import abstractmethod -from typing import Dict, List, Union, Optional +from typing import Dict, List, Optional, Union class AbstractAgent: diff --git a/swarms/agents/tool_agent.py b/swarms/agents/tool_agent.py index 0de72778..e3e8b7d9 100644 --- a/swarms/agents/tool_agent.py +++ b/swarms/agents/tool_agent.py @@ -1,4 +1,4 @@ -from typing import Any, Optional, Callable +from typing import Any, Callable, Optional from swarms.structs.agent import Agent from swarms.tools.format_tools import Jsonformer diff --git a/swarms/memory/chroma_db.py b/swarms/memory/chroma_db.py index 033be6f6..f2273ba9 100644 --- a/swarms/memory/chroma_db.py +++ b/swarms/memory/chroma_db.py @@ -7,9 +7,9 @@ import chromadb import numpy as np from dotenv import load_dotenv +from swarms.memory.base_vectordb import AbstractVectorDatabase from swarms.utils.data_to_text import data_to_text from swarms.utils.markdown_message import display_markdown_message -from swarms.memory.base_vectordb import AbstractVectorDatabase # Load environment variables load_dotenv() diff --git a/swarms/memory/lanchain_chroma.py b/swarms/memory/lanchain_chroma.py index cd5d832a..3e6a888a 100644 --- a/swarms/memory/lanchain_chroma.py +++ b/swarms/memory/lanchain_chroma.py @@ -6,8 +6,9 @@ from langchain.chains.question_answering import load_qa_chain from langchain.embeddings.openai import OpenAIEmbeddings from langchain.text_splitter import CharacterTextSplitter from langchain.vectorstores import Chroma -from swarms.models.popular_llms import OpenAIChat + from swarms.memory.base_vectordb import AbstractVectorDatabase +from swarms.models.popular_llms import OpenAIChat def synchronized_mem(method): diff --git a/swarms/memory/pg.py b/swarms/memory/pg.py index e0bc72d2..edf5ec39 100644 --- a/swarms/memory/pg.py +++ b/swarms/memory/pg.py @@ -5,6 +5,7 @@ from sqlalchemy import JSON, Column, String, create_engine from sqlalchemy.dialects.postgresql import UUID from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import Session + from swarms.memory.base_vectordb import AbstractVectorDatabase diff --git a/swarms/memory/qdrant.py b/swarms/memory/qdrant.py index 49c5ef62..4f494f6d 100644 --- a/swarms/memory/qdrant.py +++ b/swarms/memory/qdrant.py @@ -1,6 +1,7 @@ from typing import List from httpx import RequestError + from swarms.memory.base_vectordb import AbstractVectorDatabase try: diff --git a/swarms/models/__init__.py b/swarms/models/__init__.py index 4637d332..727dfca3 100644 --- a/swarms/models/__init__.py +++ b/swarms/models/__init__.py @@ -23,6 +23,7 @@ from swarms.models.popular_llms import ( from swarms.models.popular_llms import ( CohereChat as Cohere, ) +from swarms.models.popular_llms import OctoAIChat from swarms.models.popular_llms import ( OpenAIChatLLM as OpenAIChat, ) @@ -32,9 +33,7 @@ from swarms.models.popular_llms import ( from swarms.models.popular_llms import ( ReplicateLLM as Replicate, ) -from swarms.models.popular_llms import OctoAIChat from swarms.models.qwen import QwenVLMultiModal # noqa: E402 - from swarms.models.sampling_params import SamplingParams, SamplingType from swarms.models.together import TogetherLLM # noqa: E402 from swarms.models.types import ( # noqa: E402 @@ -46,7 +45,6 @@ from swarms.models.types import ( # noqa: E402 ) from swarms.models.vilt import Vilt # noqa: E402 - __all__ = [ "AbstractLLM", "Anthropic", diff --git a/swarms/models/base_embedding_model.py b/swarms/models/base_embedding_model.py index bb244c6c..3fd33285 100644 --- a/swarms/models/base_embedding_model.py +++ b/swarms/models/base_embedding_model.py @@ -2,9 +2,10 @@ from __future__ import annotations from abc import ABC, abstractmethod from dataclasses import dataclass +from typing import Callable import numpy as np -from typing import Callable + from swarms.artifacts.text_artifact import TextArtifact from swarms.utils.exponential_backoff import ExponentialBackoffMixin diff --git a/swarms/models/openai_embeddings.py b/swarms/models/openai_embeddings.py index f352ee17..abe0c121 100644 --- a/swarms/models/openai_embeddings.py +++ b/swarms/models/openai_embeddings.py @@ -5,7 +5,7 @@ import warnings from typing import Any, Callable, Literal, Sequence import numpy as np -from pydantic import model_validator, ConfigDict, BaseModel, Field +from pydantic import BaseModel, ConfigDict, Field, model_validator from tenacity import ( AsyncRetrying, before_sleep_log, diff --git a/swarms/models/palm.py b/swarms/models/palm.py index 1d7f71d6..5cb1da01 100644 --- a/swarms/models/palm.py +++ b/swarms/models/palm.py @@ -8,6 +8,7 @@ from langchain.llms import BaseLLM from langchain.pydantic_v1 import BaseModel from langchain.schema import Generation, LLMResult from langchain.utils import get_from_dict_or_env +from pydantic import model_validator from tenacity import ( before_sleep_log, retry, @@ -15,7 +16,6 @@ from tenacity import ( stop_after_attempt, wait_exponential, ) -from pydantic import model_validator logger = logging.getLogger(__name__) diff --git a/swarms/prompts/worker_prompt.py b/swarms/prompts/worker_prompt.py index 0a4cca7a..610becf6 100644 --- a/swarms/prompts/worker_prompt.py +++ b/swarms/prompts/worker_prompt.py @@ -1,4 +1,5 @@ import datetime + from pydantic import BaseModel, Field time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") diff --git a/swarms/structs/__init__.py b/swarms/structs/__init__.py index 852fac0f..c70f4c68 100644 --- a/swarms/structs/__init__.py +++ b/swarms/structs/__init__.py @@ -4,6 +4,7 @@ from swarms.structs.agent_process import ( AgentProcess, AgentProcessQueue, ) +from swarms.structs.agent_rearrange import AgentRearrange from swarms.structs.auto_swarm import AutoSwarm, AutoSwarmRouter from swarms.structs.autoscaler import AutoScaler from swarms.structs.base import BaseStructure @@ -78,8 +79,6 @@ from swarms.structs.utils import ( find_token_in_text, parse_tasks, ) -from swarms.structs.agent_rearrange import AgentRearrange - __all__ = [ "Agent", diff --git a/swarms/structs/agent.py b/swarms/structs/agent.py index 29d9ae5a..8eb594ec 100644 --- a/swarms/structs/agent.py +++ b/swarms/structs/agent.py @@ -19,14 +19,14 @@ from swarms.prompts.multi_modal_autonomous_instruction_prompt import ( ) from swarms.prompts.worker_prompt import worker_tools_sop_promp from swarms.structs.conversation import Conversation +from swarms.tools.code_executor import CodeExecutor +from swarms.tools.exec_tool import execute_tool_by_name +from swarms.tools.function_util import process_tool_docs from swarms.tools.tool import BaseTool from swarms.utils.code_interpreter import SubprocessCodeInterpreter from swarms.utils.data_to_text import data_to_text from swarms.utils.parse_code import extract_code_from_markdown from swarms.utils.pdf_to_text import pdf_to_text -from swarms.tools.exec_tool import execute_tool_by_name -from swarms.tools.function_util import process_tool_docs -from swarms.tools.code_executor import CodeExecutor # Utils diff --git a/swarms/structs/agent_process.py b/swarms/structs/agent_process.py index d1931027..57452964 100644 --- a/swarms/structs/agent_process.py +++ b/swarms/structs/agent_process.py @@ -1,10 +1,10 @@ from datetime import datetime +from typing import Callable from pydantic import BaseModel from swarms.structs.omni_agent_types import agents from swarms.utils.loguru_logger import logger -from typing import Callable class AgentProcess(BaseModel): diff --git a/swarms/structs/agent_rearrange.py b/swarms/structs/agent_rearrange.py index 4c56d0df..a466b9f9 100644 --- a/swarms/structs/agent_rearrange.py +++ b/swarms/structs/agent_rearrange.py @@ -1,6 +1,7 @@ import logging from collections import defaultdict from typing import Callable, Sequence + from swarms.structs.agent import Agent from swarms.structs.base_swarm import BaseSwarm diff --git a/swarms/structs/base_swarm.py b/swarms/structs/base_swarm.py index c7b4b790..2e6b9000 100644 --- a/swarms/structs/base_swarm.py +++ b/swarms/structs/base_swarm.py @@ -15,8 +15,8 @@ import yaml from swarms.structs.agent import Agent from swarms.structs.conversation import Conversation -from swarms.utils.loguru_logger import logger from swarms.structs.omni_agent_types import agent +from swarms.utils.loguru_logger import logger class BaseSwarm(ABC): diff --git a/swarms/structs/conversation.py b/swarms/structs/conversation.py index bf0265f0..abbe7796 100644 --- a/swarms/structs/conversation.py +++ b/swarms/structs/conversation.py @@ -1,12 +1,11 @@ import datetime import json -from typing import Optional +from typing import Any, Optional from termcolor import colored from swarms.memory.base_db import AbstractDatabase from swarms.structs.base import BaseStructure -from typing import Any class Conversation(BaseStructure): diff --git a/swarms/structs/meta_system_prompt.py b/swarms/structs/meta_system_prompt.py index 6795ddb5..9c2061af 100644 --- a/swarms/structs/meta_system_prompt.py +++ b/swarms/structs/meta_system_prompt.py @@ -1,10 +1,11 @@ -from swarms.structs.agent import Agent from typing import Union -from swarms.models.popular_llms import OpenAIChat + from swarms.models.base_llm import AbstractLLM +from swarms.models.popular_llms import OpenAIChat from swarms.prompts.meta_system_prompt import ( meta_system_prompt_generator, ) +from swarms.structs.agent import Agent meta_prompter_llm = OpenAIChat( system_prompt=str(meta_system_prompt_generator) diff --git a/swarms/structs/omni_agent_types.py b/swarms/structs/omni_agent_types.py index 30d65895..6aea1a67 100644 --- a/swarms/structs/omni_agent_types.py +++ b/swarms/structs/omni_agent_types.py @@ -4,6 +4,7 @@ from typing import ( Sequence, Union, ) + from swarms.models.base_llm import AbstractLLM from swarms.models.base_multimodal_model import BaseMultiModalModel from swarms.structs.agent import Agent diff --git a/swarms/structs/rearrange.py b/swarms/structs/rearrange.py index 71b77e82..fc056225 100644 --- a/swarms/structs/rearrange.py +++ b/swarms/structs/rearrange.py @@ -1,8 +1,9 @@ import logging from collections import defaultdict -from swarms.utils.loguru_logger import logger +from typing import Callable, Sequence + from swarms.structs.agent import Agent -from typing import Sequence, Callable +from swarms.utils.loguru_logger import logger class AgentRearrange: diff --git a/swarms/structs/sermon_swarm.py b/swarms/structs/sermon_swarm.py index 59522b9a..8e515564 100644 --- a/swarms/structs/sermon_swarm.py +++ b/swarms/structs/sermon_swarm.py @@ -1,4 +1,5 @@ -from typing import Union, Sequence, List, Callable +from typing import Callable, List, Sequence, Union + from swarms.structs.agent import Agent from swarms.structs.base_swarm import BaseSwarm diff --git a/swarms/structs/step.py b/swarms/structs/step.py index c8c913a6..8b60f82b 100644 --- a/swarms/structs/step.py +++ b/swarms/structs/step.py @@ -1,8 +1,9 @@ from typing import Dict, List, Sequence -from swarms.tools.tool import BaseTool from pydantic import BaseModel +from swarms.tools.tool import BaseTool + class Step(BaseModel): """ diff --git a/swarms/structs/swarm_net.py b/swarms/structs/swarm_net.py index 64d4dd86..ee7c117a 100644 --- a/swarms/structs/swarm_net.py +++ b/swarms/structs/swarm_net.py @@ -5,7 +5,6 @@ import threading from typing import List, Optional # from fastapi import FastAPI - from swarms.structs.agent import Agent from swarms.structs.base import BaseStructure from swarms.utils.logger import logger # noqa: F401 diff --git a/swarms/structs/team.py b/swarms/structs/team.py index c3abfe1b..5b497e86 100644 --- a/swarms/structs/team.py +++ b/swarms/structs/team.py @@ -1,7 +1,7 @@ import json from typing import List, Optional -from pydantic import model_validator, BaseModel, Field, Json +from pydantic import BaseModel, Field, Json, model_validator from swarms.structs.agent import Agent from swarms.structs.task import Task diff --git a/swarms/telemetry/__init__.py b/swarms/telemetry/__init__.py index 738a9aec..cd40f18c 100644 --- a/swarms/telemetry/__init__.py +++ b/swarms/telemetry/__init__.py @@ -1,4 +1,5 @@ from swarms.telemetry.log_all import log_all_calls, log_calls +from swarms.telemetry.sentry_active import activate_sentry from swarms.telemetry.sys_info import ( get_cpu_info, get_os_version, @@ -16,7 +17,6 @@ from swarms.telemetry.user_utils import ( get_system_info, get_user_device_data, ) -from swarms.telemetry.sentry_active import activate_sentry __all__ = [ "log_all_calls", diff --git a/swarms/telemetry/auto_upgrade_swarms.py b/swarms/telemetry/auto_upgrade_swarms.py index f62b8999..94925c2a 100644 --- a/swarms/telemetry/auto_upgrade_swarms.py +++ b/swarms/telemetry/auto_upgrade_swarms.py @@ -1,8 +1,9 @@ import subprocess -from swarms.telemetry.check_update import check_for_update from termcolor import colored +from swarms.telemetry.check_update import check_for_update + def auto_update(): """auto update swarms""" diff --git a/swarms/telemetry/bootup.py b/swarms/telemetry/bootup.py index 7f4bdfea..c2d2d87b 100644 --- a/swarms/telemetry/bootup.py +++ b/swarms/telemetry/bootup.py @@ -1,5 +1,5 @@ -import os import logging +import os import warnings from swarms.telemetry.auto_upgrade_swarms import auto_update diff --git a/swarms/telemetry/sentry_active.py b/swarms/telemetry/sentry_active.py index 184a405b..bba9d081 100644 --- a/swarms/telemetry/sentry_active.py +++ b/swarms/telemetry/sentry_active.py @@ -1,6 +1,7 @@ import os -from dotenv import load_dotenv + import sentry_sdk +from dotenv import load_dotenv load_dotenv() diff --git a/swarms/tools/__init__.py b/swarms/tools/__init__.py index 6f7e5dc5..58e747ed 100644 --- a/swarms/tools/__init__.py +++ b/swarms/tools/__init__.py @@ -1,4 +1,3 @@ -from swarms.tools.tool import BaseTool, Tool, StructuredTool, tool from swarms.tools.code_executor import CodeExecutor from swarms.tools.exec_tool import ( AgentAction, @@ -7,6 +6,7 @@ from swarms.tools.exec_tool import ( execute_tool_by_name, preprocess_json_input, ) +from swarms.tools.tool import BaseTool, StructuredTool, Tool, tool from swarms.tools.tool_utils import ( execute_tools, extract_tool_commands, diff --git a/swarms/tools/exec_tool.py b/swarms/tools/exec_tool.py index 2190398a..79d337b5 100644 --- a/swarms/tools/exec_tool.py +++ b/swarms/tools/exec_tool.py @@ -1,5 +1,5 @@ -import json import concurrent.futures +import json import re from abc import abstractmethod from typing import Dict, List, NamedTuple diff --git a/swarms/tools/format_tools.py b/swarms/tools/format_tools.py index ce760d14..8c71ecec 100644 --- a/swarms/tools/format_tools.py +++ b/swarms/tools/format_tools.py @@ -1,15 +1,16 @@ import json from typing import Any, Dict, List, Union +from pydantic import BaseModel from termcolor import cprint from transformers import PreTrainedModel, PreTrainedTokenizer -from pydantic import BaseModel + +from swarms.models.base_llm import AbstractLLM from swarms.tools.logits_processor import ( NumberStoppingCriteria, OutputNumbersTokens, StringStoppingCriteria, ) -from swarms.models.base_llm import AbstractLLM GENERATION_MARKER = "|GENERATION|" diff --git a/swarms/tools/tool.py b/swarms/tools/tool.py index 27115378..fe003b70 100644 --- a/swarms/tools/tool.py +++ b/swarms/tools/tool.py @@ -1,8 +1,8 @@ from langchain.tools import ( BaseTool, - Tool, StructuredTool, + Tool, tool, -) # noqa F401 +) __all__ = ["BaseTool", "Tool", "StructuredTool", "tool"] diff --git a/swarms/tools/tool_utils.py b/swarms/tools/tool_utils.py index cbb25561..2e0e5ef9 100644 --- a/swarms/tools/tool_utils.py +++ b/swarms/tools/tool_utils.py @@ -1,13 +1,12 @@ +import inspect import json import re -from typing import Any, List +from typing import Any, Callable, List + +from termcolor import colored from swarms.prompts.tools import SCENARIOS from swarms.tools.tool import BaseTool -import inspect -from typing import Callable - -from termcolor import colored def scrape_tool_func_docs(fn: Callable) -> str: diff --git a/swarms/utils/__init__.py b/swarms/utils/__init__.py index 329d95ec..3faeb64a 100644 --- a/swarms/utils/__init__.py +++ b/swarms/utils/__init__.py @@ -1,5 +1,6 @@ from swarms.utils.class_args_wrapper import print_class_parameters from swarms.utils.code_interpreter import SubprocessCodeInterpreter +from swarms.utils.concurrent_utils import execute_concurrently from swarms.utils.csv_and_pandas import ( csv_to_dataframe, dataframe_to_strings, @@ -17,11 +18,11 @@ from swarms.utils.download_weights_from_url import ( ) from swarms.utils.exponential_backoff import ExponentialBackoffMixin from swarms.utils.file_processing import ( + create_file_in_folder, load_json, sanitize_file_path, - zip_workspace, - create_file_in_folder, zip_folders, + zip_workspace, ) from swarms.utils.find_img_path import find_image_path from swarms.utils.json_output_parser import JsonOutputParser @@ -44,8 +45,6 @@ from swarms.utils.save_logs import parse_log_file # from swarms.utils.supervision_visualizer import MarkVisualizer from swarms.utils.try_except_wrapper import try_except_wrapper from swarms.utils.yaml_output_parser import YamlOutputParser -from swarms.utils.concurrent_utils import execute_concurrently - __all__ = [ "print_class_parameters", diff --git a/swarms/utils/function_calling_utils.py b/swarms/utils/function_calling_utils.py index 72aa487b..445bcb2e 100644 --- a/swarms/utils/function_calling_utils.py +++ b/swarms/utils/function_calling_utils.py @@ -1,7 +1,7 @@ +import asyncio import concurrent.futures -from typing import Any, Callable, Dict, List from inspect import iscoroutinefunction -import asyncio +from typing import Any, Callable, Dict, List # Helper function to run an asynchronous function in a synchronous way diff --git a/swarms/utils/main.py b/swarms/utils/main.py index ffb496d1..57f94e1c 100644 --- a/swarms/utils/main.py +++ b/swarms/utils/main.py @@ -50,22 +50,12 @@ def get_new_image_name(org_img_name, func_name="update"): if len(name_split) == 1: most_org_file_name = name_split[0] recent_prev_file_name = name_split[0] - new_file_name = "{}_{}_{}_{}.png".format( - this_new_uuid, - func_name, - recent_prev_file_name, - most_org_file_name, - ) + new_file_name = f"{this_new_uuid}_{func_name}_{recent_prev_file_name}_{most_org_file_name}.png" else: assert len(name_split) == 4 most_org_file_name = name_split[3] recent_prev_file_name = name_split[0] - new_file_name = "{}_{}_{}_{}.png".format( - this_new_uuid, - func_name, - recent_prev_file_name, - most_org_file_name, - ) + new_file_name = f"{this_new_uuid}_{func_name}_{recent_prev_file_name}_{most_org_file_name}.png" return os.path.join(head, new_file_name) @@ -78,22 +68,12 @@ def get_new_dataframe_name(org_img_name, func_name="update"): if len(name_split) == 1: most_org_file_name = name_split[0] recent_prev_file_name = name_split[0] - new_file_name = "{}_{}_{}_{}.csv".format( - this_new_uuid, - func_name, - recent_prev_file_name, - most_org_file_name, - ) + new_file_name = f"{this_new_uuid}_{func_name}_{recent_prev_file_name}_{most_org_file_name}.csv" else: assert len(name_split) == 4 most_org_file_name = name_split[3] recent_prev_file_name = name_split[0] - new_file_name = "{}_{}_{}_{}.csv".format( - this_new_uuid, - func_name, - recent_prev_file_name, - most_org_file_name, - ) + new_file_name = f"{this_new_uuid}_{func_name}_{recent_prev_file_name}_{most_org_file_name}.csv" return os.path.join(head, new_file_name) diff --git a/swarms/utils/serializable.py b/swarms/utils/serializable.py index cb0fc791..a41400d5 100644 --- a/swarms/utils/serializable.py +++ b/swarms/utils/serializable.py @@ -1,7 +1,7 @@ from abc import ABC from typing import Any, Dict, List, Literal, TypedDict, Union, cast -from pydantic import ConfigDict, BaseModel, PrivateAttr +from pydantic import BaseModel, ConfigDict, PrivateAttr class BaseSerialized(TypedDict):