Demonstrates the power of LangGraph by building a multi-step text analysis pipeline. This pipeline showcases how LangGraph can be used to create a modular, extensible workflow for natural language processing tasks.
Our use case will focus on processing a given text through three key stages:
- Text Classification: We'll categorize the input text into predefined categories (e.g., News, Blog, Research, or Other).
- Entity Extraction: We'll identify and extract key entities such as persons, organizations, and locations from the text.
- Text Summarization: Finally, we'll generate a concise summary of the input text.
- State Management: Maintains processing context using a
Stateclass - Modular Nodes: Independent nodes for classification, entity extraction, and summarization
- LLM Integration: Utilizes Ollama's LLM (llama3.2:1b) for NLP tasks
- Visualization: Auto-generates workflow diagrams using Mermaid
- Test Pipeline: Includes sample text processing demonstration
- Requirements:
- Python 3.10+
- Ollama installed locally
- llama3.2:1b model downloaded (
ollama pull llama3.2:1b)
- Start Ollama server:
ollama serve- Run Jupyter notebook:
jupyter notebook AgenticClassification.ipynbAgenticClassification.ipynb
βββ Imports
βββ State Class Definition
βββ Node Implementations
β βββ Classification
β βββ Entity Extraction
β βββ Summarization
βββ Workflow Construction
βββ Visualization
βββ Test Pipeline-
Classification:
- Uses prompt template for category prediction
- Categories: News, Blog, Research, Other
-
Entity Extraction:
- Identifies named entities (Person, Organization, Location)
- Returns comma-separated list
-
Summarization:
- Generates concise one-sentence summary
- Maintains key information from source text
Note: Ensure Ollama server is running and the specified model is downloaded before executing the notebook. Temperature parameter is set to 0 for deterministic outputs.
