OpenDeepSearch is a lightweight yet powerful search tool designed for seamless integration with AI agents. It enables deep web search and retrieval, optimized for use with Hugging Face's SmolAgents ecosystem.
CodeAgent
.To install OpenDeepSearch, run:
pip install -e . #you can also use: uv pip install -e .
pip install -r requirements.txt #you can also use: uv pip install -r requirements.txt
Note: you must have torch
installed.
Note: using uv
instead of regular pip
makes life much easier!
You can also use PDM as an alternative package manager for OpenDeepSearch. PDM is a modern Python package and dependency manager supporting the latest PEP standards.
# Install PDM if you haven't already
curl -sSL https://raw.githubusercontent.com/pdm-project/pdm/main/install-pdm.py | python3 -
# Initialize a new PDM project
pdm init
# Install OpenDeepSearch and its dependencies
pdm install
# Activate the virtual environment
eval "$(pdm venv activate)"
PDM offers several advantages:
Choose a Search Provider:
Option 1: Serper.dev: Get free 2500 credits and add your API key.
export SERPER_API_KEY='your-api-key-here'
Option 2: SearXNG: Use a self-hosted or public SearXNG instance.
export SEARXNG_INSTANCE_URL='https://your-searxng-instance.com'
export SEARXNG_API_KEY='your-api-key-here' # Optional
Choose a Reranking Solution:
Set up LiteLLM Provider:
export <PROVIDER>_API_KEY='your-api-key-here' # e.g., OPENAI_API_KEY, ANTHROPIC_API_KEY
export OPENAI_BASE_URL='https://your-custom-openai-endpoint.com'
# General default model (fallback for all tasks)
export LITELLM_MODEL_ID='openrouter/google/gemini-2.0-flash-001'
# Task-specific models
export LITELLM_SEARCH_MODEL_ID='openrouter/google/gemini-2.0-flash-001' # For search tasks
export LITELLM_ORCHESTRATOR_MODEL_ID='openrouter/google/gemini-2.0-flash-001' # For agent orchestration
export LITELLM_EVAL_MODEL_ID='gpt-4o-mini' # For evaluation tasks
search_agent = OpenDeepSearchTool(model_name="provider/model-name") # e.g., "anthropic/claude-3-opus-20240229", 'huggingface/microsoft/codebert-base', 'openrouter/google/gemini-2.0-flash-001'
You can use OpenDeepSearch independently or integrate it with SmolAgents for enhanced reasoning and code generation capabilities.
from opendeepsearch import OpenDeepSearchTool
import os
# Set environment variables for API keys
os.environ["SERPER_API_KEY"] = "your-serper-api-key-here" # If using Serper
# Or for SearXNG
# os.environ["SEARXNG_INSTANCE_URL"] = "https://your-searxng-instance.com"
# os.environ["SEARXNG_API_KEY"] = "your-api-key-here" # Optional
os.environ["OPENROUTER_API_KEY"] = "your-openrouter-api-key-here"
os.environ["JINA_API_KEY"] = "your-jina-api-key-here"
# Using Serper (default)
search_agent = OpenDeepSearchTool(
model_name="openrouter/google/gemini-2.0-flash-001",
reranker="jina"
)
# Or using SearXNG
# search_agent = OpenDeepSearchTool(
# model_name="openrouter/google/gemini-2.0-flash-001",
# reranker="jina",
# search_provider="searxng",
# searxng_instance_url="https://your-searxng-instance.com",
# searxng_api_key="your-api-key-here" # Optional
# )
if not search_agent.is_initialized:
search_agent.setup()
query = "Fastest land animal?"
result = search_agent.forward(query)
print(result)
To try out OpenDeepSearch with a user-friendly interface, simply run:
python gradio_demo.py
This will launch a local web interface where you can test different search queries and modes interactively.
You can customize the demo with command-line arguments:
# Using Serper (default)
python gradio_demo.py --model-name "openrouter/google/gemini-2.0-flash-001" --reranker "jina"
# Using SearXNG
python gradio_demo.py --model-name "openrouter/google/gemini-2.0-flash-001" --reranker "jina" \
--search-provider "searxng" --searxng-instance "https://your-searxng-instance.com" \
--searxng-api-key "your-api-key-here" # Optional
Available options:
--model-name
: LLM model to use for search--orchestrator-model
: LLM model for the agent orchestrator--reranker
: Reranker to use (jina
or infinity
)--search-provider
: Search provider to use (serper
or searxng
)--searxng-instance
: SearXNG instance URL (required if using searxng
)--searxng-api-key
: SearXNG API key (optional)--serper-api-key
: Serper API key (optional, will use environment variable if not provided)--openai-base-url
: OpenAI API base URL (optional, will use OPENAI_BASE_URL env var if not provided)from opendeepsearch import OpenDeepSearchTool
from smolagents import CodeAgent, LiteLLMModel
import os
# Set environment variables for API keys
os.environ["SERPER_API_KEY"] = "your-serper-api-key-here" # If using Serper
# Or for SearXNG
# os.environ["SEARXNG_INSTANCE_URL"] = "https://your-searxng-instance.com"
# os.environ["SEARXNG_API_KEY"] = "your-api-key-here" # Optional
os.environ["OPENROUTER_API_KEY"] = "your-openrouter-api-key-here"
os.environ["JINA_API_KEY"] = "your-jina-api-key-here"
# Using Serper (default)
search_agent = OpenDeepSearchTool(
model_name="openrouter/google/gemini-2.0-flash-001",
reranker="jina"
)
# Or using SearXNG
# search_agent = OpenDeepSearchTool(
# model_name="openrouter/google/gemini-2.0-flash-001",
# reranker="jina",
# search_provider="searxng",
# searxng_instance_url="https://your-searxng-instance.com",
# searxng_api_key="your-api-key-here" # Optional
# )
model = LiteLLMModel(
"openrouter/google/gemini-2.0-flash-001",
temperature=0.2
)
code_agent = CodeAgent(tools=[search_agent], model=model)
query = "How long would a cheetah at full speed take to run the length of Pont Alexandre III?"
result = code_agent.run(query)
print(result)
from opendeepsearch import OpenDeepSearchTool
from opendeepsearch.wolfram_tool import WolframAlphaTool
from opendeepsearch.prompts import REACT_PROMPT
from smolagents import LiteLLMModel, ToolCallingAgent, Tool
import os
# Set environment variables for API keys
os.environ["SERPER_API_KEY"] = "your-serper-api-key-here"
os.environ["JINA_API_KEY"] = "your-jina-api-key-here"
os.environ["WOLFRAM_ALPHA_APP_ID"] = "your-wolfram-alpha-app-id-here"
os.environ["FIREWORKS_API_KEY"] = "your-fireworks-api-key-here"
model = LiteLLMModel(
"fireworks_ai/llama-v3p1-70b-instruct", # Your Fireworks Deepseek model
temperature=0.7
)
search_agent = OpenDeepSearchTool(model_name="fireworks_ai/llama-v3p1-70b-instruct", reranker="jina") # Set reranker to "jina" or "infinity"
# Initialize the Wolfram Alpha tool
wolfram_tool = WolframAlphaTool(app_id=os.environ["WOLFRAM_ALPHA_APP_ID"])
# Initialize the React Agent with search and wolfram tools
react_agent = ToolCallingAgent(
tools=[search_agent, wolfram_tool],
model=model,
prompt_templates=REACT_PROMPT # Using REACT_PROMPT as system prompt
)
# Example query for the React Agent
query = "What is the distance, in metres, between the Colosseum in Rome and the Rialto bridge in Venice"
result = react_agent.run(query)
print(result)
OpenDeepSearch offers two distinct search modes to balance between speed and depth:
OpenDeepSearch is built on the shoulders of great open-source projects:
If you use OpenDeepSearch
in your works, please cite it using the following BibTex entry:
@misc{alzubi2025opendeepsearchdemocratizing,
title={Open Deep Search: Democratizing Search with Open-source Reasoning Agents},
author={Salaheddin Alzubi and Creston Brooks and Purva Chiniya and Edoardo Contente and Chiara von Gerlach and Lucas Irwin and Yihan Jiang and Arda Kaz and Windsor Nguyen and Sewoong Oh and Himanshu Tyagi and Pramod Viswanath},
year={2025},
eprint={2503.20201},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/2503.20201},
}
For questions or collaborations, open an issue or reach out to the maintainers.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。