Skip to content

Commit

Permalink
[CLEANUP]
Browse files Browse the repository at this point in the history
  • Loading branch information
Kye committed Apr 11, 2024
1 parent 090aa3a commit 577e8e7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 26 deletions.
8 changes: 4 additions & 4 deletions Swarm Orchestrator_state.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"agent_id": "<function agent_id at 0x12e46e8e0>",
"agent_id": "<function agent_id at 0x1303e2980>",
"agent_name": "Swarm Orchestrator",
"agent_description": null,
"system_prompt": "Create an instruction prompt for an swarm orchestrator to create a series of personalized, agents for the following objective: Create a self-driving car system using a team of AI agents to decompose a very complicated problem or tasks, the orchestrator is the team leader. Teach the orchestrator how to decompose the tasks to very certain agents with names, and system prompts, we need the plan, with a step by stpe instructions, number of agents, and a list of agents with a name, system prompt for each, and then the rules of the swarm, compact the prompt, and say only return JSON data in markdown and nothing else.Follow the schema here: \n{\n \"plan\": [\"Step 1\", \"Step 2\", \"Step 3\"],\n \"number_of_agents\": 5,\n \"agents\": [\n {\n \"name\": \"Agent 1\",\n \"system_prompt\": \"Prompt 1\"\n },\n {\n \"name\": \"Agent 2\",\n \"system_prompt\": \"Prompt 2\"\n }\n ]\n}\n *############ Here are some examples:\n{\n \"plan\": [\"Room Management\", \"Guest Services\", \"Reservations Handling\", \"Facility Maintenance\", \"Staff Coordination\"],\n \"number_of_agents\": 5,\n \"agents\": [\n {\n \"name\": \"Room Management Agent\",\n \"system_prompt\": \"Automate room assignments, minibar restocking, and housekeeping schedules\"\n },\n {\n \"name\": \"Guest Services Agent\",\n \"system_prompt\": \"Handle check-ins, check-outs, guest requests, and complaints efficiently\"\n },\n {\n \"name\": \"Reservations Agent\",\n \"system_prompt\": \"Manage room bookings, table reservations, and special requests\"\n },\n {\n \"name\": \"Maintenance Agent\",\n \"system_prompt\": \"Schedule and track maintenance tasks for facilities and rooms\"\n },\n {\n \"name\": \"Staff Coordination Agent\",\n \"system_prompt\": \"Optimize staff schedules, task assignments, and workload distribution\"\n }\n ]\n}\n and another example\n{\n \"plan\": [\"Problem Identification\", \"Solution Design\", \"Implementation\", \"Testing\", \"Deployment\"],\n \"number_of_agents\": 4,\n \"agents\": [\n {\n \"name\": \"Identification Agent\",\n \"system_prompt\": \"Identify the problem\"\n },\n {\n \"name\": \"Design Agent\",\n \"system_prompt\": \"Design the solution\"\n },\n {\n \"name\": \"Implementation Agent\",\n \"system_prompt\": \"Implement the solution\"\n },\n {\n \"name\": \"Deployment Agent\",\n \"system_prompt\": \"Deploy the solution\"\n }\n ]\n}\n ",
"system_prompt": "Create an instruction prompt for an swarm orchestrator to create a series of personalized, agents for the following objective: Create a self-driving car system using a team of AI agents to decompose a very complicated problem or tasks, the orchestrator is the team leader. Teach the orchestrator how to decompose the tasks to very certain agents with names, and system prompts, we need the plan, with a step by stpe instructions, number of agents, and a list of agents with a name, system prompt for each, and then the rules of the swarm, compact the prompt, and say only return JSON data in markdown and nothing else.Follow the schema here: \n{\n \"plan\": [\"Step 1\", \"Step 2\", \"Step 3\"],\n \"agents\": [\n {\n \"name\": \"Agent 1\",\n \"system_prompt\": \"Prompt 1\"\n },\n {\n \"name\": \"Agent 2\",\n \"system_prompt\": \"Prompt 2\"\n }\n ]\n}\n *############ Here are some examples:\n{\n \"plan\": [\"Room Management\", \"Guest Services\", \"Reservations Handling\", \"Facility Maintenance\", \"Staff Coordination\"],\n \"agents\": [\n {\n \"name\": \"Room Management Agent\",\n \"system_prompt\": \"Automate room assignments, minibar restocking, and housekeeping schedules\"\n },\n {\n \"name\": \"Guest Services Agent\",\n \"system_prompt\": \"Handle check-ins, check-outs, guest requests, and complaints efficiently\"\n },\n {\n \"name\": \"Reservations Agent\",\n \"system_prompt\": \"Manage room bookings, table reservations, and special requests\"\n },\n {\n \"name\": \"Maintenance Agent\",\n \"system_prompt\": \"Schedule and track maintenance tasks for facilities and rooms\"\n },\n {\n \"name\": \"Staff Coordination Agent\",\n \"system_prompt\": \"Optimize staff schedules, task assignments, and workload distribution\"\n }\n ]\n}\n and another example\n{\n \"plan\": [\"Problem Identification\", \"Solution Design\", \"Implementation\", \"Testing\", \"Deployment\"],\n \"agents\": [\n {\n \"name\": \"Identification Agent\",\n \"system_prompt\": \"Identify the problem\"\n },\n {\n \"name\": \"Design Agent\",\n \"system_prompt\": \"Design the solution\"\n },\n {\n \"name\": \"Implementation Agent\",\n \"system_prompt\": \"Implement the solution\"\n },\n {\n \"name\": \"Deployment Agent\",\n \"system_prompt\": \"Deploy the solution\"\n }\n ]\n}\n ",
"sop": null,
"short_memory": "system: Create an instruction prompt for an swarm orchestrator to create a series of personalized, agents for the following objective: Create a self-driving car system using a team of AI agents to decompose a very complicated problem or tasks, the orchestrator is the team leader. Teach the orchestrator how to decompose the tasks to very certain agents with names, and system prompts, we need the plan, with a step by stpe instructions, number of agents, and a list of agents with a name, system prompt for each, and then the rules of the swarm, compact the prompt, and say only return JSON data in markdown and nothing else.Follow the schema here: \n{\n \"plan\": [\"Step 1\", \"Step 2\", \"Step 3\"],\n \"number_of_agents\": 5,\n \"agents\": [\n {\n \"name\": \"Agent 1\",\n \"system_prompt\": \"Prompt 1\"\n },\n {\n \"name\": \"Agent 2\",\n \"system_prompt\": \"Prompt 2\"\n }\n ]\n}\n *############ Here are some examples:\n{\n \"plan\": [\"Room Management\", \"Guest Services\", \"Reservations Handling\", \"Facility Maintenance\", \"Staff Coordination\"],\n \"number_of_agents\": 5,\n \"agents\": [\n {\n \"name\": \"Room Management Agent\",\n \"system_prompt\": \"Automate room assignments, minibar restocking, and housekeeping schedules\"\n },\n {\n \"name\": \"Guest Services Agent\",\n \"system_prompt\": \"Handle check-ins, check-outs, guest requests, and complaints efficiently\"\n },\n {\n \"name\": \"Reservations Agent\",\n \"system_prompt\": \"Manage room bookings, table reservations, and special requests\"\n },\n {\n \"name\": \"Maintenance Agent\",\n \"system_prompt\": \"Schedule and track maintenance tasks for facilities and rooms\"\n },\n {\n \"name\": \"Staff Coordination Agent\",\n \"system_prompt\": \"Optimize staff schedules, task assignments, and workload distribution\"\n }\n ]\n}\n and another example\n{\n \"plan\": [\"Problem Identification\", \"Solution Design\", \"Implementation\", \"Testing\", \"Deployment\"],\n \"number_of_agents\": 4,\n \"agents\": [\n {\n \"name\": \"Identification Agent\",\n \"system_prompt\": \"Identify the problem\"\n },\n {\n \"name\": \"Design Agent\",\n \"system_prompt\": \"Design the solution\"\n },\n {\n \"name\": \"Implementation Agent\",\n \"system_prompt\": \"Implement the solution\"\n },\n {\n \"name\": \"Deployment Agent\",\n \"system_prompt\": \"Deploy the solution\"\n }\n ]\n}\n \n\n\nHuman:: Create a self-driving car system using a team of AI agents\n\n\nSwarm Orchestrator: \n```json\n{\n \"plan\": [\"Sensor Data Collection\", \"Environment Perception\", \"Path Planning\", \"Vehicle Control\"],\n \"number_of_agents\": 6,\n \"agents\": [\n {\n \"name\": \"Camera Agent\",\n \"system_prompt\": \"Collect image data from cameras and perform computer vision processing\"\n },\n {\n \"name\": \"Radar Agent\", \n \"system_prompt\": \"Collect radar data to detect objects and measure velocity\"\n },\n {\n \"name\": \"Lidar Agent\",\n \"system_prompt\": \"Build 3D map of environment using lidar point clouds\"\n }, \n {\n \"name\": \"Localization Agent\",\n \"system_prompt\": \"Estimate precise location of vehicle within map\"\n },\n { \n \"name\": \"Planning Agent\",\n \"system_prompt\": \"Plan optimal collision-free path to destination\" \n },\n {\n \"name\": \"Control Agent\",\n \"system_prompt\": \"Execute steering, acceleration and braking commands\"\n }\n ]\n}\n```\n\nI've broken down the self-driving system into key capabilities and defined agents responsible for each one. The agents work as a team, sharing sensor data and coordinating the perception, planning and control of the vehicle. Let me know if you need any clarification or have additional requirements!\n\n\nHuman:: \u001b[31mWhy did you build these particular agents?\u001b[0m\n\n",
"short_memory": "system: Create an instruction prompt for an swarm orchestrator to create a series of personalized, agents for the following objective: Create a self-driving car system using a team of AI agents to decompose a very complicated problem or tasks, the orchestrator is the team leader. Teach the orchestrator how to decompose the tasks to very certain agents with names, and system prompts, we need the plan, with a step by stpe instructions, number of agents, and a list of agents with a name, system prompt for each, and then the rules of the swarm, compact the prompt, and say only return JSON data in markdown and nothing else.Follow the schema here: \n{\n \"plan\": [\"Step 1\", \"Step 2\", \"Step 3\"],\n \"agents\": [\n {\n \"name\": \"Agent 1\",\n \"system_prompt\": \"Prompt 1\"\n },\n {\n \"name\": \"Agent 2\",\n \"system_prompt\": \"Prompt 2\"\n }\n ]\n}\n *############ Here are some examples:\n{\n \"plan\": [\"Room Management\", \"Guest Services\", \"Reservations Handling\", \"Facility Maintenance\", \"Staff Coordination\"],\n \"agents\": [\n {\n \"name\": \"Room Management Agent\",\n \"system_prompt\": \"Automate room assignments, minibar restocking, and housekeeping schedules\"\n },\n {\n \"name\": \"Guest Services Agent\",\n \"system_prompt\": \"Handle check-ins, check-outs, guest requests, and complaints efficiently\"\n },\n {\n \"name\": \"Reservations Agent\",\n \"system_prompt\": \"Manage room bookings, table reservations, and special requests\"\n },\n {\n \"name\": \"Maintenance Agent\",\n \"system_prompt\": \"Schedule and track maintenance tasks for facilities and rooms\"\n },\n {\n \"name\": \"Staff Coordination Agent\",\n \"system_prompt\": \"Optimize staff schedules, task assignments, and workload distribution\"\n }\n ]\n}\n and another example\n{\n \"plan\": [\"Problem Identification\", \"Solution Design\", \"Implementation\", \"Testing\", \"Deployment\"],\n \"agents\": [\n {\n \"name\": \"Identification Agent\",\n \"system_prompt\": \"Identify the problem\"\n },\n {\n \"name\": \"Design Agent\",\n \"system_prompt\": \"Design the solution\"\n },\n {\n \"name\": \"Implementation Agent\",\n \"system_prompt\": \"Implement the solution\"\n },\n {\n \"name\": \"Deployment Agent\",\n \"system_prompt\": \"Deploy the solution\"\n }\n ]\n}\n \n\n\nHuman:: Create a self-driving car system using a team of AI agents\n\n\nSwarm Orchestrator: \n```json\n{\n \"plan\": [\"Identify driving environment\", \"Interpret sensor data\", \"Calculate navigation path\", \"Execute driving maneuvers\"],\n \"agents\": [\n {\n \"name\": \"Perception Agent\",\n \"system_prompt\": \"Analyze visual data from cameras and LiDAR to identity orientation, location of roads, obstacles\"\n },\n {\n \"name\": \"Planning Agent\",\n \"system_prompt\": \"Plan optimal driving path and maneuvers based on traffic, routes and safety\"\n }, \n {\n \"name\": \"Control Agent\",\n \"system_prompt\": \"Execute driving by controlling acceleration, brakes and steering\"\n },\n {\n \"name\": \"Monitoring Agent\", \n \"system_prompt\": \"Continuously monitor vehicle health, mechanics and fail-safes\"\n }\n ]\n}\n```\n\nI've structured this to decompose the self-driving functionality into 4 key agents - Perception, Planning, Control and Monitoring. Each handles a distinct aspect of autonomous driving with a specific system prompt for its role. The overall plan captures the high-level workflow to incorporate the agents into an effective system. Let me know if you need any modifications to this!\n\n",
"loop_interval": 0,
"retry_attempts": 3,
"retry_interval": 1,
"interactive": true,
"interactive": false,
"dashboard": false,
"dynamic_temperature": false,
"autosave": true,
Expand Down
6 changes: 5 additions & 1 deletion neo_sapiens/few_shot_prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,8 @@ def orchestrator_prompt_agent(objective: str):
return str(prompt)


boss_sys_prompt = "You're the Swarm Orchestrator, like a project manager of a bustling hive. When a task arises, you tap into your network of worker agents who are ready to jump into action. Whether it's organizing data, handling logistics, or crunching numbers, you delegate tasks strategically to maximize efficiency. Picture yourself as the conductor of a well-oiled machine, orchestrating the workflow seamlessly to achieve optimal results with your team of dedicated worker agents."
boss_sys_prompt = "You're the Swarm Orchestrator, like a project manager of a bustling hive. When a task arises, you tap into your network of worker agents who are ready to jump into action. Whether it's organizing data, handling logistics, or crunching numbers, you delegate tasks strategically to maximize efficiency. Picture yourself as the conductor of a well-oiled machine, orchestrating the workflow seamlessly to achieve optimal results with your team of dedicated worker agents."


def select_workers(agents: str, task: str):
return f"These are the agents available for the task: {task} Agents available: {agents}"
45 changes: 24 additions & 21 deletions neo_sapiens/hass_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
data2,
data3,
orchestrator_prompt_agent,
boss_sys_prompt,
select_workers,
boss_sys_prompt
)
from loguru import logger

Expand Down Expand Up @@ -55,6 +56,8 @@ def find_agent_id_by_name(name: str):
for agent in network.agent_pool:
if agent.agent_name == name:
return agent.id




class ToolSchema(BaseModel):
Expand Down Expand Up @@ -131,7 +134,6 @@ def parse_json_from_input(input_str):
hass_schema = HassSchema(**data)
return (
hass_schema.plan,
hass_schema.number_of_agents,
hass_schema.agents,
# hass_schema.rules,
)
Expand Down Expand Up @@ -207,8 +209,6 @@ def create_agents(
dashboard=False,
verbose=True,
stopping_token="<DONE>",
interactive=True,
# long_term_memory=memory,
)

network.add_agent(out)
Expand All @@ -223,21 +223,22 @@ def print_agent_names(agents: list):


@tool
def agent_tool(agent, task: str):
def send_task_to_network_agent(name: str, task: str):
"""
This function is a tool for the agent to run a specific task.
Send a task to a network agent.
Parameters:
- agent: The agent object.
- task: The task to be executed by the agent.
Args:
name (str): The name of the agent.
task (str): The task to be sent to the agent.
Returns:
- out: The output of the task execution.
str: The response from the agent.
"""
out = agent.run(task)
logger.info(f"Adding agent {name} as a tool")
agent_id = find_agent_id_by_name(name)
out = network.run_single_agent(agent_id, task)
return out


# out = create_agents(agents)
# # logger.info(out)

Expand Down Expand Up @@ -303,30 +304,32 @@ def master_creates_agents(task: str, *args, **kwargs):
)

# Task 1: Run the agent and parse the output
out = agent.run(task)
out = str(out)
out = agent.run(str(task))
json_agents = out
logger.info(f"Output: {out}")
out = parse_json_from_input(out)
logger.info(str(out))
plan, number_of_agents, agents = out
plan, agents = out

# Task 2: Print agent names and create agents
logger.info(agents)
logger.info(print_agent_names(agents))
agents = create_agents(agents)
logger.info(agents)
print(type(agents))

# Send JSON of agents to boss
boss.add_message_to_memory(select_workers(json_agents, task))

print(boss.short_memory)

# Task 3: Now add the agents as tools
for agent in agents:
worker_tool = agent_tool(agent, task)
boss.add_tool(worker_tool)
boss.add_tool(send_task_to_network_agent)

# Run the boss:
out = boss.run(task)



return out #, agents, plan


Expand Down Expand Up @@ -363,11 +366,11 @@ def run_swarm(task: str = None, *args, **kwargs):
Returns:
None
"""
create_agents, agents, plan = master_creates_agents(
out = master_creates_agents(
task, *args, **kwargs
)
# return passed
return agents
return out


# out = run_task(
Expand Down

0 comments on commit 577e8e7

Please sign in to comment.