使用 OpenAI 代理 SDK 实现的客户服务用例演示
This repository contains a demo of a Customer Service interface built on top of the OpenAI Agents SDK.
It is composed of two parts:
A python backend that handles the agent orchestration logic, implementing the Agents SDK customer service example
A Next.js UI allowing the visualization of the agent orchestration process and providing a chat interface. It uses ChatKit to provide a high-quality chat interface.
You can set your OpenAI API key in your environment variables by running the following command in your terminal:
export OPENAI_API_KEY=your_api_key
You can also follow these instructions to set your OpenAI key at a global level.
Alternatively, you can set the OPENAI_API_KEY environment variable in an .env file at the root of the python-backend folder. You will need to install the python-dotenv package to load the environment variables from the .env file. And then, add these lines of code to your app:
from dotenv import load_dotenv
load_dotenv()
Install the dependencies for the backend by running the following commands:
cd python-backend
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
For the UI, you can run:
cd ui
npm install
You can either run the backend independently if you want to use a separate UI, or run both the UI and backend at the same time.
From the python-backend folder, run:
python -m uvicorn main:app --reload --port 8000
The backend will be available at: http://localhost:8000
From the ui folder, run:
npm run dev
The frontend will be available at: http://localhost:3000
This command will also start the backend.
This app is designed for demonstration purposes. Feel free to update the agent prompts, guardrails, and tools to fit your own customer service workflows or experiment with new use cases! The modular structure makes it easy to extend or modify the orchestration logic for your needs.
Start with a seat change request:
Seat Booking:
Flight Status Inquiry:
Curiosity/FAQ:
This flow demonstrates how the system intelligently routes your requests to the right specialist agent, ensuring you get accurate and helpful responses for a variety of airline-related needs.
Start with a cancellation request:
Confirm cancellation:
Trigger the Relevance Guardrail:
Trigger the Jailbreak Guardrail:
This flow demonstrates how the system not only routes requests to the appropriate agent, but also enforces guardrails to keep the conversation focused on airline-related topics and prevent attempts to bypass system instructions.
Start with the disrupted trip:
get_matching_flights (NY950 and NY982 arriving the next day).Automatic rebooking:
book_new_flight to move you to NY950 the next morning, auto-assigns a seat, and confirms the updated itinerary and confirmation number.Seat and special services:
assign_special_service_seat to secure a front-row seat (1A/2A) on the rebooked flight and saves it to your confirmation.Compensation and policy check:
issue_compensation to open a case, provide hotel and meal credits, and note ground transportation coverage.There are two mock itineraries so both scenarios continue to work: the disrupted Paris -> New York -> Austin trip (PA441/NY802 with rebook to NY950) and the existing on-time flight (FLT-123) used in the first two demo flows.
You are welcome to open issues or submit PRs to improve this app, however, please note that we may not review all suggestions.
This project is licensed under the MIT License. See the LICENSE file for details.
暂无开放 Issues,或尚未同步最近议题。