Building AI Agents with LangChain and LangGraph: Part 2 › Setting Up Our Environment
Michael BrenndoerferAugust 2, 20251 min read
Building AI Agents with LangChain and LangGraph: Part 2 › Setting Up Our EnvironmentOne section · Sections in this article2 / 9 ↓
Sections in this article9
Reading tools Definitions & inline links
Toggle tooltip visibility. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
We'll build on the foundation from Part 1 while introducing new concepts for workflow orchestration:
StateGraph: The core abstraction for building multi-step workflowsMessagesState: LangGraph's built-in state for conversation handlingInMemorySaver: For maintaining conversation history and checkpointsCommand&interrupt: For human-in-the-loop interactionscreate_react_agent: A pre-built agent pattern for common use cases
These tools will allow us to create sophisticated agents that can handle complex, multi-turn conversations while maintaining context and state.
In[1]:
Codefrom langchain.chat_models import init_chat_model
from langchain.tools import tool
from langgraph.graph import StateGraph, START, END, MessagesState
from langgraph.checkpoint.memory import InMemorySaver
from langgraph.prebuilt import create_react_agent
from langgraph.types import Command, interrupt
from typing import TypedDict, Literal
from typing_extensions import TypedDict
from rich.markdown import Markdown
from pprint import pprint
from IPython.display import Image
import json