2024-09-13 16:28:17 -07:00
2024-09-13 16:28:17 -07:00
2024-09-13 16:28:17 -07:00
2024-09-13 16:28:17 -07:00
2024-09-13 16:28:17 -07:00
2024-09-13 16:28:17 -07:00
2024-09-13 16:28:17 -07:00
2024-09-13 16:28:17 -07:00
2024-09-13 16:28:17 -07:00
2024-09-13 16:28:17 -07:00
2024-09-13 16:28:17 -07:00
2024-09-13 16:28:17 -07:00
2024-09-13 16:28:17 -07:00
2024-09-13 16:28:17 -07:00

LangGraph ReAct Agent Template

CI Integration Tests

This template showcases a ReAct agent implemented using LangGraph, designed for LangGraph Studio. ReAct agents are uncomplicated, prototypical agents that can be flexibly extended to many tools.

Graph view in LangGraph studio UI

The core logic, defined in src/react_agent/graph.py, demonstrates a flexible ReAct agent that iteratively reasons about user queries and executes actions, showcasing the power of this approach for complex problem-solving tasks.

What it does

The ReAct agent:

  1. Takes a user query as input
  2. Reasons about the query and decides on an action
  3. Executes the chosen action using available tools
  4. Observes the result of the action
  5. Repeats steps 2-4 until it can provide a final answer

By default, it's set up with a basic set of tools, but can be easily extended with custom tools to suit various use cases.

Getting Started

Assuming you have already installed LangGraph Studio, to set up:

  1. Create a .env file.
cp .env.example .env
  1. Define required API keys in your .env file.

The primary search tool [^1] used is Tavily. Create an API key here.

Set up your LLM API keys. This repo defaults to using Claude.

  1. Customize whatever you'd like in the code.
  2. Open the folder LangGraph Studio!

How to customize

  1. Add new tools: Extend the agent's capabilities by adding new tools in tools.py. These can be any Python functions that perform specific tasks.
  2. Select a different model: We default to Anthropic's Claude 3 Sonnet. You can select a compatible chat model using provider/model-name via configuration. Example: openai/gpt-4-turbo-preview.
  3. Customize the prompt: We provide a default system prompt in configuration.py. You can easily update this via configuration in the studio.

You can also quickly extend this template by:

  • Modifying the agent's reasoning process in graph.py.
  • Adjusting the ReAct loop or adding additional steps to the agent's decision-making process.

Development

While iterating on your graph, you can edit past state and rerun your app from past states to debug specific nodes. Local changes will be automatically applied via hot reload. Try adding an interrupt before the agent calls tools, updating the default system message in src/react_agent/configuration.py to take on a persona, or adding additional nodes and edges!

Follow up requests will be appended to the same thread. You can create an entirely new thread, clearing previous history, using the + button in the top right.

You can find the latest (under construction) docs on LangGraph here, including examples and other references. Using those guides can help you pick the right patterns to adapt here for your use case.

LangGraph Studio also integrates with LangSmith for more in-depth tracing and collaboration with teammates.

Description
No description provided
Readme MIT 2 MiB
Languages
Python 70%
Makefile 30%