Update README.md
This commit is contained in:
@@ -1,54 +1,45 @@
|
|||||||
# Deep Agent based on LangGraph & LangChain
|
# Deep Agent
|
||||||
|
|
||||||
This repository contains a minimal implementation of a **Deep Agent** that can:
|
This repository contains a minimal implementation of a **Deep Agent** inspired by the *Deep Agents from Scratch* course. The agent can:
|
||||||
|
|
||||||
1. Search the web using the Tavily search API.
|
1. Search the web (DuckDuckGo).
|
||||||
2. Create virtual files in an in‑memory file system.
|
2. Create, read and combine virtual files.
|
||||||
3. Export all virtual files to the real filesystem.
|
3. Export the virtual files to the real filesystem.
|
||||||
|
4. Use LangChain + Ollama for LLM inference.
|
||||||
|
|
||||||
The agent is built on top of the *LangGraph* framework and uses the *LangChain* tools API.
|
## Setup
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Create a virtual environment (recommended)
|
|
||||||
python -m venv .venv
|
|
||||||
source .venv/bin/activate
|
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
> **Note**: The Tavily API key is required for the web search tool. Set it via the
|
|
||||||
> environment variable `TAVILY_API_KEY`.
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```python
|
|
||||||
from agent import create_agent_executor, vfs
|
|
||||||
|
|
||||||
# Create an executor
|
|
||||||
executor = create_agent_executor()
|
|
||||||
|
|
||||||
# Run the agent with a simple prompt
|
|
||||||
result = executor.invoke({"input": "Find the latest news about Python and create a file called news.txt with the summary."})
|
|
||||||
print(result)
|
|
||||||
|
|
||||||
# After the agent finishes, export the virtual files
|
|
||||||
vfs.export_to_disk("output")
|
|
||||||
```
|
|
||||||
|
|
||||||
The `output` directory will contain `news.txt` with the content produced by the agent.
|
|
||||||
|
|
||||||
## Testing
|
|
||||||
|
|
||||||
The project includes a simple test that verifies the existence of the two
|
|
||||||
required functions:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
python -m unittest discover -s tests
|
python deep_agent.py "Write a summary of the latest Python release and store it in summary.txt"
|
||||||
```
|
```
|
||||||
|
|
||||||
## License
|
The agent will perform the task, create virtual files, and export them to `output_files/`.
|
||||||
|
|
||||||
MIT
|
## Architecture
|
||||||
|
|
||||||
|
- `DeepAgent` class implements the agent logic.
|
||||||
|
- `search` uses DuckDuckGo HTML API.
|
||||||
|
- `write_file`, `read_file`, `combine` manage a simple in‑memory virtual filesystem.
|
||||||
|
- `export_files` writes the virtual files to disk.
|
||||||
|
- The agent loop uses a JSON‑based action protocol.
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- Python 3.10+
|
||||||
|
- LangChain >= 1.0.0
|
||||||
|
- LangGraph >= 1.0.0
|
||||||
|
- langchain_ollama
|
||||||
|
- langchain_text_splitters
|
||||||
|
- langchain_chroma
|
||||||
|
- requests
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Feel free to extend the agent with more actions or integrate other LLM providers.
|
||||||
Reference in New Issue
Block a user