A collection of hands-on Jupyter notebooks exploring how to model tasks as stateful workflows with LangGraph. The examples progress from deterministic Python transformations to local-LLM question answering, sequential generation, parallel computations, and structured essay evaluation.
This repository is a learning and portfolio project. It demonstrates workflow design and orchestration patterns; it is not a production application or a validated HR, weather, or academic assessment system.
- Defining workflow state with Python
TypedDict - Building, compiling, invoking, and visualizing LangGraph workflows
- Passing state between deterministic Python and LLM-backed nodes
- Sequencing LLM calls and combining parallel branches
- Using a state reducer to collect parallel evaluation scores
- Requesting structured LLM output with Pydantic
- Running language models locally through Ollama
| Notebook | Workflow | Concepts |
|---|---|---|
| 1 - Temperature conversion | Celsius input → Fahrenheit conversion → temperature label | Typed state, Python nodes, sequential graph edges |
| 2 - Simple LLM Q&A | Question → locally generated answer | LLM-backed node, state updates, Ollama |
| 3 - Prompt chaining | Topic → outline → blog draft | Sequential LLM calls, intermediate state, prompt context |
| 4 - Employee analytics | Employee data → parallel calculations and project evaluation → summary | Parallel graph branches, state merging, deterministic business rules |
| 5 - Essay evaluation | Essay → parallel rubric evaluations → consolidated feedback and average score | Parallel LLM calls, Pydantic structured output, state reducers |
Converts Celsius to Fahrenheit and assigns a label in a two-node graph:
flowchart LR
Start([START]) --> Convert[convert_temp]
Convert --> Label[label_weather]
Label --> End([END])
The sample input is 23 °C, which converts to 73.4 °F. See
known limitations for an issue in the current label
conditions.
A single-node graph sends a question to a local Ollama model and returns the answer in workflow state. The notebook's example asks who created eFootball Mobile.
The first node creates an outline from a topic; the next uses both the topic and outline as context to draft a blog post. The example topic is “Rise of AI in Kenya.”
flowchart LR
Start([START]) --> Outline[create_outline]
Outline --> Blog[create_blog]
Blog --> End([END])
Three independent nodes calculate yearly salary, calculate a bonus, and assess project completion. Their results join at a summary node. The sample rules calculate yearly salary as monthly salary × 12, bonus as two months of salary, and label five or more completed projects “Excellent.”
flowchart LR
Start([START]) --> Salary[calculate_yearly_salary]
Start --> Bonus[calculate_bonus]
Start --> Projects[project_evaluation]
Salary --> Summary[summary]
Bonus --> Summary
Projects --> Summary
Summary --> End([END])
Three parallel nodes assess language quality, depth of analysis, and clarity of thought. Each uses a Pydantic schema to return feedback and a score from 0 to 10. A reducer collects the scores; a final node produces overall feedback and calculates their arithmetic mean.
flowchart LR
Start([START]) --> Language[evaluate_language]
Start --> Analysis[evaluate_analysis]
Start --> Clarity[evaluate_thought]
Language --> Final[final_evaluation]
Analysis --> Final
Clarity --> Final
Final --> End([END])
The Q&A, prompt-chaining, and essay-evaluation notebooks use the local
qwen3.5:2b model through ChatOllama. Their results depend on the local model
and its responses.
- Python
- LangGraph for workflow orchestration
- LangChain Ollama integration and Ollama for local LLM inference
- Pydantic for structured essay-evaluation output
- Jupyter notebooks for runnable, step-by-step examples
- Python 3.11 (used for the current project environment)
- Jupyter Notebook or JupyterLab
- Ollama for the LLM-backed notebooks
Create and activate a virtual environment, then install the project dependencies:
python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install -r requirements.txt
python -m pip install notebookOn macOS or Linux, activate the environment with
source .venv/bin/activate instead.
Install and start Ollama, then download the model used by the LLM notebooks:
ollama pull qwen3.5:2bLaunch Jupyter and run a notebook's cells from top to bottom:
jupyter notebookThe temperature-conversion and employee-analytics notebooks do not require Ollama. The Q&A, prompt-chaining, and essay-evaluation notebooks require the Ollama service and model to be available locally.
- The temperature notebook checks
fahrenheit >= 50before a later50 <= fahrenheit < 77condition, making that later branch unreachable. As a result, the sample73.4 °Fis labeledCold. This is a learning example, not a validated weather classification. - Employee bonus and project-status rules are illustrative heuristics, not compensation or performance recommendations. The input includes working days, which the current calculations do not use.
- LLM-generated answers and evaluations are not independently validated and should not be treated as authoritative assessments.
- The repository currently consists of interactive notebooks; it does not include an application interface or an automated test suite.
.
├── 1_Temperature_Conversion_workflow.ipynb
├── 2_Simple_QA_LLM_Workflow.ipynb
├── 3_Prompt_Chaining_Workflow.ipynb
├── 4_Employee_analytics_Workflow.ipynb
├── 5_Essay_workflow.ipynb
├── README.md
└── requirements.txt