From 2dfe8a5dda50bcca53a9008292a1218828172506 Mon Sep 17 00:00:00 2001 From: ascender1729 Date: Wed, 30 Apr 2025 17:17:59 +0530 Subject: [PATCH 1/5] docs: update quickstart with simplified YAML configuration and example.py --- docs/swarms/install/quickstart.md | 102 +++++++++++------------------- 1 file changed, 38 insertions(+), 64 deletions(-) diff --git a/docs/swarms/install/quickstart.md b/docs/swarms/install/quickstart.md index 0b0df39d..16d31150 100644 --- a/docs/swarms/install/quickstart.md +++ b/docs/swarms/install/quickstart.md @@ -70,51 +70,51 @@ The `create_agents_from_yaml` function works by reading agent configurations fro ```yaml agents: - agent_name: "Financial-Analysis-Agent" - model: - openai_api_key: "your_openai_api_key" - model_name: "gpt-4o-mini" - temperature: 0.1 - max_tokens: 2000 - system_prompt: "financial_agent_sys_prompt" + system_prompt: "You are a financial analysis expert. Analyze market trends and provide investment recommendations." + model_name: "claude-3-opus-20240229" max_loops: 1 - autosave: true + autosave: false dashboard: false - verbose: true - dynamic_temperature_enabled: true - saved_state_path: "finance_agent.json" + verbose: false + dynamic_temperature_enabled: false user_name: "swarms_corp" retry_attempts: 1 context_length: 200000 return_step_meta: false output_type: "str" - task: "How can I establish a ROTH IRA to buy stocks and get a tax break?" - - - agent_name: "Stock-Analysis-Agent" - model: - openai_api_key: "your_openai_api_key" - model_name: "gpt-4o-mini" - temperature: 0.2 - max_tokens: 1500 - system_prompt: "stock_agent_sys_prompt" - max_loops: 2 - autosave: true + task: "Analyze tech stocks for 2024 investment strategy. Provide detailed analysis and recommendations." + + - agent_name: "Risk-Analysis-Agent" + system_prompt: "You are a risk analysis expert. Evaluate investment risks and provide mitigation strategies." + model_name: "claude-3-opus-20240229" + max_loops: 1 + autosave: false dashboard: false - verbose: true + verbose: false dynamic_temperature_enabled: false - saved_state_path: "stock_agent.json" - user_name: "stock_user" - retry_attempts: 3 + user_name: "swarms_corp" + retry_attempts: 1 context_length: 150000 - return_step_meta: true - output_type: "json" - task: "What is the best strategy for long-term stock investment?" + return_step_meta: false + output_type: "str" + task: "Conduct a comprehensive risk analysis of the top 5 tech companies in 2024. Include risk factors and mitigation strategies." + +swarm_architecture: + name: "Financial Analysis Swarm" + description: "A swarm for comprehensive financial and risk analysis" + max_loops: 1 + swarm_type: "SequentialWorkflow" + task: "Analyze tech stocks and their associated risks for 2024 investment strategy" + autosave: false + return_json: true ``` ### Key Configuration Fields: - **agent_name**: Name of the agent. -- **model**: Defines the language model settings (e.g., API key, model name, temperature, and max tokens). - **system_prompt**: The system prompt used to guide the agent's behavior. -- **task**: (Optional) Task for the agent to execute once created. +- **model_name**: The language model to use (e.g., claude-3-opus-20240229). +- **task**: Task for the agent to execute. +- **swarm_architecture**: (Optional) Configuration for swarm behavior. --- @@ -122,49 +122,23 @@ agents: Now, create the main Python script that will use the `create_agents_from_yaml` function. -### `main.py`: +### `example.py`: ```python -import os - -from dotenv import load_dotenv -from loguru import logger -from swarm_models import OpenAIChat +from swarms.agents.create_agents_from_yaml import create_agents_from_yaml -from swarms.agents.create_agents_from_yaml import ( - create_agents_from_yaml, +# Create agents and get task results +task_results = create_agents_from_yaml( + yaml_file="agents_config.yaml", + return_type="run_swarm" ) -# Load environment variables -load_dotenv() - -# Path to your YAML file -yaml_file = "agents.yaml" - -# Get the OpenAI API key from the environment variable -api_key = os.getenv("OPENAI_API_KEY") - -# Create an instance of the OpenAIChat class -model = OpenAIChat( - openai_api_key=api_key, model_name="gpt-4o-mini", temperature=0.1 -) - - -try: - # Create agents and run tasks (using 'both' to return agents and task results) - task_results = create_agents_from_yaml( - model=model, yaml_file=yaml_file, return_type="tasks" - ) - - logger.info(f"Results from agents: {task_results}") -except Exception as e: - logger.error(f"An error occurred: {e}") - +print(task_results) ``` ### Example Run: ```bash -python main.py +python example.py ``` This will: From c93d2632359992bc02c473bb8ebd5f065b2a9b70 Mon Sep 17 00:00:00 2001 From: ascender1729 Date: Wed, 30 Apr 2025 17:24:17 +0530 Subject: [PATCH 2/5] docs: update quickstart to use main.py instead of example.py --- docs/swarms/install/quickstart.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/swarms/install/quickstart.md b/docs/swarms/install/quickstart.md index 16d31150..7d8c5b8c 100644 --- a/docs/swarms/install/quickstart.md +++ b/docs/swarms/install/quickstart.md @@ -122,7 +122,7 @@ swarm_architecture: Now, create the main Python script that will use the `create_agents_from_yaml` function. -### `example.py`: +### `main.py`: ```python from swarms.agents.create_agents_from_yaml import create_agents_from_yaml @@ -138,7 +138,7 @@ print(task_results) ### Example Run: ```bash -python example.py +python main.py ``` This will: From 30b7277723b84d3112a7fbe1fdbc6eda7e945e2c Mon Sep 17 00:00:00 2001 From: ascender1729 Date: Wed, 30 Apr 2025 17:44:38 +0530 Subject: [PATCH 3/5] feat: add temperature and max_tokens parameters to agent config --- docs/swarms/install/quickstart.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/swarms/install/quickstart.md b/docs/swarms/install/quickstart.md index 7d8c5b8c..42843d11 100644 --- a/docs/swarms/install/quickstart.md +++ b/docs/swarms/install/quickstart.md @@ -82,6 +82,8 @@ agents: context_length: 200000 return_step_meta: false output_type: "str" + temperature: 0.1 + max_tokens: 2000 task: "Analyze tech stocks for 2024 investment strategy. Provide detailed analysis and recommendations." - agent_name: "Risk-Analysis-Agent" @@ -97,6 +99,8 @@ agents: context_length: 150000 return_step_meta: false output_type: "str" + temperature: 0.1 + max_tokens: 2000 task: "Conduct a comprehensive risk analysis of the top 5 tech companies in 2024. Include risk factors and mitigation strategies." swarm_architecture: From e7391ff6e10c0d6d30bbfb034bd62f5ec50c9541 Mon Sep 17 00:00:00 2001 From: ascender1729 Date: Thu, 1 May 2025 18:28:53 +0530 Subject: [PATCH 4/5] fix: update vision.md with improved agent examples and documentation --- docs/swarms/concept/vision.md | 67 ++++++++++++----------------------- 1 file changed, 22 insertions(+), 45 deletions(-) diff --git a/docs/swarms/concept/vision.md b/docs/swarms/concept/vision.md index 80185bb3..678b495d 100644 --- a/docs/swarms/concept/vision.md +++ b/docs/swarms/concept/vision.md @@ -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. ```python -import os -from swarms import Agent -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") +from swarms.structs.agent import Agent +from swarms.prompts.finance_agent_sys_prompt import FINANCIAL_AGENT_SYS_PROMPT -# Initialize OpenAIChat model with desired parameters -model = OpenAIChat( - openai_api_key=api_key, model_name="gpt-4o-mini", temperature=0.1 -) - -# Initialize the Financial Analysis Agent +# Initialize the Financial Analysis Agent with GPT-4o-mini model agent = Agent( agent_name="Financial-Analysis-Agent", system_prompt=FINANCIAL_AGENT_SYS_PROMPT, - llm=model, + model_name="gpt-4o-mini", max_loops=1, autosave=True, 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?" ) -# Output the agent's result +# Output the result 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. ```python -from swarms import Agent, AgentRearrange -from swarm_models import Anthropic +from swarms.structs.agent import Agent +from swarms.structs.rearrange import AgentRearrange -# Initialize the Director agent +# Initialize the Director agent using Anthropic model via model_name director = Agent( agent_name="Director", - system_prompt="Directs the tasks for the workers", - llm=Anthropic(), + 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.", + model_name="claude-3-sonnet-20240229", max_loops=1, dashboard=False, - streaming_on=True, + streaming_on=False, verbose=True, stopping_token="", state_save_file_type="json", saved_state_path="director.json", ) -# Initialize Worker 1 agent (transcript generation) +# Worker 1: transcript generation worker1 = Agent( agent_name="Worker1", - system_prompt="Generates a transcript for a YouTube video on what swarms are", - llm=Anthropic(), + 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.", + model_name="claude-3-sonnet-20240229", max_loops=1, dashboard=False, - streaming_on=True, + streaming_on=False, verbose=True, stopping_token="", state_save_file_type="json", saved_state_path="worker1.json", ) -# Initialize Worker 2 agent (summarizes transcript) +# Worker 2: summarization worker2 = Agent( agent_name="Worker2", - system_prompt="Summarizes the transcript generated by Worker1", - llm=Anthropic(), + system_prompt="You are a summarization agent. Your role is to create concise, clear summaries of technical content while maintaining key information and insights.", + model_name="claude-3-sonnet-20240229", max_loops=1, dashboard=False, - streaming_on=True, + streaming_on=False, verbose=True, stopping_token="", state_save_file_type="json", saved_state_path="worker2.json", ) -# Create a list of agents +# Orchestrate the agents in sequence agents = [director, worker1, worker2] - -# Define the workflow pattern (sequential flow) flow = "Director -> Worker1 -> Worker2" - -# Using AgentRearrange to orchestrate the agents agent_system = AgentRearrange(agents=agents, flow=flow) -# Running the system with a sample task +# Run the workflow output = agent_system.run( "Create a format to express and communicate swarms of LLMs in a structured manner for YouTube" ) - -# Output the result 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. ### 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. \ No newline at end of file From dc0c7370b1396b9319fca0c38d7c01afd0f1640c Mon Sep 17 00:00:00 2001 From: ascender1729 Date: Thu, 1 May 2025 19:07:47 +0530 Subject: [PATCH 5/5] docs: update concurrent agents API reference with correct imports and example --- docs/swarms/structs/various_execution_methods.md | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/docs/swarms/structs/various_execution_methods.md b/docs/swarms/structs/various_execution_methods.md index 5658aa3e..f9d2981d 100644 --- a/docs/swarms/structs/various_execution_methods.md +++ b/docs/swarms/structs/various_execution_methods.md @@ -91,20 +91,19 @@ Runs multiple agents concurrently with timeout limits. ## Usage Examples ```python -from swarms import Agent, run_agents_concurrently, run_agents_with_timeout, run_agents_with_different_tasks -from swarm_models import OpenAIChat - -model = OpenAIChat( - model_name="gpt-4o-mini", - temperature=0.0 +from swarms.structs.agent import Agent +from swarms.structs.multi_agent_exec import ( + run_agents_concurrently, + run_agents_with_timeout, + run_agents_with_different_tasks ) -# Initialize agents +# Initialize agents using only the built-in model_name parameter agents = [ Agent( agent_name=f"Analysis-Agent-{i}", system_prompt="You are a financial analysis expert", - llm=model, + model_name="gpt-4o-mini", max_loops=1 ) for i in range(5)