[new example docs][exa, browser use, yahoo finance]

pull/938/head
Kye Gomez 6 days ago
parent 01c670f687
commit 05d3caa8ae

@ -0,0 +1,57 @@
# Advanced Research
An enhanced implementation of the orchestrator-worker pattern from Anthropic's paper, "How we built our multi-agent research system", built on top of the bleeding-edge multi-agent framework [swarms](https://github.com/kyegomez/swarms). Our implementation of this advanced research system leverages parallel execution, LLM-as-judge evaluation, and professional report generation with export capabilities.
**Repository**: [AdvancedResearch](https://github.com/The-Swarm-Corporation/AdvancedResearch)
## Installation
```bash
pip3 install -U advanced-research
# uv pip install -U advanced-research
```
## Environment Variables
```txt
# Exa Search API Key (Required for web search functionality)
EXA_API_KEY="your_exa_api_key_here"
# Anthropic API Key (For Claude models)
ANTHROPIC_API_KEY="your_anthropic_api_key_here"
# OpenAI API Key (For GPT models)
OPENAI_API_KEY="your_openai_api_key_here"
# Worker Agent Configuration
WORKER_MODEL_NAME="gpt-4.1"
WORKER_MAX_TOKENS=8000
# Exa Search Configuration
EXA_SEARCH_NUM_RESULTS=2
EXA_SEARCH_MAX_CHARACTERS=100
```
**Note**: At minimum, you need `EXA_API_KEY` for web search functionality. For LLM functionality, you need either `ANTHROPIC_API_KEY` or `OPENAI_API_KEY`.
## Quick Start
### Basic Usage
```python
from advanced_research import AdvancedResearch
# Initialize the research system
research_system = AdvancedResearch(
name="AI Research Team",
description="Specialized AI research system",
max_loops=1,
)
# Run research and get results
result = research_system.run(
"What are the latest developments in quantum computing?"
)
print(result)
```

@ -0,0 +1,111 @@
# Browser Automation with Swarms
This example demonstrates how to use browser automation capabilities within the Swarms framework. The `BrowserUseAgent` class provides a powerful interface for web scraping, navigation, and automated browser interactions using the `browser_use` library. This is particularly useful for tasks that require real-time web data extraction, form filling, or web application testing.
## Install
```bash
pip3 install -U swarms browser-use python-dotenv langchain-openai
```
## Environment Variables
```txt
# OpenAI API Key (Required for LLM functionality)
OPENAI_API_KEY="your_openai_api_key_here"
```
## Main Code
```python
import asyncio
from browser_use import Agent as BrowserAgent
from dotenv import load_dotenv
from langchain_openai import ChatOpenAI
from swarms import Agent
load_dotenv()
class BrowserUseAgent:
def __init__(self, agent_name: str = "BrowserAgent", agent_description: str = "A browser agent that can navigate the web and perform tasks."):
"""
Initialize a BrowserAgent with a given name.
Args:
agent_name (str): The name of the browser agent.
"""
self.agent_name = agent_name
self.agent_description = agent_description
async def browser_agent_test(self, task: str):
"""
Asynchronously run the browser agent on a given task.
Args:
task (str): The task prompt for the agent.
Returns:
Any: The result of the agent's run method.
"""
agent = BrowserAgent(
task=task,
llm=ChatOpenAI(model="gpt-4.1"),
)
result = await agent.run()
return result.model_dump_json(indent=4)
def run(self, task: str):
"""
Run the browser agent synchronously on a given task.
Args:
task (str): The task prompt for the agent.
Returns:
Any: The result of the agent's run method.
"""
return asyncio.run(self.browser_agent_test(task))
def browser_agent_tool(task: str):
"""
Executes a browser automation agent as a callable tool.
This function instantiates a `BrowserAgent` and runs it synchronously on the provided task prompt.
The agent will use a language model to interpret the task, control a browser, and return the results
as a JSON-formatted string.
Args:
task (str):
A detailed instruction or prompt describing the browser-based task to perform.
For example, you can instruct the agent to navigate to a website, extract information,
or interact with web elements.
Returns:
str:
The result of the browser agent's execution, formatted as a JSON string. The output
typically includes the agent's findings, extracted data, and any relevant observations
from the automated browser session.
Example:
result = browser_agent_tool(
"Please navigate to https://www.coingecko.com and identify the best performing cryptocurrency coin over the past 24 hours."
)
print(result)
"""
return BrowserAgent().run(task)
agent = Agent(
name = "Browser Agent",
model_name = "gpt-4.1",
tools = [browser_agent_tool],
)
agent.run("Please navigate to https://www.coingecko.com and identify the best performing cryptocurrency coin over the past 24 hours.")
```

@ -0,0 +1,48 @@
# Web Search with Exa
Exa is a powerful web search API that provides real-time access to current web information. It allows AI agents to search the internet and retrieve up-to-date information on any topic, making it an essential tool for agents that need current knowledge beyond their training data.
Key features of Exa:
| Feature | Description |
|--------------------------|--------------------------------------------------------------------|
| **Real-time search** | Access the latest information from the web |
| **Semantic search** | Find relevant results using natural language queries |
| **Comprehensive coverage** | Search across billions of web pages |
| **Structured results** | Get clean, formatted search results for easy processing |
| **API integration** | Simple REST API for seamless integration with AI applications |
## Install
```bash
pip3 install -U swarms swarms-tools
```
## ENV
```txt
# Get your API key from exa
EXA_SEARCH_API=""
OPENAI_API_KEY=""
WORKSPACE_DIR=""
```
## Code
```python
from swarms import Agent
from swarms_tools import exa_search
agent = Agent(
name="Exa Search Agent",
llm="gpt-4o-mini",
tools=[exa_search],
)
out = agent.run("What are the latest experimental treatments for diabetes?")
print(out)
```

@ -425,6 +425,14 @@ nav:
- Swarms of Browser Agents: "swarms/examples/swarms_of_browser_agents.md"
- ConcurrentWorkflow with VLLM Agents: "swarms/examples/vllm.md"
- Tools & Integrations:
- Web Search with Exa: "examples/exa_search.md"
- Advanced Research: "examples/av.md"
- Browser Use: "examples/browser_use.md"
- Yahoo Finance: "swarms/examples/yahoo_finance.md"
- Apps:
- Smart Database: "examples/smart_database.md"

@ -1,12 +1,31 @@
# Swarms Tools Example with Yahoo Finance
# Yahoo Finance Integration with Swarms
- `pip3 install swarms swarms-tools`
- Add `OPENAI_API_KEY` to your `.env` file
- Run `yahoo_finance_agent.py`
- Agent will make a function call to the desired tool
- The tool will be executed and the result will be returned to the agent
- The agent will then analyze the result and return the final output
This example demonstrates how to integrate Yahoo Finance data into your Swarms agents using the `swarms-tools` package. The agent can analyze real-time financial data, stock metrics, and market information by making function calls to the Yahoo Finance API. This is particularly useful for financial analysis, portfolio management, and market research applications.
## Install
```bash
pip3 install -U swarms swarms-tools
```
## Environment Variables
```txt
# OpenAI API Key (Required for LLM functionality)
OPENAI_API_KEY="your_openai_api_key_here"
```
## Usage
1. Install the required packages
2. Add your `OPENAI_API_KEY` to your `.env` file
3. Run the example code below
4. The agent will make a function call to the Yahoo Finance tool
5. The tool will execute and return financial data
6. The agent analyzes the result and provides insights
## Code Example
```python
from swarms import Agent
@ -24,19 +43,12 @@ agent = Agent(
system_prompt=FINANCIAL_AGENT_SYS_PROMPT,
max_loops=1,
model_name="gpt-4o",
dynamic_temperature_enabled=True,
user_name="swarms_corp",
retry_attempts=3,
context_length=8192,
return_step_meta=False,
output_type="str", # "json", "dict", "csv" OR "string" "yaml" and
auto_generate_prompt=False, # Auto generate prompt for the agent based on name, description, and system prompt, task
max_tokens=4000, # max output tokens
saved_state_path="agent_00.json",
interactive=False,
tools=[yahoo_finance_api],
)
# Run financial analysis
agent.run("Analyze the latest metrics for nvidia")
# Less than 30 lines of code....
```
**Result**: Less than 30 lines of code to get a fully functional financial analysis agent!

@ -0,0 +1,11 @@
from swarms import Agent
from swarms_tools import exa_search
agent = Agent(
name="Exa Search Agent",
llm="gpt-4o-mini",
tools=[exa_search],
)
agent.run("What are the latest experimental treatments for diabetes?")

@ -0,0 +1,90 @@
import asyncio
from browser_use import Agent as BrowserAgent
from dotenv import load_dotenv
from langchain_openai import ChatOpenAI
from swarms import Agent
load_dotenv()
class BrowserUseAgent:
def __init__(self, agent_name: str = "BrowserAgent", agent_description: str = "A browser agent that can navigate the web and perform tasks."):
"""
Initialize a BrowserAgent with a given name.
Args:
agent_name (str): The name of the browser agent.
"""
self.agent_name = agent_name
self.agent_description = agent_description
async def browser_agent_test(self, task: str):
"""
Asynchronously run the browser agent on a given task.
Args:
task (str): The task prompt for the agent.
Returns:
Any: The result of the agent's run method.
"""
agent = BrowserAgent(
task=task,
llm=ChatOpenAI(model="gpt-4.1"),
)
result = await agent.run()
return result.model_dump_json(indent=4)
def run(self, task: str):
"""
Run the browser agent synchronously on a given task.
Args:
task (str): The task prompt for the agent.
Returns:
Any: The result of the agent's run method.
"""
return asyncio.run(self.browser_agent_test(task))
def browser_agent_tool(task: str):
"""
Executes a browser automation agent as a callable tool.
This function instantiates a `BrowserAgent` and runs it synchronously on the provided task prompt.
The agent will use a language model to interpret the task, control a browser, and return the results
as a JSON-formatted string.
Args:
task (str):
A detailed instruction or prompt describing the browser-based task to perform.
For example, you can instruct the agent to navigate to a website, extract information,
or interact with web elements.
Returns:
str:
The result of the browser agent's execution, formatted as a JSON string. The output
typically includes the agent's findings, extracted data, and any relevant observations
from the automated browser session.
Example:
result = browser_agent_tool(
"Please navigate to https://www.coingecko.com and identify the best performing cryptocurrency coin over the past 24 hours."
)
print(result)
"""
return BrowserAgent().run(task)
agent = Agent(
name = "Browser Agent",
model_name = "gpt-4.1",
tools = [browser_agent_tool],
)
agent.run("Please navigate to https://www.coingecko.com and identify the best performing cryptocurrency coin over the past 24 hours.")

@ -34,7 +34,7 @@ class BrowserAgent:
llm=ChatOpenAI(model="gpt-4.1"),
)
result = await agent.run()
return result
return result.model_dump_json(indent=4)
def run(self, task: str):
"""

Loading…
Cancel
Save