An AI-powered research assistant that performs iterative, deep research on any topic by combining web search, content analysis, and large language models.
🔬 Simple yet powerful research automation in Python
The goal is to provide the simplest implementation of a deep research agent that can refine its research direction over time and dive deep into any topic. Optimized for ease of use and understanding.
git clone https://github.com/Finance-LLMs/deep-research-python.git
cd deep-research-python
pip install -r requirements.txt
Create a .env.local file with your API keys:
# Required: Web search and scraping
FIRECRAWL_KEY="your_firecrawl_key"
# AI Provider (choose one)
OPEN_ROUTER_KEY="your_openrouter_key" # free models available
# NVIDIA_API_KEY="your_nvidia_api_key" # Alternative - Llama 3.1 70B, DeepSeek R1
# OPENAI_KEY="your_openai_key" # Alternative - GPT-4o-mini
# FIREWORKS_KEY="your_fireworks_key" # Alternative - DeepSeek R1
# Optional: Advanced features
USE_RERANKING=true # Enable semantic re-ranking (default: true)
DEDUP_THRESHOLD=0.9 # Deduplication threshold (default: 0.9)
MIN_YEAR=2020 # Minimum year for documents (default: 2020)
python run_dashboard.py
# Open http://localhost:5000
python -m src.run
python -m src.api
# Server starts on port 3051
The system automatically selects the best available model in this order:
CUSTOM_MODEL and OPENAI_ENDPOINT are setOPEN_ROUTER_KEY is setNVIDIA_API_KEY is setFIREWORKS_KEY is setOpenRouter
NVIDIA API
Local/Custom Models
OPENAI_ENDPOINT="http://localhost:1234/v1"
CUSTOM_MODEL="your_model_name"
OPENAI_KEY="your_api_key_if_needed"
Start the interactive web dashboard:
python run_dashboard.py
# Open http://localhost:5000
Features:
python -m src.run
You'll be prompted to enter your research query and configure parameters:
python -m src.api
# Server starts on port 3051
Endpoints:
# Research with concise answer
curl -X POST http://localhost:3051/api/research \
-H "Content-Type: application/json" \
-d '{"query": "Tesla stock performance 2025", "breadth": 3, "depth": 2}'
# Generate detailed report
curl -X POST http://localhost:3051/api/generate-report \
-H "Content-Type: application/json" \
-d '{"query": "AI trends 2025", "breadth": 4, "depth": 2}'
The system includes advanced retrieval processing for higher quality results:
Configuration:
USE_RERANKING=true # Enable processing (default: true)
DEDUP_THRESHOLD=0.9 # Similarity threshold (default: 0.9)
MIN_YEAR=2020 # Minimum document year (default: 2020)
Every research finding includes transparent source attribution:
Example Output:
### Learning #1
**Finding:** Python 3.12 introduces improved error messages
**Source:** "Python 3.12 now provides more detailed error messages..."
**From:** https://docs.python.org/3.12/whatsnew
**Confidence:** 95%
Access Provenance Data:
from src.deep_research import deep_research
result = await deep_research("Your query", breadth=4, depth=2)
if result.learnings_with_provenance:
for provenance in result.learnings_with_provenance:
print(f"Learning: {provenance['learning']}")
print(f"Source: {provenance['source_url']}")
print(f"Evidence: {provenance['supporting_snippet']}")
print(f"Confidence: {provenance['confidence_score']:.1%}")
| Variable | Description | Default | Options |
|---|---|---|---|
| Core APIs | |||
FIRECRAWL_KEY | Firecrawl API key (required) | - | Your API key |
FIRECRAWL_BASE_URL | Custom Firecrawl endpoint | https://api.firecrawl.dev | URL |
OPEN_ROUTER_KEY | OpenRouter API key | - | Your API key |
NVIDIA_API_KEY | NVIDIA API key | - | Your API key |
OPENAI_KEY | OpenAI API key | - | Your API key |
FIREWORKS_KEY | Fireworks AI API key | - | Your API key |
| Local Models | |||
CUSTOM_MODEL | Custom model name | - | Model name |
OPENAI_ENDPOINT | Custom endpoint URL | - | http://localhost:1234/v1 |
| Search Quality | |||
USE_RERANKING | Enable retrieval processing | true | true/false |
DEDUP_THRESHOLD | Deduplication threshold | 0.9 | 0.0-1.0 |
MIN_YEAR | Minimum document year | 2020 | 2000-2025 |
| Performance | |||
FIRECRAWL_CONCURRENCY | Concurrent requests | 2 | 1-10 |
CONTEXT_SIZE | Max context size | 128000 | Number |
.env.local file with your API keysdocker build -t deep-research-python .
docker run -p 3051:3051 --env-file .env.local deep-research-python
Or with Docker Compose:
docker compose up -d
The research process follows these steps:
flowchart TB
Q[User Query] --> DR[Deep Research]
DR --> SQ[Generate SERP Queries]
SQ --> SR[Search & Scrape]
SR --> QE[Quality Enhancement]
QE --> LE[Extract Learnings]
LE --> PT[Track Provenance]
PT --> D{Depth > 0?}
D -->|Yes| RD[Generate Directions]
RD --> DR
D -->|No| R[Generate Report]
Configure concurrency based on your plan:
# Free tier
FIRECRAWL_CONCURRENCY=1
# Paid tier or self-hosted
FIRECRAWL_CONCURRENCY=5
breadth=2, depth=1 for testing| Issue | Solution |
|---|---|
| "No model found" error | Ensure at least one AI provider API key is set |
| Rate limit errors | Reduce FIRECRAWL_CONCURRENCY or upgrade Firecrawl plan |
| Empty search results | Check Firecrawl API key and connectivity |
| Import/dependency errors | Run pip install -r requirements.txt |
| Slow processing | Enable GPU, use smaller parameters, or faster model |
Modify logging in src/deep_research.py:
def log(*args):
print(*args) # Enable all debug output
This project is licensed under MIT LICENSE.
27 commits
1 commits
Python
79.2%
JavaScript
9.4%
CSS
7.1%
HTML
4.0%
An AI-powered research assistant that performs iterative, deep research on any topic by combining web search, content analysis, and large language models.
🔬 Simple yet powerful research automation in Python
The goal is to provide the simplest implementation of a deep research agent that can refine its research direction over time and dive deep into any topic. Optimized for ease of use and understanding.
git clone https://github.com/Finance-LLMs/deep-research-python.git
cd deep-research-python
pip install -r requirements.txt
Create a .env.local file with your API keys:
# Required: Web search and scraping
FIRECRAWL_KEY="your_firecrawl_key"
# AI Provider (choose one)
OPEN_ROUTER_KEY="your_openrouter_key" # free models available
# NVIDIA_API_KEY="your_nvidia_api_key" # Alternative - Llama 3.1 70B, DeepSeek R1
# OPENAI_KEY="your_openai_key" # Alternative - GPT-4o-mini
# FIREWORKS_KEY="your_fireworks_key" # Alternative - DeepSeek R1
# Optional: Advanced features
USE_RERANKING=true # Enable semantic re-ranking (default: true)
DEDUP_THRESHOLD=0.9 # Deduplication threshold (default: 0.9)
MIN_YEAR=2020 # Minimum year for documents (default: 2020)
python run_dashboard.py
# Open http://localhost:5000
python -m src.run
python -m src.api
# Server starts on port 3051
The system automatically selects the best available model in this order:
CUSTOM_MODEL and OPENAI_ENDPOINT are setOPEN_ROUTER_KEY is setNVIDIA_API_KEY is setFIREWORKS_KEY is setOpenRouter
NVIDIA API
Local/Custom Models
OPENAI_ENDPOINT="http://localhost:1234/v1"
CUSTOM_MODEL="your_model_name"
OPENAI_KEY="your_api_key_if_needed"
Start the interactive web dashboard:
python run_dashboard.py
# Open http://localhost:5000
Features:
python -m src.run
You'll be prompted to enter your research query and configure parameters:
python -m src.api
# Server starts on port 3051
Endpoints:
# Research with concise answer
curl -X POST http://localhost:3051/api/research \
-H "Content-Type: application/json" \
-d '{"query": "Tesla stock performance 2025", "breadth": 3, "depth": 2}'
# Generate detailed report
curl -X POST http://localhost:3051/api/generate-report \
-H "Content-Type: application/json" \
-d '{"query": "AI trends 2025", "breadth": 4, "depth": 2}'
The system includes advanced retrieval processing for higher quality results:
Configuration:
USE_RERANKING=true # Enable processing (default: true)
DEDUP_THRESHOLD=0.9 # Similarity threshold (default: 0.9)
MIN_YEAR=2020 # Minimum document year (default: 2020)
Every research finding includes transparent source attribution:
Example Output:
### Learning #1
**Finding:** Python 3.12 introduces improved error messages
**Source:** "Python 3.12 now provides more detailed error messages..."
**From:** https://docs.python.org/3.12/whatsnew
**Confidence:** 95%
Access Provenance Data:
from src.deep_research import deep_research
result = await deep_research("Your query", breadth=4, depth=2)
if result.learnings_with_provenance:
for provenance in result.learnings_with_provenance:
print(f"Learning: {provenance['learning']}")
print(f"Source: {provenance['source_url']}")
print(f"Evidence: {provenance['supporting_snippet']}")
print(f"Confidence: {provenance['confidence_score']:.1%}")
| Variable | Description | Default | Options |
|---|---|---|---|
| Core APIs | |||
FIRECRAWL_KEY | Firecrawl API key (required) | - | Your API key |
FIRECRAWL_BASE_URL | Custom Firecrawl endpoint | https://api.firecrawl.dev | URL |
OPEN_ROUTER_KEY | OpenRouter API key | - | Your API key |
NVIDIA_API_KEY | NVIDIA API key | - | Your API key |
OPENAI_KEY | OpenAI API key | - | Your API key |
FIREWORKS_KEY | Fireworks AI API key | - | Your API key |
| Local Models | |||
CUSTOM_MODEL | Custom model name | - | Model name |
OPENAI_ENDPOINT | Custom endpoint URL | - | http://localhost:1234/v1 |
| Search Quality | |||
USE_RERANKING | Enable retrieval processing | true | true/false |
DEDUP_THRESHOLD | Deduplication threshold | 0.9 | 0.0-1.0 |
MIN_YEAR | Minimum document year | 2020 | 2000-2025 |
| Performance | |||
FIRECRAWL_CONCURRENCY | Concurrent requests | 2 | 1-10 |
CONTEXT_SIZE | Max context size | 128000 | Number |
.env.local file with your API keysdocker build -t deep-research-python .
docker run -p 3051:3051 --env-file .env.local deep-research-python
Or with Docker Compose:
docker compose up -d
The research process follows these steps:
flowchart TB
Q[User Query] --> DR[Deep Research]
DR --> SQ[Generate SERP Queries]
SQ --> SR[Search & Scrape]
SR --> QE[Quality Enhancement]
QE --> LE[Extract Learnings]
LE --> PT[Track Provenance]
PT --> D{Depth > 0?}
D -->|Yes| RD[Generate Directions]
RD --> DR
D -->|No| R[Generate Report]
Configure concurrency based on your plan:
# Free tier
FIRECRAWL_CONCURRENCY=1
# Paid tier or self-hosted
FIRECRAWL_CONCURRENCY=5
breadth=2, depth=1 for testing| Issue | Solution |
|---|---|
| "No model found" error | Ensure at least one AI provider API key is set |
| Rate limit errors | Reduce FIRECRAWL_CONCURRENCY or upgrade Firecrawl plan |
| Empty search results | Check Firecrawl API key and connectivity |
| Import/dependency errors | Run pip install -r requirements.txt |
| Slow processing | Enable GPU, use smaller parameters, or faster model |
Modify logging in src/deep_research.py:
def log(*args):
print(*args) # Enable all debug output
This project is licensed under MIT LICENSE.
27 commits
1 commits
Python
79.2%
JavaScript
9.4%
CSS
7.1%
HTML
4.0%