pull/421/head
Kye 10 months ago
parent 50215f229f
commit e922e7fb84

@ -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="<DONE>",
tools=[search_api],
)
# Run the workflow on a task

@ -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()

@ -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

@ -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)

@ -1,6 +1 @@
from langchain.tools import (
BaseTool,
Tool,
tool,
StructuredTool,
) # noqa
from langchain.tools import BaseTool, StructuredTool, Tool, tool # noqa F401

@ -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)
return json.dumps(response, indent=indent)

Loading…
Cancel
Save