From 49ba63214068e785f7adce75cf4e942a014a8faa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B8=D1=80=D0=B8=D0=BB=D0=BB=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Fri, 5 Jun 2026 10:31:14 +0000 Subject: [PATCH] Update README.md --- README.md | 76 ++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 58 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 737edbe..08d3321 100644 --- a/README.md +++ b/README.md @@ -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. \ No newline at end of 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. \ No newline at end of file