-
-
Notifications
You must be signed in to change notification settings - Fork 445
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DEMO][Swarm of MultiModalityRobots][sequential_workflow with images
- Loading branch information
Kye
committed
Nov 26, 2023
1 parent
a56b0b6
commit b457511
Showing
11 changed files
with
396 additions
and
50 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
129 changes: 129 additions & 0 deletions
129
playground/demos/swarm_of_mma_manufacturing/flow_iter.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
""" | ||
Swarm of multi modal autonomous agents for manufacturing! | ||
--------------------------------------------------------- | ||
Health Security agent: Agent that monitors the health of working conditions: input image of factory output: health safety index 0.0 - 1.0 being the highest | ||
Quality Control agent: Agent that monitors the quality of the product: input image of product output: quality index 0.0 - 1.0 being the highest | ||
Productivity agent: Agent that monitors the productivity of the factory: input image of factory output: productivity index 0.0 - 1.0 being the highest | ||
Safety agent: Agent that monitors the safety of the factory: input image of factory output: safety index 0.0 - 1.0 being the highest | ||
Security agent: Agent that monitors the security of the factory: input image of factory output: security index 0.0 - 1.0 being the highest | ||
Sustainability agent: Agent that monitors the sustainability of the factory: input image of factory output: sustainability index 0.0 - 1.0 being the highest | ||
Efficiency agent: Agent that monitors the efficiency of the factory: input image of factory output: efficiency index 0.0 - 1.0 being the highest | ||
Flow: | ||
health security agent -> quality control agent -> productivity agent -> safety agent -> security agent -> sustainability agent -> efficiency agent | ||
""" | ||
from swarms.structs import Flow, SequentialWorkflow | ||
import os | ||
from dotenv import load_dotenv | ||
from swarms.models import GPT4VisionAPI | ||
from swarms.prompts.multi_modal_autonomous_instruction_prompt import ( | ||
MULTI_MODAL_AUTO_AGENT_SYSTEM_PROMPT_1, | ||
) | ||
|
||
load_dotenv() | ||
api_key = os.getenv("OPENAI_API_KEY") | ||
|
||
llm = GPT4VisionAPI( | ||
openai_api_key=api_key | ||
) | ||
|
||
assembly_line = "playground/demos/swarm_of_mma_manufacturing/assembly_line.jpg" | ||
red_robots = "playground/demos/swarm_of_mma_manufacturing/red_robots.jpg" | ||
robots = "playground/demos/swarm_of_mma_manufacturing/robots.jpg" | ||
tesla_assembly_line = "playground/demos/swarm_of_mma_manufacturing/tesla_assembly.jpg" | ||
|
||
|
||
# Define detailed prompts for each agent | ||
tasks = { | ||
"health_safety": ( | ||
"Analyze the factory's working environment for health safety. Focus on" | ||
" cleanliness, ventilation, spacing between workstations, and personal" | ||
" protective equipment availability." | ||
), | ||
"productivity": ( | ||
"Review the factory's workflow efficiency, machine utilization, and" | ||
" employee engagement. Identify operational delays or bottlenecks." | ||
), | ||
"safety": ( | ||
"Analyze the factory's safety measures, including fire exits, safety" | ||
" signage, and emergency response equipment." | ||
), | ||
"security": ( | ||
"Evaluate the factory's security systems, entry/exit controls, and" | ||
" potential vulnerabilities." | ||
), | ||
"sustainability": ( | ||
"Inspect the factory's sustainability practices, including waste" | ||
" management, energy usage, and eco-friendly processes." | ||
), | ||
"efficiency": ( | ||
"Assess the manufacturing process's efficiency, considering the layout," | ||
" logistics, and automation level." | ||
), | ||
} | ||
|
||
|
||
# Define prompts for each agent | ||
health_safety_prompt = tasks["health_safety"] | ||
productivity_prompt = tasks["productivity"] | ||
safety_prompt = tasks["safety"] | ||
security_prompt = tasks["security"] | ||
sustainability_prompt = tasks["sustainability"] | ||
efficiency_prompt = tasks["efficiency"] | ||
|
||
|
||
# Health security agent | ||
health_security_agent = Flow( | ||
llm=llm, | ||
sop_list=health_safety_prompt, | ||
max_loops=2, | ||
multi_modal=True | ||
) | ||
|
||
# Quality control agent | ||
productivity_check_agent = Flow( | ||
llm=llm, | ||
sop=productivity_prompt, | ||
max_loops=2, | ||
multi_modal=True | ||
) | ||
|
||
# Security agent | ||
security_check_agent = Flow( | ||
llm=llm, | ||
sop=security_prompt, | ||
max_loops=2, | ||
multi_modal=True | ||
) | ||
|
||
# Efficiency agent | ||
efficiency_check_agent = Flow( | ||
llm=llm, | ||
sop=efficiency_prompt, | ||
max_loops=2, | ||
multi_modal=True | ||
) | ||
|
||
|
||
# Add the first task to the health_security_agent | ||
health_check = health_security_agent.run( | ||
"Analyze the safety of this factory", | ||
robots | ||
) | ||
|
||
# Add the third task to the productivity_check_agent | ||
productivity_check = productivity_check_agent.run( | ||
health_check, assembly_line | ||
) | ||
|
||
# Add the fourth task to the security_check_agent | ||
security_check = security_check_agent.add( | ||
productivity_check, red_robots | ||
) | ||
|
||
# Add the fifth task to the efficiency_check_agent | ||
efficiency_check = efficiency_check_agent.run( | ||
security_check, tesla_assembly_line | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" | |
|
||
[tool.poetry] | ||
name = "swarms" | ||
version = "2.4.3" | ||
version = "2.4.5" | ||
description = "Swarms - Pytorch" | ||
license = "MIT" | ||
authors = ["Kye Gomez <[email protected]>"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.