Files
2026-06-05 10:31:14 +00:00

69 lines
2.0 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Deep Agent with StateGraph
This repository contains a minimal implementation of a **Deep Agent** based on the
`deep-agents-from-scratch` notebook. The agent uses a LangGraph
`StateGraph` to orchestrate the following steps:
1. **Think** decide what to search for.
2. **Search** perform a web search with Tavily.
3. **Summarize** summarize each search result and store the raw content in a
virtual file system.
4. **Write File** dump all virtual files to disk.
The implementation follows the modern LangChain API guidelines:
* All imports use the current modular packages (`langchain_openai`,
`langgraph`, `langchain_core`, etc.).
* No legacy `langchain.chat_models` or `langchain.llms` imports.
* The agent can be run from the command line.
## Setup
```bash
# Create a virtual environment (recommended)
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Run the agent interactively
python src/deep_agents_from_scratch/deep_agent.py
```
## Usage
After starting the script you will be prompted to enter a research question.
The agent will perform a web search, summarize the results, and write the
raw content to the `output/` directory.
## Project Structure
```
src/
├── deep_agents_from_scratch/
│ ├── __init__.py
│ ├── deep_agent.py
│ ├── research_tools.py
│ └── state.py
```
- `state.py` defines the `DeepAgentState` dataclass used by the graph.
- `research_tools.py` contains the Tavily search, think, and summarization
tools.
- `deep_agent.py` builds the `StateGraph`, defines node functions, and
provides a CLI entry point.
## Extending the Agent
You can add more tools or nodes by following the pattern used in
`deep_agent.py`. For example, to add a node that writes the summaries to a
PDF you would:
1. Create a new tool that formats the summaries.
2. Add a node function that calls the tool.
3. Connect the node in the graph.
## License
MIT License.