From a19ddc9fb8a72eab8b9c7d5e82397074574123d3 Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Mon, 29 Sep 2025 18:53:12 +0300 Subject: [PATCH 01/28] Update agent_builder.py --- swarms/structs/agent_builder.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/swarms/structs/agent_builder.py b/swarms/structs/agent_builder.py index 4bf9894f..11ad79cc 100644 --- a/swarms/structs/agent_builder.py +++ b/swarms/structs/agent_builder.py @@ -5,7 +5,7 @@ from loguru import logger from pydantic import BaseModel, Field from swarms.structs.agent import Agent -from swarms.utils.function_caller_model import OpenAIFunctionCaller +from swarms.utils.litellm_wrapper import LiteLLM BOSS_SYSTEM_PROMPT = """ # Swarm Intelligence Orchestrator @@ -193,12 +193,11 @@ class AgentsBuilder: list: List of created agents """ logger.info("Creating agents for task") - model = OpenAIFunctionCaller( + model = LiteLLM( + model_name=self.model_name, system_prompt=self.system_prompt, - api_key=os.getenv("OPENAI_API_KEY"), temperature=0.1, - base_model=Agents, - model_name=self.model_name, + response_format=Agents, max_tokens=8192, ) From 9ebd54de574fffe302583432d64cf19cb4b9286f Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Mon, 29 Sep 2025 18:53:39 +0300 Subject: [PATCH 02/28] Update meme_agent_persona_generator.py --- swarms/structs/meme_agent_persona_generator.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/swarms/structs/meme_agent_persona_generator.py b/swarms/structs/meme_agent_persona_generator.py index 1866ea45..f8b61889 100644 --- a/swarms/structs/meme_agent_persona_generator.py +++ b/swarms/structs/meme_agent_persona_generator.py @@ -9,7 +9,7 @@ from pydantic import BaseModel, Field from swarms.structs.agent import Agent from swarms.structs.swarm_router import SwarmRouter -from swarms.utils.function_caller_model import OpenAIFunctionCaller +from swarms.utils.litellm_wrapper import LiteLLM load_dotenv() @@ -162,11 +162,11 @@ class MemeAgentGenerator: list: List of created agents """ logger.info("Creating agents for task") - model = OpenAIFunctionCaller( + model = LiteLLM( + model_name="gpt-4o", system_prompt=BOSS_SYSTEM_PROMPT, - api_key=os.getenv("OPENAI_API_KEY"), temperature=0.1, - base_model=MemeSwarmConfig, + response_format=MemeSwarmConfig, ) agents_dictionary = model.run(task) From a602dff8443c845872899f071c7029f89c45a438 Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Mon, 29 Sep 2025 18:54:08 +0300 Subject: [PATCH 03/28] Update model_router.py --- swarms/structs/model_router.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/swarms/structs/model_router.py b/swarms/structs/model_router.py index 32015e4a..e2668697 100644 --- a/swarms/structs/model_router.py +++ b/swarms/structs/model_router.py @@ -4,7 +4,6 @@ from concurrent.futures import ThreadPoolExecutor from typing import Optional from pydantic import BaseModel, Field -from swarms.utils.function_caller_model import OpenAIFunctionCaller from swarms.utils.any_to_str import any_to_str from swarms.utils.formatter import formatter from swarms.utils.litellm_wrapper import LiteLLM @@ -174,7 +173,7 @@ class ModelRouter: temperature (float): Temperature parameter for model randomness max_workers (int): Maximum concurrent workers for batch processing model_output (ModelOutput): Pydantic model for structured outputs - model_caller (OpenAIFunctionCaller): Function calling interface + model_caller (LiteLLM): Function calling interface """ def __init__( @@ -210,11 +209,11 @@ class ModelRouter: if self.max_workers == "auto": self.max_workers = os.cpu_count() - self.model_caller = OpenAIFunctionCaller( - base_model=ModelOutput, + self.model_caller = LiteLLM( + model_name="gpt-4o", + response_format=ModelOutput, temperature=self.temperature, system_prompt=self.system_prompt, - api_key=api_key, ) except Exception as e: raise RuntimeError( From dc134dd49db81ea990a237c2640e194387c1ea8b Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Mon, 29 Sep 2025 18:54:41 +0300 Subject: [PATCH 04/28] Update auto_swarm_builder.py --- swarms/structs/auto_swarm_builder.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/swarms/structs/auto_swarm_builder.py b/swarms/structs/auto_swarm_builder.py index 989ff118..0d177fe7 100644 --- a/swarms/structs/auto_swarm_builder.py +++ b/swarms/structs/auto_swarm_builder.py @@ -358,14 +358,7 @@ class AutoSwarmBuilder: raise e def build_llm_agent(self, config: BaseModel): - # return OpenAIFunctionCaller( - # system_prompt=BOSS_SYSTEM_PROMPT, - # api_key=os.getenv("OPENAI_API_KEY"), - # temperature=0.5, - # base_model=config, - # model_name=self.model_name, - # max_tokens=self.max_tokens, - # ) + # Legacy OpenAIFunctionCaller code removed - now using LiteLLM for multi-provider support return LiteLLM( model_name=self.model_name, system_prompt=BOSS_SYSTEM_PROMPT, From 5e3863ffb965e9f789c20c8a9c779920108b7d70 Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Mon, 29 Sep 2025 18:55:36 +0300 Subject: [PATCH 05/28] Delete swarms/utils/function_caller_model.py --- swarms/utils/function_caller_model.py | 123 -------------------------- 1 file changed, 123 deletions(-) delete mode 100644 swarms/utils/function_caller_model.py diff --git a/swarms/utils/function_caller_model.py b/swarms/utils/function_caller_model.py deleted file mode 100644 index fb9135fc..00000000 --- a/swarms/utils/function_caller_model.py +++ /dev/null @@ -1,123 +0,0 @@ -import os -from concurrent.futures import ThreadPoolExecutor -from typing import List - -from pydantic import BaseModel - - -from openai import OpenAI - -SUPPORTED_MODELS = [ - "o3-mini-2025-1-31", - "o1-2024-12-17", - "gpt-4o-mini-2024-07-18", - "gpt-4o-2024-08-06", -] - - -def check_api_key(): - api_key = os.getenv("OPENAI_API_KEY") - if api_key is None: - raise ValueError( - "API key is not set. Please set the API key using the api_key parameter." - ) - return api_key - - -class OpenAIFunctionCaller: - """ - A class to interact with the OpenAI API for generating text based on a system prompt and a task. - - Attributes: - - system_prompt (str): The system prompt to guide the AI's response. - - api_key (str): The API key for the OpenAI service. - - temperature (float): The temperature parameter for the AI model, controlling randomness. - - base_model (BaseModel): The Pydantic model to parse the response into. - - max_tokens (int): The maximum number of tokens in the response. - - client (OpenAI): The OpenAI client instance. - """ - - def __init__( - self, - system_prompt: str, - base_model: BaseModel, - api_key: str = os.getenv("OPENAI_API_KEY"), - temperature: float = 0.1, - max_tokens: int = 5000, - model_name: str = "gpt-4o-2024-08-06", - ): - self.system_prompt = system_prompt - self.api_key = api_key - self.temperature = temperature - self.base_model = base_model - self.max_tokens = max_tokens - self.model_name = model_name - - self.client = OpenAI(api_key=self.api_key) - - def run(self, task: str): - """ - Run the OpenAI model with the system prompt and task to generate a response. - - Args: - - task (str): The task to be completed. - - *args: Additional positional arguments for the OpenAI API. - - **kwargs: Additional keyword arguments for the OpenAI API. - - Returns: - - BaseModel: The parsed response based on the base_model. - """ - try: - completion = self.client.beta.chat.completions.parse( - model=self.model_name, - messages=[ - {"role": "system", "content": self.system_prompt}, - {"role": "user", "content": task}, - ], - response_format=self.base_model, - max_tokens=self.max_tokens, - temperature=self.temperature, - ) - - return completion.choices[0].message.parsed - - except Exception as e: - print(f"There was an error: {e}") - - def check_model_support(self): - # need to print the supported models - for model in SUPPORTED_MODELS: - print(model) - - return SUPPORTED_MODELS - - def batch_run(self, tasks: List[str]) -> List[BaseModel]: - """ - Batch run the OpenAI model with the system prompt and task to generate a response. - """ - return [self.run(task) for task in tasks] - - def concurrent_run(self, tasks: List[str]) -> List[BaseModel]: - """ - Concurrent run the OpenAI model with the system prompt and task to generate a response. - """ - with ThreadPoolExecutor(max_workers=len(tasks)) as executor: - return list(executor.map(self.run, tasks)) - - -# class TestModel(BaseModel): -# name: str -# age: int - -# # Example usage -# model = OpenAIFunctionCaller( -# system_prompt="You are a helpful assistant that returns structured data about people.", -# base_model=TestModel, -# api_key=os.getenv("OPENAI_API_KEY"), -# temperature=0.7, -# max_tokens=1000 -# ) - -# # Test with a more appropriate prompt for the TestModel schema -# response = model.run("Tell me about a person named John who is 25 years old") -# print(response) From 60e80e61040a4777c4586c46087ea9d9004399cb Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Mon, 29 Sep 2025 18:56:13 +0300 Subject: [PATCH 06/28] Update hs_stock_team.py --- examples/multi_agent/hiearchical_swarm/hs_stock_team.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/multi_agent/hiearchical_swarm/hs_stock_team.py b/examples/multi_agent/hiearchical_swarm/hs_stock_team.py index d4cbe763..898c8ab9 100644 --- a/examples/multi_agent/hiearchical_swarm/hs_stock_team.py +++ b/examples/multi_agent/hiearchical_swarm/hs_stock_team.py @@ -7,16 +7,16 @@ from swarms.structs.hiearchical_swarm import ( HierarchicalSwarm, SwarmSpec, ) -from swarms.utils.function_caller_model import OpenAIFunctionCaller +from swarms.utils.litellm_wrapper import LiteLLM load_dotenv() # ------------------------------------------------------------------------------ # Trading Director: Responsible for orchestrating tasks among multiple stock analysts # ------------------------------------------------------------------------------ -director_llm = OpenAIFunctionCaller( - base_model=SwarmSpec, - api_key=os.getenv("OPENAI_API_KEY"), +director_llm = LiteLLM( + model_name="gpt-4o", + response_format=SwarmSpec, system_prompt=( "You are the Trading Director in charge of coordinating a team of specialized " "Stock Analysts. Your responsibilities include:\n\n" From 655687671a45f0dd6d12baffc9f485d299224301 Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Mon, 29 Sep 2025 18:56:38 +0300 Subject: [PATCH 07/28] Update hierarchical_swarm_example.py --- .../hiearchical_swarm/hierarchical_swarm_example.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/multi_agent/hiearchical_swarm/hierarchical_swarm_example.py b/examples/multi_agent/hiearchical_swarm/hierarchical_swarm_example.py index 5be9008f..a73e8bc1 100644 --- a/examples/multi_agent/hiearchical_swarm/hierarchical_swarm_example.py +++ b/examples/multi_agent/hiearchical_swarm/hierarchical_swarm_example.py @@ -7,7 +7,7 @@ from swarms.structs.hiearchical_swarm import ( HierarchicalSwarm, SwarmSpec, ) -from swarms.utils.function_caller_model import OpenAIFunctionCaller +from swarms.utils.litellm_wrapper import LiteLLM load_dotenv() @@ -15,9 +15,9 @@ load_dotenv() # ------------------------------------------------------------------------------ # Director LLM: Responsible for orchestrating tasks among the agents # ------------------------------------------------------------------------------ -llm = OpenAIFunctionCaller( - base_model=SwarmSpec, - api_key=os.getenv("OPENAI_API_KEY"), +llm = LiteLLM( + model_name="gpt-4o", + response_format=SwarmSpec, system_prompt=( "As the Director of this Hierarchical Agent Swarm, you are in charge of " "coordinating and overseeing all tasks, ensuring that each is executed " From 695510a11ffb6d1af0da776d5415f8516128da6e Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Mon, 29 Sep 2025 18:57:17 +0300 Subject: [PATCH 08/28] Update sarasowti.py --- examples/demos/hackathon_feb16/sarasowti.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/demos/hackathon_feb16/sarasowti.py b/examples/demos/hackathon_feb16/sarasowti.py index 5943d47f..5f223ea1 100644 --- a/examples/demos/hackathon_feb16/sarasowti.py +++ b/examples/demos/hackathon_feb16/sarasowti.py @@ -1,6 +1,6 @@ from dotenv import load_dotenv from swarms import Agent -from swarms.utils.function_caller_model import OpenAIFunctionCaller +from swarms.utils.litellm_wrapper import LiteLLM from pydantic import BaseModel, Field from swarms.structs.conversation import Conversation @@ -180,8 +180,9 @@ Maintain a warm, friendly, and authentic presence while ensuring all interaction # Initialize Agents using swarms ######################################## -model = OpenAIFunctionCaller( - base_model=CallLog, +model = LiteLLM( + model_name="gpt-4o", + response_format=CallLog, system_prompt=MASTER_AGENT_SYS_PROMPT, ) From 4442ab5e03f7fffb29600e9570a5585622984d63 Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Mon, 29 Sep 2025 18:58:05 +0300 Subject: [PATCH 09/28] Update test_comprehensive_test.py --- tests/test_comprehensive_test.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/test_comprehensive_test.py b/tests/test_comprehensive_test.py index 2ef00e1e..bff0e699 100644 --- a/tests/test_comprehensive_test.py +++ b/tests/test_comprehensive_test.py @@ -463,9 +463,7 @@ def test_spreadsheet_swarm(): def test_hierarchical_swarm(): """Test HierarchicalSwarm structure""" try: - from swarms.utils.function_caller_model import ( - OpenAIFunctionCaller, - ) + from swarms.utils.litellm_wrapper import LiteLLM from swarms.structs.hiearchical_swarm import SwarmSpec # Create worker agents @@ -481,9 +479,9 @@ def test_hierarchical_swarm(): ] # Create director agent with explicit knowledge of available agents - director = OpenAIFunctionCaller( - base_model=SwarmSpec, - api_key=API_KEY, + director = LiteLLM( + model_name="gpt-4o", + response_format=SwarmSpec, system_prompt=( "As the Director of this Hierarchical Agent Swarm, you coordinate tasks among agents. " "You must ONLY assign tasks to the following available agents:\n" From 8617ebde6f877e02173f73a7520c9379c294a1fe Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Mon, 29 Sep 2025 18:58:41 +0300 Subject: [PATCH 10/28] Update agent_rearrange_test.py --- examples/demos/spike/agent_rearrange_test.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/examples/demos/spike/agent_rearrange_test.py b/examples/demos/spike/agent_rearrange_test.py index e6aa044d..3340091a 100644 --- a/examples/demos/spike/agent_rearrange_test.py +++ b/examples/demos/spike/agent_rearrange_test.py @@ -9,7 +9,7 @@ Todo import os from dotenv import load_dotenv from swarms import Agent, AgentRearrange -from swarm_models import OpenAIChat, OpenAIFunctionCaller +from swarms.utils.litellm_wrapper import LiteLLM from pydantic import BaseModel from typing import List @@ -31,10 +31,8 @@ load_dotenv() api_key = os.getenv("GROQ_API_KEY") # Initialize the model -model = OpenAIChat( - openai_api_base="https://api.groq.com/openai/v1", - openai_api_key=api_key, - model_name="llama-3.1-70b-versatile", +model = LiteLLM( + model_name="groq/llama-3.1-70b-versatile", temperature=0.1, ) @@ -52,11 +50,11 @@ You are a college selection final decision maker. Your role is to: """ -function_caller = OpenAIFunctionCaller( +function_caller = LiteLLM( + model_name="gpt-4o", system_prompt=FINAL_AGENT_PROMPT, - openai_api_key=os.getenv("OPENAI_API_KEY"), - base_model=CollegesRecommendation, - parallel_tool_calls=True, + response_format=CollegesRecommendation, + temperature=0.1, ) # Student Profile Analyzer Agent From afad94024f335f778626006924a14b6265a3cf8d Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Mon, 29 Sep 2025 18:58:57 +0300 Subject: [PATCH 11/28] Update function_caller_example.py --- examples/demos/spike/function_caller_example.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/examples/demos/spike/function_caller_example.py b/examples/demos/spike/function_caller_example.py index 0578df7d..46c8b9fe 100644 --- a/examples/demos/spike/function_caller_example.py +++ b/examples/demos/spike/function_caller_example.py @@ -8,7 +8,7 @@ Todo import os from dotenv import load_dotenv -from swarm_models import OpenAIChat, OpenAIFunctionCaller +from swarms.utils.litellm_wrapper import LiteLLM from pydantic import BaseModel from typing import List @@ -30,21 +30,19 @@ load_dotenv() api_key = os.getenv("GROQ_API_KEY") # Initialize the model -model = OpenAIChat( - openai_api_base="https://api.groq.com/openai/v1", - openai_api_key=api_key, - model_name="llama-3.1-70b-versatile", +model = LiteLLM( + model_name="groq/llama-3.1-70b-versatile", temperature=0.1, ) -function_caller = OpenAIFunctionCaller( +function_caller = LiteLLM( + model_name="gpt-4o", system_prompt="""You are a college selection final decision maker. Your role is to: - Balance all relevant factors and stakeholder input. - Only return the output in the schema format. """, - openai_api_key=os.getenv("OPENAI_API_KEY"), - base_model=CollegesRecommendation, - # parallel_tool_calls=True, + response_format=CollegesRecommendation, + temperature=0.1, ) From debb9496ac8d380732b5c0b40d50fb93f172cf3a Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Mon, 29 Sep 2025 18:59:12 +0300 Subject: [PATCH 12/28] Update test.py --- examples/demos/spike/test.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/examples/demos/spike/test.py b/examples/demos/spike/test.py index 3c1f5fb5..d22a15c4 100644 --- a/examples/demos/spike/test.py +++ b/examples/demos/spike/test.py @@ -9,7 +9,7 @@ Todo import os from dotenv import load_dotenv from swarms import Agent, SequentialWorkflow -from swarm_models import OpenAIChat, OpenAIFunctionCaller +from swarms.utils.litellm_wrapper import LiteLLM from pydantic import BaseModel from typing import List @@ -31,10 +31,8 @@ load_dotenv() api_key = os.getenv("GROQ_API_KEY") # Initialize the model -model = OpenAIChat( - openai_api_base="https://api.groq.com/openai/v1", - openai_api_key=api_key, - model_name="llama-3.1-70b-versatile", +model = LiteLLM( + model_name="groq/llama-3.1-70b-versatile", temperature=0.1, ) @@ -52,11 +50,11 @@ You are a college selection final decision maker. Your role is to: """ -function_caller = OpenAIFunctionCaller( +function_caller = LiteLLM( + model_name="gpt-4o", system_prompt=FINAL_AGENT_PROMPT, - openai_api_key=os.getenv("OPENAI_API_KEY"), - base_model=CollegesRecommendation, - parallel_tool_calls=True, + response_format=CollegesRecommendation, + temperature=0.1, ) # Student Profile Analyzer Agent From 96767d5d5c26ec0944b925a1d01fc9beefa353fc Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Mon, 29 Sep 2025 18:59:58 +0300 Subject: [PATCH 13/28] Update auto_agent.py --- examples/multi_agent/asb/auto_agent.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/examples/multi_agent/asb/auto_agent.py b/examples/multi_agent/asb/auto_agent.py index 7c7ee1d1..f0ab1454 100644 --- a/examples/multi_agent/asb/auto_agent.py +++ b/examples/multi_agent/asb/auto_agent.py @@ -5,7 +5,7 @@ from typing import Any, Callable, Dict, Optional, Type, Union from dotenv import load_dotenv from pydantic import BaseModel, Field, ValidationError, create_model -from swarm_models.openai_function_caller import OpenAIFunctionCaller +from swarms.utils.litellm_wrapper import LiteLLM class DynamicParser: @@ -216,14 +216,13 @@ Your role is to make decisions and complete tasks independently without seeking Always respond in a strict JSON format as described below. Ensure your responses can be parsed with Python's `json.loads`: """ -# Initialize the OpenAIFunctionCaller -model = OpenAIFunctionCaller( +# Initialize the LiteLLM +model = LiteLLM( + model_name="gpt-4o", system_prompt=SYSTEM_PROMPT, max_tokens=4000, temperature=0.9, - base_model=AgentResponse, # Pass the Pydantic schema as the base model - parallel_tool_calls=False, - openai_api_key=os.getenv("OPENAI_API_KEY"), + response_format=AgentResponse, # Pass the Pydantic schema as the response format ) # Example usage From 9b4621e9ef80f464f732dd11685a90fb37300906 Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Mon, 29 Sep 2025 21:39:41 +0300 Subject: [PATCH 14/28] Delete swarms/structs/agent_builder.py --- swarms/structs/agent_builder.py | 292 -------------------------------- 1 file changed, 292 deletions(-) delete mode 100644 swarms/structs/agent_builder.py diff --git a/swarms/structs/agent_builder.py b/swarms/structs/agent_builder.py deleted file mode 100644 index 11ad79cc..00000000 --- a/swarms/structs/agent_builder.py +++ /dev/null @@ -1,292 +0,0 @@ -import os -from typing import Any, List, Optional, Tuple - -from loguru import logger -from pydantic import BaseModel, Field - -from swarms.structs.agent import Agent -from swarms.utils.litellm_wrapper import LiteLLM - -BOSS_SYSTEM_PROMPT = """ -# Swarm Intelligence Orchestrator - -You are the Chief Orchestrator of a sophisticated agent swarm. Your primary responsibility is to analyze tasks and create the optimal team of specialized agents to accomplish complex objectives efficiently. - -## Agent Creation Protocol - -1. **Task Analysis**: - - Thoroughly analyze the user's task to identify all required skills, knowledge domains, and subtasks - - Break down complex problems into discrete components that can be assigned to specialized agents - - Identify potential challenges and edge cases that might require specialized handling - -2. **Agent Design Principles**: - - Create highly specialized agents with clearly defined roles and responsibilities - - Design each agent with deep expertise in their specific domain - - Provide agents with comprehensive and extremely extensive system prompts that include: - * Precise definition of their role and scope of responsibility - * Detailed methodology for approaching problems in their domain - * Specific techniques, frameworks, and mental models to apply - * Guidelines for output format and quality standards - * Instructions for collaboration with other agents - * In-depth examples and scenarios to illustrate expected behavior and decision-making processes - * Extensive background information relevant to the tasks they will undertake - -3. **Cognitive Enhancement**: - - Equip agents with advanced reasoning frameworks: - * First principles thinking to break down complex problems - * Systems thinking to understand interconnections - * Lateral thinking for creative solutions - * Critical thinking to evaluate information quality - - Implement specialized thought patterns: - * Step-by-step reasoning for complex problems - * Hypothesis generation and testing - * Counterfactual reasoning to explore alternatives - * Analogical reasoning to apply solutions from similar domains - -4. **Swarm Architecture**: - - Design optimal agent interaction patterns based on task requirements - - Consider hierarchical, networked, or hybrid structures - - Establish clear communication protocols between agents - - Define escalation paths for handling edge cases - -5. **Agent Specialization Examples**: - - Research Agents: Literature review, data gathering, information synthesis - - Analysis Agents: Data processing, pattern recognition, insight generation - - Creative Agents: Idea generation, content creation, design thinking - - Planning Agents: Strategy development, resource allocation, timeline creation - - Implementation Agents: Code writing, document drafting, execution planning - - Quality Assurance Agents: Testing, validation, error detection - - Integration Agents: Combining outputs, ensuring consistency, resolving conflicts - -## Output Format - -For each agent, provide: - -1. **Agent Name**: Clear, descriptive title reflecting specialization -2. **Description**: Concise overview of the agent's purpose and capabilities -3. **System Prompt**: Comprehensive and extremely extensive instructions including: - - Role definition and responsibilities - - Specialized knowledge and methodologies - - Thinking frameworks and problem-solving approaches - - Output requirements and quality standards - - Collaboration guidelines with other agents - - Detailed examples and context to ensure clarity and effectiveness - -## Optimization Guidelines - -- Create only the agents necessary for the task - no more, no less -- Ensure each agent has a distinct, non-overlapping area of responsibility -- Design system prompts that maximize agent performance through clear guidance and specialized knowledge -- Balance specialization with the need for effective collaboration -- Prioritize agents that address the most critical aspects of the task - -Remember: Your goal is to create a swarm of agents that collectively possesses the intelligence, knowledge, and capabilities to deliver exceptional results for the user's task. -""" - - -class AgentSpec(BaseModel): - agent_name: Optional[str] = Field( - None, - description="The unique name assigned to the agent, which identifies its role and functionality within the swarm.", - ) - description: Optional[str] = Field( - None, - description="A detailed explanation of the agent's purpose, capabilities, and any specific tasks it is designed to perform.", - ) - system_prompt: Optional[str] = Field( - None, - description="The initial instruction or context provided to the agent, guiding its behavior and responses during execution.", - ) - model_name: Optional[str] = Field( - description="The name of the AI model that the agent will utilize for processing tasks and generating outputs. For example: gpt-4o, gpt-4o-mini, openai/o3-mini" - ) - auto_generate_prompt: Optional[bool] = Field( - description="A flag indicating whether the agent should automatically create prompts based on the task requirements." - ) - max_tokens: Optional[int] = Field( - None, - description="The maximum number of tokens that the agent is allowed to generate in its responses, limiting output length.", - ) - temperature: Optional[float] = Field( - description="A parameter that controls the randomness of the agent's output; lower values result in more deterministic responses." - ) - role: Optional[str] = Field( - description="The designated role of the agent within the swarm, which influences its behavior and interaction with other agents." - ) - max_loops: Optional[int] = Field( - description="The maximum number of times the agent is allowed to repeat its task, enabling iterative processing if necessary." - ) - - -class Agents(BaseModel): - """Configuration for a collection of agents that work together as a swarm to accomplish tasks.""" - - agents: List[AgentSpec] = Field( - description="A list containing the specifications of each agent that will participate in the swarm, detailing their roles and functionalities." - ) - - -class AgentsBuilder: - """A class that automatically builds and manages swarms of AI agents. - - This class handles the creation, coordination and execution of multiple AI agents working - together as a swarm to accomplish complex tasks. It uses a boss agent to delegate work - and create new specialized agents as needed. - - Args: - name (str): The name of the swarm - description (str): A description of the swarm's purpose - verbose (bool, optional): Whether to output detailed logs. Defaults to True. - max_loops (int, optional): Maximum number of execution loops. Defaults to 1. - """ - - def __init__( - self, - name: str = "swarm-creator-01", - description: str = "This is a swarm that creates swarms", - verbose: bool = True, - max_loops: int = 1, - model_name: str = "gpt-4o", - return_dictionary: bool = True, - system_prompt: str = BOSS_SYSTEM_PROMPT, - ): - self.name = name - self.description = description - self.verbose = verbose - self.max_loops = max_loops - self.agents_pool = [] - self.model_name = model_name - self.return_dictionary = return_dictionary - self.system_prompt = system_prompt - logger.info( - f"Initialized AutoSwarmBuilder: {name} {description}" - ) - - def run( - self, task: str, image_url: str = None, *args, **kwargs - ) -> Tuple[List[Agent], int]: - """Run the swarm on a given task. - - Args: - task (str): The task to be accomplished - image_url (str, optional): URL of an image input if needed. Defaults to None. - *args: Variable length argument list - **kwargs: Arbitrary keyword arguments - - Returns: - The output from the swarm's execution - """ - logger.info(f"Running swarm on task: {task}") - agents = self._create_agents(task, image_url, *args, **kwargs) - - return agents - - def _create_agents(self, task: str, *args, **kwargs): - """Create the necessary agents for a task. - - Args: - task (str): The task to create agents for - *args: Variable length argument list - **kwargs: Arbitrary keyword arguments - - Returns: - list: List of created agents - """ - logger.info("Creating agents for task") - model = LiteLLM( - model_name=self.model_name, - system_prompt=self.system_prompt, - temperature=0.1, - response_format=Agents, - max_tokens=8192, - ) - - agents_dictionary = model.run(task) - print(agents_dictionary) - - print(type(agents_dictionary)) - logger.info("Agents successfully created") - logger.info(f"Agents: {len(agents_dictionary.agents)}") - - if self.return_dictionary: - logger.info("Returning dictionary") - - # Convert swarm config to dictionary - agents_dictionary = agents_dictionary.model_dump() - return agents_dictionary - else: - logger.info("Returning agents") - return self.create_agents(agents_dictionary) - - def create_agents(self, agents_dictionary: Any): - # Create agents from config - agents = [] - for agent_config in agents_dictionary.agents: - # Convert dict to AgentConfig if needed - if isinstance(agent_config, dict): - agent_config = Agents(**agent_config) - - agent = self.build_agent( - agent_name=agent_config.model_name, - agent_description=agent_config.description, - agent_system_prompt=agent_config.system_prompt, - model_name=agent_config.model_name, - max_loops=agent_config.max_loops, - dynamic_temperature_enabled=True, - auto_generate_prompt=agent_config.auto_generate_prompt, - role=agent_config.role, - max_tokens=agent_config.max_tokens, - temperature=agent_config.temperature, - ) - agents.append(agent) - - return agents - - def build_agent( - self, - agent_name: str, - agent_description: str, - agent_system_prompt: str, - max_loops: int = 1, - model_name: str = "gpt-4o", - dynamic_temperature_enabled: bool = True, - auto_generate_prompt: bool = False, - role: str = "worker", - max_tokens: int = 8192, - temperature: float = 0.5, - ): - """Build a single agent with the given specifications. - - Args: - agent_name (str): Name of the agent - agent_description (str): Description of the agent's purpose - agent_system_prompt (str): The system prompt for the agent - - Returns: - Agent: The constructed agent instance - """ - logger.info(f"Building agent: {agent_name}") - agent = Agent( - agent_name=agent_name, - description=agent_description, - system_prompt=agent_system_prompt, - model_name=model_name, - max_loops=max_loops, - dynamic_temperature_enabled=dynamic_temperature_enabled, - context_length=200000, - output_type="str", # "json", "dict", "csv" OR "string" soon "yaml" and - streaming_on=False, - auto_generate_prompt=auto_generate_prompt, - role=role, - max_tokens=max_tokens, - temperature=temperature, - ) - - return agent - - -# if __name__ == "__main__": -# builder = AgentsBuilder(model_name="gpt-4o") -# agents = builder.run("Create a swarm that can write a book about the history of the world") -# print(agents) -# print(type(agents)) From 64ecf70a73480e924edd8fb8f0a18c7c2a3398db Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Mon, 29 Sep 2025 21:42:11 +0300 Subject: [PATCH 15/28] Delete examples/multi_agent/asb/agents_builder.py --- examples/multi_agent/asb/agents_builder.py | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 examples/multi_agent/asb/agents_builder.py diff --git a/examples/multi_agent/asb/agents_builder.py b/examples/multi_agent/asb/agents_builder.py deleted file mode 100644 index 191f0b84..00000000 --- a/examples/multi_agent/asb/agents_builder.py +++ /dev/null @@ -1,9 +0,0 @@ -from swarms.structs.agent_builder import AgentsBuilder - -example_task = "Write a blog post about the benefits of using Swarms for AI agents." - -agents_builder = AgentsBuilder() - -agents = agents_builder.run(example_task) - -print(agents) From 9116a6572a6d15a4e02f493d59c7b1f13d223b29 Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Mon, 29 Sep 2025 21:46:17 +0300 Subject: [PATCH 16/28] Update auto_swarm_builder.py --- swarms/structs/auto_swarm_builder.py | 203 ++++++++++++++++++++++++++- 1 file changed, 201 insertions(+), 2 deletions(-) diff --git a/swarms/structs/auto_swarm_builder.py b/swarms/structs/auto_swarm_builder.py index 0d177fe7..1fc23069 100644 --- a/swarms/structs/auto_swarm_builder.py +++ b/swarms/structs/auto_swarm_builder.py @@ -1,6 +1,6 @@ import json import traceback -from typing import List, Optional +from typing import Any, List, Optional, Tuple from dotenv import load_dotenv from loguru import logger @@ -127,11 +127,57 @@ When creating a multi-agent system, provide: """ +class AgentSpec(BaseModel): + """Configuration for an individual agent specification.""" + + agent_name: Optional[str] = Field( + None, + description="The unique name assigned to the agent, which identifies its role and functionality within the swarm.", + ) + description: Optional[str] = Field( + None, + description="A detailed explanation of the agent's purpose, capabilities, and any specific tasks it is designed to perform.", + ) + system_prompt: Optional[str] = Field( + None, + description="The initial instruction or context provided to the agent, guiding its behavior and responses during execution.", + ) + model_name: Optional[str] = Field( + description="The name of the AI model that the agent will utilize for processing tasks and generating outputs. For example: gpt-4o, gpt-4o-mini, openai/o3-mini" + ) + auto_generate_prompt: Optional[bool] = Field( + description="A flag indicating whether the agent should automatically create prompts based on the task requirements." + ) + max_tokens: Optional[int] = Field( + None, + description="The maximum number of tokens that the agent is allowed to generate in its responses, limiting output length.", + ) + temperature: Optional[float] = Field( + description="A parameter that controls the randomness of the agent's output; lower values result in more deterministic responses." + ) + role: Optional[str] = Field( + description="The designated role of the agent within the swarm, which influences its behavior and interaction with other agents." + ) + max_loops: Optional[int] = Field( + description="The maximum number of times the agent is allowed to repeat its task, enabling iterative processing if necessary." + ) + + +class Agents(BaseModel): + """Configuration for a collection of agents that work together as a swarm to accomplish tasks.""" + + agents: List[AgentSpec] = Field( + description="A list containing the specifications of each agent that will participate in the swarm, detailing their roles and functionalities." + ) + + execution_types = [ "return-agents", "execute-swarm-router", "return-swarm-router-config", "return-agent-configurations", + "return-agent-specs", + "return-agent-dictionary", ] @@ -225,6 +271,8 @@ class AutoSwarmBuilder: interactive (bool): Whether to enable interactive mode. Defaults to False. max_tokens (int): Maximum tokens for the LLM responses. Defaults to 8000. execution_type (str): Type of execution to perform. Defaults to "return-agents". + return_dictionary (bool): Whether to return dictionary format for agent specs. Defaults to True. + system_prompt (str): System prompt for the boss agent. Defaults to BOSS_SYSTEM_PROMPT. """ def __init__( @@ -238,6 +286,8 @@ class AutoSwarmBuilder: interactive: bool = False, max_tokens: int = 8000, execution_type: execution_types = "return-agents", + return_dictionary: bool = True, + system_prompt: str = BOSS_SYSTEM_PROMPT, ): """Initialize the AutoSwarmBuilder. @@ -251,6 +301,8 @@ class AutoSwarmBuilder: interactive (bool): Whether to enable interactive mode max_tokens (int): Maximum tokens for the LLM responses execution_type (str): Type of execution to perform + return_dictionary (bool): Whether to return dictionary format for agent specs + system_prompt (str): System prompt for the boss agent """ self.name = name self.description = description @@ -261,7 +313,10 @@ class AutoSwarmBuilder: self.interactive = interactive self.max_tokens = max_tokens self.execution_type = execution_type + self.return_dictionary = return_dictionary + self.system_prompt = system_prompt self.conversation = Conversation() + self.agents_pool = [] self.reliability_check() @@ -307,6 +362,10 @@ class AutoSwarmBuilder: return self.create_router_config(task) elif self.execution_type == "return-agent-configurations": return self.create_agents(task) + elif self.execution_type == "return-agent-specs": + return self._create_agent_specs(task) + elif self.execution_type == "return-agent-dictionary": + return self._create_agent_dictionary(task) else: return self._execute_task(task) @@ -358,7 +417,6 @@ class AutoSwarmBuilder: raise e def build_llm_agent(self, config: BaseModel): - # Legacy OpenAIFunctionCaller code removed - now using LiteLLM for multi-provider support return LiteLLM( model_name=self.model_name, system_prompt=BOSS_SYSTEM_PROMPT, @@ -497,5 +555,146 @@ class AutoSwarmBuilder: return [self.run(task) for task in tasks] + def _create_agent_specs(self, task: str) -> Tuple[List[Agent], int]: + """Create agent specifications for a given task. + + Args: + task (str): The task to create agents for + + Returns: + Tuple[List[Agent], int]: List of created agents and count + """ + logger.info("Creating agent specifications for task") + agents = self._create_agents_from_specs(task) + return agents, len(agents) + + def _create_agent_dictionary(self, task: str): + """Create agent dictionary for a given task. + + Args: + task (str): The task to create agents for + + Returns: + dict: Dictionary containing agent configurations + """ + logger.info("Creating agent dictionary for task") + agents_dictionary = self._create_agents_from_specs(task, return_dict=True) + return agents_dictionary + + def _create_agents_from_specs(self, task: str, return_dict: bool = False): + """Create agents from specifications. + + Args: + task (str): The task to create agents for + return_dict (bool): Whether to return dictionary format + + Returns: + List[Agent] or dict: Created agents or dictionary + """ + logger.info("Creating agents from specifications") + model = LiteLLM( + model_name=self.model_name, + system_prompt=self.system_prompt, + temperature=0.1, + response_format=Agents, + max_tokens=8192, + ) + + agents_dictionary = model.run(task) + print(agents_dictionary) + print(type(agents_dictionary)) + logger.info("Agents successfully created") + logger.info(f"Agents: {len(agents_dictionary.agents)}") + + if return_dict or self.return_dictionary: + logger.info("Returning dictionary") + # Convert swarm config to dictionary + agents_dictionary = agents_dictionary.model_dump() + return agents_dictionary + else: + logger.info("Returning agents") + return self.create_agents_from_specs(agents_dictionary) + + def create_agents_from_specs(self, agents_dictionary: Any) -> List[Agent]: + """Create agents from agent specifications. + + Args: + agents_dictionary: Dictionary containing agent specifications + + Returns: + List[Agent]: List of created agents + """ + # Create agents from config + agents = [] + for agent_config in agents_dictionary.agents: + # Convert dict to AgentSpec if needed + if isinstance(agent_config, dict): + agent_config = AgentSpec(**agent_config) + + agent = self.build_agent_from_spec( + agent_name=agent_config.agent_name, + agent_description=agent_config.description, + agent_system_prompt=agent_config.system_prompt, + model_name=agent_config.model_name, + max_loops=agent_config.max_loops, + dynamic_temperature_enabled=True, + auto_generate_prompt=agent_config.auto_generate_prompt, + role=agent_config.role, + max_tokens=agent_config.max_tokens, + temperature=agent_config.temperature, + ) + agents.append(agent) + + return agents + + def build_agent_from_spec( + self, + agent_name: str, + agent_description: str, + agent_system_prompt: str, + max_loops: int = 1, + model_name: str = "gpt-4o", + dynamic_temperature_enabled: bool = True, + auto_generate_prompt: bool = False, + role: str = "worker", + max_tokens: int = 8192, + temperature: float = 0.5, + ) -> Agent: + """Build a single agent from agent specification. + + Args: + agent_name (str): Name of the agent + agent_description (str): Description of the agent's purpose + agent_system_prompt (str): The system prompt for the agent + max_loops (int): Maximum number of loops + model_name (str): Model name to use + dynamic_temperature_enabled (bool): Whether to enable dynamic temperature + auto_generate_prompt (bool): Whether to auto-generate prompts + role (str): Role of the agent + max_tokens (int): Maximum tokens + temperature (float): Temperature setting + + Returns: + Agent: The constructed agent instance + """ + logger.info(f"Building agent from spec: {agent_name}") + agent = Agent( + agent_name=agent_name, + description=agent_description, + system_prompt=agent_system_prompt, + model_name=model_name, + max_loops=max_loops, + dynamic_temperature_enabled=dynamic_temperature_enabled, + context_length=200000, + output_type="str", + streaming_on=False, + auto_generate_prompt=auto_generate_prompt, + role=role, + max_tokens=max_tokens, + temperature=temperature, + ) + + return agent + def list_types(self): return execution_types From 009db7f3402b184bab45ded16fb8beb5db59e99b Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Mon, 29 Sep 2025 22:24:40 +0300 Subject: [PATCH 17/28] Update sarasowti.py --- examples/demos/hackathon_feb16/sarasowti.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/demos/hackathon_feb16/sarasowti.py b/examples/demos/hackathon_feb16/sarasowti.py index 5f223ea1..668fcf86 100644 --- a/examples/demos/hackathon_feb16/sarasowti.py +++ b/examples/demos/hackathon_feb16/sarasowti.py @@ -181,7 +181,7 @@ Maintain a warm, friendly, and authentic presence while ensuring all interaction ######################################## model = LiteLLM( - model_name="gpt-4o", + model_name="gpt-4.1", response_format=CallLog, system_prompt=MASTER_AGENT_SYS_PROMPT, ) @@ -193,7 +193,7 @@ counselor_agent = Agent( agent_description="Provides empathetic and effective college counseling and guidance.", system_prompt=COUNSELOR_AGENT_SYS_PROMPT, max_loops=1, - model_name="gpt-4o", + model_name="gpt-4.1", dynamic_temperature_enabled=True, ) @@ -203,7 +203,7 @@ buddy_agent = Agent( agent_description="Acts as a supportive, friendly companion to the student.", system_prompt=BUDDY_AGENT_SYS_PROMPT, max_loops=1, - model_name="gpt-4o", + model_name="gpt-4.1", dynamic_temperature_enabled=True, ) From ba99ecbf7009c31994f32e57cb8cde824cc62bb0 Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Mon, 29 Sep 2025 22:25:54 +0300 Subject: [PATCH 18/28] Update agent_rearrange_test.py --- examples/demos/spike/agent_rearrange_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/demos/spike/agent_rearrange_test.py b/examples/demos/spike/agent_rearrange_test.py index 3340091a..eaf94368 100644 --- a/examples/demos/spike/agent_rearrange_test.py +++ b/examples/demos/spike/agent_rearrange_test.py @@ -51,7 +51,7 @@ You are a college selection final decision maker. Your role is to: """ function_caller = LiteLLM( - model_name="gpt-4o", + model_name="gpt-4.1", system_prompt=FINAL_AGENT_PROMPT, response_format=CollegesRecommendation, temperature=0.1, From cd7230c60c63724a07aa826872c02830e5ce5cf4 Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Mon, 29 Sep 2025 22:26:24 +0300 Subject: [PATCH 19/28] Update function_caller_example.py --- examples/demos/spike/function_caller_example.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/demos/spike/function_caller_example.py b/examples/demos/spike/function_caller_example.py index 46c8b9fe..dbf8f032 100644 --- a/examples/demos/spike/function_caller_example.py +++ b/examples/demos/spike/function_caller_example.py @@ -36,7 +36,7 @@ model = LiteLLM( ) function_caller = LiteLLM( - model_name="gpt-4o", + model_name="gpt-4.1", system_prompt="""You are a college selection final decision maker. Your role is to: - Balance all relevant factors and stakeholder input. - Only return the output in the schema format. From b06fd663c0473e8a9c40f340278ae0760d79078b Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Mon, 29 Sep 2025 22:26:52 +0300 Subject: [PATCH 20/28] Update test.py --- examples/demos/spike/test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/demos/spike/test.py b/examples/demos/spike/test.py index d22a15c4..2bda04ea 100644 --- a/examples/demos/spike/test.py +++ b/examples/demos/spike/test.py @@ -51,7 +51,7 @@ You are a college selection final decision maker. Your role is to: """ function_caller = LiteLLM( - model_name="gpt-4o", + model_name="gpt-4.1", system_prompt=FINAL_AGENT_PROMPT, response_format=CollegesRecommendation, temperature=0.1, From 43542d14449f98837705312240d68097e6a42011 Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Mon, 29 Sep 2025 22:27:20 +0300 Subject: [PATCH 21/28] Update auto_agent.py --- examples/multi_agent/asb/auto_agent.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/multi_agent/asb/auto_agent.py b/examples/multi_agent/asb/auto_agent.py index f0ab1454..7ac9039c 100644 --- a/examples/multi_agent/asb/auto_agent.py +++ b/examples/multi_agent/asb/auto_agent.py @@ -218,7 +218,7 @@ Always respond in a strict JSON format as described below. Ensure your responses # Initialize the LiteLLM model = LiteLLM( - model_name="gpt-4o", + model_name="gpt-4.1", system_prompt=SYSTEM_PROMPT, max_tokens=4000, temperature=0.9, From b957864b4734e45faffc126130722f92f1b412ea Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Mon, 29 Sep 2025 22:27:42 +0300 Subject: [PATCH 22/28] Update hierarchical_swarm_example.py --- .../hiearchical_swarm/hierarchical_swarm_example.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/multi_agent/hiearchical_swarm/hierarchical_swarm_example.py b/examples/multi_agent/hiearchical_swarm/hierarchical_swarm_example.py index a73e8bc1..7050d5ed 100644 --- a/examples/multi_agent/hiearchical_swarm/hierarchical_swarm_example.py +++ b/examples/multi_agent/hiearchical_swarm/hierarchical_swarm_example.py @@ -16,7 +16,7 @@ load_dotenv() # Director LLM: Responsible for orchestrating tasks among the agents # ------------------------------------------------------------------------------ llm = LiteLLM( - model_name="gpt-4o", + model_name="gpt-4.1", response_format=SwarmSpec, system_prompt=( "As the Director of this Hierarchical Agent Swarm, you are in charge of " @@ -57,7 +57,7 @@ def main(): # -------------------------------------------------------------------------- analysis_agent = Agent( agent_name="Stock-Analysis-Agent", - model_name="gpt-4o", + model_name="gpt-4.1", max_loops=1, interactive=False, streaming_on=False, From 33661ea13269340fa717ae2ff8d14c54befc8e9a Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Mon, 29 Sep 2025 22:28:13 +0300 Subject: [PATCH 23/28] Update hs_stock_team.py --- .../multi_agent/hiearchical_swarm/hs_stock_team.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/multi_agent/hiearchical_swarm/hs_stock_team.py b/examples/multi_agent/hiearchical_swarm/hs_stock_team.py index 898c8ab9..c336469f 100644 --- a/examples/multi_agent/hiearchical_swarm/hs_stock_team.py +++ b/examples/multi_agent/hiearchical_swarm/hs_stock_team.py @@ -15,7 +15,7 @@ load_dotenv() # Trading Director: Responsible for orchestrating tasks among multiple stock analysts # ------------------------------------------------------------------------------ director_llm = LiteLLM( - model_name="gpt-4o", + model_name="gpt-4.1", response_format=SwarmSpec, system_prompt=( "You are the Trading Director in charge of coordinating a team of specialized " @@ -51,7 +51,7 @@ def main(): # -------------------------------------------------------------------------- macro_agent = Agent( agent_name="Macro-Economic-Analysis-Agent", - model_name="gpt-4o", + model_name="gpt-4.1", max_loops=1, interactive=False, streaming_on=False, @@ -81,7 +81,7 @@ def main(): # -------------------------------------------------------------------------- sector_agent = Agent( agent_name="Sector-Performance-Analysis-Agent", - model_name="gpt-4o", + model_name="gpt-4.1", max_loops=1, interactive=False, streaming_on=False, @@ -113,7 +113,7 @@ def main(): # -------------------------------------------------------------------------- technical_agent = Agent( agent_name="Technical-Analysis-Agent", - model_name="gpt-4o", + model_name="gpt-4.1", max_loops=1, interactive=False, streaming_on=False, @@ -145,7 +145,7 @@ def main(): # -------------------------------------------------------------------------- risk_agent = Agent( agent_name="Risk-Analysis-Agent", - model_name="gpt-4o", + model_name="gpt-4.1", max_loops=1, interactive=False, streaming_on=False, From 6ed99b05ebb94ded5222b6054dc50d9a7e09b87c Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Mon, 29 Sep 2025 22:29:16 +0300 Subject: [PATCH 24/28] Update meme_agent_persona_generator.py --- swarms/structs/meme_agent_persona_generator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/swarms/structs/meme_agent_persona_generator.py b/swarms/structs/meme_agent_persona_generator.py index f8b61889..aed37a49 100644 --- a/swarms/structs/meme_agent_persona_generator.py +++ b/swarms/structs/meme_agent_persona_generator.py @@ -163,7 +163,7 @@ class MemeAgentGenerator: """ logger.info("Creating agents for task") model = LiteLLM( - model_name="gpt-4o", + model_name="gpt-4.1", system_prompt=BOSS_SYSTEM_PROMPT, temperature=0.1, response_format=MemeSwarmConfig, @@ -227,7 +227,7 @@ class MemeAgentGenerator: agent_name=agent_name, description=agent_description, system_prompt=agent_system_prompt, - model_name="gpt-4o-mini", + model_name="gpt-4.1", max_loops=max_loops, autosave=True, dashboard=False, From 055bf3171e25d420ff6428de8d0e3d75fa16cfe0 Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Mon, 29 Sep 2025 22:30:24 +0300 Subject: [PATCH 25/28] Update test_comprehensive_test.py --- tests/test_comprehensive_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_comprehensive_test.py b/tests/test_comprehensive_test.py index bff0e699..70834342 100644 --- a/tests/test_comprehensive_test.py +++ b/tests/test_comprehensive_test.py @@ -159,7 +159,7 @@ def write_markdown_report( def create_test_agent( name: str, system_prompt: str = None, - model_name: str = "gpt-4o-mini", + model_name: str = "gpt-4.1", tools: List[Callable] = None, **kwargs, ) -> Agent: From 147f277733b0cd9cdacb8e2062f1a8fc7d418210 Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Mon, 29 Sep 2025 22:31:40 +0300 Subject: [PATCH 26/28] Update test_comprehensive_test.py --- tests/test_comprehensive_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_comprehensive_test.py b/tests/test_comprehensive_test.py index 70834342..5c1dc65d 100644 --- a/tests/test_comprehensive_test.py +++ b/tests/test_comprehensive_test.py @@ -480,7 +480,7 @@ def test_hierarchical_swarm(): # Create director agent with explicit knowledge of available agents director = LiteLLM( - model_name="gpt-4o", + model_name="gpt-4.1", response_format=SwarmSpec, system_prompt=( "As the Director of this Hierarchical Agent Swarm, you coordinate tasks among agents. " From 79251be936ceb77965dfa2b3a81ff5908be1f9aa Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Mon, 29 Sep 2025 22:36:05 +0300 Subject: [PATCH 27/28] Update pyproject.toml --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index d563d02e..64a354e2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -75,7 +75,6 @@ numpy = "*" litellm = "*" httpx = "*" mcp = "*" -openai = "*" aiohttp = "*" orjson = "*" schedule = "*" From 88f3fb146304d8d86986e91e0d769e2f81cd04c5 Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Mon, 29 Sep 2025 22:36:24 +0300 Subject: [PATCH 28/28] Update requirements.txt --- requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index d1103e64..6eb2936b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -24,7 +24,6 @@ httpx aiohttp mcp numpy -openai orjson schedule uvloop