|
|
||
|---|---|---|
| .. | ||
| README.md | ||
| flow.py | ||
| main.py | ||
| nodes.py | ||
| requirements.txt | ||
README.md
PocketFlow Communication Example
This example demonstrates the Communication concept in PocketFlow, specifically focusing on the Shared Store pattern.
Overview
The example implements a simple word counter that shows how nodes can communicate using a shared store. It demonstrates:
- How to initialize and structure a shared store
- How nodes can read from and write to the shared store
- How to maintain state across multiple node executions
- Best practices for shared store usage
Project Structure
pocketflow-communication/
├── README.md
├── requirements.txt
├── main.py
├── flow.py
└── nodes.py
Installation
pip install -r requirements.txt
Usage
python main.py
Enter text when prompted. The program will:
- Count words in the text
- Store statistics in the shared store
- Display running statistics (total texts, total words, average)
Enter 'q' to quit.
How it Works
The example uses three nodes:
TextInput: Reads user input and initializes the shared storeWordCounter: Counts words and updates statistics in the shared storeShowStats: Displays statistics from the shared store
This demonstrates how nodes can share and maintain state using the shared store pattern.