Spring AI 集成 DeepSeek 大模型

一、DeepSeek 大模型介绍

DeepSeek 近日推出了两款新大模型:

1、DeepSeek V 系列,专注于对话功能,其模型命名为 deepseek-chat。

2、DeepSeek R 系列,主要致力于推理能力,模型名称为 deepseek-reasoner。

若想了解这些模型的发布和演进历程,可以查阅 DeepSeek 官方的更新日志。

https://api-docs.deepseek.com/zh-cn/updates

二、Spring AI 集成 DeepSeek 大模型

DeepSeek AI 推出了开源的 DeepSeek V3 模型,该模型在推理和问题解决方面具有领先的技术实力而著称。
nowjava.com
Spring AI 通过复用现成的 OpenAI 客户端实现了与 DeepSeek AI 的集成。首先,您需要申请 DeepSeek API 的密钥,设置基础 URL,并从支持的模型中选择一个进行使用。

三、Spring AI 集成前准备

1、创建 API 密钥:访问地址:https://api-docs.deepseek.com/zh-cn/ 创建 API 密钥。使用 Spring AI 项目中的 spring.ai.openai.api-key 属性对其进行配置。

2、设置 DeepSeek 基本 URL:将 spring.ai.openai.base-url 属性设置为 api.deepseek.com。

3、选择 DeepSeek 模型:使用属性 spring.ai.openai.chat.model=<model name> 指定模型。有关可用选项,请参阅支持的型号。

Spring AI 集成 DeepSeek 实例

第一步、引入依赖

<dependency>
    <groupId>org.springframework.ai</groupId>
    <artifactId>spring-ai-openai-spring-boot-starter</artifactId>
</dependency>


第二步、配置

spring:
  ai:
    openai:
      api-key: sk-xxx   // 填写自己申请的key
      base-url: https://api.deepseek.com
      chat:
        options:
          model: deepseek-chat


第三步、聊天 Agent 智能体案例

展开阅读全文

本文系作者在时代Java发表,未经许可,不得转载。

如有侵权,请联系nowjava@qq.com删除。

编辑于

关注时代Java

关注时代Java