From e03b6985b36f2485ec02432c841f5c7537a31dfe Mon Sep 17 00:00:00 2001 From: Aksh Parekh Date: Wed, 1 Oct 2025 21:26:53 -0700 Subject: [PATCH] [CLEANUP] Docs & EXA --- docs/examples/ma_swarm.md | 11 +---- examples/demos/apps/m&a_swarm.py | 72 +------------------------------- 2 files changed, 3 insertions(+), 80 deletions(-) diff --git a/docs/examples/ma_swarm.md b/docs/examples/ma_swarm.md index 57868863..ebe6a7a3 100644 --- a/docs/examples/ma_swarm.md +++ b/docs/examples/ma_swarm.md @@ -25,21 +25,14 @@ To set up and run the M&A Advisory Swarm, follow these steps: ### Installation -1. **Clone the Swarms repository:** - ```bash - git clone https://github.com/kyegomez/swarms.git - cd swarms - ``` - *(Note: The `ma_advisory.py` file is assumed to be in `examples/demos/apps/`)* - -2. **Install dependencies:** +1. **Install dependencies:** The `ma_advisory.py` script relies on several libraries. These can be installed using the `requirements.txt` file located at the root of your project: ```bash pip install -r requirements.txt ``` This will install `httpx`, `python-dotenv`, `loguru`, and other necessary packages. -3. **Set up Exa API Key:** +2. **Set up Exa API Key:** The `Market & Strategic Analysis Agent` utilizes the `exa_search` tool, which requires an `EXA_API_KEY`. Create a `.env` file in the root directory of your project (or wherever your application loads environment variables) and add your Exa API key: ``` diff --git a/examples/demos/apps/m&a_swarm.py b/examples/demos/apps/m&a_swarm.py index e78b5dcc..f5b7e6d6 100644 --- a/examples/demos/apps/m&a_swarm.py +++ b/examples/demos/apps/m&a_swarm.py @@ -1,79 +1,9 @@ from typing import List -import os -from dotenv import load_dotenv from loguru import logger -import httpx from swarms.structs.agent import Agent from swarms.structs.conversation import Conversation from swarms.utils.history_output_formatter import history_output_formatter -from swarms.utils.any_to_str import any_to_str - -# --- Exa Search Tool Integration --- -def exa_search( - query: str, - characters: int = 1000, # Increased for more detailed M&A research - sources: int = 5, # More sources for comprehensive analysis -) -> str: - """ - Perform a highly summarized Exa web search for M&A market intelligence. - - Args: - query (str): Search query for M&A research. - characters (int): Max characters for summary. - sources (int): Number of sources. - - Returns: - str: Condensed summary of search results. - """ - api_key = os.getenv("EXA_API_KEY") - if not api_key: - raise ValueError("EXA_API_KEY environment variable is not set") - - headers = { - "x-api-key": api_key, - "content-type": "application/json", - } - - payload = { - "query": query, - "type": "auto", - "numResults": sources, - "contents": { - "text": True, - "summary": { - "schema": { - "type": "object", - "required": ["answer"], - "additionalProperties": False, - "properties": { - "answer": { - "type": "string", - "description": "Highly condensed summary of the M&A research result", - } - }, - } - }, - "context": {"maxCharacters": characters}, - }, - } - - try: - logger.info(f"[SEARCH] Exa M&A research: {query[:50]}...") - response = httpx.post( - "https://api.exa.ai/search", - json=payload, - headers=headers, - timeout=30, - ) - response.raise_for_status() - json_data = response.json() - return any_to_str(json_data) - except Exception as e: - logger.error(f"Exa search failed: {e}") - return f"Search failed: {str(e)}. Please try again." - -# Load environment variables -load_dotenv() +from swarms_tools import exa_search # System prompts for each agent INTAKE_AGENT_PROMPT = """