Afiz ⚡️
Afiz ⚡️
@itsafiz
Jan 10 11 days ago 8 tweets Read on X

LangGraph 101: (with code snippets)

Are you new to LangGraph? Curious about how to build AI Agents using LangGraph ? This thread is for you.

A Thread 🧵👇

Tweet image 1

What is LangGraph?

LangGraph is a low-level orchestration framework designed for building stateful, multi-agent systems by representing workflows as graphs

Its core architecture is built upon four primary components:
1. State
2. Nodes
3. Edges
4. Graph

1. State: The application's memory

The State is a shared data structure that acts as the application's memory. It tracks variables and context that nodes can access and modify during execution.

Tweet image 1

2. Nodes (The "Workers")

Nodes are individual Python functions or operations that perform specific tasks
. Every node receives the current state as input, processes it, and returns a dictionary containing updates to that state

Tweet image 1

3. Edges (The "Roadmap")

Edges define the flow of execution between nodes.

• Normal Edges: Create a direct, sequential path from one node to another

• Conditional Edges: Use logic-based routing to decide the next step based on the current state (e.g., a router deciding between a therapist agent or a logical agent)
.
• Virtual Nodes: The graph uses START and END to mark where the workflow begins and concludes

Tweet image 1

4. The Graph (Orchestration Framework)

The StateGraph is the framework used to design and manage the task flow.

Once the nodes and edges are defined, the graph must be compiled into a runnable application and then invoked with an initial state

Tweet image 1

Here is the complete working code all together. Build your first agent and let me know what you think about it.

Tweet image 1

I hope you find this post useful.

Follow me for more such content.

Like and RT this post to share with your friends.

Missing some Tweet in this thread? You can try to Update

Unroll Another Thread

Convert any Twitter threads to an easy-to-read article instantly

Have you tried our Twitter bot?

You can now unroll any thread without leaving Twitter/X. Here's how to use our Twitter bot to do it.

  • Give us a follow on Twitter. follow us
  • Drop a comment, mentioning us @unrollnow on the thread you want to Unroll.
  • Wait For Some Time, We will reply to your comment with Unroll Link.
UnrollNow Twitter Bot
Modal Image
0:00 / 0:00