diff --git a/.DS_Store b/.DS_Store
new file mode 100644
index 0000000..fff7150
Binary files /dev/null and b/.DS_Store differ
diff --git a/README.md b/README.md
index 62b3a9c..3d45e0b 100644
--- a/README.md
+++ b/README.md
@@ -1,18 +1,41 @@
-# Spring AI Summary
+
+## Spring AI Summary

+
- 🇨🇳 中文
- 🇺🇸 English
+
+
+
-🚀🚀🚀 本项目是一个 Spring AI 快速入门的样例工程项目,旨在通过一些小的案例展示 Spring AI 框架的核心功能和使用方法。
-项目采用模块化设计,每个模块都专注于特定的功能领域,便于学习和扩展。
-## 📖 关于 Spring AI
-Spring AI 项目的目标是简化集成人工智能功能的应用程序的开发过程,避免引入不必要的复杂性。关于 Spring AI 的更多信息,请访问 [Spring AI 官方文档](https://spring.io/projects/spring-ai)。
+🚀🚀🚀 Spring AI Summary 是一个基于原生 Spring AI 开发的样例工程集合,旨在帮助开发者快速掌握 Spring AI 框架的核心功能和使用方法。通过模块化设计,每个模块专注于特定功能领域,提供清晰的代码示例和详细的文档,帮助开发者轻松上手并深入理解框架的核心概念。
+
+### 项目特点
+
+- **模块化设计**:每个模块聚焦于一个功能领域,例如聊天、RAG(检索增强生成)、文本向量化、工具函数调用、会话记忆管理等,方便开发者按需学习和应用。
+- **实用示例**:每个模块都包含完整的示例代码和文档,展示 Spring AI 的实际应用场景,帮助开发者快速构建自己的 AI 应用。
+- **持续更新**:紧跟 Spring AI 的最新动态和版本更新,及时优化示例代码和文档,确保内容始终与框架保持同步。
+- **社区支持**:同步优质技术文章和实践经验,分享最佳实践,帮助开发者更好地理解和应用 Spring AI。
+
+### 适合人群
+
+Spring AI Summary 面向对 Spring AI 框架感兴趣的开发者,无论是初学者还是有经验的工程师,都可以通过本项目快速了解框架的核心功能,并将其应用到实际项目中。
+
+通过 Spring AI Summary,您可以:
+
+- 掌握 Spring AI 的核心概念和功能。
+- 学习如何构建高效的 AI 应用。
+- 获取最新的技术动态和实践经验。
+
+欢迎您加入社区,共同探索 Spring AI 的无限可能 (因群二维码有过期时间限制,请加群主二维码邀请进群,备注 Spring AI)!
+
+
+
+
## 🗂️ 项目结构
@@ -26,65 +49,50 @@ spring-ai-summary/
│ ├── spring-ai-chat-doubao/ # 豆包模型接入
│ ├── spring-ai-chat-deepseek/ # DeepSeek 模型接入
│ ├── spring-ai-chat-multi/ # 多 chat 模型调用
+│ │ spring-ai-chat-ollama/ # 接入 ollma
│ └── spring-ai-chat-multi-openai/ # 多 OpenAI 协议模型调用
├── spring-ai-rag/ # RAG 检索增强生成
-├── spring-ai-embedding/ # 文本向量化服务
+├── spring-ai-vector/ # 文本向量化服务
+ |── spring-ai-vector-milvus/ # Milvus 向量存储
+ ├── spring-ai-vector-redis/ # redis 向量存储
├── spring-ai-tool-calling/ # 工具函数调用示例
├── spring-ai-chat-memory/ # 会话记忆管理
+ ├── spring-ai-chat-memory-jdbc # 基于 jdbc 实现存储
+ ├── spring-ai-chat-memory-local # 基于 内存 实现存储
├── spring-ai-evaluation/ # AI 回答评估
└── spring-ai-mcp/ # MCP 示例
+ ├── spring-ai-mcp-server # MCP 服务器
+ ├── spring-ai-mcp-client # MCP 客户端
+└── spring-ai-agent/ # agent 示例
```
-**不同工程模块的文档列表如下:**
-
-* **spring-ai-chat-聊天模块**
- * [spring-ai-chat-openai](spring-ai-chat/spring-ai-chat-openai/README.md) - OpenAI 模型接入
- * [spring-ai-chat-qwen](spring-ai-chat/spring-ai-chat-qwen/README.md) - 通义千问模型接入
- * [spring-ai-chat-doubao](spring-ai-chat/spring-ai-chat-doubao/README.md) - 豆包模型接入
- * [spring-ai-chat-deepseek](spring-ai-chat/spring-ai-chat-deepseek/README.md) - DeepSeek 模型接入
- * [spring-ai-chat-multi](spring-ai-chat/spring-ai-chat-multi/README.md) - 多 chat 模型接入
- * [spring-ai-chat-multi-openai](spring-ai-chat/spring-ai-chat-multi-openai/README.md) - 多 OpenAI 协议模型接入
-* **[spring-ai-embedding-文本向量化服务]()** --待补充
-* **[spring-ai-rag-RAG 检索增强生成]()** --待补充
-* **[spring-ai-tool-calling-工具函数调用示例]()** --待补充
-* **[spring-ai-chat-memory-会话记忆管理]()** --待补充
-* **[spring-ai-mcp-MCP 示例]()** --待补充
-* **[spring-ai-evaluation-AI 回答评估]()** --待补充
-
-## 🧩 核心功能实现
-
-本案例工程的核心功能实现包括:
-
-- **多模型支持**:集成 OpenAI、通义千问、豆包、DeepSeek 等多种 LLM 模型
-- **RAG 实现**:完整的检索增强生成实现,支持文档向量化和语义搜索
-- **Function Calling**:支持函数调用(Function Calling)和工具集成
-- **Chat Memory**:支持多种存储方式的会话历史管理
-- **评估系统**:AI 回答质量评估工具
-- **监控统计**:Token 使用量统计和性能监控
-
-下面你可以通过快速开始部分来快速运行项目。
-
-
## 🚀 快速开始
### ⚙️ 环境要求
-- SpringBoot 3.3.6
-- Spring AI 1.0.0
-- JDK 21+
-- Maven 3.6+
-- Docker(用于运行 Milvus)
+| 依赖项 | 版本/要求 | 说明 |
+| -------------- | ---------------- | ------------------- |
+| SpringBoot | 3.3.6 | |
+| Spring AI | 1.0.0 | |
+| JDK | 21+ | |
+| Maven | 3.6+ | |
+| Docker | (用于运行 Milvus) | |
### 1. 🧬 克隆项目
```bash
-git clone https://github.com/glmapper/spring-ai-summary.git
-cd spring-ai-summary
+# 克隆项目到本地
+git clone https://github.com/java-ai-tech/spring-ai-summary.git
+# 进入项目目录并且 compile 项目
+cd spring-ai-summary && mvn clean compile -DskipTests
```
+> 如果遇到 Maven 依赖下载慢的问题,可以尝试使用国内的 Maven 镜像源,如阿里云、清华大学等;运行过程中如果有其他任何问题,可以扫码加入上面的微信群进行咨询交流~~~
+
### 2. 🛠️ 配置环境变量
对于每个模块的 resource 文件夹下的 `application.yml`/`application.properties` 文件,根据你的需求配置相应的 API 密钥。如 **spring-ai-chat-deepseek** 模块:
+
```properties
# because we do not use the OpenAI protocol
spring.ai.deepseek.api-key=${spring.ai.deepseek.api-key}
@@ -92,19 +100,14 @@ spring.ai.deepseek.base-url=https://api.deepseek.com
spring.ai.deepseek.chat.completions-path=/v1/chat/completions
spring.ai.deepseek.chat.options.model=deepseek-chat
```
-将你的 `spring.ai.deepseek.api-key` 替换为实际的 API 密钥即可启动运行。
-
-### 3. 🗄️ 启动 Milvus
-
-Milvus 是一个开源的向量数据库,用于存储和检索高维向量数据。本项目是使用 Docker 来运行 Milvus,当然你也可以选择其他方式安装 Milvus或者使用已经部署好的 Milvus 服务。
-
-> PS: 如果你不运行 spring-ai-rag 模块和 spring-ai-embedding 模块,可以跳过此步骤。
+将你的 `spring.ai.deepseek.api-key` 替换为实际的 API 密钥即可启动运行。关于如何申请 api key ,可以移步项目 [Wiki 页面](https://github.com/java-ai-tech/spring-ai-summary/wiki)进行查看。
-这个项目使用的 milvus 版本是 2.5.0 版本,安装方式见:[Install Milvus in Docker](https://milvus.io/docs/install_standalone-docker.md)。
+有一个一劳永逸的办法,将对应的spring.ai.deepseek.api-key添加到对应环境变量中,后续启动时会带进来,不用再去修改代码了对应的application.yml,不用担心提交代码泄露key
+将IDEA启动项中的环境变量添加spring.ai.openai.api-key=sk-***************(你自己对应的 key),运行项目时,会自动带入环境变量。
+不过对应的子module每个模块都需要配置
-⚠️本人的电脑是 Mac Air M2 芯片,使用官方文档中的 docker-compose 文件启动 Milvus 时,遇到 `milvus-standalone` 镜像不匹配问题。
-### 4. ▶️ 运行示例
+### 3. ▶️ 运行示例
完成上述步骤后,你可以选择运行不同的示例模块来体验 Spring AI 的功能。如启动运行 **spring-ai-chat-deepseek** 模块(具体端口可以根据你自己的配置而定):
```bash
@@ -122,16 +125,17 @@ Milvus 是一个开源的向量数据库,用于存储和检索高维向量数
2025-06-04T14:18:45.175+08:00 INFO 88446 --- [spring-ai-chat-deepseek] [on(2)-127.0.0.1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2025-06-04T14:18:45.176+08:00 INFO 88446 --- [spring-ai-chat-deepseek] [on(2)-127.0.0.1] o.s.web.servlet.DispatcherServlet : Completed initialization in 1 ms
```
-启动完成后,可以通过 HTTPie 或 Postman 等工具进行测试。
+启动完成后,可以通过 cUrl、HTTPie 或 Postman 等工具进行测试。
+
```bash
-GET /api/deepseek/chatWithMetric?userInput="你是谁" HTTP/1.1
-Host: localhost:8081
-User-Agent: HTTPie
+curl localhost:8081/api/deepseek/chatWithMetric?userInput="你是谁?"
```
结果如下:
+

你可以继续使用下面的请求来查看 Token 使用情况:
+
```bash
# completion tokens
http://localhost:8081/actuator/metrics/ai.completion.tokens
@@ -154,38 +158,38 @@ http://localhost:8081/actuator/metrics/ai.total.tokens
}
```
-## 📚 模块说明
+**关于其他模块的使用方法和配置,可以查看 [Wiki 页面](https://github.com/java-ai-tech/spring-ai-summary/wiki)或各模块的 `README.md` 文件。**
-### 1. 💬 聊天模块 (spring-ai-chat)
+## 📚 学习资料(持续更新中)
-提供多种 LLM 模型的接入实现,支持:
-- 单模型对话:支持 OpenAI、通义千问、豆包、DeepSeek 等模型
-- 多模型并行调用:支持多个模型同时调用,结果对比
-- 提示词模板:支持自定义提示词模板和变量替换
-- Token 统计:支持输入输出 Token 统计和成本估算
+以下是一些推荐的学习资源:
-### 2. 📖 RAG 模块 (spring-ai-rag)
+> 官方也有一个[学习资料汇总](https://github.com/spring-ai-community/awesome-spring-ai),但主要是汇总的国外的一些资料,所以本项目更聚焦在汇总了一些国内的学习资源,供大家参考。
-实现检索增强生成,包含:
-- 文档向量化:支持多种文档格式的向量化处理
-- 向量存储:使用 Milvus 进行高效的向量存储和检索
-- 语义检索:支持相似度搜索和混合检索
-- 问答生成:基于检索结果生成准确的回答
+#### 技术社区
-### 3. 🛠️ 工具调用模块 (spring-ai-tool-calling)
+- [Spring AI 官方文档](https://spring.io/projects/spring-ai)
+- [Spring AI Alibaba 官方文档](https://github.com/alibaba/spring-ai-alibaba)
-展示如何实现工具函数调用:
-- 函数定义:使用 @Tool 注解定义工具函数
-- 工具注册:支持动态注册和配置工具
-- 动态调用:支持运行时动态调用工具
-- 结果处理:支持工具调用结果的格式化和处理
+#### 项目系列
+- [MindMark(心印)是一款基于 SpringAI 的 RAG 系统](https://gitee.com/mumu-osc/mind-mark)
+- [My AI Agent 是一个基于 Spring Boot 和 Spring AI 框架构建的智能代理服务](https://github.com/Cunninger/my-ai-agent)
-### 4. 🧠 会话记忆模块 (spring-ai-chat-memory)
+#### 博客系列
+- [码匠的流水账--Spring AI 系列专栏](https://cloud.tencent.com/developer/column/72423) 因为作者没有进行专栏管理,所以是链接到了主页;此外这个系列的文章用来学习 Spring AI 的一些设计思路和实现方式非常不错,但是他是基于 M 系列版本写作的,所以有些内容可能会和最新版本不一致。
+- [深入解析 Spring AI 系列](https://www.cnblogs.com/guoxiaoyu/p/18666904)
+- [如何用Spring AI构建MCP Client-Server架构](https://spring.didispace.com/article/spring-ai-mcp.html)
+- [Building Effective Agents with Spring AI](https://spring.io/blog/2025/01/21/spring-ai-agentic-patterns) 🌟🌟🌟🌟🌟
+- [Spring AI 大模型返回内容格式化源码分析及简单使用](https://juejin.cn/post/7378696051082199080)
+- [Spring AI EmbeddingModel 概念与源码分析](https://my.oschina.net/u/2391658/blog/18534829)
+- [全量RAG技术:更简单、更实用的实现方法 ✨](https://www.readme-i18n.com/FareedKhan-dev/all-rag-techniques?lang=zh)
+- [Spring AI 框架原理与实战](https://juejin.cn/column/7375109287716372520) 🌟🌟🌟
-提供会话历史管理:
-- JDBC 持久化:支持数据库存储会话历史
-- 本地文件存储:支持文件系统存储会话历史
-- 会话上下文管理:支持会话上下文的管理和清理
+#### 视频系列
+- [How to Build Agents with Spring AI](https://www.youtube.com/watch?v=d7m6nJxfi0g)
+- [Spring AI 系列视频教程](https://www.youtube.com/watch?v=yyvjT0v3lpY&list=PLZV0a2jwt22uoDm3LNDFvN6i2cAVU_HTH)
+- [马克的技术工作坊](https://space.bilibili.com/1815948385) 🌟🌟🌟🌟🌟
+大家如果有好的文章或资源,也欢迎提交 PR 或 Issue 进行补充和完善。下面开发和贡献指南。
## 🔧 开发指南
@@ -227,26 +231,6 @@ http://localhost:8081/actuator/metrics/ai.total.tokens
- 填写 PR 描述,说明改动内容和原因
- 等待代码审查和合并
-### 开发环境设置
-1. **IDE 配置**
- - 推荐使用 IntelliJ IDEA
- - 安装 Lombok 插件
- - 配置 Java 21 SDK
-2. **Maven 配置**
- ```xml
-
- 21
- 1.0.0
-
- ```
-3. **运行测试**
- ```bash
- # 运行所有测试
- mvn test
- # 运行特定模块的测试
- mvn test -pl spring-ai-chat
- ```
-
## 📝 注意事项
1. **API 密钥安全**
@@ -254,12 +238,7 @@ http://localhost:8081/actuator/metrics/ai.total.tokens
- 切勿在代码仓库中硬编码密钥
- 定期轮换密钥,提升安全性
-2. **Milvus 使用**
- - 创建集合时需确保向量维度与 embedding 模型一致
- - 检索前需先加载集合(load collection)
- - 创建索引后再进行检索,提升性能
-
-3. **Token 使用**
+2. **Token 使用**
- 持续监控 Token 消耗,避免超额
- 设置合理的 Token 限制,防止滥用
- 推荐实现缓存机制,提升响应速度与成本控制
@@ -280,3 +259,10 @@ http://localhost:8081/actuator/metrics/ai.total.tokens
- [通义千问](https://qianwen.aliyun.com) - 提供 Qwen 系列模型
- [豆包](https://www.volcengine.com/docs/82379) - 提供豆包系列模型
- [Milvus](https://milvus.io) - 提供向量数据库支持
+
+本项目是一个完全开源项目,主要目的是汇聚更多优质的 Spring AI 相关的学习资源,当然**相关学习资源主要来源于网络,如有侵权,请联系删除!!!**;在此也对参与开源贡献和所有在技术社区分享技术的朋友们表示衷心的感谢!
+
+
+## Star History
+
+[](https://www.star-history.com/#java-ai-tech/spring-ai-summary&Date)
\ No newline at end of file
diff --git a/README_EN.md b/README_EN.md
index 00c6f80..b7ee5c1 100644
--- a/README_EN.md
+++ b/README_EN.md
@@ -1,22 +1,43 @@
# Spring AI Summary

+
- 🇨🇳 中文
- 🇺🇸 English
+
+
+
-🚀🚀🚀 This project is a quick-start sample for Spring AI, designed to demonstrate the core features and usage of the Spring AI framework through practical mini-cases. The project adopts a modular design, with each module focusing on a specific functional area for easy learning and extension.
+🚀🚀🚀 Spring AI Summary is a collection of sample projects based on native Spring AI, designed to help developers quickly master the core features and usage of the Spring AI framework. With a modular design, each module focuses on a specific functional area, providing clear code examples and detailed documentation to help you get started easily and deeply understand the core concepts of the framework.
-## 📖 About Spring AI
+### Project Features
-The goal of the Spring AI project is to simplify the development of applications that integrate AI capabilities, avoiding unnecessary complexity. For more information, please visit the [Spring AI official documentation](https://spring.io/projects/spring-ai).
+- **Modular Design**: Each module focuses on a functional area, such as chat, RAG (Retrieval Augmented Generation), text embedding, tool function calling, chat memory management, etc., making it easy for developers to learn and apply as needed.
+- **Practical Examples**: Each module contains complete sample code and documentation, demonstrating real-world application scenarios of Spring AI, helping you quickly build your own AI applications.
+- **Continuous Updates**: The project keeps up with the latest developments and version updates of Spring AI, optimizing sample code and documentation in a timely manner to ensure content is always up-to-date.
+- **Community Support**: High-quality technical articles and practical experience are shared, offering best practices to help developers better understand and apply Spring AI.
+
+### Who Is This For?
+
+Spring AI Summary is for developers interested in the Spring AI framework. Whether you are a beginner or an experienced engineer, you can quickly learn the core features of the framework and apply them to real projects through this project.
+
+With Spring AI Summary, you can:
+
+- Master the core concepts and features of Spring AI.
+- Learn how to build efficient AI applications.
+- Get the latest technical trends and practical experience.
+
+Welcome to join the community and explore the infinite possibilities of Spring AI together!
+
+
+
+
## 🗂️ Project Structure
-This project uses a modular design, divided by feature as follows:
+This project adopts a modular design, mainly divided into the following modules by feature:
```
spring-ai-summary/
@@ -25,65 +46,51 @@ spring-ai-summary/
│ ├── spring-ai-chat-qwen/ # Qwen integration
│ ├── spring-ai-chat-doubao/ # Doubao integration
│ ├── spring-ai-chat-deepseek/ # DeepSeek integration
-│ ├── spring-ai-chat-multi/ # Multi-model parallel
-│ └── spring-ai-chat-multi-openai/ # OpenAI multi-model parallel
+│ ├── spring-ai-chat-multi/ # Multi chat model
+│ │ spring-ai-chat-ollama/ # Ollama integration
+│ └── spring-ai-chat-multi-openai/ # Multi OpenAI protocol models
├── spring-ai-rag/ # RAG (Retrieval Augmented Generation)
-├── spring-ai-embedding/ # Text embedding service
+├── spring-ai-vector/ # Text embedding service
+│ ├── spring-ai-vector-milvus/ # Milvus vector storage
+│ ├── spring-ai-vector-redis/ # Redis vector storage
├── spring-ai-tool-calling/ # Tool/function calling examples
├── spring-ai-chat-memory/ # Chat memory management
+│ ├── spring-ai-chat-memory-jdbc # JDBC-based storage
+│ ├── spring-ai-chat-memory-local # In-memory storage
├── spring-ai-evaluation/ # AI answer evaluation
└── spring-ai-mcp/ # MCP examples
+ ├── spring-ai-mcp-server # MCP server
+ ├── spring-ai-mcp-client # MCP client
+└── spring-ai-agent/ # Agent examples
```
-**The documentation list for different project modules is as follows.:**
-
-* **spring-ai-chat-chat module**
- * [spring-ai-chat-openai](spring-ai-chat/spring-ai-chat-openai/README.md) - OpenAI Model access
- * [spring-ai-chat-qwen](spring-ai-chat/spring-ai-chat-qwen/README.md) - Qwen Model access
- * [spring-ai-chat-doubao](spring-ai-chat/spring-ai-chat-doubao/README.md) - Doubao Model access
- * [spring-ai-chat-deepseek](spring-ai-chat/spring-ai-chat-deepseek/README.md) - DeepSeek Model access
- * [spring-ai-chat-multi](spring-ai-chat/spring-ai-chat-multi/README.md) - multi chat Model access
- * [spring-ai-chat-multi-openai](spring-ai-chat/spring-ai-chat-multi-openai/README.md) - multi OpenAI protocol Model access
-* **[spring-ai-embedding-文本向量化服务]()** --to be added
-* **[spring-ai-rag-RAG 检索增强生成]()** --to be added
-* **[spring-ai-tool-calling-工具函数调用示例]()** --to be added
-* **[spring-ai-chat-memory-会话记忆管理]()** --to be added
-* **[spring-ai-mcp-MCP 示例]()** --to be added
-* **[spring-ai-evaluation-AI 回答评估]()** --to be added
-*
-## 🧩 Core Features
-
-This sample project implements the following core features:
-
-- **Multi-model support**: Integrates OpenAI, Qwen, Doubao, DeepSeek, and more LLMs
-- **RAG implementation**: Complete retrieval-augmented generation, supporting document embedding and semantic search
-- **Function Calling**: Supports function calling and tool integration
-- **Chat Memory**: Multiple storage options for chat history
-- **Evaluation System**: AI answer quality evaluation tools
-- **Monitoring & Stats**: Token usage and performance monitoring
-
-You can quickly get started by following the steps below.
-
## 🚀 Quick Start
### ⚙️ Requirements
-- SpringBoot 3.3.6
-- Spring AI 1.0.0
-- JDK 21+
-- Maven 3.6+
-- Docker (for running Milvus)
+| Dependency | Version/Requirement | Note |
+| -------------- | ------------------ | ------------------- |
+| SpringBoot | 3.3.6 | |
+| Spring AI | 1.0.0 | |
+| JDK | 21+ | |
+| Maven | 3.6+ | |
+| Docker | (for running Milvus)| |
### 1. 🧬 Clone the Project
```bash
-git clone https://github.com/glmapper/spring-ai-summary.git
-cd spring-ai-summary
+# Clone the project
+git clone https://github.com/java-ai-tech/spring-ai-summary.git
+# Enter the project directory and compile
+cd spring-ai-summary && mvn clean compile -DskipTests
```
+> If you encounter slow Maven dependency downloads, try using a domestic Maven mirror (e.g., Aliyun, Tsinghua). For any other issues, feel free to join the WeChat group above for discussion and support.
+
### 2. 🛠️ Configure Environment Variables
For each module, configure the required API keys in the `application.yml`/`application.properties` file under the `resources` folder. For example, in **spring-ai-chat-deepseek**:
+
```properties
# because we do not use the OpenAI protocol
spring.ai.deepseek.api-key=${spring.ai.deepseek.api-key}
@@ -91,35 +98,32 @@ spring.ai.deepseek.base-url=https://api.deepseek.com
spring.ai.deepseek.chat.completions-path=/v1/chat/completions
spring.ai.deepseek.chat.options.model=deepseek-chat
```
-Replace `spring.ai.deepseek.api-key` with your actual API key to start the service.
-
-### 3. 🗄️ Start Milvus
-
-Milvus is an open-source vector database for storing and retrieving high-dimensional vector data. This project uses Docker to run Milvus, but you can use other installation methods or an existing Milvus service.
-
-> PS: If you do not use the spring-ai-rag or spring-ai-embedding modules, you can skip this step.
+Replace `spring.ai.deepseek.api-key` with your actual API key to start the service. For how to apply for an API key, see the project [Wiki page](https://github.com/java-ai-tech/spring-ai-summary/wiki).
-The project uses Milvus version 2.5.0. See the [Install Milvus in Docker](https://milvus.io/docs/install_standalone-docker.md) guide.
+There's a one-time setup solution: add the spring.ai.deepseek.api-key to your environment variables. This will be automatically loaded during subsequent application startups without needing code modifications in application.yml, eliminating concerns about accidentally committing the code and exposing the key.
-⚠️ On Mac Air M2, there may be issues with the `milvus-standalone` image when using the official docker-compose file.
+In IntelliJ IDEA's launch configuration, add the environment variable spring.ai.openai.api-key=sk-***************(your_actual_key). The project will automatically include this environment variable when running.
-### 4. ▶️ Run Examples
+Note: Each submodule requires separate configuration for this setting.
+### 3. ▶️ Run Examples
After the above steps, you can run different modules to experience Spring AI features. For example, to start **spring-ai-chat-deepseek** (port may vary):
+
```bash
2025-06-04T14:18:43.939+08:00 INFO 88446 --- [spring-ai-chat-deepseek] [ main] c.g.ai.chat.deepseek.DsChatApplication : Starting DsChatApplication using Java 21.0.2 with PID 88446 (/Users/glmapper/Documents/projects/glmapper/spring-ai-summary/spring-ai-chat/spring-ai-chat-deepseek/target/classes started by glmapper in /Users/glmapper/Documents/projects/glmapper/spring-ai-summary)
...
```
-Once started, you can test with HTTPie or Postman:
+Once started, you can test with cUrl, HTTPie, or Postman:
+
```bash
-GET /api/deepseek/chatWithMetric?userInput="Who are you?" HTTP/1.1
-Host: localhost:8081
-User-Agent: HTTPie
+curl localhost:8081/api/deepseek/chatWithMetric?userInput="Who are you?"
```
Result:
+

You can also check token usage:
+
```bash
# completion tokens
http://localhost:8081/actuator/metrics/ai.completion.tokens
@@ -142,38 +146,37 @@ Example response for `ai.completion.tokens`:
}
```
-## 📚 Module Overview
+**For usage and configuration of other modules, see the [Wiki page](https://github.com/java-ai-tech/spring-ai-summary/wiki) or each module's `README.md`.**
-### 1. 💬 Chat Module (spring-ai-chat)
+## 📚 Learning Resources (Continuously Updated)
-Provides integration with multiple LLMs:
-- Single-model chat: OpenAI, Qwen, Doubao, DeepSeek, etc.
-- Multi-model parallel: Call multiple models and compare results
-- Prompt templates: Customizable prompt templates and variable replacement
-- Token stats: Input/output token statistics and cost estimation
+Here are some recommended learning resources:
-### 2. 📖 RAG Module (spring-ai-rag)
+> The official [Awesome Spring AI](https://github.com/spring-ai-community/awesome-spring-ai) list is also available, but it mainly collects overseas resources. This project focuses on aggregating domestic learning resources for your reference.
-Implements retrieval-augmented generation:
-- Document embedding: Supports various document formats
-- Vector storage: Efficient storage and retrieval with Milvus
-- Semantic search: Similarity and hybrid search
-- Answer generation: Generate accurate answers based on retrieval
+#### Technical Community
-### 3. 🛠️ Tool Calling Module (spring-ai-tool-calling)
+- [Spring AI Official Documentation](https://spring.io/projects/spring-ai)
+- [Spring AI Alibaba Official Documentation](https://github.com/alibaba/spring-ai-alibaba)
-Demonstrates tool/function calling:
-- Function definition: Use @Tool annotation to define tools
-- Tool registration: Dynamic registration and configuration
-- Dynamic invocation: Call tools at runtime
-- Result handling: Format and process tool results
+#### Project Series
+- [MindMark: A RAG system based on SpringAI](https://gitee.com/mumu-osc/mind-mark)
+- [My AI Agent: An intelligent agent service based on Spring Boot and Spring AI](https://github.com/Cunninger/my-ai-agent)
-### 4. 🧠 Chat Memory Module (spring-ai-chat-memory)
+#### Blog Series
+- [MaJiang's Spring AI Series](https://cloud.tencent.com/developer/column/72423) (Chinese, some content may be outdated)
+- [In-depth Spring AI Series](https://www.cnblogs.com/guoxiaoyu/p/18666904) (Chinese, discontinued)
+- [How to Build MCP Client-Server Architecture with Spring AI](https://spring.didispace.com/article/spring-ai-mcp.html)
+- [Building Effective Agents with Spring AI](https://spring.io/blog/2025/01/21/spring-ai-agentic-patterns)
+- [Spring AI Large Model Output Formatting and Simple Usage](https://juejin.cn/post/7378696051082199080)
+- [Spring AI EmbeddingModel Concept and Source Code Analysis](https://my.oschina.net/u/2391658/blog/18534829)
-Provides chat history management:
-- JDBC persistence: Store chat history in a database
-- Local file storage: Store chat history in the file system
-- Context management: Manage and clean up chat context
+#### Video Series
+- [How to Build Agents with Spring AI (YouTube)](https://www.youtube.com/watch?v=d7m6nJxfi0g)
+- [Spring AI Video Tutorials (YouTube)](https://www.youtube.com/watch?v=yyvjT0v3lpY&list=PLZV0a2jwt22uoDm3LNDFvN6i2cAVU_HTH)
+- [马克的技术工作坊](https://space.bilibili.com/1815948385) 🌟🌟🌟🌟🌟
+
+If you have good articles or resources, feel free to submit a PR or Issue to supplement and improve this list. See below for development and contribution guidelines.
## 🔧 Development Guide
@@ -189,6 +192,7 @@ Provides chat history management:
2. **Create a feature branch**
```bash
+ # Create and switch to a new feature branch
git checkout -b feature/your-feature-name
```
@@ -211,26 +215,6 @@ Provides chat history management:
- Describe your changes and reasons
- Wait for review and merge
-### Development Environment Setup
-1. **IDE Setup**
- - Recommend IntelliJ IDEA
- - Install Lombok plugin
- - Configure Java 21 SDK
-2. **Maven Setup**
- ```xml
-
- 21
- 1.0.0
-
- ```
-3. **Run Tests**
- ```bash
- # Run all tests
- mvn test
- # Run tests for a specific module
- mvn test -pl spring-ai-chat
- ```
-
## 📝 Notes
1. **API Key Security**
@@ -238,12 +222,7 @@ Provides chat history management:
- Never hardcode keys in the codebase
- Rotate keys regularly for better security
-2. **Milvus Usage**
- - Ensure vector dimension matches the embedding model when creating collections
- - Load the collection before retrieval (load collection)
- - Create indexes before retrieval for better performance
-
-3. **Token Usage**
+2. **Token Usage**
- Monitor token consumption to avoid overuse
- Set reasonable token limits to prevent abuse
- Implement caching to improve response speed and cost control
@@ -264,3 +243,10 @@ Provides chat history management:
- [Qwen](https://qianwen.aliyun.com) - Qwen series models
- [Doubao](https://www.volcengine.com/docs/82379) - Doubao series models
- [Milvus](https://milvus.io) - Vector database support
+
+This project is fully open source, aiming to aggregate more high-quality Spring AI learning resources. Most resources are collected from the internet. If there is any infringement, please contact for removal. Special thanks to all open source contributors and everyone who shares technology in the community!
+
+
+## Star History
+
+[](https://www.star-history.com/#java-ai-tech/spring-ai-summary&Date)
\ No newline at end of file
diff --git a/docs/.DS_Store b/docs/.DS_Store
new file mode 100644
index 0000000..52c9212
Binary files /dev/null and b/docs/.DS_Store differ
diff --git a/docs/statics/my_chat.png b/docs/statics/my_chat.png
new file mode 100644
index 0000000..87a25fc
Binary files /dev/null and b/docs/statics/my_chat.png differ
diff --git a/docs/statics/tc-ToolCallingManager.png b/docs/statics/tc-ToolCallingManager.png
new file mode 100644
index 0000000..ea42c46
Binary files /dev/null and b/docs/statics/tc-ToolCallingManager.png differ
diff --git a/docs/statics/tc-core-component.png b/docs/statics/tc-core-component.png
new file mode 100644
index 0000000..486727c
Binary files /dev/null and b/docs/statics/tc-core-component.png differ
diff --git a/docs/statics/tc-returnDirect.png b/docs/statics/tc-returnDirect.png
new file mode 100644
index 0000000..6edaade
Binary files /dev/null and b/docs/statics/tc-returnDirect.png differ
diff --git a/docs/statics/tool-context.png b/docs/statics/tool-context.png
new file mode 100644
index 0000000..73977af
Binary files /dev/null and b/docs/statics/tool-context.png differ
diff --git a/pom.xml b/pom.xml
index d2674b3..cc59094 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,6 +21,8 @@
spring-ai-evaluation
spring-ai-chat-memory
spring-ai-tool-calling
+ spring-ai-agent
+ spring-ai-observability
diff --git a/spring-ai-agent/pom.xml b/spring-ai-agent/pom.xml
new file mode 100644
index 0000000..fcdd806
--- /dev/null
+++ b/spring-ai-agent/pom.xml
@@ -0,0 +1,24 @@
+
+
+ 4.0.0
+
+ com.glmapper
+ spring-ai-summary
+ 0.0.1
+
+ spring-ai-agent
+ pom
+ spring-ai-agent
+
+
+ 21
+ 1.0.0
+
+
+
+ spring-ai-workflow
+ spring-ai-agent-orchestrator
+
+
+
\ No newline at end of file
diff --git a/spring-ai-agent/spring-ai-agent-orchestrator/README.md b/spring-ai-agent/spring-ai-agent-orchestrator/README.md
new file mode 100644
index 0000000..00b0dea
--- /dev/null
+++ b/spring-ai-agent/spring-ai-agent-orchestrator/README.md
@@ -0,0 +1,197 @@
+
+# 基于大模型的 OrchestratorWorkersWorkflow 智能编排
+
+## 一、背景与目标
+
+在智能体(AI Agent)和自动化编排领域,复杂任务往往需要拆解为多个子任务,并由不同的“worker”并行处理。本文将介绍如何基于 Spring AI 和大模型(LLM),实现一个通用的 OrchestratorWorkersWorkflow,自动完成任务拆解、分发与结果汇总,并通过单元测试进行验证和评估。
+
+---
+
+## 二、核心设计思路
+
+### 1. 任务拆解(Orchestration)
+
+- 利用大模型(如 OpenAI、Qwen 等)对用户输入的复杂任务进行智能拆解,输出结构化的子任务列表。
+- 拆解 prompt 采用系统提示词,要求模型以 JSON 数组返回所有可独立执行的子任务。
+
+### 2. 子任务处理(Workers)
+
+- 对每个子任务,worker 再次调用大模型,让其“执行”或“回答”该子任务,实现通用型处理。
+- 支持并行处理,提升效率。
+
+### 3. 结果汇总
+
+- 汇总所有 worker 的输出,形成最终的 content。
+- 同时保留原始拆解、子任务列表、各 worker 输出,便于溯源和分析。
+
+---
+
+## 三、核心代码实现
+
+### 1. WorkflowResponse 结构
+
+```java
+@Data
+@Builder
+public class WorkflowResponse {
+ private String analysis; // 大模型原始拆解输出
+ private List subtasks; // 拆解出的所有子任务
+ private List workerResponses; // 每个 worker 的输出
+ private String content; // 最终合成内容
+ private boolean success; // 是否成功
+ private String errorMessage; // 错误信息
+}
+```
+
+### 2. OrchestratorWorkersWorkflow 主要逻辑
+
+```java
+@Component
+public class OrchestratorWorkersWorkflow {
+
+ @Autowired
+ private ChatClient chatClient;
+
+ private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
+
+ public WorkflowResponse process(String taskDescription) {
+ try {
+ // 1. 用大模型拆解任务
+ LlmSubtaskResult subtaskResult = callLlmForSubtasks(taskDescription);
+ List subtasks = subtaskResult.subtasks;
+ String analysis = subtaskResult.analysis;
+ if (subtasks == null || subtasks.isEmpty()) {
+ return WorkflowResponse.builder()
+ .success(false)
+ .errorMessage("大模型未能拆解出子任务")
+ .analysis(analysis)
+ .subtasks(subtasks)
+ .build();
+ }
+
+ // 2. Workers process subtasks in parallel
+ List workerResponses = subtasks.stream()
+ .map(subtask -> CompletableFuture.supplyAsync(() -> workerProcess(subtask)))
+ .collect(Collectors.toList())
+ .stream()
+ .map(CompletableFuture::join)
+ .collect(Collectors.toList());
+
+ // 3. Results are combined into final response
+ String combined = String.join("\n", workerResponses);
+ return WorkflowResponse.builder()
+ .content(combined)
+ .success(true)
+ .analysis(analysis)
+ .subtasks(subtasks)
+ .workerResponses(workerResponses)
+ .build();
+ } catch (Exception e) {
+ return WorkflowResponse.builder()
+ .success(false)
+ .errorMessage("Orchestrator/Worker 执行失败: " + e.getMessage())
+ .build();
+ }
+ }
+
+ // 用大模型拆解任务
+ private LlmSubtaskResult callLlmForSubtasks(String taskDescription) throws Exception {
+ List messages = List.of(
+ new SystemMessage("你是一个任务拆解专家。请将用户输入的复杂任务描述拆解为若干可以独立执行的子任务,输出格式为 JSON 数组,每个元素为一个子任务字符串。"),
+ new UserMessage(taskDescription)
+ );
+ Prompt prompt = new Prompt(messages);
+ String modelResult = chatClient.prompt(prompt).call().content();
+ List subtasks;
+ try {
+ subtasks = OBJECT_MAPPER.readValue(modelResult, new TypeReference>() {});
+ } catch (Exception e) {
+ subtasks = Arrays.stream(modelResult.split("[。,.,\n]")).map(String::trim).filter(s -> !s.isEmpty()).collect(Collectors.toList());
+ }
+ return new LlmSubtaskResult(modelResult, subtasks);
+ }
+
+ // 通用 worker 处理逻辑:再次用大模型处理子任务
+ private String workerProcess(String subtask) {
+ try {
+ String systemPrompt = "你是一个高效的AI助手,请认真完成以下子任务:";
+ List messages = List.of(
+ new SystemMessage(systemPrompt),
+ new UserMessage(subtask)
+ );
+ Prompt prompt = new Prompt(messages);
+ return chatClient.prompt(prompt).call().content();
+ } catch (Exception e) {
+ return "[Worker Error] " + e.getMessage();
+ }
+ }
+
+ // 内部类:封装大模型分析结果
+ private static class LlmSubtaskResult {
+ final String analysis;
+ final List subtasks;
+ LlmSubtaskResult(String analysis, List subtasks) {
+ this.analysis = analysis;
+ this.subtasks = subtasks;
+ }
+ }
+}
+```
+
+---
+
+## 四、测试用例与验证
+
+### 1. 测试用例设计
+
+- 输入任务描述:"Generate both technical and user-friendly documentation for a REST API endpoint"
+- 期望:大模型能拆解出合理的文档编写子任务,worker 能对每个子任务给出专业输出。
+
+### 2. 测试结果(test_result.md 摘要)
+
+- **Analysis**(大模型拆解原始输出):
+ ```json
+ [
+ "Identify the REST API endpoint to be documented",
+ "Gather technical specifications of the endpoint (e.g., HTTP method, URL, request/response formats)",
+ "Document the endpoint's purpose and functionality",
+ ...
+ "Format the documentation for readability and consistency"
+ ]
+ ```
+- **Worker Outputs**(每个子任务的处理结果):
+ - 针对“Identify the REST API endpoint to be documented”,worker 会主动询问 API 细节,体现了智能 agent 的交互性。
+ - 针对“Gather technical specifications...”,worker 会列举常见的技术规格项,并给出格式建议。
+ - 针对“Write clear, step-by-step usage instructions for developers”,worker 会输出结构化的开发者指引。
+ - 其他子任务也都能得到合理、专业的响应。
+
+- **最终 content**:为所有 worker 输出的合成文本,便于直接展示或下游处理。
+
+---
+
+## 五、结果评估与客观分析
+
+### 1. 优点
+
+- **高度自动化**:无需手写拆解规则,完全依赖大模型智能分析。
+- **通用性强**:worker 逻辑可适配各种类型的子任务,适合多场景复用。
+- **可扩展性好**:支持并行处理,易于横向扩展。
+- **结构化输出**:便于前端展示、流程追踪和后续分析。
+
+### 2. 局限与改进空间
+
+- **大模型输出稳定性**:部分模型可能输出非严格 JSON,需做好容错处理。
+- **worker 处理深度**:如需更专业的子任务处理,可为不同类型子任务定制专属 worker。
+- **性能优化**:大规模并发时可引入线程池、限流等机制。
+
+### 3. 适用场景
+
+- 智能文档生成、API 文档自动化
+- 复杂任务的自动拆解与执行
+- AI Agent、RPA、智能问答等
+
+---
+
+## 六、结语
+
+通过 OrchestratorWorkersWorkflow 的实现与验证,我们可以看到大模型驱动的智能编排在实际业务中的巨大潜力。只需简单 prompt,即可实现复杂任务的自动拆解与高效执行。未来,结合更细粒度的 worker 能力和更强的模型,智能体编排将更加智能和实用。
\ No newline at end of file
diff --git a/spring-ai-agent/spring-ai-agent-orchestrator/pom.xml b/spring-ai-agent/spring-ai-agent-orchestrator/pom.xml
new file mode 100644
index 0000000..b35e089
--- /dev/null
+++ b/spring-ai-agent/spring-ai-agent-orchestrator/pom.xml
@@ -0,0 +1,26 @@
+
+ 4.0.0
+
+ com.glmapper
+ spring-ai-agent
+ 0.0.1
+
+
+ spring-ai-agent-orchestrator
+ jar
+
+ spring-ai-agent-orchestrator
+
+
+
+ org.springframework.ai
+ spring-ai-starter-model-openai
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
diff --git a/spring-ai-agent/spring-ai-agent-orchestrator/src/main/java/com/glmapper/ai/workflow/OrchestratorWorkersWorkflowApplication.java b/spring-ai-agent/spring-ai-agent-orchestrator/src/main/java/com/glmapper/ai/workflow/OrchestratorWorkersWorkflowApplication.java
new file mode 100644
index 0000000..edda90f
--- /dev/null
+++ b/spring-ai-agent/spring-ai-agent-orchestrator/src/main/java/com/glmapper/ai/workflow/OrchestratorWorkersWorkflowApplication.java
@@ -0,0 +1,14 @@
+package com.glmapper.ai.workflow;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+/**
+ * Hello world!
+ */
+@SpringBootApplication
+public class OrchestratorWorkersWorkflowApplication {
+ public static void main(String[] args) {
+ SpringApplication.run(OrchestratorWorkersWorkflowApplication.class, args);
+ }
+}
diff --git a/spring-ai-agent/spring-ai-agent-orchestrator/src/main/java/com/glmapper/ai/workflow/config/OpenaiChatClientConfigs.java b/spring-ai-agent/spring-ai-agent-orchestrator/src/main/java/com/glmapper/ai/workflow/config/OpenaiChatClientConfigs.java
new file mode 100644
index 0000000..345fce7
--- /dev/null
+++ b/spring-ai-agent/spring-ai-agent-orchestrator/src/main/java/com/glmapper/ai/workflow/config/OpenaiChatClientConfigs.java
@@ -0,0 +1,30 @@
+package com.glmapper.ai.workflow.config;
+
+import org.springframework.ai.chat.client.ChatClient;
+import org.springframework.ai.openai.OpenAiChatModel;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+
+/**
+ * @Classname OpenaiChatClientConfigs
+ * @Description 注入 ChatClient
+ *
+ * @Date 2025/6/10 09:23
+ * @Created by Gepeng18
+ */
+@Configuration
+public class OpenaiChatClientConfigs {
+
+ /**
+ * 注入ChatClient
+ *
+ * @param chatModel
+ * @return
+ */
+ @Bean
+ public ChatClient chatClient(OpenAiChatModel chatModel) {
+ return ChatClient.builder(chatModel)
+ .build();
+ }
+}
\ No newline at end of file
diff --git a/spring-ai-agent/spring-ai-agent-orchestrator/src/main/java/com/glmapper/ai/workflow/workflow/OrchestratorWorkersWorkflow.java b/spring-ai-agent/spring-ai-agent-orchestrator/src/main/java/com/glmapper/ai/workflow/workflow/OrchestratorWorkersWorkflow.java
new file mode 100644
index 0000000..91a86db
--- /dev/null
+++ b/spring-ai-agent/spring-ai-agent-orchestrator/src/main/java/com/glmapper/ai/workflow/workflow/OrchestratorWorkersWorkflow.java
@@ -0,0 +1,110 @@
+package com.glmapper.ai.workflow.workflow;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.glmapper.ai.workflow.workflow.model.WorkflowResponse;
+import org.springframework.ai.chat.client.ChatClient;
+import org.springframework.ai.chat.messages.SystemMessage;
+import org.springframework.ai.chat.messages.UserMessage;
+import org.springframework.ai.chat.prompt.Prompt;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+import java.util.stream.Collectors;
+
+/**
+ * @Classname OrchestratorWorkersWorkflow
+ * @Description Orchestrator 用大模型拆解任务,Worker 并行处理,合并结果
+ * @Date 2025/6/12 20:19
+ * @Created by glmapper
+ */
+
+@Component
+public class OrchestratorWorkersWorkflow {
+
+ @Autowired
+ private ChatClient chatClient;
+
+ private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
+
+ public WorkflowResponse process(String taskDescription) {
+ try {
+ // 1. 用大模型拆解任务
+ LlmSubtaskResult subtaskResult = callLlmForSubtasks(taskDescription);
+ List subtasks = subtaskResult.subtasks;
+ String analysis = subtaskResult.analysis;
+ if (subtasks == null || subtasks.isEmpty()) {
+ return WorkflowResponse.builder()
+ .success(false)
+ .errorMessage("大模型未能拆解出子任务")
+ .analysis(analysis)
+ .subtasks(subtasks)
+ .build();
+ }
+
+ // 2. Workers process subtasks in parallel
+ List workerResponses = subtasks.stream()
+ .map(subtask -> CompletableFuture.supplyAsync(() -> workerProcess(subtask)))
+ .collect(Collectors.toList())
+ .stream()
+ .map(CompletableFuture::join)
+ .collect(Collectors.toList());
+
+ // 3. Results are combined into final response
+ String combined = String.join("\n", workerResponses);
+ return WorkflowResponse.builder()
+ .content(combined)
+ .success(true)
+ .analysis(analysis)
+ .subtasks(subtasks)
+ .workerResponses(workerResponses)
+ .build();
+ } catch (Exception e) {
+ return WorkflowResponse.builder()
+ .success(false)
+ .errorMessage("Orchestrator/Worker 执行失败: " + e.getMessage())
+ .build();
+ }
+ }
+
+ // 用大模型拆解任务,返回原始分析和子任务列表
+ private LlmSubtaskResult callLlmForSubtasks(String taskDescription) throws Exception {
+ List messages = List.of(new SystemMessage("你是一个任务拆解专家。请将用户输入的复杂任务描述拆解为若干可以独立执行的子任务,输出格式为 JSON 数组,每个元素为一个子任务字符串。"), new UserMessage(taskDescription));
+ Prompt prompt = new Prompt(messages);
+ String modelResult = chatClient.prompt(prompt).call().content();
+ // 解析为 List
+ List subtasks;
+ try {
+ subtasks = OBJECT_MAPPER.readValue(modelResult, new TypeReference>() {
+ });
+ } catch (Exception e) {
+ // 容错:如果模型返回不是严格 JSON 数组,尝试简单分割
+ subtasks = Arrays.stream(modelResult.split("[。,.,\n]"))
+ .map(String::trim)
+ .filter(s -> !s.isEmpty())
+ .collect(Collectors.toList());
+ }
+ return new LlmSubtaskResult(modelResult, subtasks);
+ }
+
+ // 内部类:封装大模型分析结果
+ private record LlmSubtaskResult(String analysis, List subtasks) {
+ }
+
+ private String workerProcess(String subtask) {
+ try {
+ // 你可以根据业务自定义 system prompt
+ String systemPrompt = "你是一个高效的AI助手,请认真完成以下子任务:";
+ List messages = List.of(new SystemMessage(systemPrompt), new UserMessage(subtask));
+ Prompt prompt = new Prompt(messages);
+ // 直接用 chatClient 让大模型"执行"子任务
+ return chatClient.prompt(prompt).call().content();
+ } catch (Exception e) {
+ // 失败时返回错误信息,便于排查
+ return "[Worker Error] " + e.getMessage();
+ }
+ }
+}
diff --git a/spring-ai-agent/spring-ai-agent-orchestrator/src/main/java/com/glmapper/ai/workflow/workflow/model/WorkflowRequest.java b/spring-ai-agent/spring-ai-agent-orchestrator/src/main/java/com/glmapper/ai/workflow/workflow/model/WorkflowRequest.java
new file mode 100644
index 0000000..1fe2e58
--- /dev/null
+++ b/spring-ai-agent/spring-ai-agent-orchestrator/src/main/java/com/glmapper/ai/workflow/workflow/model/WorkflowRequest.java
@@ -0,0 +1,22 @@
+package com.glmapper.ai.workflow.workflow.model;
+
+import lombok.Builder;
+import lombok.Data;
+
+/**
+ * @Classname WorkflowRequest
+ * @Description 用户请求
+ *
+ * @Date 2025/6/10 11:23
+ * @Created by Gepeng18
+ */
+@Data
+@Builder
+public class WorkflowRequest {
+
+ /**
+ * 请求内容
+ */
+ private String question;
+
+}
\ No newline at end of file
diff --git a/spring-ai-agent/spring-ai-agent-orchestrator/src/main/java/com/glmapper/ai/workflow/workflow/model/WorkflowResponse.java b/spring-ai-agent/spring-ai-agent-orchestrator/src/main/java/com/glmapper/ai/workflow/workflow/model/WorkflowResponse.java
new file mode 100644
index 0000000..9804132
--- /dev/null
+++ b/spring-ai-agent/spring-ai-agent-orchestrator/src/main/java/com/glmapper/ai/workflow/workflow/model/WorkflowResponse.java
@@ -0,0 +1,47 @@
+package com.glmapper.ai.workflow.workflow.model;
+
+import lombok.Builder;
+import lombok.Data;
+
+/**
+ * @Classname WorkflowResponse
+ * @Description 工作流响应
+ *
+ * @Date 2025/6/10 14:32
+ * @Created by Gepeng18
+ */
+@Data
+@Builder
+public class WorkflowResponse {
+
+ /**
+ * 大模型对任务的分析/拆解原始输出
+ */
+ private String analysis;
+
+ /**
+ * 拆解出的所有子任务
+ */
+ private java.util.List subtasks;
+
+ /**
+ * 每个 worker 的输出结果
+ */
+ private java.util.List workerResponses;
+
+ /**
+ * 最终合成的内容(如汇总、总结、最终答案等)
+ */
+ private String content;
+
+ /**
+ * 总体是否成功
+ */
+ private boolean success;
+
+ /**
+ * 错误信息(如有)
+ */
+ private String errorMessage;
+
+}
\ No newline at end of file
diff --git a/spring-ai-agent/spring-ai-agent-orchestrator/src/main/resources/application.yml b/spring-ai-agent/spring-ai-agent-orchestrator/src/main/resources/application.yml
new file mode 100644
index 0000000..b7b491c
--- /dev/null
+++ b/spring-ai-agent/spring-ai-agent-orchestrator/src/main/resources/application.yml
@@ -0,0 +1,14 @@
+server:
+ port: 8080
+spring:
+ application:
+ name: spring-ai-workflow-orchestrator
+ ai:
+ openai:
+ api-key: ${OPENAI_API_KEY}
+ base-url: https://api.deepseek.com
+ chat:
+ options:
+ model: deepseek-chat
+ temperature: 0.7
+ completions-path: /v1/chat/completions
\ No newline at end of file
diff --git a/spring-ai-agent/spring-ai-agent-orchestrator/src/test/java/com/glmapper/ai/workflow/OrchestratorWorkersWorkflowTest.java b/spring-ai-agent/spring-ai-agent-orchestrator/src/test/java/com/glmapper/ai/workflow/OrchestratorWorkersWorkflowTest.java
new file mode 100644
index 0000000..0c2404a
--- /dev/null
+++ b/spring-ai-agent/spring-ai-agent-orchestrator/src/test/java/com/glmapper/ai/workflow/OrchestratorWorkersWorkflowTest.java
@@ -0,0 +1,25 @@
+package com.glmapper.ai.workflow;
+
+import com.glmapper.ai.workflow.workflow.OrchestratorWorkersWorkflow;
+import com.glmapper.ai.workflow.workflow.model.WorkflowResponse;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * Unit test for simple App.
+ */
+@SpringBootTest(classes = OrchestratorWorkersWorkflowApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+public class OrchestratorWorkersWorkflowTest {
+
+ @Autowired
+ private OrchestratorWorkersWorkflow orchestratorWorkersWorkflow;
+
+ @Test
+ public void test() {
+ WorkflowResponse response = orchestratorWorkersWorkflow.process("Generate both technical and user-friendly documentation for a REST API endpoint");
+ // 执行结果见 resources/test_result.md
+ System.out.println("Analysis: " + response.getAnalysis());
+ System.out.println("Worker Outputs: " + response.getWorkerResponses());
+ }
+}
diff --git a/spring-ai-agent/spring-ai-agent-orchestrator/src/test/resources/test_result.md b/spring-ai-agent/spring-ai-agent-orchestrator/src/test/resources/test_result.md
new file mode 100644
index 0000000..905a9d2
--- /dev/null
+++ b/spring-ai-agent/spring-ai-agent-orchestrator/src/test/resources/test_result.md
@@ -0,0 +1,1075 @@
+Analysis: ```json
+[
+"Identify the REST API endpoint to be documented",
+"Gather technical specifications of the endpoint (e.g., HTTP method, URL, request/response formats)",
+"Document the endpoint's purpose and functionality",
+"List all required and optional parameters with their data types and descriptions",
+"Provide example request payloads for different scenarios",
+"Document all possible response codes and their meanings",
+"Include example response payloads for different scenarios",
+"Write clear, step-by-step usage instructions for developers",
+"Create user-friendly explanations of technical concepts for non-technical users",
+"Add any necessary warnings or best practices for using the endpoint",
+"Include troubleshooting tips for common issues",
+"Review and validate the documentation for accuracy and completeness",
+"Format the documentation for readability and consistency"
+]
+```
+Worker Outputs: [```json
+{
+ "response": "I am ready to assist you with any tasks or questions you have. Please provide the details of the sub-tasks you'd like me to complete, and I will handle them efficiently."
+}
+```, 我是一个高效的AI助手,很高兴为您服务!我会认真完成您分配的任何任务。请告诉我您需要帮助的具体内容,我会以最专业、最有效的方式为您提供支持。
+
+无论您需要:
+- 信息查询
+- 问题解答
+- 文本处理
+- 数据分析
+- 创意生成
+- 或其他任何任务
+
+我都会以清晰、准确、高效的方式完成。请随时告诉我您的具体需求,让我们开始工作吧!, To identify the REST API endpoint that needs to be documented, I would need the following details:
+
+1. **Base URL**: The root path of the API (e.g., `https://api.example.com/v1`)
+2. **Endpoint Path**: The specific resource path (e.g., `/users`, `/orders/{id}`)
+3. **HTTP Method**: The type of request (`GET`, `POST`, `PUT`, `DELETE`, etc.)
+4. **Parameters**: Any query, path, or request body parameters
+5. **Purpose**: A brief description of what the endpoint does
+
+### Example Format:
+```plaintext
+Endpoint: GET /api/v1/users/{id}
+Description: Retrieves user details by ID.
+Parameters:
+ - Path: `id` (required, integer)
+ - Query: `fields` (optional, string)
+```
+
+If you provide the API details, I can help structure the documentation effectively. Let me know how you'd like to proceed!, It seems like your request got cut off. Could you please provide the complete details of what you're looking for regarding the endpoint's technical specifications?
+
+For example, are you looking for:
+1. API endpoint specifications (URL, methods, parameters, etc.)?
+2. Hardware specifications of a device endpoint?
+3. Network endpoint details (IP, ports, protocols)?
+4. Something else entirely?
+
+Please provide more context so I can give you the most accurate and helpful response., 你好!我是一个高效的AI助手,随时准备帮助你完成各种任务。无论是解答问题、提供建议、处理文本,还是协助规划,我都会尽力提供准确、快速的支持。请告诉我你需要什么帮助,我会立即开始工作!, HTTP (Hypertext Transfer Protocol) methods, also known as HTTP verbs, indicate the desired action to be performed on a resource. Here are the most common HTTP methods:
+
+### **Core Methods**
+1. **GET**
+ - Requests data from a specified resource (should only retrieve data, no side effects).
+ - Example: Fetching a webpage or API data.
+
+2. **POST**
+ - Submits data to be processed to a specified resource (often creates new records).
+ - Example: Submitting a form or uploading a file.
+
+3. **PUT**
+ - Updates an existing resource or creates it if it doesn’t exist (idempotent).
+ - Example: Updating a user’s profile.
+
+4. **DELETE**
+ - Removes a specified resource.
+ - Example: Deleting a blog post.
+
+5. **PATCH**
+ - Partially updates a resource (only sends changes, not the full entity).
+ - Example: Updating a single field in a user profile.
+
+### **Additional Methods**
+6. **HEAD**
+ - Similar to GET but returns only headers (no body), useful for checking resource existence.
+
+7. **OPTIONS**
+ - Describes communication options for the target resource (used in CORS).
+
+8. **CONNECT**
+ - Establishes a tunnel to the server (used for HTTPS proxies).
+
+9. **TRACE**
+ - Echoes back the received request (used for debugging).
+
+### **Idempotency & Safety**
+- **Safe Methods** (GET, HEAD, OPTIONS) – Do not modify the server state.
+- **Idempotent Methods** (GET, PUT, DELETE, HEAD, OPTIONS, TRACE) – Repeated requests have the same effect as a single request.
+
+Would you like details on REST API best practices or specific use cases?, 您似乎只输入了“URL”这个词。如果您需要帮助解析、缩短或处理某个URL,请提供具体的网址或详细说明您的需求。例如:
+
+1. **解析URL**:我可以帮您分解网址的各个部分(协议、域名、路径等)。
+2. **缩短URL**:提供长链接,我可以生成短链接建议。
+3. **检查安全性**:需要验证某个URL是否安全?请提供具体链接。
+4. **其他操作**:如编码/解码、参数提取等。
+
+请补充信息,我会全力协助! 🔍, Here are common request/response formats used in AI interactions, APIs, and web services:
+
+### 1. **Plain Text**
+- **Request:** Simple text input
+- **Response:** Plain text output
+- **Example:**
+ *User:* "What's the weather today?"
+ *AI:* "Sunny, 75°F"
+
+### 2. **JSON (API Standard)**
+- **Request:** Structured JSON with parameters
+ ```json
+ {
+ "query": "weather in Tokyo",
+ "user_id": "12345",
+ "language": "en"
+ }
+ ```
+- **Response:**
+ ```json
+ {
+ "response": "Partly cloudy, 22°C",
+ "source": "WeatherAPI",
+ "timestamp": "2023-11-15T09:30:00Z"
+ }
+ ```
+
+### 3. **XML (Legacy Systems)**
+- **Request:**
+ ```xml
+
+ Define AI
+ short
+
+ ```
+- **Response:**
+ ```xml
+
+ Artificial Intelligence
+ Machine simulation of human intelligence.
+
+ ```
+
+### 4. **Chat Markdown (LLMs like ChatGPT)**
+- **Request:**
+ ```markdown
+ Summarize this in 3 bullet points:
+ - AI assistants can process natural language.
+ - They leverage machine learning models.
+ - Responses may include formatted text.
+ ```
+- **Response:**
+ ```markdown
+ - Process natural language input
+ - Use ML models (e.g., transformers)
+ - Support formatted outputs (tables, code)
+ ```
+
+### 5. **GraphQL (Flexible API Queries)**
+- **Request:**
+ ```graphql
+ query {
+ book(id: "101") {
+ title
+ author
+ pages
+ }
+ }
+ ```
+- **Response:**
+ ```json
+ {
+ "data": {
+ "book": {
+ "title": "AI Fundamentals",
+ "author": "Jane Doe",
+ "pages": 300
+ }
+ }
+ }
+ ```
+
+### 6. **gRPC (Binary Protocol)**
+- **Protocol Buffers Definition:**
+ ```proto
+ message Request {
+ string question = 1;
+ }
+ message Response {
+ string answer = 1;
+ }
+ ```
+- **Binary payloads** (not human-readable)
+
+### Key Considerations:
+- **APIs:** JSON/GraphQL dominate modern systems
+- **AI Assistants:** Often use markdown with embedded JSON/HTML for rich responses
+- **Legacy:** XML still used in banking/healthcare
+- **Performance:** gRPC for microservices, JSON for web
+
+Need a specific format explained further?, Certainly! Below is a structured documentation template for describing an endpoint's purpose and functionality. Replace the placeholders (e.g., ``) with the relevant details.
+
+---
+
+### **Endpoint Documentation**
+**Endpoint**: `` ``
+**Version**: `` (e.g., `v1`)
+**Authentication**: `` (e.g., `Bearer Token`, `API Key`, `None`)
+
+---
+
+#### **Purpose**
+
+"This endpoint allows authenticated users to `` (e.g., retrieve a list of resources, submit data, delete a record)."
+
+---
+
+#### **Functionality**
+
+1. **Input Parameters**:
+ - **Query Parameters**: (e.g., `?filter=active&limit=10`)
+ - **Path Parameters**: (e.g., `/users/{id}`)
+ - **Request Body**: (e.g., JSON payload for `POST/PUT` requests)
+ - **Headers**: (e.g., `Authorization: Bearer `, `Content-Type: application/json`)
+
+2. **Behavior**:
+ - Success scenarios (e.g., "Returns `200 OK` with a list of items").
+ - Error scenarios (e.g., "Returns `404 Not Found` if the resource doesn’t exist").
+
+3. **Response Format**:
+ - Example success response (JSON/XML):
+ ```json
+ {
+ "status": "success",
+ "data": [ /* array of items */ ]
+ }
+ ```
+ - Example error response:
+ ```json
+ {
+ "status": "error",
+ "code": 404,
+ "message": "Resource not found."
+ }
+ ```
+
+---
+
+#### **Examples**
+**Request**:
+```http
+GET /api/v1/users?role=admin HTTP/1.1
+Authorization: Bearer
+```
+
+**Response**:
+```json
+{
+ "data": [
+ { "id": 1, "name": "Admin User", "role": "admin" }
+ ]
+}
+```
+
+---
+
+#### **Notes**
+-
+-
+
+---
+
+Let me know if you'd like to refine this for a specific endpoint (e.g., REST, GraphQL, RPC)!, Here is a structured template for listing required and optional parameters with their data types and descriptions:
+
+---
+
+### **Parameters**
+
+#### **Required Parameters**
+*(Must be provided for the function/API to work)*
+
+| Parameter | Data Type | Description |
+|-------------|-----------|-----------------------------------------------------------------------------|
+| `param1` | `string` | Explanation of what this parameter does (e.g., "Username for authentication"). |
+| `param2` | `integer` | Description (e.g., "Age of the user, must be a positive number"). |
+
+#### **Optional Parameters**
+*(Can be omitted; default values may apply)*
+
+| Parameter | Data Type | Default Value | Description |
+|-------------|-------------|---------------|-----------------------------------------------------------------------------|
+| `optParam1` | `boolean` | `true` | Description (e.g., "If enabled, sends notifications"). |
+| `optParam2` | `string[]` | `[]` | Description (e.g., "List of tags for filtering results"). |
+
+---
+
+### **Notes**
+- Replace placeholders (`param1`, `optParam1`, etc.) with actual parameter names.
+- Adjust **data types** (e.g., `number`, `object`, `array`) as needed.
+- Specify **constraints** (e.g., "Must be a valid email") if applicable.
+- Mention **default values** for optional parameters.
+
+Would you like this tailored for a specific API, function, or programming language?, Here are example request payloads for different scenarios across common API use cases:
+
+### 1. User Authentication (Login)
+```json
+{
+ "username": "johndoe",
+ "password": "securePassword123!",
+ "remember_me": true
+}
+```
+
+### 2. E-commerce Product Creation
+```json
+{
+ "name": "Wireless Bluetooth Headphones",
+ "description": "Noise-cancelling with 30hr battery life",
+ "price": 129.99,
+ "stock_quantity": 150,
+ "categories": ["electronics", "audio"],
+ "sku": "WBH-2023-XL"
+}
+```
+
+### 3. Weather Data Query
+```json
+{
+ "location": {
+ "city": "Seattle",
+ "country": "US",
+ "coordinates": {
+ "lat": 47.6062,
+ "lon": -122.3321
+ }
+ },
+ "date_range": {
+ "start": "2023-11-15",
+ "end": "2023-11-20"
+ },
+ "units": "metric"
+}
+```
+
+### 4. Bank Transaction
+```json
+{
+ "transaction_id": "TX987654321",
+ "from_account": "ACC123456",
+ "to_account": "ACC789012",
+ "amount": 2500.00,
+ "currency": "USD",
+ "description": "Invoice #INV-2023-456",
+ "metadata": {
+ "invoice_id": "INV-2023-456",
+ "client_id": "CLT-789"
+ }
+}
+```
+
+### 5. IoT Device Telemetry
+```json
+{
+ "device_id": "thermo-7X9B2",
+ "timestamp": "2023-11-15T08:23:45Z",
+ "readings": {
+ "temperature": 23.4,
+ "humidity": 45,
+ "power_consumption": 2.34,
+ "battery_level": 87
+ },
+ "status": "normal"
+}
+```
+
+### 6. Calendar Event Creation
+```json
+{
+ "title": "Team Sync Meeting",
+ "description": "Weekly project status update",
+ "start_time": "2023-11-20T14:00:00-08:00",
+ "end_time": "2023-11-20T15:00:00-08:00",
+ "attendees": [
+ {"email": "alice@example.com", "rsvp": true},
+ {"email": "bob@example.com", "rsvp": null}
+ ],
+ "reminders": [
+ {"method": "email", "minutes": 30},
+ {"method": "popup", "minutes": 10}
+ ]
+}
+```
+
+### 7. AI Image Generation Request
+```json
+{
+ "prompt": "A futuristic cityscape at sunset with flying cars",
+ "style": "cyberpunk",
+ "resolution": "1024x768",
+ "num_images": 3,
+ "advanced": {
+ "seed": 42,
+ "steps": 50,
+ "cfg_scale": 7.5
+ }
+}
+```
+
+### 8. Support Ticket Submission
+```json
+{
+ "subject": "Login issues after recent update",
+ "description": "Unable to login since v2.3 update - getting 403 error",
+ "user": {
+ "id": "USR-7890",
+ "email": "user@example.com",
+ "device_info": "iPhone 13, iOS 16.4"
+ },
+ "attachments": ["error_screenshot.jpg"],
+ "priority": "high",
+ "category": "authentication"
+}
+```
+
+Each payload demonstrates:
+- Proper structure for the domain
+- Common required fields
+- Example data formats
+- Optional parameters where relevant
+
+Would you like me to provide payload examples for any specific scenario or industry?, Here is a comprehensive list of common HTTP response status codes, grouped by their categories, along with their meanings:
+
+---
+
+### **1xx: Informational Responses**
+*(Request received, continuing process)*
+- **100 Continue**
+ - The server acknowledges the initial part of the request; the client should proceed.
+- **101 Switching Protocols**
+ - The server agrees to switch protocols (e.g., upgrading to WebSocket).
+- **102 Processing** (WebDAV)
+ - The server is processing the request but has not yet completed it.
+- **103 Early Hints**
+ - Used to return some response headers before the final response.
+
+---
+
+### **2xx: Success Responses**
+*(Request successfully received, understood, and processed)*
+- **200 OK**
+ - The request succeeded.
+- **201 Created**
+ - A new resource was successfully created (e.g., after a POST request).
+- **202 Accepted**
+ - The request was accepted but not yet processed.
+- **203 Non-Authoritative Information**
+ - The response is a modified version of the origin server’s response.
+- **204 No Content**
+ - The request succeeded, but there is no content to return.
+- **205 Reset Content**
+ - The client should reset the document view (e.g., clear a form).
+- **206 Partial Content**
+ - The server is delivering only part of the resource (used for range requests).
+- **207 Multi-Status** (WebDAV)
+ - Contains multiple status codes for a batch request.
+- **208 Already Reported** (WebDAV)
+ - Prevents redundant listing of resources.
+- **226 IM Used**
+ - The server has fulfilled a request for the resource with instance manipulation.
+
+---
+
+### **3xx: Redirection Responses**
+*(Further action is needed to complete the request)*
+- **300 Multiple Choices**
+ - The request has multiple possible responses (user/agent should choose one).
+- **301 Moved Permanently**
+ - The resource has been permanently moved to a new URL.
+- **302 Found (Previously "Moved Temporarily")**
+ - The resource is temporarily moved to a different URL.
+- **303 See Other**
+ - The response can be found under a different URL (used for POST-to-GET redirects).
+- **304 Not Modified**
+ - Indicates caching; the resource has not been modified since the last request.
+- **305 Use Proxy** (Deprecated)
+ - The request must be accessed through a proxy.
+- **307 Temporary Redirect**
+ - The resource is temporarily moved, but the method and body must not change.
+- **308 Permanent Redirect**
+ - The resource is permanently moved, and the method must not change.
+
+---
+
+### **4xx: Client Error Responses**
+*(The request contains errors or cannot be fulfilled)*
+- **400 Bad Request**
+ - The server cannot process the request due to client-side errors (e.g., malformed syntax).
+- **401 Unauthorized**
+ - Authentication is required, and the client has not provided valid credentials.
+- **402 Payment Required** (Rarely used)
+ - Reserved for future use (originally intended for digital payments).
+- **403 Forbidden**
+ - The server refuses to authorize the request (even if authenticated).
+- **404 Not Found**
+ - The requested resource does not exist.
+- **405 Method Not Allowed**
+ - The HTTP method is not supported for the resource.
+- **406 Not Acceptable**
+ - The server cannot produce a response matching the client’s `Accept` headers.
+- **407 Proxy Authentication Required**
+ - The client must authenticate with the proxy first.
+- **408 Request Timeout**
+ - The server timed out waiting for the request.
+- **409 Conflict**
+ - The request conflicts with the current state of the server (e.g., edit collisions).
+- **410 Gone**
+ - The resource is permanently deleted (unlike 404, this is intentional).
+- **411 Length Required**
+ - The server requires a `Content-Length` header.
+- **412 Precondition Failed**
+ - A client-side condition (e.g., `If-Match`) failed.
+- **413 Payload Too Large**
+ - The request exceeds the server’s size limits.
+- **414 URI Too Long**
+ - The URL is longer than the server can process.
+- **415 Unsupported Media Type**
+ - The payload format is unsupported by the server.
+- **416 Range Not Satisfiable**
+ - The requested range (e.g., bytes) is invalid.
+- **417 Expectation Failed**
+ - The server cannot meet the `Expect` header’s requirements.
+- **418 I’m a Teapot** (RFC 2324, April Fools’ joke)
+ - The server refuses to brew coffee because it is a teapot.
+- **421 Misdirected Request**
+ - The request was sent to a server unable to respond (e.g., wrong TLS config).
+- **422 Unprocessable Entity** (WebDAV)
+ - The request was well-formed but semantically incorrect (e.g., validation errors).
+- **423 Locked** (WebDAV)
+ - The resource is locked and cannot be modified.
+- **424 Failed Dependency** (WebDAV)
+ - The request failed because it depended on another failed request.
+- **425 Too Early**
+ - The server is unwilling to process a request that might be replayed.
+- **426 Upgrade Required**
+ - The client must switch to a different protocol (e.g., TLS).
+- **428 Precondition Required**
+ - The server requires conditional requests (e.g., `If-Match`).
+- **429 Too Many Requests**
+ - The client has exceeded rate limits.
+- **431 Request Header Fields Too Large**
+ - The headers exceed the server’s size limit.
+- **451 Unavailable For Legal Reasons**
+ - The resource is blocked due to legal restrictions.
+
+---
+
+### **5xx: Server Error Responses**
+*(The server failed to fulfill a valid request)*
+- **500 Internal Server Error**
+ - A generic server-side error occurred.
+- **501 Not Implemented**
+ - The server lacks the functionality to fulfill the request.
+- **502 Bad Gateway**
+ - The server acting as a gateway received an invalid response.
+- **503 Service Unavailable**
+ - The server is temporarily unable to handle requests (e.g., overloaded).
+- **504 Gateway Timeout**
+ - The gateway server did not receive a timely response.
+- **505 HTTP Version Not Supported**
+ - The server does not support the HTTP version used in the request.
+- **506 Variant Also Negotiates**
+ - The server has a configuration error in content negotiation.
+- **507 Insufficient Storage** (WebDAV)
+ - The server cannot store the representation needed to complete the request.
+- **508 Loop Detected** (WebDAV)
+ - The server detected an infinite loop while processing the request.
+- **510 Not Extended**
+ - Further extensions to the request are required.
+- **511 Network Authentication Required**
+ - The client must authenticate to access the network (e.g., captive portals).
+
+---
+
+### **Unofficial / Non-Standard Codes**
+- **418 I’m a Teapot** (Kept for historical reasons)
+- **420 Enhance Your Calm** (Twitter API rate-limiting)
+- **450 Blocked by Windows Parental Controls** (Microsoft)
+- **509 Bandwidth Limit Exceeded** (Apache/cPanel)
+
+---
+
+This list covers the most widely recognized HTTP status codes. Let me know if you'd like further details on any specific code!, Certainly! Below are example response payloads for different scenarios across various contexts (e.g., REST APIs, webhooks, or event-driven systems). Each example includes a brief description of the scenario and the corresponding payload in JSON format.
+
+---
+
+### **1. Successful API Response (e.g., Fetching User Data)**
+**Scenario**: A GET request to `/users/123` returns the details of user with ID `123`.
+**Response**:
+```json
+{
+ "status": "success",
+ "data": {
+ "id": 123,
+ "name": "John Doe",
+ "email": "john.doe@example.com",
+ "role": "admin",
+ "created_at": "2023-01-15T10:30:00Z"
+ }
+}
+```
+
+---
+
+### **2. Error Response (e.g., Invalid Request)**
+**Scenario**: A POST request to `/users` fails due to missing required fields.
+**Response**:
+```json
+{
+ "status": "error",
+ "code": 400,
+ "message": "Validation failed",
+ "errors": [
+ {
+ "field": "email",
+ "message": "Email is required"
+ },
+ {
+ "field": "name",
+ "message": "Name must be at least 3 characters"
+ }
+ ]
+}
+```
+
+---
+
+### **3. Paginated List Response**
+**Scenario**: A GET request to `/products` returns a paginated list of products.
+**Response**:
+```json
+{
+ "status": "success",
+ "data": [
+ {
+ "id": 1,
+ "name": "Laptop",
+ "price": 999.99
+ },
+ {
+ "id": 2,
+ "name": "Smartphone",
+ "price": 699.99
+ }
+ ],
+ "pagination": {
+ "total_items": 42,
+ "current_page": 1,
+ "per_page": 10,
+ "total_pages": 5
+ }
+}
+```
+
+---
+
+### **4. Webhook Notification (e.g., Payment Processed)**
+**Scenario**: A payment service sends a webhook notification after a successful transaction.
+**Payload**:
+```json
+{
+ "event_id": "evt_123456789",
+ "type": "payment.succeeded",
+ "data": {
+ "payment_id": "pay_987654321",
+ "amount": 2500,
+ "currency": "USD",
+ "customer_id": "cus_abc123",
+ "timestamp": "2023-05-20T14:22:10Z"
+ }
+}
+```
+
+---
+
+### **5. Empty Response (e.g., No Results Found)**
+**Scenario**: A search query for `/orders?status=cancelled` returns no matching orders.
+**Response**:
+```json
+{
+ "status": "success",
+ "data": [],
+ "message": "No orders found with the specified criteria."
+}
+```
+
+---
+
+### **6. Authentication Token Response**
+**Scenario**: A successful login request to `/auth/login` returns a JWT token.
+**Response**:
+```json
+{
+ "status": "success",
+ "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
+ "expires_in": 3600,
+ "user": {
+ "id": 123,
+ "name": "John Doe"
+ }
+}
+```
+
+---
+
+### **7. Event-Driven System (e.g., Order Shipped)**
+**Scenario**: A message queue publishes an event when an order is shipped.
+**Payload**:
+```json
+{
+ "event": "order.shipped",
+ "event_id": "evt_789012345",
+ "timestamp": "2023-05-20T09:15:33Z",
+ "payload": {
+ "order_id": "ord_456789",
+ "customer_id": "cust_123",
+ "tracking_number": "UPS123456789",
+ "shipping_address": "123 Main St, City, Country"
+ }
+}
+```
+
+---
+
+### Key Takeaways:
+- Use consistent structures (e.g., `status`, `data`, `errors`).
+- Include metadata (e.g., pagination, timestamps) where relevant.
+- For errors, provide actionable details (e.g., field-specific validation errors).
+- Use standard HTTP status codes (e.g., `200`, `400`, `404`).
+
+Let me know if you'd like examples for other scenarios!, Here’s a clear and concise response to your request:
+
+---
+**"Write clear"**
+
+To write clearly:
+1. **Be concise** – Use simple words and avoid unnecessary jargon.
+2. **Structure logically** – Organize ideas with headings, bullet points, or short paragraphs.
+3. **Focus on the reader** – Tailor language to their level of understanding.
+4. **Edit ruthlessly** – Remove redundancies and tighten sentences.
+5. **Use active voice** – E.g., "The team completed the project" (not "The project was completed").
+
+Example of clear writing:
+> *"Submit the report by Friday. Include budget details and risks. Contact me if you need help."*
+
+Let me know if you'd like help with a specific text!
+
+---
+Would you like me to refine or expand on any part?, Here’s a clear, step-by-step guide for developers to effectively use your AI assistant:
+
+---
+
+### **Step-by-Step Usage Instructions for Developers**
+
+#### **1. Access the AI Assistant**
+- **Via API**:
+ - Obtain your API key (if authentication is required).
+ - Use the endpoint: `POST https://api.example.com/v1/assistant`
+ - Include headers:
+ ```json
+ {
+ "Authorization": "Bearer YOUR_API_KEY",
+ "Content-Type": "application/json"
+ }
+ ```
+
+- **Via SDK (if available)**:
+ ```python
+ from ai_assistant import Assistant
+ assistant = Assistant(api_key="YOUR_API_KEY")
+ ```
+
+#### **2. Define Your Task**
+Structure your request with:
+- **Input**: Clearly describe the task (e.g., "Debug this Python code" or "Generate a SQL query").
+- **Context**: Provide relevant code snippets, error logs, or constraints.
+
+**Example API Request**:
+```json
+{
+ "task": "Optimize this Python function for speed",
+ "context": "def calculate(...): ..."
+}
+```
+
+#### **3. Submit the Request**
+- **API**:
+ ```bash
+ curl -X POST https://api.example.com/v1/assistant \
+ -H "Authorization: Bearer YOUR_API_KEY" \
+ -d '{"task":"...", "context":"..."}'
+ ```
+- **SDK**:
+ ```python
+ response = assistant.ask(task="...", context="...")
+ ```
+
+#### **4. Process the Response**
+- The AI will return structured output (e.g., code, explanations, or steps).
+- **Example Response**:
+ ```json
+ {
+ "response": "Here’s the optimized function...",
+ "suggestions": ["Use list comprehensions", "Avoid nested loops"]
+ }
+ ```
+
+#### **5. Iterate (If Needed)**
+- Refine your query based on initial results:
+ - Add more context (e.g., "The function must handle edge cases like X").
+ - Ask follow-ups (e.g., "Explain why you chose this approach").
+
+#### **6. Integrate into Workflow**
+- **Automation**: Schedule tasks via cron jobs/webhooks.
+- **Error Handling**: Check for `status_code` or `error` fields in responses.
+
+#### **7. Best Practices**
+- **Be Specific**: Narrow tasks yield better results (e.g., "Fix this null pointer exception" vs. "Debug my app").
+- **Secure Data**: Avoid sharing sensitive info; use placeholders if needed.
+- **Rate Limits**: Check API docs for call limits.
+
+#### **8. Troubleshooting**
+- **Common Issues**:
+ - `401 Unauthorized`: Verify your API key.
+ - `400 Bad Request`: Check input JSON formatting.
+ - Timeouts: Reduce payload size or retry.
+
+---
+
+**Example Use Case**:
+```python
+# Ask the AI to generate a React component
+response = assistant.ask(
+ task="Create a React button component with hover effects",
+ context="Use Tailwind CSS for styling."
+)
+print(response["code"])
+```
+
+Let me know if you’d like details for a specific language/platform!, Certainly! Here’s a structured approach to creating user-friendly explanations of technical concepts for non-technical audiences:
+
+### **1. Simplify the Language**
+- **Avoid jargon**: Replace technical terms with everyday words.
+ - *Example*: Instead of "The API fetches data," say, "The system retrieves information from another service."
+- **Use analogies**: Compare the concept to something familiar.
+ - *Example*: "A **firewall** is like a security guard that checks who can enter a building."
+
+### **2. Focus on the "Why" Before the "How"**
+- Explain the **purpose** first, not the mechanics.
+ - *Example*: "**Encryption** scrambles your messages so only the intended person can read them—like sending a locked box instead of a postcard."
+
+### **3. Break It Down Step-by-Step**
+- Use short, clear sentences.
+ - *Example*:
+ 1. You type a website name (e.g., "google.com").
+ 2. Your browser finds the correct address (like GPS for the internet).
+ 3. The website loads on your screen.
+
+### **4. Visual Aids (When Possible)**
+- Simple diagrams, icons, or metaphors help.
+ - *Example*: "Cloud storage is like a virtual filing cabinet—you store files online instead of on your computer."
+
+### **5. Relate to Real-Life Scenarios**
+- Tie the concept to daily experiences.
+ - *Example*: "A **VPN** is like a tunnel that keeps your internet activity private, even on public Wi-Fi."
+
+### **6. Anticipate Questions**
+- Address common concerns naturally.
+ - *Example*: "Yes, **two-factor authentication** adds an extra step, but it’s like a second lock on your door—it’s worth it!"
+
+### **7. Keep It Concise**
+- Avoid overwhelming details. Stick to what’s relevant.
+
+---
+### **Example: Explaining "Machine Learning"**
+**Technical**: "Machine learning uses algorithms to parse data, learn patterns, and make predictions."
+**User-Friendly**:
+> "Machine learning helps computers learn from experience, like how a child improves at catching a ball over time. The more examples it sees (e.g., spam emails), the better it gets at spotting similar things."
+
+Would you like me to adapt a specific technical concept for you? 😊, Here are some essential warnings and best practices for using the endpoint effectively and safely:
+
+### **Warnings:**
+1. **Rate Limiting** – Avoid excessive requests to prevent being throttled or blocked. Check the API documentation for rate limits.
+2. **Data Privacy** – Do not send sensitive, personally identifiable information (PII) unless the endpoint is explicitly designed for it.
+3. **Error Handling** – Always implement proper error handling for failed requests (e.g., timeouts, invalid inputs).
+4. **Authentication** – Keep API keys and credentials secure. Never expose them in client-side code.
+5. **Deprecation Risks** – Endpoints may change or be deprecated; monitor API updates to avoid disruptions.
+
+### **Best Practices:**
+✅ **Validate Inputs** – Ensure request payloads match the expected format before sending.
+✅ **Use Retries with Backoff** – Implement exponential backoff for transient failures.
+✅ **Monitor Usage** – Track API consumption to stay within limits and optimize costs.
+✅ **Cache Responses** – Store frequent, non-changing responses to reduce unnecessary calls.
+✅ **Follow API Documentation** – Adhere to the provider’s guidelines for optimal performance.
+
+Would you like me to tailor these further for a specific use case?, Certainly! Below is a structured troubleshooting guide for common issues, which you can adapt to your specific needs (e.g., software, hardware, or general problems).
+
+---
+
+### **Troubleshooting Tips for Common Issues**
+
+#### **1. Device/Application Not Responding**
+- **Fix 1**: Force-close the app/restart the device.
+- **Fix 2**: Check for updates (OS, firmware, or app updates).
+- **Fix 3**: Clear cache/data (for apps) or free up memory/storage.
+
+#### **2. Slow Performance**
+- **Fix 1**: Close unnecessary background apps.
+- **Fix 2**: Check for malware/viruses (run a scan).
+- **Fix 3**: Upgrade hardware (RAM/SSD) if applicable.
+
+#### **3. Connection Issues (Wi-Fi/Bluetooth)**
+- **Fix 1**: Restart the router or device.
+- **Fix 2**: Forget and reconnect to the network.
+- **Fix 3**: Check for interference (distance, obstacles, other devices).
+
+#### **4. Login/Password Problems**
+- **Fix 1**: Use "Forgot Password" to reset.
+- **Fix 2**: Check caps lock/num lock.
+- **Fix 3**: Clear browser cache or try incognito mode.
+
+#### **5. Error Messages/Crashes**
+- **Fix 1**: Note the exact error code and search online.
+- **Fix 2**: Reinstall the software/driver.
+- **Fix 3**: Check system compatibility (OS version, hardware).
+
+#### **6. Peripheral Issues (Printer/Mouse/Keyboard)**
+- **Fix 1**: Reconnect/restart the device.
+- **Fix 2**: Update or reinstall drivers.
+- **Fix 3**: Test on another device to isolate the issue.
+
+#### **7. Battery Draining Quickly**
+- **Fix 1**: Reduce screen brightness/disable unused features.
+- **Fix 2**: Check for battery-hogging apps.
+- **Fix 3**: Replace the battery if old/degraded.
+
+#### **8. File Corruption/Data Loss**
+- **Fix 1**: Use file recovery software.
+- **Fix 2**: Restore from backup (if available).
+- **Fix 3**: Check storage health (for hardware issues).
+
+#### **General Tips:**
+- **Restart first**: Solves many temporary glitches.
+- **Check logs**: System/application logs often reveal root causes.
+- **Search forums**: Others may have solved the same issue.
+
+---
+
+Would you like this tailored to a specific product or scenario? Let me know, and I can refine it further!, Certainly! Below is a structured approach to reviewing and validating documentation for accuracy and completeness:
+
+### **1. Define the Scope and Objectives**
+- Identify the type of documentation (e.g., technical, user manuals, API docs, process guides).
+- Clarify the purpose (e.g., compliance, training, operational reference).
+
+### **2. Check for Completeness**
+- Verify all required sections are included (e.g., introduction, procedures, troubleshooting, references).
+- Ensure no missing steps, diagrams, or critical details.
+- Cross-check against a checklist or template (if available).
+
+### **3. Validate Accuracy**
+- **Technical Accuracy:**
+ - Confirm that instructions, code snippets, and configurations are correct.
+ - Test procedures (if applicable) to ensure they work as described.
+- **Consistency:**
+ - Ensure terminology, formatting, and style are uniform.
+ - Check for contradictions between sections.
+- **Up-to-date Information:**
+ - Verify that content aligns with the latest software version, policies, or processes.
+ - Remove outdated references or deprecated features.
+
+### **4. Review Clarity and Usability**
+- Ensure language is clear, concise, and free of jargon (unless audience-specific).
+- Check that diagrams, screenshots, or examples support understanding.
+- Assess logical flow—can a user follow the document without confusion?
+
+### **5. Compliance & Standards Alignment**
+- Confirm adherence to organizational/industry standards (e.g., ISO, GDPR, internal style guides).
+- Validate that mandatory disclaimers, version control, and approval signatures are present.
+
+### **6. Peer Review & Feedback**
+- Engage SMEs (Subject Matter Experts) to verify technical content.
+- Conduct a walkthrough with end-users to identify gaps.
+
+### **7. Final Approval & Version Control**
+- Document revisions and track changes.
+- Obtain formal approval before publishing.
+
+### **Tools to Assist:**
+- **Grammar/Clarity:** Grammarly, Hemingway Editor
+- **Version Control:** Git, SharePoint
+- **Collaboration:** Confluence, Google Docs, MS Teams
+
+### **Output:**
+- A revised document with tracked changes.
+- A validation report noting corrections, approvals, and open issues (if any).
+
+Would you like a template for the validation checklist or a specific focus area (e.g., API docs, SOPs)?, Certainly! Below is a structured and consistent documentation template that improves readability. You can customize it based on your specific needs.
+
+---
+
+# **Documentation Title**
+*Brief description or tagline (optional)*
+
+## **1. Overview**
+*A concise introduction to the purpose, scope, and key features of the project/tool.*
+
+## **2. Installation**
+### **Prerequisites**
+- List any dependencies (e.g., Python 3.8+, Node.js, etc.).
+- Required libraries or frameworks.
+
+### **Steps**
+1. Step-by-step installation guide (e.g., `pip install package-name`).
+2. Additional setup if needed (e.g., environment variables).
+
+## **3. Usage**
+### **Basic Commands**
+```bash
+command --example "Usage syntax"
+```
+- Explanation of the command.
+
+### **Examples**
+- Example 1: Brief description.
+ ```bash
+ command --input file.txt --output results/
+ ```
+- Example 2: Brief description.
+
+## **4. Configuration**
+*Describe configuration files, flags, or options.*
+- **`config.yml`** (example):
+ ```yaml
+ key: value
+ enabled: true
+ ```
+
+## **5. Troubleshooting**
+| Issue | Solution |
+|-------|----------|
+| Error XYZ | Fix steps or workaround. |
+
+## **6. FAQ**
+**Q:** Common question?
+**A:** Clear answer.
+
+## **7. Contributing**
+- Guidelines for pull requests, issues, or code style.
+- Link to a `CONTRIBUTING.md` if applicable.
+
+## **8. License**
+*Specify the license (e.g., MIT, Apache 2.0).*
+
+---
+
+### **Formatting Tips for Consistency**
+- Use **headings** (h1/h2/h3) for hierarchy.
+- **Code blocks** with syntax highlighting.
+- **Bullet points** for lists.
+- **Tables** for structured data (e.g., troubleshooting).
+- **Bold/italic** for emphasis.
+
+Let me know if you'd like this adapted for a specific tool or language!, 你好!我是一个高效的AI助手,很高兴为你服务。请问有什么我可以帮助你的吗?无论是问题解答、任务处理还是创意生成,我都会尽力提供快速、准确的帮助。请告诉我你的具体需求吧!, 您好!我是一个高效的AI助手,很高兴为您服务。请问有什么我可以帮助您完成的子任务吗?我会认真、专业地协助您解决问题。]
diff --git a/spring-ai-agent/spring-ai-workflow/README.md b/spring-ai-agent/spring-ai-workflow/README.md
new file mode 100644
index 0000000..4f81f1f
--- /dev/null
+++ b/spring-ai-agent/spring-ai-workflow/README.md
@@ -0,0 +1 @@
+# todo 待补充
\ No newline at end of file
diff --git a/spring-ai-agent/spring-ai-workflow/pom.xml b/spring-ai-agent/spring-ai-workflow/pom.xml
new file mode 100644
index 0000000..105ca73
--- /dev/null
+++ b/spring-ai-agent/spring-ai-workflow/pom.xml
@@ -0,0 +1,25 @@
+
+
+ 4.0.0
+
+ com.glmapper
+ spring-ai-agent
+ 0.0.1
+
+ spring-ai-workflow
+ spring-ai-workflow
+ Spring AI Workflow Module
+
+
+
+ org.springframework.ai
+ spring-ai-starter-model-openai
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
\ No newline at end of file
diff --git a/spring-ai-agent/spring-ai-workflow/src/main/java/com/glmapper/ai/workflow/WorkflowApplication.java b/spring-ai-agent/spring-ai-workflow/src/main/java/com/glmapper/ai/workflow/WorkflowApplication.java
new file mode 100644
index 0000000..2632c86
--- /dev/null
+++ b/spring-ai-agent/spring-ai-workflow/src/main/java/com/glmapper/ai/workflow/WorkflowApplication.java
@@ -0,0 +1,13 @@
+package com.glmapper.ai.workflow;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+
+@SpringBootApplication
+public class WorkflowApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(WorkflowApplication.class, args);
+ }
+}
\ No newline at end of file
diff --git a/spring-ai-agent/spring-ai-workflow/src/main/java/com/glmapper/ai/workflow/config/OpenaiChatClientConfigs.java b/spring-ai-agent/spring-ai-workflow/src/main/java/com/glmapper/ai/workflow/config/OpenaiChatClientConfigs.java
new file mode 100644
index 0000000..345fce7
--- /dev/null
+++ b/spring-ai-agent/spring-ai-workflow/src/main/java/com/glmapper/ai/workflow/config/OpenaiChatClientConfigs.java
@@ -0,0 +1,30 @@
+package com.glmapper.ai.workflow.config;
+
+import org.springframework.ai.chat.client.ChatClient;
+import org.springframework.ai.openai.OpenAiChatModel;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+
+/**
+ * @Classname OpenaiChatClientConfigs
+ * @Description 注入 ChatClient
+ *
+ * @Date 2025/6/10 09:23
+ * @Created by Gepeng18
+ */
+@Configuration
+public class OpenaiChatClientConfigs {
+
+ /**
+ * 注入ChatClient
+ *
+ * @param chatModel
+ * @return
+ */
+ @Bean
+ public ChatClient chatClient(OpenAiChatModel chatModel) {
+ return ChatClient.builder(chatModel)
+ .build();
+ }
+}
\ No newline at end of file
diff --git a/spring-ai-agent/spring-ai-workflow/src/main/java/com/glmapper/ai/workflow/core/WorkflowFactory.java b/spring-ai-agent/spring-ai-workflow/src/main/java/com/glmapper/ai/workflow/core/WorkflowFactory.java
new file mode 100644
index 0000000..ba07ee1
--- /dev/null
+++ b/spring-ai-agent/spring-ai-workflow/src/main/java/com/glmapper/ai/workflow/core/WorkflowFactory.java
@@ -0,0 +1,58 @@
+package com.glmapper.ai.workflow.core;
+
+import com.glmapper.ai.workflow.core.workflow.Workflow;
+import com.glmapper.ai.workflow.core.step.WorkflowStep;
+import com.glmapper.ai.workflow.core.workflow.impl.ChainWorkflow;
+import com.glmapper.ai.workflow.core.workflow.impl.ParallelizationWorkflow;
+import com.glmapper.ai.workflow.core.workflow.impl.RoutingWorkflow;
+import lombok.AllArgsConstructor;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Classname WorkflowFactory
+ * @Description 工作流工厂
+ *
+ * @Date 2025/6/10 15:40
+ * @Created by Gepeng18
+ */
+@Component
+@AllArgsConstructor
+public class WorkflowFactory {
+
+ private final WorkflowStepFactory workflowStepFactory;
+
+ /**
+ * 链式工作流实现:按顺序执行一系列工作流步骤,前一步骤的输出作为后一步骤的输入
+ *
+ * @param steps 工作流步骤
+ * @return 创建的工作流
+ */
+ public Workflow createChainWorkflow(List steps) {
+ return new ChainWorkflow(steps);
+ }
+
+ /**
+ * 并行工作流实现:同时执行多个工作流步骤,所有步骤使用相同的输入,最终结果是所有步骤结果的集合
+ *
+ * @param steps 工作流步骤
+ * @return 创建的工作流
+ */
+ public Workflow createParallelizationWorkflow(List steps) {
+ return new ParallelizationWorkflow(steps);
+ }
+
+ /**
+ * 路由工作流实现:基于路由规则选择合适的工作流步骤执行
+ *
+ * @param stepMap 工作流步骤
+ * @return 创建的工作流
+ */
+ public Workflow createRoutingWorkflow(Map stepMap) {
+ // 创建AI路由选择器
+ WorkflowStep routerSelector = workflowStepFactory.createAiRouterSelector("AI路由选择器", stepMap);
+ return new RoutingWorkflow(routerSelector, stepMap);
+ }
+}
\ No newline at end of file
diff --git a/spring-ai-agent/spring-ai-workflow/src/main/java/com/glmapper/ai/workflow/core/WorkflowStepFactory.java b/spring-ai-agent/spring-ai-workflow/src/main/java/com/glmapper/ai/workflow/core/WorkflowStepFactory.java
new file mode 100644
index 0000000..e4db288
--- /dev/null
+++ b/spring-ai-agent/spring-ai-workflow/src/main/java/com/glmapper/ai/workflow/core/WorkflowStepFactory.java
@@ -0,0 +1,48 @@
+package com.glmapper.ai.workflow.core;
+
+import com.glmapper.ai.workflow.core.step.WorkflowStep;
+import com.glmapper.ai.workflow.core.step.impl.DefaultWorkflowStep;
+import com.glmapper.ai.workflow.core.step.impl.RouterSelectorWorkflowStep;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.ai.chat.client.ChatClient;
+import org.springframework.stereotype.Service;
+
+import java.util.Map;
+
+/**
+ * @Classname WorkflowStepFactory
+ * @Description 提供创建AI工作流步骤的功能
+ *
+ * @Date 2025/6/10 15:40
+ * @Created by Gepeng18
+ */
+@Service
+@Slf4j
+@AllArgsConstructor
+public class WorkflowStepFactory {
+
+ private final ChatClient chatClient;
+
+ /**
+ * 创建AI工作流步骤
+ *
+ * @param name 步骤名称
+ * @param promptTemplate 提示词模板
+ * @return 工作流步骤
+ */
+ public WorkflowStep createAiStep(String name, String promptTemplate) {
+ return new DefaultWorkflowStep(name, promptTemplate, chatClient);
+ }
+
+ /**
+ * 创建AI路由选择器
+ *
+ * @param name 步骤名称
+ * @param stepMap 步骤映射
+ * @return AI路由选择器
+ */
+ public RouterSelectorWorkflowStep createAiRouterSelector(String name, Map stepMap) {
+ return new RouterSelectorWorkflowStep(chatClient, stepMap, name);
+ }
+}
\ No newline at end of file
diff --git a/spring-ai-agent/spring-ai-workflow/src/main/java/com/glmapper/ai/workflow/core/step/WorkflowStep.java b/spring-ai-agent/spring-ai-workflow/src/main/java/com/glmapper/ai/workflow/core/step/WorkflowStep.java
new file mode 100644
index 0000000..f5d718e
--- /dev/null
+++ b/spring-ai-agent/spring-ai-workflow/src/main/java/com/glmapper/ai/workflow/core/step/WorkflowStep.java
@@ -0,0 +1,27 @@
+package com.glmapper.ai.workflow.core.step;
+
+
+/**
+ * @Classname WorkflowStep
+ * @Description 工作流步骤接口
+ *
+ * @Date 2025/6/10 11:40
+ * @Created by Gepeng18
+ */
+public interface WorkflowStep {
+
+ /**
+ * 执行步骤
+ *
+ * @param input 输入数据
+ * @return 步骤执行结果
+ */
+ Object execute(Object input);
+
+ /**
+ * 获取步骤名称
+ *
+ * @return 步骤名称
+ */
+ String name();
+}
\ No newline at end of file
diff --git a/spring-ai-agent/spring-ai-workflow/src/main/java/com/glmapper/ai/workflow/core/step/impl/DefaultWorkflowStep.java b/spring-ai-agent/spring-ai-workflow/src/main/java/com/glmapper/ai/workflow/core/step/impl/DefaultWorkflowStep.java
new file mode 100644
index 0000000..317a3f7
--- /dev/null
+++ b/spring-ai-agent/spring-ai-workflow/src/main/java/com/glmapper/ai/workflow/core/step/impl/DefaultWorkflowStep.java
@@ -0,0 +1,35 @@
+package com.glmapper.ai.workflow.core.step.impl;
+
+import com.glmapper.ai.workflow.core.step.WorkflowStep;
+import org.springframework.ai.chat.client.ChatClient;
+import org.springframework.ai.chat.messages.SystemMessage;
+import org.springframework.ai.chat.messages.UserMessage;
+import org.springframework.ai.chat.prompt.Prompt;
+
+
+/**
+ * @Classname DefaultWorkflowStep
+ * @Description 工作流步骤
+ *
+ * @Date 2025/6/10 17:23
+ * @Created by Gepeng18
+ */
+public record DefaultWorkflowStep(String name, String promptTemplate, ChatClient chatClient) implements WorkflowStep {
+
+ /**
+ * 执行本步骤
+ *
+ * @param input 输入数据
+ * @return 步骤执行结果
+ */
+ @Override
+ public Object execute(Object input) {
+ String inputStr = input != null ? input.toString() : "";
+ Prompt prompt = new Prompt(
+ new SystemMessage(promptTemplate),
+ new UserMessage(inputStr)
+ );
+
+ return chatClient.prompt(prompt).call().content();
+ }
+}
\ No newline at end of file
diff --git a/spring-ai-agent/spring-ai-workflow/src/main/java/com/glmapper/ai/workflow/core/step/impl/RouterSelectorWorkflowStep.java b/spring-ai-agent/spring-ai-workflow/src/main/java/com/glmapper/ai/workflow/core/step/impl/RouterSelectorWorkflowStep.java
new file mode 100644
index 0000000..6c31d9a
--- /dev/null
+++ b/spring-ai-agent/spring-ai-workflow/src/main/java/com/glmapper/ai/workflow/core/step/impl/RouterSelectorWorkflowStep.java
@@ -0,0 +1,84 @@
+package com.glmapper.ai.workflow.core.step.impl;
+
+import com.glmapper.ai.workflow.core.step.WorkflowStep;
+import com.glmapper.ai.workflow.model.WorkflowRequest;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.ai.chat.client.ChatClient;
+import org.springframework.ai.chat.messages.SystemMessage;
+import org.springframework.ai.chat.messages.UserMessage;
+import org.springframework.ai.chat.prompt.Prompt;
+
+import javax.validation.constraints.Null;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * @Classname RouterSelectorWorkflowStep
+ * @Description AI路由选择器实现WorkflowStep接口,用于根据用户问题选择合适的路由
+ *
+ * @Date 2025/6/10 16:36
+ * @Created by Gepeng18
+ */
+@Slf4j
+public class RouterSelectorWorkflowStep implements WorkflowStep {
+
+ private final ChatClient chatClient;
+ private final Map stepMap;
+ private final String name;
+
+ public RouterSelectorWorkflowStep(ChatClient chatClient, Map stepMap, String name) {
+ this.chatClient = chatClient;
+ this.stepMap = stepMap;
+ this.name = name;
+ }
+
+ private static final String PROMPT_TEMPLATE = """
+ 你是一个专业的路由选择器。根据用户的问题,从以下可用的路由中选择最合适的一个:
+ 可用路由:
+ %s \s
+ 请仅返回最合适的路由的键名,不要包含任何额外解释。例如,如果最合适的路由是"technical",只需返回"technical"。""";
+
+ /**
+ * 执行步骤
+ *
+ * @param input 输入数据
+ * @return 步骤执行结果
+ */
+ @Null
+ @Override
+ public Object execute(Object input) {
+ if (!(input instanceof WorkflowRequest)) {
+ throw new IllegalArgumentException("Input must be of type WorkflowRequest");
+ }
+
+ WorkflowRequest request = (WorkflowRequest) input;
+
+ // 构建提示文本
+ String routeInfo = stepMap.entrySet().stream()
+ .map(entry -> "- " + entry.getKey() + ": " + entry.getValue().name())
+ .collect(Collectors.joining("\n"));
+
+ String promptTemplate = String.format(PROMPT_TEMPLATE, routeInfo);
+
+ // 创建并发送提示
+ Prompt prompt = new Prompt(
+ new SystemMessage(promptTemplate),
+ new UserMessage(request.getQuestion())
+ );
+
+ String routeKey = chatClient.prompt(prompt).call().content().trim();
+
+ // 确保获取到的是有效路由
+ if (!stepMap.containsKey(routeKey)) {
+ return null;
+ }
+
+ return routeKey;
+ }
+
+ @Override
+ public String name() {
+ return name;
+ }
+
+}
\ No newline at end of file
diff --git a/spring-ai-agent/spring-ai-workflow/src/main/java/com/glmapper/ai/workflow/core/workflow/Workflow.java b/spring-ai-agent/spring-ai-workflow/src/main/java/com/glmapper/ai/workflow/core/workflow/Workflow.java
new file mode 100644
index 0000000..bf032fe
--- /dev/null
+++ b/spring-ai-agent/spring-ai-workflow/src/main/java/com/glmapper/ai/workflow/core/workflow/Workflow.java
@@ -0,0 +1,23 @@
+package com.glmapper.ai.workflow.core.workflow;
+
+import com.glmapper.ai.workflow.model.WorkflowRequest;
+import com.glmapper.ai.workflow.model.WorkflowResponse;
+
+
+/**
+ * @Classname Workflow
+ * @Description 工作流核心接口
+ *
+ * @Date 2025/6/10 10:21
+ * @Created by Gepeng18
+ */
+public interface Workflow {
+
+ /**
+ * 执行本工作流
+ *
+ * @param input 输入的请求
+ * @return 工作流执行结果
+ */
+ WorkflowResponse execute(WorkflowRequest input);
+}
\ No newline at end of file
diff --git a/spring-ai-agent/spring-ai-workflow/src/main/java/com/glmapper/ai/workflow/core/workflow/impl/ChainWorkflow.java b/spring-ai-agent/spring-ai-workflow/src/main/java/com/glmapper/ai/workflow/core/workflow/impl/ChainWorkflow.java
new file mode 100644
index 0000000..be3c2ec
--- /dev/null
+++ b/spring-ai-agent/spring-ai-workflow/src/main/java/com/glmapper/ai/workflow/core/workflow/impl/ChainWorkflow.java
@@ -0,0 +1,54 @@
+package com.glmapper.ai.workflow.core.workflow.impl;
+
+import com.glmapper.ai.workflow.model.WorkflowRequest;
+import com.glmapper.ai.workflow.model.WorkflowResponse;
+import com.glmapper.ai.workflow.core.workflow.Workflow;
+import com.glmapper.ai.workflow.core.step.WorkflowStep;
+import lombok.extern.slf4j.Slf4j;
+
+import java.util.List;
+
+
+/**
+ * @Classname ChainWorkflow
+ * @Description 链式工作流实现:按顺序执行一系列工作流步骤,前一步骤的输出作为后一步骤的输入
+ *
+ * @Date 2025/6/10 14:21
+ * @Created by Gepeng18
+ */
+@Slf4j
+public class ChainWorkflow implements Workflow {
+
+ private final List steps;
+
+ public ChainWorkflow(List steps) {
+ this.steps = steps;
+ }
+
+ @Override
+ public WorkflowResponse execute(WorkflowRequest input) {
+ Object currentInput = input.getQuestion();
+
+ try {
+ log.info("开始执行链式工作流, 步骤数量: {}", steps.size());
+
+ for (WorkflowStep step : steps) {
+ log.info("执行步骤: {}, 模型输入:{}", step.name(), currentInput);
+ currentInput = step.execute(currentInput);
+ }
+
+ log.info("链式工作流执行完成");
+ return WorkflowResponse.builder()
+ .content(currentInput != null ? currentInput.toString() : null)
+ .success(true)
+ .build();
+
+ } catch (Exception e) {
+ log.error("链式工作流执行失败", e);
+ return WorkflowResponse.builder()
+ .success(false)
+ .errorMessage("工作流执行失败: " + e.getMessage())
+ .build();
+ }
+ }
+}
\ No newline at end of file
diff --git a/spring-ai-agent/spring-ai-workflow/src/main/java/com/glmapper/ai/workflow/core/workflow/impl/ParallelizationWorkflow.java b/spring-ai-agent/spring-ai-workflow/src/main/java/com/glmapper/ai/workflow/core/workflow/impl/ParallelizationWorkflow.java
new file mode 100644
index 0000000..e9ff00e
--- /dev/null
+++ b/spring-ai-agent/spring-ai-workflow/src/main/java/com/glmapper/ai/workflow/core/workflow/impl/ParallelizationWorkflow.java
@@ -0,0 +1,97 @@
+package com.glmapper.ai.workflow.core.workflow.impl;
+
+import com.glmapper.ai.workflow.model.WorkflowRequest;
+import com.glmapper.ai.workflow.model.WorkflowResponse;
+import com.glmapper.ai.workflow.core.workflow.Workflow;
+import com.glmapper.ai.workflow.core.step.WorkflowStep;
+import lombok.extern.slf4j.Slf4j;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
+import java.util.stream.Collectors;
+
+
+/**
+ * @Classname ParallelizationWorkflow
+ * @Description 并行工作流实现:同时执行多个工作流步骤,所有步骤使用相同的输入,最终结果是所有步骤结果的集合
+ *
+ * @Date 2025/6/10 14:27
+ * @Created by Gepeng18
+ */
+@Slf4j
+public class ParallelizationWorkflow implements Workflow {
+
+ private final List steps;
+
+ public ParallelizationWorkflow(List steps) {
+ this.steps = steps;
+ }
+
+ @Override
+ public WorkflowResponse execute(WorkflowRequest input) {
+ try {
+ log.info("开始执行并行工作流, 步骤数量: {}", steps.size());
+
+ List>> futures = new ArrayList<>();
+
+ // 为每个步骤创建一个异步任务
+ for (WorkflowStep step : steps) {
+ CompletableFuture> future = CompletableFuture.supplyAsync(() -> {
+ log.info("执行步骤: {}", step.name());
+ Object result = step.execute(input.getQuestion());
+ return Map.entry(step.name(), result);
+ });
+ futures.add(future);
+ }
+
+ // 等待所有异步任务完成
+ CompletableFuture allFutures = CompletableFuture.allOf(
+ futures.toArray(new CompletableFuture[0])
+ );
+
+ // 收集所有结果
+ CompletableFuture