[CLEANUP] Docs & EXA

pull/1107/head
Aksh Parekh 1 week ago
parent 8ade837f05
commit e03b6985b3

@ -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:
```

@ -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 = """

Loading…
Cancel
Save