[BUGF][Agent]

pull/459/merge
Kye 8 months ago
parent dd1af43013
commit ed4b129b04

@ -0,0 +1,73 @@
from swarms import Agent, AgentRearrange, rearrange, Anthropic
# Initialize the director agent
director = Agent(
agent_name="Director",
system_prompt="Directs the tasks for the workers",
llm=Anthropic(),
max_loops=1,
dashboard=False,
streaming_on=True,
verbose=True,
stopping_token="<DONE>",
state_save_file_type="json",
saved_state_path="director.json",
)
# Initialize worker 1
worker1 = Agent(
agent_name="Worker1",
system_prompt="Generates a transcript for a youtube video on what swarms are",
llm=Anthropic(),
max_loops=1,
dashboard=False,
streaming_on=True,
verbose=True,
stopping_token="<DONE>",
state_save_file_type="json",
saved_state_path="worker1.json",
)
# Initialize worker 2
worker2 = Agent(
agent_name="Worker2",
system_prompt="Summarizes the transcript generated by Worker1",
llm=Anthropic(),
max_loops=1,
dashboard=False,
streaming_on=True,
verbose=True,
stopping_token="<DONE>",
state_save_file_type="json",
saved_state_path="worker2.json",
)
# Create a list of agents
agents = [director, worker1, worker2]
# Define the flow pattern
flow = "Director -> Worker1 -> Worker2"
# Using AgentRearrange class
agent_system = AgentRearrange(agents=agents, flow=flow)
output = agent_system.run(
"Create a format to express and communicate swarms of llms in a structured manner for youtube"
)
print(output)
# Using rearrange function
output = rearrange(
agents,
flow,
"Create a format to express and communicate swarms of llms in a structured manner for youtube",
)
print(output)

@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api"
[tool.poetry]
name = "swarms"
version = "4.9.8"
version = "5.0.0"
description = "Swarms - Pytorch"
license = "MIT"
authors = ["Kye Gomez <kye@apac.ai>"]

@ -13,4 +13,4 @@ from swarms.prompts import * # noqa: E402, F403
from swarms.structs import * # noqa: E402, F403
from swarms.telemetry import * # noqa: E402, F403
from swarms.tools import * # noqa: E402, F403
from swarms.utils import * # noqa: E402, F403
from swarms.utils import * # noqa: E402, F403

@ -155,5 +155,5 @@ __all__ = [
"pydantic_type_to_yaml_schema",
"YamlModel",
"MessagePool",
"rearrange"
"rearrange",
]

@ -314,11 +314,10 @@ class Agent:
self.execute_tool = execute_tool
self.planning = planning
self.planning_prompt = planning_prompt
# Name
self.name = agent_name
# Description
self.description = agent_description
# Agentic stuff
self.reply = ""
@ -334,14 +333,6 @@ class Agent:
if self.multi_modal:
self.sop = MULTI_MODAL_AUTO_AGENT_SYSTEM_PROMPT_1
# If the user inputs a list of strings for the sop then join them and set the sop
if self.sop_list:
self.sop = "\n".join(self.sop_list)
self.short_memory.add(role=self.user_name, content=self.sop)
if self.sop is not None:
self.short_memory.add(role=self.user_name, content=self.sop)
# Memory
self.feedback = []
@ -451,7 +442,7 @@ class Agent:
# Add the tool schema to the short memory
logger.info("Adding tool schema to short memory")
self.short_memory.add(
role=self.user_name, content=tool_schema_str
role=self.user_name, content=tool_schemas
)
# If the algorithm of thoughts is enabled then set the sop to the algorithm of thoughts
@ -466,6 +457,15 @@ class Agent:
logger.info(f"Beginning of Agent {self.agent_name} History")
logger.info(self.short_memory.return_history_as_string())
logger.info(f"End of Agent {self.agent_name} History")
# If the user inputs a list of strings for the sop then join them and set the sop
if self.sop_list:
self.sop = "\n".join(self.sop_list)
self.short_memory.add(role=self.user_name, content=self.sop)
if self.sop is not None:
self.short_memory.add(role=self.user_name, content=self.sop)
def set_system_prompt(self, system_prompt: str):
"""Set the system prompt"""

Loading…
Cancel
Save