61 lines
1.3 KiB
Markdown
61 lines
1.3 KiB
Markdown
# LangGraph Reflection and Rewrite Workflow
|
||
|
||
This repository demonstrates a simple **Python** project built with the
|
||
[LangGraph](https://github.com/langchain-ai/langgraph) framework.
|
||
The workflow consists of two custom nodes:
|
||
|
||
1. **ReflectNode** – Generates a reflection message based on user input.
|
||
2. **RewriteNode** – Rewrites the reflection into a more formal style.
|
||
|
||
## Project Structure
|
||
|
||
```
|
||
src/
|
||
├── nodes/
|
||
│ ├── reflect.py # ReflectNode implementation
|
||
│ └── rewrite.py # RewriteNode implementation
|
||
├── graph.py # Graph definition
|
||
└── main.py # Entry point to run the graph
|
||
tests/
|
||
├── test_reflect.py
|
||
├── test_rewrite.py
|
||
└── test_graph.py
|
||
requirements.txt
|
||
```
|
||
|
||
## Installation
|
||
|
||
```bash
|
||
# Create a virtual environment (optional but recommended)
|
||
python -m venv venv
|
||
source venv/bin/activate # On Windows use `venv\Scripts\activate`
|
||
|
||
# Install dependencies
|
||
pip install -r requirements.txt
|
||
```
|
||
|
||
## Running the Workflow
|
||
|
||
```bash
|
||
python src/main.py
|
||
```
|
||
|
||
You should see output similar to:
|
||
|
||
```
|
||
Graph output: {'rewritten': "I notice that you said: 'Hello world'. Let's reflect on that."}
|
||
```
|
||
|
||
## Testing
|
||
|
||
Run the test suite with `pytest`:
|
||
|
||
```bash
|
||
pytest
|
||
```
|
||
|
||
All tests should pass, confirming that the nodes and graph work as expected.
|
||
|
||
## License
|
||
|
||
MIT License |