基于 Spring Boot 3 与 Java 21 的 AI 恋爱大师应用与 ReAct 智能体教学项目,涵盖 Spring AI、RAG、Tool Calling 及 MCP 协议实战。
项目概述#
Yu AI Agent(YuManus)是一个面向程序员的 AI 开发实战教程项目,基于 Spring Boot 3.4.4 和 Java 21 构建,集成了 Spring AI 框架。
核心特性#
模型接入#
- 阿里云百练/灵积大模型:通过 Spring AI Alibaba (DashScope SDK 2.19.1) 集成
- Ollama 本地模型:支持端侧模型部署
- LangChain4J 集成:提供备选实现路径
- 多模型统一接入:云侧与端侧模型灵活切换
AI 能力#
- Prompt 工程:提示词设计与优化、上下文管理
- RAG 检索增强生成:向量数据库集成、相似性搜索
- Tool Calling:外部工具和服务调用能力
- MCP 协议:Model Context Protocol 实现,维护 AI 交互上下文
- ReAct Agent:自主规划智能体(Reasoning + Acting 模式)
应用场景#
- AI 恋爱大师对话机器人
- 自主规划智能体 YuManus
- 企业级 AI 应用原型开发
- Java 开发者 AI 技能学习
环境要求#
- JDK 21(必需)
- Maven 3.x 或 Maven Wrapper
快速开始#
# 克隆仓库
git clone https://github.com/hfgwygey/yu-ai-agent.git
# 进入目录
cd yu-ai-agent
# 安装依赖
mvn install
# 启动应用
mvn spring-boot:run
访问入口#
- 应用地址:http://localhost:8080
- API 文档:http://localhost:8080/doc.html(基于 Knife4j 惯例)
核心依赖#
- Spring Boot 3.4.4
- Spring AI 1.0.0-M6
- spring-ai-alibaba-starter 1.0.0-M6.1
- spring-ai-ollama-spring-boot-starter 1.0.0-M6
- langchain4j-community-dashscope 1.0.0-beta2
- Knife4j OpenAPI3 4.4.0
配置要点#
需配置 Spring Milestones 仓库以下载 Spring AI 依赖,并在 application.yml 中配置阿里云 DashScope API 密钥或 Ollama 服务地址。
项目状态#
版本 0.0.1-SNAPSHOT,处于早期开发阶段,适合学习和技术预研。