From 92c9db48e1e20d99cb1649ecb989ff106f82095c Mon Sep 17 00:00:00 2001 From: Kye Gomez Date: Wed, 13 Aug 2025 08:45:57 -0700 Subject: [PATCH] Community resources docs --- docs/examples/community_resources.md | 36 ++++++++++++++++ docs/mkdocs.yml | 1 + examples/single_agent/llms/mistral_example.py | 20 +++++++++ swarms/sims/senator_assembly.py | 7 ++-- swarms/structs/__init__.py | 1 - swarms/structs/agent.py | 42 +++++++++---------- swarms/structs/concurrent_workflow.py | 2 +- swarms/structs/deep_research_swarm.py | 4 -- swarms/tools/py_func_to_openai_func_str.py | 2 +- 9 files changed, 84 insertions(+), 31 deletions(-) create mode 100644 docs/examples/community_resources.md create mode 100644 examples/single_agent/llms/mistral_example.py diff --git a/docs/examples/community_resources.md b/docs/examples/community_resources.md new file mode 100644 index 00000000..fcc38e6f --- /dev/null +++ b/docs/examples/community_resources.md @@ -0,0 +1,36 @@ +# Community Resources + +Welcome to the Community Resources page! Here you'll find a curated collection of articles, tutorials, and guides created by the Swarms community and core contributors. + +These resources cover a wide range of topics, including building your first agent, advanced multi-agent architectures, API integrations, and using Swarms with both Python and Rust. Whether you're a beginner or an experienced developer, these links will help you deepen your understanding and accelerate your development with the Swarms framework. + + +## Python + +| Title | Description | Link | +|-------|-------------|------| +| **Build Your First Swarms Agent in Under 10 Minutes** | Step-by-step beginner guide to creating your first Swarms agent quickly. | [Read Article](https://medium.com/@devangvashistha/build-your-first-swarms-agent-in-under-10-minutes-ddff23b6c703) | +| **Building Multi-Agent Systems with GPT-5 and The Swarms Framework** | Learn how to leverage GPT-5 with Swarms for advanced multi-agent system design. | [Read Article](https://medium.com/@kyeg/building-multi-agent-systems-with-gpt-5-and-the-swarms-framework-e52ffaf0fa4f) | +| **Learn How to Build Production-Grade Agents with OpenAI’s Latest Model: GPT-OSS Locally and in the Cloud** | Guide to building robust agents using OpenAI’s GPT-OSS, both locally and in cloud environments. | [Read Article](https://medium.com/@kyeg/learn-how-to-build-production-grade-agents-with-openais-latest-model-gpt-oss-locally-and-in-the-c5826c7cca7c) | +| **Building Gemini 2.5 Agents with Swarms Framework** | Tutorial on integrating Gemini 2.5 models into Swarms agents for enhanced capabilities. | [Read Article](https://medium.com/@kyeg/building-gemini-2-5-agents-with-swarms-framework-20abdcf82cac) | +| **Enterprise Developer Guide: Leveraging OpenAI’s o3 and o4-mini Models with The Swarms Framework** | Enterprise-focused guide to using OpenAI’s o3 and o4-mini models within Swarms. | [Read Article](https://medium.com/@kyeg/enterprise-developer-guide-leveraging-openais-o3-and-o4-mini-models-with-the-swarms-framework-89490c57820a) | +| **Enneagram of Thoughts Using the Swarms Framework: A Multi-Agent Approach to Holistic Problem Solving** | Explores using Swarms for holistic, multi-perspective problem solving via the Enneagram model. | [Read Article](https://medium.com/@kyeg/enneagram-of-thoughts-using-the-swarms-framework-a-multi-agent-approach-to-holistic-problem-c26c7df5e7eb) | +| **Building Production-Grade Financial Agents with tickr-agent: An Enterprise Solution for Comprehensive Stock Analysis** | How to build advanced financial analysis agents using tickr-agent and Swarms. | [Read Article](https://medium.com/@kyeg/building-production-grade-financial-agents-with-tickr-agent-an-enterprise-solution-for-db867ec93193) | +| **Automating Your Startup’s Financial Analysis Using AI Agents: A Comprehensive Guide** | Comprehensive guide to automating your startup’s financial analysis with AI agents using Swarms. | [Read Article](https://medium.com/@kyeg/automating-your-startups-financial-analysis-using-ai-agents-a-comprehensive-guide-b2fa0e2c09d5) | +| **Managing Thousands of Agent Outputs at Scale with The Spreadsheet Swarm: All-New Multi-Agent Architecture** | Learn how to manage and scale thousands of agent outputs efficiently using the Spreadsheet Swarm architecture. | [Read Article](https://medium.com/@kyeg/managing-thousands-of-agent-outputs-at-scale-with-the-spreadsheet-swarm-all-new-multi-agent-f16f5f40fd5a) | +| **Introducing GPT-4o Mini: The Future of Cost-Efficient AI Intelligence** | Discover the capabilities and advantages of GPT-4o Mini for building cost-effective, intelligent agents. | [Read Article](https://medium.com/@kyeg/introducing-gpt-4o-mini-the-future-of-cost-efficient-ai-intelligence-a3e3fe78d939) | + + +### API + +| Title | Description | Link | +|-------|-------------|------| +| **Specialized Healthcare Agents with Swarms Agent Completions API** | Guide to building healthcare-focused agents using the Swarms API. | [Read Article](https://medium.com/@kyeg/specialized-healthcare-agents-with-swarms-agent-completions-api-b56d067e3b11) | +| **Building Multi-Agent Systems for Finance & Accounting with the Swarms API: A Technical Guide** | Technical walkthrough for creating finance and accounting multi-agent systems with the Swarms API. | [Read Article](https://medium.com/@kyeg/building-multi-agent-systems-for-finance-accounting-with-the-swarms-api-a-technical-guide-bf6f7005b708) | + +### Swarms Rust + +| Title | Description | Link | +|-------|-------------|------| +| **Building Medical Multi-Agent Systems with Swarms Rust: A Comprehensive Tutorial** | Comprehensive tutorial for developing medical multi-agent systems using Swarms Rust. | [Read Article](https://medium.com/@kyeg/building-medical-multi-agent-systems-with-swarms-rust-a-comprehensive-tutorial-1e8e060601f9) | +| **Building Production-Grade Agentic Applications with Swarms Rust: A Comprehensive Tutorial** | Learn to build robust, production-ready agentic applications with Swarms Rust. | [Read Article](https://medium.com/@kyeg/building-production-grade-agentic-applications-with-swarms-rust-a-comprehensive-tutorial-bb567c02340f) | diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index 888f7f30..7e27c017 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -354,6 +354,7 @@ nav: - CookBook Index: "examples/cookbook_index.md" - Paper Implementations: "examples/paper_implementations.md" - Templates & Applications: "examples/templates.md" + - Community Resources: "examples/community_resources.md" - Basic Examples: - Individual Agents: - Basic Agent: "swarms/examples/basic_agent.md" diff --git a/examples/single_agent/llms/mistral_example.py b/examples/single_agent/llms/mistral_example.py new file mode 100644 index 00000000..9d22143d --- /dev/null +++ b/examples/single_agent/llms/mistral_example.py @@ -0,0 +1,20 @@ +from swarms import Agent + +# Initialize the agent +agent = Agent( + agent_name="Quantitative-Trading-Agent", + agent_description="Quantitative trading and analysis agent", + system_prompt="You are an expert quantitative trading agent. Answer concisely and accurately using your knowledge of trading strategies, risk management, and financial markets.", + model_name="mistral/mistral-tiny", + dynamic_temperature_enabled=True, + output_type="str-all-except-first", + max_loops="auto", + interactive=True, + no_reasoning_prompt=True, + streaming_on=True, +) + +out = agent.run( + task="What are the best top 3 etfs for gold coverage?" +) +print(out) diff --git a/swarms/sims/senator_assembly.py b/swarms/sims/senator_assembly.py index 64e3d34e..c125e2c6 100644 --- a/swarms/sims/senator_assembly.py +++ b/swarms/sims/senator_assembly.py @@ -6,13 +6,14 @@ each with detailed backgrounds, political positions, and comprehensive system pr that reflect their real-world characteristics, voting patterns, and policy priorities. """ +from functools import lru_cache from typing import Dict, List, Optional -from swarms import Agent -from swarms.structs.multi_agent_exec import run_agents_concurrently -from functools import lru_cache from loguru import logger + +from swarms.structs.agent import Agent from swarms.structs.conversation import Conversation +from swarms.structs.multi_agent_exec import run_agents_concurrently @lru_cache(maxsize=1) diff --git a/swarms/structs/__init__.py b/swarms/structs/__init__.py index acad1008..9ea95998 100644 --- a/swarms/structs/__init__.py +++ b/swarms/structs/__init__.py @@ -96,7 +96,6 @@ from swarms.structs.swarming_architectures import ( star_swarm, ) - __all__ = [ "Agent", "BaseStructure", diff --git a/swarms/structs/agent.py b/swarms/structs/agent.py index aaf8d028..73435c30 100644 --- a/swarms/structs/agent.py +++ b/swarms/structs/agent.py @@ -27,9 +27,12 @@ from pydantic import BaseModel from swarms.agents.ape_agent import auto_generate_prompt from swarms.artifacts.main_artifact import Artifact from swarms.prompts.agent_system_prompts import AGENT_SYSTEM_PROMPT_3 +from swarms.prompts.max_loop_prompt import generate_reasoning_prompt from swarms.prompts.multi_modal_autonomous_instruction_prompt import ( MULTI_MODAL_AUTO_AGENT_SYSTEM_PROMPT_1, ) +from swarms.prompts.react_base_prompt import REACT_SYS_PROMPT +from swarms.prompts.safety_prompt import SAFETY_PROMPT from swarms.prompts.tools import tool_sop_prompt from swarms.schemas.agent_mcp_errors import ( AgentMCPConnectionError, @@ -41,19 +44,30 @@ from swarms.schemas.base_schemas import ( ChatCompletionResponseChoice, ChatMessageResponse, ) +from swarms.schemas.conversation_schema import ConversationSchema from swarms.schemas.llm_agent_schema import ModelConfigOrigin +from swarms.schemas.mcp_schemas import ( + MCPConnection, +) from swarms.structs.agent_rag_handler import ( - RAGConfig, AgentRAGHandler, + RAGConfig, ) from swarms.structs.agent_roles import agent_roles from swarms.structs.conversation import Conversation +from swarms.structs.ma_utils import set_random_models_for_agents from swarms.structs.safe_loading import ( SafeLoaderUtils, SafeStateManager, ) from swarms.telemetry.main import log_agent_data from swarms.tools.base_tool import BaseTool +from swarms.tools.mcp_client_call import ( + execute_multiple_tools_on_multiple_mcp_servers_sync, + execute_tool_call_simple, + get_mcp_tools_sync, + get_tools_for_multiple_mcp_servers, +) from swarms.tools.py_func_to_openai_func_str import ( convert_multiple_functions_to_openai_function_schema, ) @@ -64,28 +78,14 @@ from swarms.utils.generate_keys import generate_api_key from swarms.utils.history_output_formatter import ( history_output_formatter, ) -from swarms.utils.litellm_tokenizer import count_tokens -from swarms.utils.litellm_wrapper import LiteLLM -from swarms.utils.pdf_to_text import pdf_to_text -from swarms.prompts.react_base_prompt import REACT_SYS_PROMPT -from swarms.prompts.max_loop_prompt import generate_reasoning_prompt -from swarms.prompts.safety_prompt import SAFETY_PROMPT -from swarms.structs.ma_utils import set_random_models_for_agents -from swarms.tools.mcp_client_call import ( - execute_multiple_tools_on_multiple_mcp_servers_sync, - execute_tool_call_simple, - get_mcp_tools_sync, - get_tools_for_multiple_mcp_servers, -) -from swarms.schemas.mcp_schemas import ( - MCPConnection, -) from swarms.utils.index import ( exists, format_data_structure, ) -from swarms.schemas.conversation_schema import ConversationSchema +from swarms.utils.litellm_tokenizer import count_tokens +from swarms.utils.litellm_wrapper import LiteLLM from swarms.utils.output_types import OutputType +from swarms.utils.pdf_to_text import pdf_to_text def stop_when_repeats(response: str) -> bool: @@ -899,9 +899,9 @@ class Agent: bool: True if model supports vision and image is provided, False otherwise. """ from litellm.utils import ( - supports_vision, supports_function_calling, supports_parallel_function_calling, + supports_vision, ) # Only check vision support if an image is provided @@ -1549,11 +1549,11 @@ class Agent: raise def reliability_check(self): + from litellm import model_list from litellm.utils import ( - supports_function_calling, get_max_tokens, + supports_function_calling, ) - from litellm import model_list if self.system_prompt is None: logger.warning( diff --git a/swarms/structs/concurrent_workflow.py b/swarms/structs/concurrent_workflow.py index 86cba2a1..4ceb62e0 100644 --- a/swarms/structs/concurrent_workflow.py +++ b/swarms/structs/concurrent_workflow.py @@ -5,12 +5,12 @@ from typing import Callable, List, Optional, Union from swarms.structs.agent import Agent from swarms.structs.base_swarm import BaseSwarm from swarms.structs.conversation import Conversation +from swarms.utils.formatter import formatter from swarms.utils.get_cpu_cores import get_cpu_cores from swarms.utils.history_output_formatter import ( history_output_formatter, ) from swarms.utils.loguru_logger import initialize_logger -from swarms.utils.formatter import formatter logger = initialize_logger(log_folder="concurrent_workflow") diff --git a/swarms/structs/deep_research_swarm.py b/swarms/structs/deep_research_swarm.py index 188ac7ea..b71e81c1 100644 --- a/swarms/structs/deep_research_swarm.py +++ b/swarms/structs/deep_research_swarm.py @@ -23,10 +23,6 @@ MAX_WORKERS = ( os.cpu_count() * 2 ) # Optimal number of workers based on CPU cores -############################################################################### -# 1. System Prompts for Each Scientist Agent -############################################################################### - def exa_search(query: str, **kwargs: Any) -> str: """Performs web search using Exa.ai API and returns formatted results.""" diff --git a/swarms/tools/py_func_to_openai_func_str.py b/swarms/tools/py_func_to_openai_func_str.py index 26f64455..a1232ed0 100644 --- a/swarms/tools/py_func_to_openai_func_str.py +++ b/swarms/tools/py_func_to_openai_func_str.py @@ -1,8 +1,8 @@ -import os import concurrent.futures import functools import inspect import json +import os from logging import getLogger from typing import ( Any,