diff --git a/README.md b/README.md index dece5e8a8c26743b5fa013ba80e23de8b6db19c0..65a30870f1b470e1d89a735fe1c0727a8c6a96c9 100644 --- a/README.md +++ b/README.md @@ -1,49 +1,66 @@ + + # Spring AI Alibaba Examples -> Spring AI Alibaba Repo: https://github.com/alibaba/spring-ai-alibaba -> -> Spring AI Alibaba Website: https://java2ai.com -> -> Spring AI Alibaba Website Repo: https://github.com/springaialibaba/spring-ai-alibaba-website +[Spring AI Alibaba](https://github.com/alibaba/spring-ai-alibaba) 的各类型Example 模块集合,旨在展示 Spring AI 与 Spring AI Alibaba 的最佳实践用法。 + +## 模块总览 + +本仓库包含多个 Example 子模块,覆盖以下场景: + +| 类别 | 模块 | 说明 | +|------|------|------| +| 基础示例 | spring-ai-alibaba-helloworld | 基础对话、流式响应、Advisor、对话记忆 | +| 对话模型 | spring-ai-alibaba-chat-example | DashScope、OpenAI、DeepSeek、MiniMax、智谱等模型调用示例 | +| 图像生成 | spring-ai-alibaba-image-example | 通义图像、OpenAI DALL·E 图像生成 | +| 音频处理 | spring-ai-alibaba-audio-example | 语音合成(TTS)、语音转录(ASR) | +| 函数调用 | spring-ai-alibaba-tool-calling-example | 工具调用示例(地图API等) | +| MCP | spring-ai-alibaba-mcp-example | Model Context Protocol 多种集成示例 | +| RAG | spring-ai-alibaba-rag-example | 检索增强生成示例 | +| Graph工作流 | spring-ai-alibaba-graph-example | 状态图工作流、并行节点、人机协作 | +| Agent | spring-ai-alibaba-agent-example | React Agent、多Agent协作 | +| 评估 | spring-ai-alibaba-evaluation-example | AI模型回答质量评估 | +| 百炼 | spring-ai-alibaba-bailian-example | 阿里云百炼应用调用 | + +## 快速开始 + +### 环境要求 + +- JDK 17+ +- Maven 3.8+ +- 模型 API Key(如 AI_DASHSCOPE_API_KEY) -[English](./README-en.md) | 中文 +### 运行示例 -## 介绍 +```bash +# 方式一:运行特定模块 +mvn -pl spring-ai-alibaba-helloworld spring-boot:run -此仓库中包含许多 Example 模块项目来介绍 Spring AI 和 Spring AI Alibaba 从基础到高级的各种用法和 AI 项目的最佳实践。 +# 方式二:打包后运行 +mvn -pl spring-ai-alibaba-helloworld package +java -jar spring-ai-alibaba-helloworld/target/*.jar +``` -更详细的介绍请参阅每个子项目中的 README.md 和 [Spring AI Alibaba 官网](https://java2ai.com)。 +### 环境变量配置 -## 参与建设 +常见配置键: -欢迎任何形式的代码贡献。 +| 配置键 | 说明 | 常见模块 | +|--------|------|----------| +| AI_DASHSCOPE_API_KEY | 通义千问API Key | helloworld, dashscope-chat | +| OPENAI_API_KEY | OpenAI API Key | openai-chat | +| AI_DEEPSEEK_API_KEY | DeepSeek API Key | deepseek-chat | -## Quickstart Matrix (Community Contribution) +## 文档索引 -| module | purpose | command | required services | env vars | env template | entry | -|---|---|---|---|---|---|---| -| spring-ai-alibaba-helloworld | basic chat and advisor examples | `mvn -pl spring-ai-alibaba-helloworld spring-boot:run` | none | `AI_DASHSCOPE_API_KEY` | — | [README](./spring-ai-alibaba-helloworld/README.md) | -| spring-ai-alibaba-chat-example/dashscope-chat | DashScope chat basics | `mvn -pl spring-ai-alibaba-chat-example/dashscope-chat spring-boot:run` | none | `AI_DASHSCOPE_API_KEY` | — | [README](./spring-ai-alibaba-chat-example/dashscope-chat/README.md) | -| spring-ai-alibaba-image-example/dashscope-image | DashScope image generation | `mvn -pl spring-ai-alibaba-image-example/dashscope-image spring-boot:run` | none | `AI_DASHSCOPE_API_KEY` | — | [README](./spring-ai-alibaba-image-example/dashscope-image/README.md) | -| spring-ai-alibaba-mcp-example | MCP demo | `mvn -pl spring-ai-alibaba-mcp-example spring-boot:run` | none/local mcp tool | model api key | [`.env.example`](./spring-ai-alibaba-mcp-example/.env.example) | [README](./spring-ai-alibaba-mcp-example/README.md) | -| spring-ai-alibaba-rag-example | RAG demo | `mvn -pl spring-ai-alibaba-rag-example spring-boot:run` | vector db (optional by profile) | model api key, embedding model | [`.env.example`](./spring-ai-alibaba-rag-example/.env.example) | [README](./spring-ai-alibaba-rag-example/README.md) | -| spring-ai-alibaba-tool-calling-example | tool calling | `mvn -pl spring-ai-alibaba-tool-calling-example spring-boot:run` | none | model api key, map api key | [`.env.example`](./spring-ai-alibaba-tool-calling-example/.env.example) | [README](./spring-ai-alibaba-tool-calling-example/README.md) | +各模块独立 README 请参见对应模块目录下文档: -## 常用配置键速查 +- [spring-ai-alibaba-helloworld](./spring-ai-alibaba-helloworld/README.md) +- [spring-ai-alibaba-chat-example](./spring-ai-alibaba-chat-example/README.md) +- [spring-ai-alibaba-mcp-example](./spring-ai-alibaba-mcp-example/readme.md) -| 配置键 | 常见模块 | 说明 | -|---|---|---| -| `AI_DASHSCOPE_API_KEY` | `spring-ai-alibaba-helloworld`、DashScope chat/image、tool calling、evaluation、很多 graph/rag 示例 | DashScope 兼容模型最常见的 API Key | -| `OPENAI_API_KEY` | `spring-ai-alibaba-chat-example/openai-chat`、`spring-ai-alibaba-chat-example/vllm-chat` | OpenAI 兼容接口示例常用 | -| `AI_OPENAI_API_KEY` | `spring-ai-alibaba-image-example/openai-image` | OpenAI 图片生成示例使用 | -| `AI_DEEPSEEK_API_KEY` | `spring-ai-alibaba-chat-example/deepseek-chat`、`spring-ai-alibaba-mem0-example` | DeepSeek 相关示例使用 | -| `MINIMAX_API_KEY` | `spring-ai-alibaba-chat-example/minimax-chat` | MiniMax 模型示例使用 | -| `ZHIPUAI_API_KEY` | `spring-ai-alibaba-chat-example/zhipuai-chat` | 智谱模型示例使用 | -| `BAIDU_MAP_API_KEY` | `spring-ai-alibaba-tool-calling-example` | 地图工具调用示例需要 | +详细文档和API参考请访问 [Spring AI Alibaba 官网](https://java2ai.com)。 -## 常见启动问题 / Troubleshooting +## 许可 -- `AI_DASHSCOPE_API_KEY` 未设置 / Missing `AI_DASHSCOPE_API_KEY`: 先确认环境变量已在当前 shell 或 IDE 中生效,再重新启动示例。 -- 端口被占用 / Port already in use: 检查对应模块 `application.yml` 中的 `server.port`,释放端口或改端口后重试。 -- 本地依赖未启动 / Required local services not running: RAG、MCP、向量库或 Docker 相关示例通常需要先启动对应的中间件或容器。 -- 模块里暂时没有 `.env.example` / No `.env.example` in a module yet: 优先查看该模块 README 和 `src/main/resources/application.yml`,确认真实的变量名和依赖服务。 +Apache License 2.0 - 详情见 [LICENSE](./LICENSE) 文件。 \ No newline at end of file