From 1a8e18d2c393d450140e6da2fed0b2a50a5a6ba2 Mon Sep 17 00:00:00 2001 From: hyz Date: Wed, 25 Jun 2025 21:39:21 +0800 Subject: [PATCH 1/2] fix mcp-client config yaml format bug, fix pom http dependency bug. due to these bugs, mcp-sample can not run success --- spring-ai-mcp/mcp-client/pom.xml | 5 +++++ .../src/main/resources/application.yaml | 19 +++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/spring-ai-mcp/mcp-client/pom.xml b/spring-ai-mcp/mcp-client/pom.xml index f39a9e6..c3ad84e 100644 --- a/spring-ai-mcp/mcp-client/pom.xml +++ b/spring-ai-mcp/mcp-client/pom.xml @@ -19,6 +19,11 @@ httpclient5 5.4.3 + + org.apache.httpcomponents.core5 + httpcore5 + 5.3.4 + org.springframework.ai diff --git a/spring-ai-mcp/mcp-client/src/main/resources/application.yaml b/spring-ai-mcp/mcp-client/src/main/resources/application.yaml index 801598b..93df710 100644 --- a/spring-ai-mcp/mcp-client/src/main/resources/application.yaml +++ b/spring-ai-mcp/mcp-client/src/main/resources/application.yaml @@ -6,11 +6,14 @@ spring: name: mcp-client profiles: active: mcp-client - ai: - openai: - api-key: sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx - chat: - base-url: https://api.deepseek.com - completions-path: /v1/chat/completions - options: - model: deepseek-chat + ai: + openai: + api-key: ${spring.ai.openai.api-key} + chat: +# base-url: https://api.deepseek.com + base-url: https://dashscope.aliyuncs.com/compatible-mode +# completions-path: /v1/chat/completions + completions-path: /v1/chat/completions + options: +# model: deepseek-chat + model: qwen-plus \ No newline at end of file From c1d27b5240288ef5c39d9d7d85da5311e5a0b694 Mon Sep 17 00:00:00 2001 From: hyz Date: Wed, 25 Jun 2025 21:57:28 +0800 Subject: [PATCH 2/2] =?UTF-8?q?add=20readme=20add=20evn=20config=20?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E9=85=8D=E7=BD=AE=E5=85=A8=E5=B1=80?= =?UTF-8?q?LLM=20key=E7=9A=84=E4=BD=BF=E7=94=A8=E6=96=B9=E5=BC=8F=E8=AF=B4?= =?UTF-8?q?=E6=98=8E=EF=BC=8C=E6=97=A0=E9=9C=80=E6=AF=8F=E6=AC=A1=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E5=AF=B9=E5=BA=94=E7=9A=84=E9=85=8D=E7=BD=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 5 +++++ README_EN.md | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/README.md b/README.md index cba16ed..fbc0293 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,11 @@ spring.ai.deepseek.chat.options.model=deepseek-chat ``` 将你的 `spring.ai.deepseek.api-key` 替换为实际的 API 密钥即可启动运行。关于如何申请 api key ,可以移步项目 [Wiki 页面](https://github.com/java-ai-tech/spring-ai-summary/wiki)进行查看。 +有一个一劳永逸的办法,将对应的spring.ai.deepseek.api-key添加到对应环境变量中,后续启动时会带进来,不用再去修改代码了对应的application.yml,不用担心提交代码泄露key +将IDEA启动项中的环境变量添加spring.ai.openai.api-key=sk-***************(你自己对应的 key),运行项目时,会自动带入环境变量。 +不过对应的子module每个模块都需要配置 + + ### 3. ▶️ 运行示例 完成上述步骤后,你可以选择运行不同的示例模块来体验 Spring AI 的功能。如启动运行 **spring-ai-chat-deepseek** 模块(具体端口可以根据你自己的配置而定): diff --git a/README_EN.md b/README_EN.md index 855e405..c59da1e 100644 --- a/README_EN.md +++ b/README_EN.md @@ -98,6 +98,11 @@ spring.ai.deepseek.chat.options.model=deepseek-chat ``` 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). +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. + +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. + +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):