pull/518/head^2
Kye Gomez 7 months ago
parent 052743bce1
commit 56857ae74d

@ -8,10 +8,7 @@ def run_model(api_key):
api_key=api_key, max_steps=500, url="https://x.com" api_key=api_key, max_steps=500, url="https://x.com"
) )
out = model.run( out = model.run(
""" ""
click on the 'Tweet' button to start a new tweet and post it saying: $pip3 install swarms
"""
) )
print(out) print(out)

@ -1127,122 +1127,6 @@ mv = MajorityVoting(
# Start the majority voting # Start the majority voting
mv.run("What is your stance on healthcare?") mv.run("What is your stance on healthcare?")
``` ```
### Real-World Deployment
### Multi-Agent Swarm for Logistics
Here's a production grade swarm ready for real-world deployment in a factory and logistics settings like warehouses. This swarm can automate 3 costly and inefficient workflows, safety checks, productivity checks, and warehouse security.
```python
import os
from dotenv import load_dotenv
from swarms.models import GPT4VisionAPI
from swarms.prompts.logistics import (
Efficiency_Agent_Prompt,
Health_Security_Agent_Prompt,
Productivity_Agent_Prompt,
Quality_Control_Agent_Prompt,
Safety_Agent_Prompt,
Security_Agent_Prompt,
Sustainability_Agent_Prompt,
)
from swarms.structs import Agent
# Load ENV
load_dotenv()
api_key = os.getenv("OPENAI_API_KEY")
# GPT4VisionAPI
llm = GPT4VisionAPI(openai_api_key=api_key)
# Image for analysis
factory_image = "factory_image1.jpg"
# Initialize agents with respective prompts
health_security_agent = Agent(
llm=llm,
sop=Health_Security_Agent_Prompt,
max_loops=1,
multi_modal=True,
)
# Quality control agent
quality_control_agent = Agent(
llm=llm,
sop=Quality_Control_Agent_Prompt,
max_loops=1,
multi_modal=True,
)
# Productivity Agent
productivity_agent = Agent(
llm=llm,
sop=Productivity_Agent_Prompt,
max_loops=1,
multi_modal=True,
)
# Initiailize safety agent
safety_agent = Agent(llm=llm, sop=Safety_Agent_Prompt, max_loops=1, multi_modal=True)
# Init the security agent
security_agent = Agent(
llm=llm, sop=Security_Agent_Prompt, max_loops=1, multi_modal=True
)
# Initialize sustainability agent
sustainability_agent = Agent(
llm=llm,
sop=Sustainability_Agent_Prompt,
max_loops=1,
multi_modal=True,
)
# Initialize efficincy agent
efficiency_agent = Agent(
llm=llm,
sop=Efficiency_Agent_Prompt,
max_loops=1,
multi_modal=True,
)
# Run agents with respective tasks on the same image
health_analysis = health_security_agent.run(
"Analyze the safety of this factory", factory_image
)
quality_analysis = quality_control_agent.run(
"Examine product quality in the factory", factory_image
)
productivity_analysis = productivity_agent.run(
"Evaluate factory productivity", factory_image
)
safety_analysis = safety_agent.run(
"Inspect the factory's adherence to safety standards",
factory_image,
)
security_analysis = security_agent.run(
"Assess the factory's security measures and systems",
factory_image,
)
sustainability_analysis = sustainability_agent.run(
"Examine the factory's sustainability practices", factory_image
)
efficiency_analysis = efficiency_agent.run(
"Analyze the efficiency of the factory's manufacturing process",
factory_image,
)
```
---
## Build your own LLMs, Agents, and Swarms! ## Build your own LLMs, Agents, and Swarms!
### Swarms Compliant Model Interface ### Swarms Compliant Model Interface

Before

Width:  |  Height:  |  Size: 174 KiB

After

Width:  |  Height:  |  Size: 174 KiB

@ -31,4 +31,4 @@ def cleanup_json_logs(name: str = None):
# Call the function # Call the function
cleanup_json_logs("arifacts_swarmm_o1") cleanup_json_logs("agriculture_swarm")

@ -8,7 +8,7 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"!pip3 install -U swarms" "!pip3 install -U swarms python-dotenv"
] ]
}, },
{ {
@ -49,7 +49,7 @@
"\n", "\n",
"# Initialize the language model\n", "# Initialize the language model\n",
"llm = OpenAIChat(\n", "llm = OpenAIChat(\n",
" temperature=0.5, model_name=\"gpt-4\", openai_api_key=api_key, max_tokens=4000\n", " temperature=0.5, openai_api_key=api_key, max_tokens=4000\n",
")\n", ")\n",
"\n", "\n",
"\n", "\n",
@ -95,7 +95,8 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"from swarms import Agent, ChromaDB, OpenAIChat\n", "from swarms import Agent, OpenAIChat\n",
"from playground.memory.chromadb_example import ChromaDB\n",
"\n", "\n",
"# Making an instance of the ChromaDB class\n", "# Making an instance of the ChromaDB class\n",
"memory = ChromaDB(\n", "memory = ChromaDB(\n",

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

@ -28,7 +28,7 @@ api_key = os.environ.get("OPENAI_API_KEY")
# llm = llm, # llm = llm,
llm = GPT4o(max_tokens=200, openai_api_key=os.getenv("OPENAI_API_KEY")) llm = GPT4o(max_tokens=3000, openai_api_key=os.getenv("OPENAI_API_KEY"))
# Initialize Diagnoser Agent # Initialize Diagnoser Agent
diagnoser_agent = Agent( diagnoser_agent = Agent(
@ -42,6 +42,7 @@ diagnoser_agent = Agent(
# saved_state_path="diagnoser.json", # saved_state_path="diagnoser.json",
multi_modal=True, multi_modal=True,
autosave=True, autosave=True,
streaming_on=True,
) )
# Initialize Harvester Agent # Initialize Harvester Agent
@ -56,6 +57,7 @@ harvester_agent = Agent(
# saved_state_path="harvester.json", # saved_state_path="harvester.json",
multi_modal=True, multi_modal=True,
autosave=True, autosave=True,
streaming_on=True,
) )
# Initialize Growth Predictor Agent # Initialize Growth Predictor Agent
@ -70,6 +72,7 @@ growth_predictor_agent = Agent(
# saved_state_path="growth_predictor.json", # saved_state_path="growth_predictor.json",
multi_modal=True, multi_modal=True,
autosave=True, autosave=True,
streaming_on=True,
) )
# Initialize Treatment Recommender Agent # Initialize Treatment Recommender Agent
@ -84,6 +87,7 @@ treatment_recommender_agent = Agent(
# saved_state_path="treatment_recommender.json", # saved_state_path="treatment_recommender.json",
multi_modal=True, multi_modal=True,
autosave=True, autosave=True,
streaming_on=True,
) )
# Initialize Disease Detector Agent # Initialize Disease Detector Agent
@ -98,6 +102,7 @@ disease_detector_agent = Agent(
# saved_state_path="disease_detector.json", # saved_state_path="disease_detector.json",
multi_modal=True, multi_modal=True,
autosave=True, autosave=True,
streaming_on=True,
) )
agents = [ agents = [
diagnoser_agent, diagnoser_agent,
@ -108,7 +113,7 @@ agents = [
] ]
task = "Conduct a diagnosis on the plants's symptoms, this wasn't grown in dirt, it grew from hydroponics" task = "Conduct a diagnosis on the plants's symptoms, this wasn't grown in dirt, it grew from hydroponics"
img = "tomato.jpg" img = "bad_tomato.jpg"
loop = 0 loop = 0
for i in range(len(agents)): for i in range(len(agents)):
Loading…
Cancel
Save