LangGraph - Agent from template

pip install "langgraph-cli[inmem]"

If working within a monorepo, navigate to the packages directory.

Create the Poetry package.

poetry new --src $"{APP_NAME}"

Create a react agent from the template in a temporary location, e.g., tmp.

langgraph new tmp --template react-agent-python

Copy all of the files into the APP_NAME directory, except pyproject.toml.

Rename react_agent

Rename all references to react_agent, the default package name, to your desired package name.

For example:

  • Rename the src/react_agent directory to src/app_name
  • Rename the react_agent in langgraph.json to the app name.

Add the package dependencies.

poetry add langgraph langchain-openai langchain-anthropic langchain langchain-fireworks python-dotenv langchain-community tavily-python
poetry add --group dev mypy ruff

Install the LangGraph CLI locally.

poetry add --group dev "langgraph-cli[inmem]"

Create the .env file.

cp .env.example .env

Add any keys to the .env file, e.g., OpenAI.

Run LangGraph Studio.

poetry run langgraph dev

Resources

LangGraph - Agent from template
Interactive graph
On this page
Resources