From e922e7fb8448ac09bfd9002c774159b0b2a57011 Mon Sep 17 00:00:00 2001 From: Kye Date: Tue, 19 Mar 2024 17:00:22 -0700 Subject: [PATCH] [CLEANUP] --- example.py | 16 +++++----------- playground/swarms/hierarchical_swarm.py | 5 ++++- requirements.txt | 2 +- swarm_network_example.py | 7 ------- swarms/tools/tool.py | 7 +------ swarms/utils/json_utils.py | 3 +-- 6 files changed, 12 insertions(+), 28 deletions(-) diff --git a/example.py b/example.py index c4691952..9d68c71d 100644 --- a/example.py +++ b/example.py @@ -1,18 +1,13 @@ from swarms import Agent, Anthropic -from langchain.tools import tool - - -# Tool -@tool -def search_api(query: str, max_results: int = 10): - """ - Search the web for the query and return the top `max_results` results. - """ - return f"Search API: {query} -> {max_results} results" ## Initialize the workflow agent = Agent( + agent_name="Transcript Generator", + agent_description=( + "Generate a transcript for a youtube video on what swarms" + " are!" + ), llm=Anthropic(), max_loops="auto", autosave=True, @@ -20,7 +15,6 @@ agent = Agent( streaming_on=True, verbose=True, stopping_token="", - tools=[search_api], ) # Run the workflow on a task diff --git a/playground/swarms/hierarchical_swarm.py b/playground/swarms/hierarchical_swarm.py index f785dfb0..f0357711 100644 --- a/playground/swarms/hierarchical_swarm.py +++ b/playground/swarms/hierarchical_swarm.py @@ -6,6 +6,7 @@ from typing import List, Optional from pydantic import BaseModel, Field from swarms.utils.json_utils import str_to_json + class HierarchicalSwarm(BaseModel): class Config: arbitrary_types_allowed = True @@ -13,7 +14,9 @@ class HierarchicalSwarm(BaseModel): agents: Optional[List[str]] = Field( None, title="List of agents in the hierarchical swarm" ) - task: Optional[str] = Field(None, title="Task to be done by the agents") + task: Optional[str] = Field( + None, title="Task to be done by the agents" + ) all_agents = HierarchicalSwarm() diff --git a/requirements.txt b/requirements.txt index a1c5c837..b8d654c3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,7 +6,7 @@ langchain-experimental httpx==0.24.1 Pillow==9.4.0 datasets==2.14.5 -pydantic +pydantic==2.6.4 huggingface-hub requests_mock pypdf==4.0.1 diff --git a/swarm_network_example.py b/swarm_network_example.py index e29c919f..f073719c 100644 --- a/swarm_network_example.py +++ b/swarm_network_example.py @@ -64,10 +64,3 @@ out = swarmnet.run_single_agent( agent2.id, "Generate a 10,000 word blog on health and wellness." ) print(out) - - -# # Run all the agents in the swarm network on a task -# out = swarmnet.run_many_agents( -# f"Summarize the blog and create a social media post: {out}" -# ) -# print(out) diff --git a/swarms/tools/tool.py b/swarms/tools/tool.py index 97cf9b84..2a5e3f87 100644 --- a/swarms/tools/tool.py +++ b/swarms/tools/tool.py @@ -1,6 +1 @@ -from langchain.tools import ( - BaseTool, - Tool, - tool, - StructuredTool, -) # noqa +from langchain.tools import BaseTool, StructuredTool, Tool, tool # noqa F401 diff --git a/swarms/utils/json_utils.py b/swarms/utils/json_utils.py index 1ce818bc..c1be4dfd 100644 --- a/swarms/utils/json_utils.py +++ b/swarms/utils/json_utils.py @@ -50,7 +50,6 @@ def base_model_to_json(base_model_instance: BaseModel) -> str: return json_string - def str_to_json(response: str, indent: int = 3): """ Converts a string representation of JSON to a JSON object. @@ -63,4 +62,4 @@ def str_to_json(response: str, indent: int = 3): str: The JSON object as a string. """ - return json.dumps(response, indent=indent) \ No newline at end of file + return json.dumps(response, indent=indent)