航空客服智能代理系统

基于AWS Bedrock AgentCore的航空客服智能代理系统,具备对话处理、成功案例库和补偿政策管理功能,适用于航空公司的客户服务场景。

  • by Anya2089
  • Python
  • 本地部署
  • 5 星标
  • 更新于
在 GitHub 查看 Anya2089/Airline-booking-demo-strandsagent-agentcore-ver2.0-withsolutionmanager

使用说明

Airline Customer Service Agent Demo - Version 2

基于 AWS Bedrock AgentCore 的航空客服智能代理系统演示。

Version 2 新增功能:Solutions Memory(成功案例库)

项目架构

┌─────────────────────────────────────────────────────────────────┐
│                        Web Demo (Streamlit)                      │
│                         web_demo.py                              │
│                    + 👍 Like / 👎 Dislike 按钮                   │
└─────────────────────────────────────────────────────────────────┘
                                │
                                │ HTTP + JWT Auth
                                ▼
┌─────────────────────────────────────────────────────────────────┐
│                    AgentCore Runtime                             │
│  ┌─────────────────────────────────────────────────────────────┐│
│  │              Agent (agent_with_gateway.py)                  ││
│  │  • Strands Agent Framework                                  ││
│  │  • Claude 3.5 Sonnet Model                                  ││
│  │  • System Prompt (src/agent/system_prompt.py)               ││
│  │  + Solutions Memory 检索 & 注入                              ││
│  └─────────────────────────────────────────────────────────────┘│
│                                │                                 │
│          ┌─────────────────────┼─────────────────────┐          │
│          ▼                     ▼                     ▼          │
│  ┌───────────────┐    ┌───────────────┐    ┌───────────────┐   │
│  │  Memory A     │    │  Memory B     │    │   Gateway     │   │
│  │  对话历史     │    │  成功案例库   │    │   Policy      │   │
│  │  (自动)       │    │  (点赞存储)   │    │   Engine      │   │
│  └───────────────┘    └───────────────┘    └───────────────┘   │
└─────────────────────────────────────────────────────────────────┘
                                │
                                │ MCP Protocol
                                ▼
┌─────────────────────────────────────────────────────────────────┐
│                    MCP Tools Server (ECS)                        │
│                  mcp-tools-server/mcp_server.py                  │
│                      16 Business Tools                           │
└─────────────────────────────────────────────────────────────────┘

Version 2 新增内容

1. Solutions Memory(成功案例库)

组件 说明
src/memory/solutions_memory.py SolutionsMemory 类 - 分层检索和存储
Memory B 独立的 AgentCore Memory 实例
点赞按钮 Web Demo 中的 👍 Like 按钮

2. 工作流程

用户请求 → 搜索 Memory B → 注入参考案例 → Agent 处理 → 返回响应
                                                          ↓
                                              用户点赞 → 存储到 Memory B

3. 新增测试场景

场景 PNR 用户 说明
场景 F DLY001 Tom Chen 航班延误4小时补偿

目录结构

demo2customer_version2/
├── agent_with_gateway.py      # AgentCore Runtime 入口 (+ Solutions Memory)
├── web_demo.py                # Streamlit Web 界面 (+ 点赞按钮)
├── Dockerfile                 # Runtime 容器构建
├── requirements.txt           # Python 依赖
├── .env.example              # 环境变量模板 (+ Solutions Memory 配置)
├── .gitignore                # Git 忽略配置
├── README.md                 # 项目说明
├── src/
│   ├── agent/
│   │   └── system_prompt.py  # Agent 系统提示词 (+ 补偿政策)
│   ├── auth/
│   │   └── cognito.py        # Cognito 用户认证
│   ├── gateway/
│   │   └── client.py         # Gateway MCP 客户端
│   ├── memory/
│   │   └── solutions_memory.py  # [新增] Solutions Memory 封装
│   ├── data_layer/
│   │   └── data_loader.py    # 数据加载器
│   └── utils/
│       └── logger.py         # 日志配置
├── data/
│   ├── users.json            # 用户测试数据 (6 用户)
│   ├── reservations.json     # 订单测试数据 (6 订单)
│   ├── flights.json          # 航班测试数据 (20 航班)
│   └── policy_config.json    # Policy 配置
├── mcp-tools-server/
│   ├── mcp_server.py         # MCP 工具服务器 (16 个工具)
│   ├── Dockerfile            # MCP Server 容器
│   ├── requirements.txt      # MCP Server 依赖
│   └── data/                 # MCP Server 数据副本
├── tests/
│   └── test_solutions_e2e.py # [新增] Solutions Memory 端到端测试
└── docs/
    ├── QUICKSTART.md         # 快速开始指南
    ├── ARCHITECTURE.md       # 架构说明
    └── SOLUTIONS_MEMORY.md   # [新增] Solutions Memory 设计文档

核心功能

1. 业务场景

场景 描述 Policy
Scenario A 航班取消全额退款 (IROP) Gateway 自动放行
Scenario B 高额退款人工审批 Gateway 拦截 > $1000
Scenario C 会员改签费豁免 Gateway 检查会员等级
Scenario D 审批状态查询 Memory 记忆功能
Scenario E 偏好记忆预订 LTM 长期记忆
Scenario F 航班延误补偿 Solutions Memory

2. 补偿政策 (CANCELLED / DELAYED)

对于取消或延误4小时以上的航班,客户有权获得:

  1. 选项 A - 全额退款

    • 100% 退还票价
    • 无取消费用
  2. 选项 B - 继续行程并获得补偿

    • 免费改签到下一班可用航班
    • 额外补偿:
      • 机场贵宾室使用券
      • 200 里程积分

3. Memory 架构

Memory ID 用途
Memory A airline_agent_memory_v2-xxx 对话历史、用户偏好
Memory B airline_solutions_memory-xxx 成功案例库

快速开始

详见 docs/QUICKSTART.md

测试数据

PNR 用户 场景
ABC123 John Smith 航班取消退款
XYZ789 Jane Johnson 高额退款审批
DEF456 Sarah Williams 会员改签
DLY001 Tom Chen 航班延误补偿

技术栈

  • Agent Framework: Strands Agents SDK
  • LLM: Claude 3.5 Sonnet (via Bedrock)
  • Runtime: AWS Bedrock AgentCore
  • Tools: MCP Protocol
  • Policy: AgentCore Gateway
  • Memory: AgentCore Memory (双 Memory 架构)
  • Auth: Amazon Cognito
  • Web UI: Streamlit