fix: update vision.md with improved agent examples and documentation

pull/829/head
ascender1729 1 week ago
parent 30b7277723
commit e7391ff6e1

@ -15,30 +15,14 @@ Swarms aims to be the definitive and most reliable multi-agent LLM framework, of
This example demonstrates a simple financial agent setup that responds to financial questions, such as establishing a ROTH IRA, using OpenAI's GPT-based model. This example demonstrates a simple financial agent setup that responds to financial questions, such as establishing a ROTH IRA, using OpenAI's GPT-based model.
```python ```python
import os from swarms.structs.agent import Agent
from swarms import Agent from swarms.prompts.finance_agent_sys_prompt import FINANCIAL_AGENT_SYS_PROMPT
from swarm_models import OpenAIChat
from swarms.prompts.finance_agent_sys_prompt import (
FINANCIAL_AGENT_SYS_PROMPT,
)
from dotenv import load_dotenv
# Load environment variables
load_dotenv()
# Get OpenAI API key from environment
api_key = os.getenv("OPENAI_API_KEY")
# Initialize OpenAIChat model with desired parameters # Initialize the Financial Analysis Agent with GPT-4o-mini model
model = OpenAIChat(
openai_api_key=api_key, model_name="gpt-4o-mini", temperature=0.1
)
# Initialize the Financial Analysis Agent
agent = Agent( agent = Agent(
agent_name="Financial-Analysis-Agent", agent_name="Financial-Analysis-Agent",
system_prompt=FINANCIAL_AGENT_SYS_PROMPT, system_prompt=FINANCIAL_AGENT_SYS_PROMPT,
llm=model, model_name="gpt-4o-mini",
max_loops=1, max_loops=1,
autosave=True, autosave=True,
dashboard=False, dashboard=False,
@ -56,7 +40,7 @@ out = agent.run(
"How can I establish a ROTH IRA to buy stocks and get a tax break? What are the criteria?" "How can I establish a ROTH IRA to buy stocks and get a tax break? What are the criteria?"
) )
# Output the agent's result # Output the result
print(out) print(out)
``` ```
@ -64,66 +48,60 @@ print(out)
The following example showcases how to use the `AgentRearrange` class to manage a multi-agent system. It sets up a director agent to orchestrate two workers—one to generate a transcript and another to summarize it. The following example showcases how to use the `AgentRearrange` class to manage a multi-agent system. It sets up a director agent to orchestrate two workers—one to generate a transcript and another to summarize it.
```python ```python
from swarms import Agent, AgentRearrange from swarms.structs.agent import Agent
from swarm_models import Anthropic from swarms.structs.rearrange import AgentRearrange
# Initialize the Director agent # Initialize the Director agent using Anthropic model via model_name
director = Agent( director = Agent(
agent_name="Director", agent_name="Director",
system_prompt="Directs the tasks for the workers", system_prompt="You are a Director agent. Your role is to coordinate and direct tasks for worker agents. Break down complex tasks into clear, actionable steps.",
llm=Anthropic(), model_name="claude-3-sonnet-20240229",
max_loops=1, max_loops=1,
dashboard=False, dashboard=False,
streaming_on=True, streaming_on=False,
verbose=True, verbose=True,
stopping_token="<DONE>", stopping_token="<DONE>",
state_save_file_type="json", state_save_file_type="json",
saved_state_path="director.json", saved_state_path="director.json",
) )
# Initialize Worker 1 agent (transcript generation) # Worker 1: transcript generation
worker1 = Agent( worker1 = Agent(
agent_name="Worker1", agent_name="Worker1",
system_prompt="Generates a transcript for a YouTube video on what swarms are", system_prompt="You are a content creator agent. Your role is to generate detailed, engaging transcripts for YouTube videos about technical topics. Focus on clarity and educational value.",
llm=Anthropic(), model_name="claude-3-sonnet-20240229",
max_loops=1, max_loops=1,
dashboard=False, dashboard=False,
streaming_on=True, streaming_on=False,
verbose=True, verbose=True,
stopping_token="<DONE>", stopping_token="<DONE>",
state_save_file_type="json", state_save_file_type="json",
saved_state_path="worker1.json", saved_state_path="worker1.json",
) )
# Initialize Worker 2 agent (summarizes transcript) # Worker 2: summarization
worker2 = Agent( worker2 = Agent(
agent_name="Worker2", agent_name="Worker2",
system_prompt="Summarizes the transcript generated by Worker1", system_prompt="You are a summarization agent. Your role is to create concise, clear summaries of technical content while maintaining key information and insights.",
llm=Anthropic(), model_name="claude-3-sonnet-20240229",
max_loops=1, max_loops=1,
dashboard=False, dashboard=False,
streaming_on=True, streaming_on=False,
verbose=True, verbose=True,
stopping_token="<DONE>", stopping_token="<DONE>",
state_save_file_type="json", state_save_file_type="json",
saved_state_path="worker2.json", saved_state_path="worker2.json",
) )
# Create a list of agents # Orchestrate the agents in sequence
agents = [director, worker1, worker2] agents = [director, worker1, worker2]
# Define the workflow pattern (sequential flow)
flow = "Director -> Worker1 -> Worker2" flow = "Director -> Worker1 -> Worker2"
# Using AgentRearrange to orchestrate the agents
agent_system = AgentRearrange(agents=agents, flow=flow) agent_system = AgentRearrange(agents=agents, flow=flow)
# Running the system with a sample task # Run the workflow
output = agent_system.run( output = agent_system.run(
"Create a format to express and communicate swarms of LLMs in a structured manner for YouTube" "Create a format to express and communicate swarms of LLMs in a structured manner for YouTube"
) )
# Output the result
print(output) print(output)
``` ```
@ -168,5 +146,4 @@ With support for extreme third-party integration, Swarms makes it easy for devel
Swarms abstracts the complexity of managing multiple agents with orchestration tools like `AgentRearrange`. Developers can define workflows that execute tasks concurrently or sequentially, depending on the problem at hand. This makes it easy to build and maintain large-scale automation systems. Swarms abstracts the complexity of managing multiple agents with orchestration tools like `AgentRearrange`. Developers can define workflows that execute tasks concurrently or sequentially, depending on the problem at hand. This makes it easy to build and maintain large-scale automation systems.
### Conclusion: ### Conclusion:
Swarms is not just another multi-agent framework; it's built specifically for developers who need powerful tools to automate complex, large-scale business operations. With flexible architecture, deep integration capabilities, and developer-friendly APIs, Swarms is the ultimate solution for businesses looking to streamline operations and future-proof their workflows. Swarms is not just another multi-agent framework; it's built specifically for developers who need powerful tools to automate complex, large-scale business operations. With flexible architecture, deep integration capabilities, and developer-friendly APIs, Swarms is the ultimate solution for businesses looking to streamline operations and future-proof their workflows.
Loading…
Cancel
Save