parent
fcf52332d1
commit
d380cae233
@ -1,28 +0,0 @@
|
||||
# Meme Agent Builder
|
||||
|
||||
- `pip3 install -U swarms`
|
||||
- Add your OpenAI API key to the `.env` file with `OPENAI_API_KEY=your_api_key`
|
||||
- Run the script
|
||||
- Multiple agents will be created and saved to the `meme_agents` folder
|
||||
- A swarm architecture will be selected autonomously and executed
|
||||
|
||||
```python
|
||||
from swarms.structs.meme_agent_persona_generator import (
|
||||
MemeAgentGenerator,
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
example = MemeAgentGenerator(
|
||||
name="Meme-Swarm",
|
||||
description="A swarm of specialized AI agents collaborating on generating and sharing memes around cool media from 2001s",
|
||||
max_loops=1,
|
||||
)
|
||||
|
||||
print(
|
||||
example.run(
|
||||
"Generate funny meme agents around cool media from 2001s"
|
||||
)
|
||||
)
|
||||
|
||||
```
|
@ -0,0 +1,77 @@
|
||||
# Processing Multiple Images
|
||||
|
||||
This tutorial shows how to process multiple images with a single agent using Swarms' multi-modal capabilities. You'll learn to configure an agent for batch image analysis, enabling efficient processing for quality control, object detection, or image comparison tasks.
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
Install the swarms package using pip:
|
||||
|
||||
```bash
|
||||
pip install -U swarms
|
||||
```
|
||||
|
||||
## Basic Setup
|
||||
|
||||
1. First, set up your environment variables:
|
||||
|
||||
```python
|
||||
WORKSPACE_DIR="agent_workspace"
|
||||
ANTHROPIC_API_KEY=""
|
||||
```
|
||||
|
||||
|
||||
## Code
|
||||
|
||||
- Create a list of images by their file paths
|
||||
|
||||
- Pass it into the `Agent.run(imgs=[str])` parameter
|
||||
|
||||
- Activate `summarize_multiple_images=True` if you want the agent to output a summary of the image analyses
|
||||
|
||||
|
||||
```python
|
||||
from swarms import Agent
|
||||
from swarms.prompts.logistics import (
|
||||
Quality_Control_Agent_Prompt,
|
||||
)
|
||||
|
||||
|
||||
# Image for analysis
|
||||
factory_image = "image.jpg"
|
||||
|
||||
# Quality control agent
|
||||
quality_control_agent = Agent(
|
||||
agent_name="Quality Control Agent",
|
||||
agent_description="A quality control agent that analyzes images and provides a detailed report on the quality of the product in the image.",
|
||||
model_name="claude-3-5-sonnet-20240620",
|
||||
system_prompt=Quality_Control_Agent_Prompt,
|
||||
multi_modal=True,
|
||||
max_loops=1,
|
||||
output_type="str-all-except-first",
|
||||
summarize_multiple_images=True,
|
||||
)
|
||||
|
||||
|
||||
response = quality_control_agent.run(
|
||||
task="what is in the image?",
|
||||
imgs=[factory_image, factory_image],
|
||||
)
|
||||
|
||||
print(response)
|
||||
```
|
||||
|
||||
## Support and Community
|
||||
|
||||
If you're facing issues or want to learn more, check out the following resources to join our Discord, stay updated on Twitter, and watch tutorials on YouTube!
|
||||
|
||||
| Platform | Link | Description |
|
||||
|----------|------|-------------|
|
||||
| 📚 Documentation | [docs.swarms.world](https://docs.swarms.world) | Official documentation and guides |
|
||||
| 📝 Blog | [Medium](https://medium.com/@kyeg) | Latest updates and technical articles |
|
||||
| 💬 Discord | [Join Discord](https://discord.gg/jM3Z6M9uMq) | Live chat and community support |
|
||||
| 🐦 Twitter | [@kyegomez](https://twitter.com/kyegomez) | Latest news and announcements |
|
||||
| 👥 LinkedIn | [The Swarm Corporation](https://www.linkedin.com/company/the-swarm-corporation) | Professional network and updates |
|
||||
| 📺 YouTube | [Swarms Channel](https://www.youtube.com/channel/UC9yXyitkbU_WSy7bd_41SqQ) | Tutorials and demos |
|
||||
| 🎫 Events | [Sign up here](https://lu.ma/5p2jnc2v) | Join our community events |
|
||||
|
@ -1,65 +0,0 @@
|
||||
from swarms.structs import Agent
|
||||
from swarms.prompts.logistics import (
|
||||
Quality_Control_Agent_Prompt,
|
||||
)
|
||||
|
||||
|
||||
# Image for analysis
|
||||
factory_image = "image.jpg"
|
||||
|
||||
|
||||
def security_analysis(danger_level: str = None) -> str:
|
||||
"""
|
||||
Analyzes the security danger level and returns an appropriate response.
|
||||
|
||||
Args:
|
||||
danger_level (str, optional): The level of danger to analyze.
|
||||
Can be "low", "medium", "high", or None. Defaults to None.
|
||||
|
||||
Returns:
|
||||
str: A string describing the danger level assessment.
|
||||
- "No danger level provided" if danger_level is None
|
||||
- "No danger" if danger_level is "low"
|
||||
- "Medium danger" if danger_level is "medium"
|
||||
- "High danger" if danger_level is "high"
|
||||
- "Unknown danger level" for any other value
|
||||
"""
|
||||
if danger_level is None:
|
||||
return "No danger level provided"
|
||||
|
||||
if danger_level == "low":
|
||||
return "No danger"
|
||||
|
||||
if danger_level == "medium":
|
||||
return "Medium danger"
|
||||
|
||||
if danger_level == "high":
|
||||
return "High danger"
|
||||
|
||||
return "Unknown danger level"
|
||||
|
||||
|
||||
# schema = BaseTool().function_to_dict(security_analysis)
|
||||
# print(json.dumps(schema, indent=4))
|
||||
|
||||
# Quality control agent
|
||||
quality_control_agent = Agent(
|
||||
agent_name="Quality Control Agent",
|
||||
agent_description="A quality control agent that analyzes images and provides a detailed report on the quality of the product in the image.",
|
||||
# model_name="anthropic/claude-3-opus-20240229",
|
||||
model_name="gpt-4o-mini",
|
||||
system_prompt=Quality_Control_Agent_Prompt,
|
||||
multi_modal=True,
|
||||
max_loops=1,
|
||||
output_type="str-all-except-first",
|
||||
# tools_list_dictionary=[schema],
|
||||
tools=[security_analysis],
|
||||
)
|
||||
|
||||
|
||||
response = quality_control_agent.run(
|
||||
task="what is in the image?",
|
||||
# img=factory_image,
|
||||
)
|
||||
|
||||
print(response)
|
Before Width: | Height: | Size: 232 KiB After Width: | Height: | Size: 232 KiB |
@ -0,0 +1,28 @@
|
||||
from swarms import Agent
|
||||
from swarms.prompts.logistics import (
|
||||
Quality_Control_Agent_Prompt,
|
||||
)
|
||||
|
||||
|
||||
# Image for analysis
|
||||
factory_image = "image.jpg"
|
||||
|
||||
# Quality control agent
|
||||
quality_control_agent = Agent(
|
||||
agent_name="Quality Control Agent",
|
||||
agent_description="A quality control agent that analyzes images and provides a detailed report on the quality of the product in the image.",
|
||||
model_name="claude-3-5-sonnet-20240620",
|
||||
system_prompt=Quality_Control_Agent_Prompt,
|
||||
multi_modal=True,
|
||||
max_loops=1,
|
||||
output_type="str-all-except-first",
|
||||
summarize_multiple_images=True,
|
||||
)
|
||||
|
||||
|
||||
response = quality_control_agent.run(
|
||||
task="what is in the image?",
|
||||
imgs=[factory_image, factory_image],
|
||||
)
|
||||
|
||||
print(response)
|
Loading…
Reference in new issue