Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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** 模块(具体端口可以根据你自己的配置而定):
Expand Down
5 changes: 5 additions & 0 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
5 changes: 5 additions & 0 deletions spring-ai-mcp/mcp-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
<artifactId>httpclient5</artifactId>
<version>5.4.3</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.core5</groupId>
<artifactId>httpcore5</artifactId>
<version>5.3.4</version> <!-- 确保版本兼容 -->
</dependency>

<dependency>
<groupId>org.springframework.ai</groupId>
Expand Down
19 changes: 11 additions & 8 deletions spring-ai-mcp/mcp-client/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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