How julio-balladares/deepresearch works
Purpose and Public Entry Points
DeepResearch is a Python library for AI-assisted OSINT: it turns a topic into a research plan, web searches, collected evidence, iterative gap analysis, and a structured Pydantic result. Primary embedding APIs are run_deep_research and dictionary routing, exported through deepresearch/__init__.py; orchestration is implemented in deepresearch/pipeline.py and API adaptation in deepresearch/router.py.
Request, Result, and Configuration Boundary
Typed request, plan, source, round, and final-result contracts form the internal data boundary in deepresearch/models.py. Runtime limits, provider selection, credentials, cache settings, and endpoint overrides are loaded from environment-backed configuration in deepresearch/config.py. This makes caller-supplied request settings and environment policy distinct from pipeline execution.
Research Orchestration
deepresearch/pipeline.py is the central control flow. It coordinates target interpretation, planning, query generation, search/read collection, source limits/deduplication, multi-round iteration, gap evaluation, and final result assembly. deepresearch/service.py provides the service-facing façade around this pipeline, separating application integration from lower-level stages.
LLM Planning and Provider Abstraction
Planning and synthesis-like AI tasks are divided between deepresearch/planner.py and deepresearch/gaps.py: the former derives target profiles, subquestions, and query plans; the latter determines unresolved research gaps to drive later rounds. deepresearch/llm.py abstracts calls to configured providers—including OpenAI, Anthropic, Gemini, Mistral, DeepSeek, xAI, OpenRouter, Perplexity, and Ollama—behind a common interface. Provider API keys and optional base URLs remain infrastructure concerns rather than pipeline logic.
Evidence Acquisition
deepresearch/search.py is the external search boundary, using SerpApi and a caller-selected Google, Bing, Yahoo, DuckDuckGo, or Yandex engine to turn planned queries into candidate web sources. deepresearch/reader.py is the page-content boundary: it fetches and constrains source text when page reading is enabled. The pipeline retains structured source metadata such as URL, domain, search snippet, associated query/subquestion, and fetch status.
Caching and Iterative Controls
deepresearch/cache.py provides local persistence for LLM responses, search results, and page reads, reducing repeated provider and network calls. Cache location and enablement are controlled via configuration. Iteration is explicitly bounded by settings such as rounds, queries, sources per query, total sources, per-source characters, final context size, and LLM timeout, primarily applied across deepresearch/pipeline.py, deepresearch/search.py, and deepresearch/reader.py.
Runtime and External Dependencies
The package runs as a Python library installed through pyproject.toml, with no indicated standalone server or web UI. Required external services are SerpApi plus one selected LLM provider; Ollama supports a local-model route. Utility cross-cutting behavior resides in deepresearch/utils.py, while tests currently focus on LLM behavior in tests/test_llm.py.
Main entry points: pipeline.py Research orchestrator · llm.py LLM provider interface · cache.py Local cache · __init__.py Package exports
Components 15
Public API
- Package exports · Exports embedding APIs.
deepresearch/__init__.py - Dictionary router
deepresearch/router.py - Service façade
deepresearch/service.py - Python package install
pyproject.toml
Research Pipeline
- Research contracts · Typed request, plan, evidence, round, and result boundary.
deepresearch/models.py - Runtime configuration
deepresearch/config.py - Research orchestrator · Coordinates planning, collection, gap-driven iteration, and result assembly.
deepresearch/pipeline.py - Plan generator · Builds target profiles, subquestions, and queries.
deepresearch/planner.py - Gap evaluator · Identifies unresolved questions for later rounds.
deepresearch/gaps.py
AI & Evidence Adapters
- Web search
deepresearch/search.py - Page reader · Fetches and constrains page text when enabled.
deepresearch/reader.py - LLM provider interface
deepresearch/llm.py - Local cache · Caches LLM, search, and page-read responses.
deepresearch/cache.py
External Services
- SerpApi · Accesses the selected web search engine.
- Configured LLM provider · Cloud providers or local Ollama supply model responses.
Connections 20
- Python package install → Package exports: installs
- Package exports → Dictionary router: exports routing
- Package exports → Research orchestrator: exports run API
- Dictionary router → Service façade: adapts dictionaries
- Service façade → Research orchestrator: invokes
- Research orchestrator → Research contracts: reads and returns contracts
- Research orchestrator → Runtime configuration: applies limits and policy
- Research orchestrator → Plan generator: creates plan
- Research orchestrator → Web search: executes queries
- Research orchestrator → Page reader: reads selected sources
- Research orchestrator → Gap evaluator: evaluates evidence gaps
- Plan generator → LLM provider interface: uses
- Gap evaluator → LLM provider interface: uses
- LLM provider interface → Configured LLM provider: provider calls
- Web search → SerpApi: search requests
- Research orchestrator → Local cache: reuses responses
- Web search → Local cache: caches results
- Page reader → Local cache: caches reads
- LLM provider interface → Local cache: caches responses
- Gap evaluator → Research orchestrator: drives next round