Update README.md
This commit is contained in:
@@ -1,29 +1,69 @@
|
||||
# Deep Agent from Scratch
|
||||
# Deep Agent with StateGraph
|
||||
|
||||
This repository contains a minimal implementation of a deep agent that can:
|
||||
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. Search the web using DuckDuckGo.
|
||||
2. Create virtual files in memory.
|
||||
3. Export the virtual files to the real file system.
|
||||
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 agent is built using the new LangChain 1.x and LangGraph 1.x APIs.
|
||||
The implementation follows the modern LangChain API guidelines:
|
||||
|
||||
## Prerequisites
|
||||
* 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.
|
||||
|
||||
- Python 3.11 or newer
|
||||
- Ollama running locally with a model such as `llama3.1`
|
||||
- `pip install -r requirements.txt`
|
||||
|
||||
## Running the Agent
|
||||
## Setup
|
||||
|
||||
```bash
|
||||
python agent.py
|
||||
# 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
|
||||
```
|
||||
|
||||
The script will run the agent with a sample prompt, create a virtual file `report.txt`, and export it to the `exported_files` directory.
|
||||
## Usage
|
||||
|
||||
## File Structure
|
||||
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.
|
||||
|
||||
- `agent.py` – Main implementation.
|
||||
- `requirements.txt` – Python dependencies.
|
||||
- `README.md` – This file.
|
||||
## 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.
|
||||
Reference in New Issue
Block a user