Flight Checkin & Upgrade
-
Overview

-
To solve most of the business or enterprise needs we need workflows
Langgraph
- Langgraph is designed around graphs which make it feasible to run business workflows
- Main Components of Langgraph (w.r.t) Development
- Node: A node is a python function or runnable.

- Edge: This is directional flow

- State: This is data which is shared to all the nodes
- Node: A node is a python function or runnable.
Setting up a project with langgraph
- Create a new folder called as hello-graph and cd into it
- Lets create a python project and dependencies
uv init .
uv add langgraph langgraph-cli[inmem]
uv sync
- Activate virtual environment
# windows
.venv/Scripts/activate
# linux or mac
source .venv/bin/activate
- Now open vscode
code .
- Lets create a simple workflow

- change the main.py code to the following
from langgraph.graph import START, END, StateGraph
from typing import TypedDict
class MyState(TypedDict):
name: str
message: str
def say_hello(state: MyState) -> MyState:
"""This is wish node
Every node in langraph takes state as input and returns
state
Args:
state (MyState): State
Returns:
MyState: State
"""
state['message'] = f"hello {state['name']}"
return state
# design your graph
state_graph = StateGraph(MyState)
state_graph.add_node("wish", say_hello)
state_graph.add_edge(START, "wish")
state_graph.add_edge("wish", END)
# compile your graph
graph = state_graph.compile()
- Now create a langraph.json file with following content
{
"dependencies": ".",
"graphs": {
"main": "main:graph"
}
}
- Now in the activate virtual environment execute the following command
langgraph dev --allow-blocking
-
It would open a browser if not
http://localhost:2024

-
Refer Here for the hello-world langgraph
Lets build a graph which does add two numbers
- Lets create a new file the same project above called as calc.py
