Skip to content

Commit fb10650

Browse files
committed
Update examples
1 parent 8cace1f commit fb10650

File tree

6 files changed

+757
-20
lines changed

6 files changed

+757
-20
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Customer Support Example
2+
3+
A simple example of building a customer support system using LangGraph Swarm. This example demonstrates how to create a system where agents can hand off conversations to other specialized agents.
4+
5+
## Overview
6+
7+
The system consists of two specialized agents:
8+
- **Flight Assistant**: Handles flight search and booking
9+
- **Hotel Assistant**: Handles hotel search and booking
10+
11+
These agents can transfer control to each other using handoff tools, allowing for a seamless customer experience.
12+
13+
## Quickstart
14+
15+
```bash
16+
uvx --refresh --from "langgraph-cli[inmem]" --with-editable . --python 3.11 langgraph dev
17+
```
18+
19+
## Features
20+
21+
- Agent handoff between specialized services
22+
- Mock data for flights and hotels
23+
- Reservation tracking by user ID
24+
- Built with LangGraph Swarm for agent orchestration
25+
26+
## How It Works
27+
28+
1. The system starts with the Flight Assistant as the default agent
29+
2. Agents can pass control using handoff tools (`transfer_to_hotel_assistant` and `transfer_to_flight_assistant`)
30+
3. User context and reservation information is maintained throughout handoffs
31+
4. Agents have access to specific tools related to their domain
32+
33+
34+
35+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"dependencies": ["."],
3+
"graphs": {
4+
"agent": "./src/agent/customer_support.py:app"
5+
}
6+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
[project]
2+
name = "swarm-customer-support"
3+
version = "0.0.1"
4+
description = "Simple customer support example using LangGraph Swarm."
5+
authors = [
6+
{ name = "Lance Martin" }
7+
]
8+
readme = "README.md"
9+
license = { text = "MIT" }
10+
requires-python = ">=3.9"
11+
dependencies = [
12+
"langchain-openai>=0.3.11",
13+
"langgraph>=0.3.21",
14+
"langgraph-swarm>=0.0.7",
15+
"langchain>=0.3.21",
16+
]
17+
18+
[project.optional-dependencies]
19+
dev = ["mypy>=1.11.1", "ruff>=0.6.1"]
20+
21+
[build-system]
22+
requires = ["setuptools>=73.0.0", "wheel"]
23+
build-backend = "setuptools.build_meta"
24+
25+
[tool.setuptools]
26+
packages = ["customer_support"]
27+
28+
[tool.setuptools.package-dir]
29+
"customer_support" = "src/agent"
30+
31+
[tool.setuptools.package-data]
32+
"*" = ["py.typed"]
33+
34+
[tool.ruff]
35+
lint.select = [
36+
"E", # pycodestyle
37+
"F", # pyflakes
38+
"I", # isort
39+
"D", # pydocstyle
40+
"D401", # First line should be in imperative mood
41+
"T201",
42+
"UP",
43+
]
44+
lint.ignore = [
45+
"UP006",
46+
"UP007",
47+
"UP035",
48+
"D417",
49+
"E501",
50+
]
51+
52+
[tool.ruff.lint.per-file-ignores]
53+
"tests/*" = ["D", "UP"]
54+
55+
[tool.ruff.lint.pydocstyle]
56+
convention = "google"

examples/customer_support/src/agent/customer_support.ipynb

Lines changed: 653 additions & 0 deletions
Large diffs are not rendered by default.

examples/customer_support/customer_support.py renamed to examples/customer_support/src/agent/customer_support.py

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
from langchain_core.runnables import RunnableConfig
66
from langchain_openai import ChatOpenAI
7-
from langgraph.checkpoint.memory import InMemorySaver
87
from langgraph.prebuilt import create_react_agent
98

109
from langgraph_swarm import create_handoff_tool, create_swarm
@@ -126,18 +125,5 @@ def prompt(state: dict, config: RunnableConfig) -> list:
126125
)
127126

128127
# Compile and run!
129-
checkpointer = InMemorySaver()
130128
builder = create_swarm([flight_assistant, hotel_assistant], default_active_agent="flight_assistant")
131-
132-
# Important: compile the swarm with a checkpointer to remember
133-
# previous interactions and last active agent
134-
app = builder.compile(checkpointer=checkpointer)
135-
# config = {"configurable": {"thread_id": "1", "user_id": "1"}}
136-
# result = app.invoke({
137-
# "messages": [
138-
# {
139-
# "role": "user",
140-
# "content": "i am looking for a flight from boston to ny tomorrow"
141-
# }
142-
# ],
143-
# }, config)
129+
app = builder.compile()

examples/research/README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ A two-phase multi-agent system that demonstrates an effective collaborative appr
55
1. **Planning Phase**: A dedicated planner agent clarifies requirements, reads documentation, and develops a structured approach
66
2. **Research Phase**: A researcher agent implements the solution based on the planner's guidance
77

8+
## Quickstart
9+
10+
```bash
11+
uvx --refresh --from "langgraph-cli[inmem]" --with-editable . --python 3.11 langgraph dev
12+
```
13+
814
## How It Works
915

1016
- The system starts with the **planner agent** that:
@@ -23,8 +29,3 @@ A two-phase multi-agent system that demonstrates an effective collaborative appr
2329

2430
This pattern demonstrates how breaking complex tasks into planning and execution phases can lead to more thorough, well-researched outcomes.
2531

26-
## Quickstart
27-
28-
```bash
29-
uvx --refresh --from "langgraph-cli[inmem]" --with-editable . --python 3.11 langgraph dev
30-
```

0 commit comments

Comments
 (0)