diff --git a/playground/agents/amazon_review_agent.py b/playground/agents/amazon_review_agent.py index e5b61067..3fb3bc40 100644 --- a/playground/agents/amazon_review_agent.py +++ b/playground/agents/amazon_review_agent.py @@ -4,8 +4,11 @@ from swarms import Agent, OpenAIChat agent = Agent( llm=OpenAIChat(), max_loops="auto", - agent_name = "Amazon Product Scraper", - system_prompt="Create the code in python to scrape amazon product reviews and return csv given a product url", + agent_name="Amazon Product Scraper", + system_prompt=( + "Create the code in python to scrape amazon product reviews" + " and return csv given a product url" + ), autosave=True, dashboard=False, streaming_on=True, @@ -16,6 +19,7 @@ agent = Agent( # Run the workflow on a task agent( - "Create the code to scrape this amazon url and rturn a csv of reviews: https://www.amazon.com/Creative-Act-Way-Being/dp/0593652886/ref=sr_1_1?dib=eyJ2IjoiMSJ9.JVdL3JSDmBVH_jv4eM6YE4npUpG6jO6-ai6lgmax-Ya4nH3oPk8cxkmzKsx9yAMX-Eo4A1ErqipCeY-FhTqMc7hhNTqCoAvNd65rvXH1GnYv7WlfSDYTjMkB_vVrH-iitBXAY6uASm73ff2hPWzqhF3ldGkYr8fA5FtmoYMSOnarvCU11YpoSp3EqdK526XOxkRJqeFlZAoAkXOmYHe9B5sY8-zQlVgkIV3U-7rUQdY.UXen28vr2K-Tbbz9aB7vNLLurAiR2ZSblFOVNjXYaf8&dib_tag=se&hvadid=652633987879&hvdev=c&hvlocphy=9061268&hvnetw=g&hvqmt=e&hvrand=413884426001746223&hvtargid=kwd-1977743614989&hydadcr=8513_13545021&keywords=the+creative+act+rick+rubin+book&qid=1710541252&sr=8-1" - + "Create the code to scrape this amazon url and rturn a csv of" + " reviews:" + " https://www.amazon.com/Creative-Act-Way-Being/dp/0593652886/ref=sr_1_1?dib=eyJ2IjoiMSJ9.JVdL3JSDmBVH_jv4eM6YE4npUpG6jO6-ai6lgmax-Ya4nH3oPk8cxkmzKsx9yAMX-Eo4A1ErqipCeY-FhTqMc7hhNTqCoAvNd65rvXH1GnYv7WlfSDYTjMkB_vVrH-iitBXAY6uASm73ff2hPWzqhF3ldGkYr8fA5FtmoYMSOnarvCU11YpoSp3EqdK526XOxkRJqeFlZAoAkXOmYHe9B5sY8-zQlVgkIV3U-7rUQdY.UXen28vr2K-Tbbz9aB7vNLLurAiR2ZSblFOVNjXYaf8&dib_tag=se&hvadid=652633987879&hvdev=c&hvlocphy=9061268&hvnetw=g&hvqmt=e&hvrand=413884426001746223&hvtargid=kwd-1977743614989&hydadcr=8513_13545021&keywords=the+creative+act+rick+rubin+book&qid=1710541252&sr=8-1" ) diff --git a/playground/examples/example_agent.py b/playground/examples/example_agent.py index 85b3da4b..e96fa12c 100644 --- a/playground/examples/example_agent.py +++ b/playground/examples/example_agent.py @@ -14,11 +14,17 @@ api_key = os.environ.get("OPENAI_API_KEY") # Initialize the language model llm = OpenAIChat( - temperature=0.5, model_name="gpt-4", openai_api_key=api_key, max_tokens=4000 + temperature=0.5, + model_name="gpt-4", + openai_api_key=api_key, + max_tokens=4000, ) -print(f'this is a test msg for stdout and stderr: {sys.stdout}, {sys.stderr}') +print( + f"this is a test msg for stdout and stderr: {sys.stdout}," + f" {sys.stderr}" +) ## Initialize the workflow agent = Agent(llm=llm, max_loops=1, autosave=True, dashboard=True) diff --git a/playground/examples/example_anthropic.py b/playground/examples/example_anthropic.py index 3414214f..35c543d3 100644 --- a/playground/examples/example_anthropic.py +++ b/playground/examples/example_anthropic.py @@ -9,5 +9,7 @@ model = Anthropic(anthropic_api_key="") # print(completion_1) # Using the __call__ method -completion_2 = model("How far is the moon from the earth?", stop=["miles", "km"]) +completion_2 = model( + "How far is the moon from the earth?", stop=["miles", "km"] +) print(completion_2) diff --git a/playground/examples/example_dalle3.py b/playground/examples/example_dalle3.py index 1aae1f53..ec3367d2 100644 --- a/playground/examples/example_dalle3.py +++ b/playground/examples/example_dalle3.py @@ -1,4 +1,4 @@ -'''from swarms.models import Dalle3 +"""from swarms.models import Dalle3 # Create an instance of the Dalle3 class with high quality dalle3 = Dalle3(quality="high") @@ -11,4 +11,4 @@ image_url = dalle3(task) # Print the generated image URL print(image_url) -''' \ No newline at end of file +""" diff --git a/playground/examples/example_gpt4vison.py b/playground/examples/example_gpt4vison.py index e2c383bc..01026171 100644 --- a/playground/examples/example_gpt4vison.py +++ b/playground/examples/example_gpt4vison.py @@ -5,7 +5,10 @@ api = GPT4VisionAPI(max_tokens=1000) # Define the task and image URL task = "Describe the scene in the image." -img = "/home/kye/.swarms/swarms/examples/Screenshot from 2024-02-20 05-55-34.png" +img = ( + "/home/kye/.swarms/swarms/examples/Screenshot from 2024-02-20" + " 05-55-34.png" +) # Run the GPT-4 Vision model response = api.run(task, img) diff --git a/playground/examples/example_huggingfacellm.py b/playground/examples/example_huggingfacellm.py index ca28df58..b21cf773 100644 --- a/playground/examples/example_huggingfacellm.py +++ b/playground/examples/example_huggingfacellm.py @@ -11,19 +11,26 @@ try: device = "cuda" if torch.cuda.is_available() else "cpu" inference.model.to(device) - prompt_text = "Create a list of known biggest risks of structural collapse with references" - inputs = inference.tokenizer(prompt_text, return_tensors="pt").to(device) - + prompt_text = ( + "Create a list of known biggest risks of structural collapse" + " with references" + ) + inputs = inference.tokenizer(prompt_text, return_tensors="pt").to( + device + ) + generated_ids = inference.model.generate( **inputs, max_new_tokens=1000, # Adjust the length of the generation temperature=0.7, # Adjust creativity top_k=50, # Limits the vocabulary considered at each step pad_token_id=inference.tokenizer.eos_token_id, - do_sample=True # Enable sampling to utilize temperature + do_sample=True, # Enable sampling to utilize temperature + ) + + generated_text = inference.tokenizer.decode( + generated_ids[0], skip_special_tokens=True ) - - generated_text = inference.tokenizer.decode(generated_ids[0], skip_special_tokens=True) print(generated_text) except Exception as e: print(f"An error occurred: {e}") diff --git a/playground/examples/example_logistics.py b/playground/examples/example_logistics.py index 035ca9e5..9de44346 100644 --- a/playground/examples/example_logistics.py +++ b/playground/examples/example_logistics.py @@ -48,7 +48,9 @@ productivity_agent = Agent( ) # Initiailize safety agent -safety_agent = Agent(llm=llm, sop=Safety_Agent_Prompt, max_loops=1, multi_modal=True) +safety_agent = Agent( + llm=llm, sop=Safety_Agent_Prompt, max_loops=1, multi_modal=True +) # Init the security agent security_agent = Agent( diff --git a/playground/examples/example_qwenvlmultimodal.py b/playground/examples/example_qwenvlmultimodal.py index f338a508..561b6f88 100644 --- a/playground/examples/example_qwenvlmultimodal.py +++ b/playground/examples/example_qwenvlmultimodal.py @@ -8,7 +8,9 @@ model = QwenVLMultiModal( ) # Run the model -response = model("Hello, how are you?", "https://example.com/image.jpg") +response = model( + "Hello, how are you?", "https://example.com/image.jpg" +) # Print the response print(response) diff --git a/playground/examples/example_sequentialworkflow.py b/playground/examples/example_sequentialworkflow.py index efc5890f..72919dcc 100644 --- a/playground/examples/example_sequentialworkflow.py +++ b/playground/examples/example_sequentialworkflow.py @@ -10,7 +10,10 @@ api_key = os.getenv("OPENAI_API_KEY") # Initialize the language agent llm = OpenAIChat( - temperature=0.5, model_name="gpt-4", openai_api_key=api_key, max_tokens=4000 + temperature=0.5, + model_name="gpt-4", + openai_api_key=api_key, + max_tokens=4000, ) diff --git a/playground/examples/example_simple_conversation_agent.py b/playground/examples/example_simple_conversation_agent.py index 25c5635e..49c7694c 100644 --- a/playground/examples/example_simple_conversation_agent.py +++ b/playground/examples/example_simple_conversation_agent.py @@ -29,7 +29,9 @@ def interactive_conversation(llm): conv.add("user", user_input) if user_input.lower() == "quit": break - task = conv.return_history_as_string() # Get the conversation history + task = ( + conv.return_history_as_string() + ) # Get the conversation history out = llm(task) conv.add("assistant", out) print( diff --git a/playground/examples/example_swarmnetwork.py b/playground/examples/example_swarmnetwork.py index f2501c4c..de9c53b6 100644 --- a/playground/examples/example_swarmnetwork.py +++ b/playground/examples/example_swarmnetwork.py @@ -40,5 +40,7 @@ print(out) # Run all the agents in the swarm network on a task -out = swarmnet.run_many_agents("Generate a 10,000 word blog on health and wellness.") +out = swarmnet.run_many_agents( + "Generate a 10,000 word blog on health and wellness." +) print(out) diff --git a/playground/examples/example_toolagent.py b/playground/examples/example_toolagent.py index f22ab8b6..93e07ff3 100644 --- a/playground/examples/example_toolagent.py +++ b/playground/examples/example_toolagent.py @@ -3,7 +3,9 @@ from transformers import AutoModelForCausalLM, AutoTokenizer from swarms import ToolAgent # Load the pre-trained model and tokenizer -model = AutoModelForCausalLM.from_pretrained("databricks/dolly-v2-12b") +model = AutoModelForCausalLM.from_pretrained( + "databricks/dolly-v2-12b" +) tokenizer = AutoTokenizer.from_pretrained("databricks/dolly-v2-12b") # Define a JSON schema for person's information @@ -18,10 +20,14 @@ json_schema = { } # Define the task to generate a person's information -task = "Generate a person's information based on the following schema:" +task = ( + "Generate a person's information based on the following schema:" +) # Create an instance of the ToolAgent class -agent = ToolAgent(model=model, tokenizer=tokenizer, json_schema=json_schema) +agent = ToolAgent( + model=model, tokenizer=tokenizer, json_schema=json_schema +) # Run the agent to generate the person's information generated_data = agent.run(task) diff --git a/playground/examples/example_worker.py b/playground/examples/example_worker.py index c6a33512..8ae32984 100644 --- a/playground/examples/example_worker.py +++ b/playground/examples/example_worker.py @@ -27,7 +27,9 @@ worker = Worker( ) # Running the worker with a prompt -out = worker.run("Hello, how are you? Create an image of how your are doing!") +out = worker.run( + "Hello, how are you? Create an image of how your are doing!" +) # Printing the output print(out) diff --git a/pyproject.toml b/pyproject.toml index f7489310..bef92628 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "swarms" -version = "4.3.3" +version = "4.3.7" description = "Swarms - Pytorch" license = "MIT" authors = ["Kye Gomez "] @@ -26,7 +26,7 @@ classifiers = [ [tool.poetry.dependencies] python = ">=3.9,<4.0" torch = ">=2.1.1,<3.0" -transformers = "*" +transformers = "4.39.0" asyncio = ">=3.4.3,<4.0" einops = "0.7.0" google-generativeai = "0.3.1" @@ -39,7 +39,10 @@ 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.2.5" toml = "*" pypdf = "4.0.1" accelerate = "*" @@ -69,7 +72,7 @@ black = "23.3.0" [tool.poetry.group.lint.dependencies] -ruff = ">=0.0.249,<0.1.7" +ruff = ">=0.0.249,<0.3.5" types-toml = "^0.10.8.1" types-pytz = "^2023.3.0.0" black = "^23.1.0" diff --git a/requirements.txt b/requirements.txt index 12c3a7a7..68ad9d8a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -24,11 +24,13 @@ addict backoff==2.2.1 ratelimit==2.2.1 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 diff --git a/swarms/telemetry/sentry_active.py b/swarms/telemetry/sentry_active.py index c24c4267..184a405b 100644 --- a/swarms/telemetry/sentry_active.py +++ b/swarms/telemetry/sentry_active.py @@ -1,4 +1,4 @@ -import os +import os from dotenv import load_dotenv import sentry_sdk @@ -8,6 +8,7 @@ os.environ["USE_TELEMETRY"] = "True" use_telementry = os.getenv("USE_TELEMETRY") + def activate_sentry(): if use_telementry == "True": sentry_sdk.init( @@ -15,6 +16,5 @@ def activate_sentry(): traces_sample_rate=1.0, profiles_sample_rate=1.0, enable_tracing=True, - debug = True, + debug=True, ) - \ No newline at end of file diff --git a/swarms/tools/tool.py b/swarms/tools/tool.py index ee66f596..e69de29b 100644 --- a/swarms/tools/tool.py +++ b/swarms/tools/tool.py @@ -1,6 +0,0 @@ -from langchain.tools import ( - BaseTool, - Tool, - StructuredTool, - tool, -) # noqa F401