Spring-Ai-Alibaba-Structured-Example 模块
模块说明
本模块是 spring-ai-alibaba-structured-example 模块,包含 3 个控制器。
接口文档
MapListController 接口
1. chatList 方法
接口路径: GET /map-list/chatMap
功能描述: 提供 chatList 相关功能
主要特性:
- 基于 Spring Boot REST API 实现
- 返回 JSON 格式响应
- 支持 UTF-8 编码
使用场景:
- AI 对话交互
- 智能问答系统
- API 集成测试
示例请求:
GET http://localhost:8080/map-list/chatMap
2. chatList 方法
接口路径: GET /map-list/chatList
功能描述: 提供 chatList 相关功能
主要特性:
- 基于 Spring Boot REST API 实现
- 返回 JSON 格式响应
- 支持 UTF-8 编码
使用场景:
- AI 对话交互
- 智能问答系统
- API 集成测试
示例请求:
GET http://localhost:8080/map-list/chatList
JsonController 接口
1. simpleChat 方法
接口路径: GET /json/chat
功能描述: 提供 simpleChat 相关功能
主要特性:
- 基于 Spring Boot REST API 实现
- 返回 JSON 格式响应
- 支持 UTF-8 编码
使用场景:
- AI 对话交互
- 智能问答系统
- API 集成测试
示例请求:
GET http://localhost:8080/json/chat
2. simpleChatFormat 方法
接口路径: GET /json/chat-format
功能描述: 提供 simpleChatFormat 相关功能
主要特性:
- 基于 Spring Boot REST API 实现
- 返回 JSON 格式响应
- 支持 UTF-8 编码
使用场景:
- AI 对话交互
- 智能问答系统
- API 集成测试
示例请求:
GET http://localhost:8080/json/chat-format
BeanController 接口
1. simpleChat 方法
接口路径: GET /bean/chat
功能描述: 提供 simpleChat 相关功能
主要特性:
- 基于 Spring Boot REST API 实现
- 返回 JSON 格式响应
- 支持 UTF-8 编码
使用场景:
- AI 对话交互
- 智能问答系统
- API 集成测试
示例请求:
GET http://localhost:8080/bean/chat
2. simpleChatFormat 方法
接口路径: GET /bean/chat-format
功能描述: 提供 simpleChatFormat 相关功能
主要特性:
- 基于 Spring Boot REST API 实现
- 返回 JSON 格式响应
- 支持 UTF-8 编码
使用场景:
- AI 对话交互
- 智能问答系统
- API 集成测试
示例请求:
GET http://localhost:8080/bean/chat-format
3. chatModel 方法
接口路径: GET /bean/chat-model-format
功能描述: 提供 chatModel 相关功能
主要特性:
- 基于 Spring Boot REST API 实现
- 返回 JSON 格式响应
- 支持 UTF-8 编码
使用场景:
- AI 对话交互
- 智能问答系统
- API 集成测试
示例请求:
GET http://localhost:8080/bean/chat-model-format
4. simpleChat 方法
接口路径: GET /bean/play
功能描述: @return {@link BeanEntity}
主要特性:
- 基于 Spring Boot REST API 实现
- 返回 JSON 格式响应
- 支持 UTF-8 编码
使用场景:
- AI 对话交互
- 智能问答系统
- API 集成测试
示例请求:
GET http://localhost:8080/bean/play
技术实现
核心组件
- Spring Boot: 应用框架
- Spring AI Alibaba: AI 功能集成
- REST Controller: HTTP 接口处理
- spring-ai-alibaba-starter-dashscope: 核心依赖
- spring-boot-starter-web: 核心依赖
配置要点
- 需要配置
AI_DASHSCOPE_API_KEY环境变量 - 默认端口:8080
- 默认上下文路径:/basic
测试指导
使用 HTTP 文件测试
模块根目录下提供了 spring-ai-alibaba-structured-example.http 文件,包含所有接口的测试用例:
- 可在 IDE 中直接执行
- 支持参数自定义
- 提供默认示例参数
使用 curl 测试
# chatList 接口测试
curl "http://localhost:8080/map-list/chatMap"
# simpleChat 接口测试
curl "http://localhost:8080/json/chat"
注意事项
- 环境变量: 确保
AI_DASHSCOPE_API_KEY已正确设置 - 网络连接: 需要能够访问阿里云 DashScope 服务
- 字符编码: 所有响应使用 UTF-8 编码,支持中文内容
- 端口配置: 确保端口 8080 未被占用
此 README.md 由自动化工具生成于 2025-12-09 23:29:55