Skip to content

Commit 54b433b

Browse files
committed
feat: Add example repo for agent inbox and LangGraph
1 parent 049ec89 commit 54b433b

17 files changed

+1296
-140
lines changed
9.1 KB
Binary file not shown.
3.82 KB
Binary file not shown.

.langgraph_api/.langgraph_ops.pckl

6.15 KB
Binary file not shown.
150 Bytes
Binary file not shown.

.langgraph_api/store.pckl

6 Bytes
Binary file not shown.

.langgraph_api/store.vectors.pckl

6 Bytes
Binary file not shown.

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"python.languageServer": "None"
3+
}

README.md

Lines changed: 45 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,75 @@
1-
# New LangGraph Project
1+
# Agent Inbox LangGraph Example
22

3-
[![CI](https://github.com/langchain-ai/new-langgraph-project/actions/workflows/unit-tests.yml/badge.svg)](https://github.com/langchain-ai/new-langgraph-project/actions/workflows/unit-tests.yml)
4-
[![Integration Tests](https://github.com/langchain-ai/new-langgraph-project/actions/workflows/integration-tests.yml/badge.svg)](https://github.com/langchain-ai/new-langgraph-project/actions/workflows/integration-tests.yml)
5-
[![Open in - LangGraph Studio](https://img.shields.io/badge/Open_in-LangGraph_Studio-00324d.svg?logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI4NS4zMzMiIGhlaWdodD0iODUuMzMzIiB2ZXJzaW9uPSIxLjAiIHZpZXdCb3g9IjAgMCA2NCA2NCI+PHBhdGggZD0iTTEzIDcuOGMtNi4zIDMuMS03LjEgNi4zLTYuOCAyNS43LjQgMjQuNi4zIDI0LjUgMjUuOSAyNC41QzU3LjUgNTggNTggNTcuNSA1OCAzMi4zIDU4IDcuMyA1Ni43IDYgMzIgNmMtMTIuOCAwLTE2LjEuMy0xOSAxLjhtMzcuNiAxNi42YzIuOCAyLjggMy40IDQuMiAzLjQgNy42cy0uNiA0LjgtMy40IDcuNkw0Ny4yIDQzSDE2LjhsLTMuNC0zLjRjLTQuOC00LjgtNC44LTEwLjQgMC0xNS4ybDMuNC0zLjRoMzAuNHoiLz48cGF0aCBkPSJNMTguOSAyNS42Yy0xLjEgMS4zLTEgMS43LjQgMi41LjkuNiAxLjcgMS44IDEuNyAyLjcgMCAxIC43IDIuOCAxLjYgNC4xIDEuNCAxLjkgMS40IDIuNS4zIDMuMi0xIC42LS42LjkgMS40LjkgMS41IDAgMi43LS41IDIuNy0xIDAtLjYgMS4xLS44IDIuNi0uNGwyLjYuNy0xLjgtMi45Yy01LjktOS4zLTkuNC0xMi4zLTExLjUtOS44TTM5IDI2YzAgMS4xLS45IDIuNS0yIDMuMi0yLjQgMS41LTIuNiAzLjQtLjUgNC4yLjguMyAyIDEuNyAyLjUgMy4xLjYgMS41IDEuNCAyLjMgMiAyIDEuNS0uOSAxLjItMy41LS40LTMuNS0yLjEgMC0yLjgtMi44LS44LTMuMyAxLjYtLjQgMS42LS41IDAtLjYtMS4xLS4xLTEuNS0uNi0xLjItMS42LjctMS43IDMuMy0yLjEgMy41LS41LjEuNS4yIDEuNi4zIDIuMiAwIC43LjkgMS40IDEuOSAxLjYgMi4xLjQgMi4zLTIuMy4yLTMuMi0uOC0uMy0yLTEuNy0yLjUtMy4xLTEuMS0zLTMtMy4zLTMtLjUiLz48L3N2Zz4=)](https://langgraph-studio.vercel.app/templates/open?githubUrl=https://github.com/langchain-ai/new-langgraph-project)
3+
The repository contains a bare minimum code example to get started with the Agent Inbox with LangGraph.
64

7-
This template demonstrates a simple chatbot implemented using [LangGraph](https://github.com/langchain-ai/langgraph), designed for [LangGraph Studio](https://github.com/langchain-ai/langgraph-studio). The chatbot maintains persistent chat memory, allowing for coherent conversations across multiple interactions.
8-
9-
![Graph view in LangGraph studio UI](./static/studio_ui.png)
5+
## Getting Started
106

11-
The core logic, defined in `src/agent/graph.py`, showcases a straightforward chatbot that responds to user queries while maintaining context from previous messages.
7+
To get started, clone the repository:
128

13-
## What it does
9+
```bash
10+
git clone https://github.com/langchain-ai/agent-inbox-example
11+
```
1412

15-
The simple chatbot:
13+
```bash
14+
cd agent-inbox-example
15+
```
1616

17-
1. Takes a user **message** as input
18-
2. Maintains a history of the conversation
19-
3. Generates a response based on the current message and conversation history
20-
4. Updates the conversation history with the new interaction
17+
Then, install the dependencies:
2118

22-
This template provides a foundation that can be easily customized and extended to create more complex conversational agents.
19+
```bash
20+
poetry install
21+
```
2322

24-
## Getting Started
23+
Next, install the [LangGraph CLI](https://langchain-ai.github.io/langgraph/cloud/reference/cli/) if not already installed. We're installing the in-memory version so we can run the LangGraph server without Docker.
2524

26-
Assuming you have already [installed LangGraph Studio](https://github.com/langchain-ai/langgraph-studio?tab=readme-ov-file#download), to set up:
25+
```bash
26+
pip install -U "langgraph-cli[inmem]"
27+
```
2728

28-
1. Create a `.env` file.
29+
After this, we can start the LangGraph server:
2930

3031
```bash
31-
cp .env.example .env
32+
langgraph dev
3233
```
3334

34-
2. Define required API keys in your `.env` file.
35+
This may take a second to start. Once the server is running, it should open a new browser tab to the LangGraph Studio through LangSmith. If this does not happen automatically, visit this URL:
36+
[https://smith.langchain.com/studio/thread?baseUrl=http%3A%2F%2F127.0.0.1%3A2024](https://smith.langchain.com/studio/thread?baseUrl=http%3A%2F%2F127.0.0.1%3A2024)
3537

36-
<!--
37-
Setup instruction auto-generated by `langgraph template lock`. DO NOT EDIT MANUALLY.
38-
-->
38+
Now that our LangGraph server is running, we can start a new run in the Studio. To do this, simply enter any string into the `Interrupt Response` field, then click the `Submit` button. This will execute the graph, and interrupt on the `human_node`. Once the graph has interrupted, we can visit the Agent Inbox site to add your graph, and manage the interrupted thread.
3939

40+
## Agent Inbox Setup
4041

42+
Visit [`dev.agentinbox.ai`](https://dev.agentinbox.ai). If it's your first time visiting the site, you'll be prompted to add a new graph.
4143

42-
<!--
43-
End setup instructions
44-
-->
44+
Enter the following fields into the form:
4545

46-
3. Customize the code as needed.
47-
4. Open the folder in LangGraph Studio!
46+
- Graph/Assistant ID: `agent` - this corresponds to the ID of the graph defined in the [`langgraph.json`](./langgraph.json) file, or the ID of an assistant tied to your graph.
47+
- Deployment URL: `http://127.0.0.1:2024` - this is the URL of the LangGraph server running locally.
48+
- Name: `My Agent` - this is the optional name of the graph. You can set this to any value you want, or leave it empty and it'll be auto-assigned.
4849

49-
## How to customize
50+
Click `Submit` and watch your graph appear in the sidebar. This should automatically fetch the interrupted threads, but if it does not, click on the sidebar item & refresh the page. Once you've done this, you should see a single interrupted item in the table:
5051

51-
1. **Modify the system prompt**: The default system prompt is defined in [configuration.py](./src/agent/configuration.py). You can easily update this via configuration in the studio to change the chatbot's personality or behavior.
52-
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`.
53-
3. **Extend the graph**: The core logic of the chatbot is defined in [graph.py](./src/agent/graph.py). You can modify this file to add new nodes, edges, or change the flow of the conversation.
52+
![Screenshot of the Agent Inbox](./static/agent_inbox_view.png)
5453

55-
You can also quickly extend this template by:
54+
Click on this row, and you'll be taken to the interrupted item page. From here, you can respond in any way you'd like:
5655

57-
- Adding custom tools or functions to enhance the chatbot's capabilities.
58-
- Implementing additional logic for handling specific types of user queries or tasks.
59-
- Integrating external APIs or databases to provide more dynamic responses.
56+
- Accept
57+
- Edit
58+
- Respond
59+
- Ignore
6060

61-
## Development
61+
![Screenshot of an interrupted item in the Agent Inbox](./static/interrupted_item.png)
6262

63-
While iterating on your graph, you can edit past state and rerun your app from previous states to debug specific nodes. Local changes will be automatically applied via hot reload. Try experimenting with:
63+
Once you take an action, the graph will resume the execution and end. The final state returned from the graph will be a string containing the type of action which was taken, and the value of the action args (unless `ignore` was chosen).
6464

65-
- Modifying the system prompt to give your chatbot a unique personality.
66-
- Adding new nodes to the graph for more complex conversation flows.
67-
- Implementing conditional logic to handle different types of user inputs.
65+
To view the result of the graph, go back to the LangGraph Studio and inspect the most recent thread results.
6866

69-
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.
67+
![Screenshot of the most recent thread results LangGraph Studio](./static/studio_thread_result.png)
7068

71-
For more advanced features and examples, refer to the [LangGraph documentation](https://github.com/langchain-ai/langgraph). These resources can help you adapt this template for your specific use case and build more sophisticated conversational agents.
69+
## Go Deeper
7270

73-
LangGraph Studio also integrates with [LangSmith](https://smith.langchain.com/) for more in-depth tracing and collaboration with teammates, allowing you to analyze and optimize your chatbot's performance.
71+
If you'd like to go deeper, you can:
7472

75-
<!--
76-
Configuration auto-generated by `langgraph template lock`. DO NOT EDIT MANUALLY.
77-
{
78-
"config_schemas": {
79-
"agent": {
80-
"type": "object",
81-
"properties": {}
82-
}
83-
}
84-
}
85-
-->
73+
- Checkout the Agent Inbox docs, and codebase here: [github.com/langchain-ai/agent-inbox](https://github.com/langchain-ai/agent-inbox)
74+
- See an open source Executive AI Assistant here: [github.com/langchain-ai/executive-ai-assistant](https://github.com/langchain-ai/executive-ai-assistant)
75+
- See an open source Social Media Agent here: [github.com/langchain-ai/social-media-agent](https://github.com/langchain-ai/social-media-agent)

0 commit comments

Comments
 (0)