springboot集成deepseek4j

ops/2025/2/27 20:44:34/

1、文档地址

快速开始 - 零基础入门Java AI

免费的模型

Models

2、pom文件依赖 parent依赖

           <dependency><groupId>com.squareup.okhttp3</groupId><artifactId>okhttp</artifactId><version>4.12.0</version></dependency><dependency><groupId>com.squareup.okhttp3</groupId><artifactId>okhttp-sse</artifactId><version>4.12.0</version></dependency><dependency><groupId>com.fasterxml.jackson</groupId><artifactId>jackson-bom</artifactId><version>2.12.4</version><type>pom</type><scope>import</scope></dependency>

工程pom

      <dependency><groupId>io.github.pig-mesh.ai</groupId><artifactId>deepseek-spring-boot-starter</artifactId><version>1.4.5</version></dependency><dependency><groupId>com.squareup.okhttp3</groupId><artifactId>okhttp</artifactId><version>4.12.0</version></dependency><dependency><groupId>com.squareup.okhttp3</groupId><artifactId>okhttp-sse</artifactId><version>4.12.0</version></dependency><dependency><groupId>com.fasterxml.jackson</groupId><artifactId>jackson-bom</artifactId><version>2.12.4</version><type>pom</type><scope>import</scope></dependency>

3、deepseek  api配置

deepseek:api-key: sk-xxxxxxxxxxxmodel: deepseek-r1base-url: https://xxx.xxxx.xxxx.xxxx.com/v1

4、代码

java">package com.yh.im.controller;import io.github.pigmesh.ai.deepseek.core.DeepSeekClient;
import io.github.pigmesh.ai.deepseek.core.chat.ChatCompletionRequest;
import io.github.pigmesh.ai.deepseek.core.chat.ChatCompletionResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;@RestController
public class DeepSeekController {@Autowiredprivate DeepSeekClient deepSeekClient;@GetMapping(value = "/chat", produces = MediaType.TEXT_EVENT_STREAM_VALUE)public Flux<ChatCompletionResponse> chat(String prompt) {return deepSeekClient.chatFluxCompletion(prompt);}@GetMapping(value = "/sync/chat")public ChatCompletionResponse syncChat(String prompt) {ChatCompletionRequest request = ChatCompletionRequest.builder()// 根据渠道模型名称动态修改这个参数
//                .model(deepSeekProperties.getModel()).addUserMessage(prompt).build();return deepSeekClient.chatCompletion(request).execute();}
}


http://www.ppmy.cn/ops/161768.html

相关文章

动态数据表格:基于 PrimeFaces 的运行时列选择实现

在现代的 Web 应用开发中&#xff0c;动态数据表格是一个非常实用的功能&#xff0c;它允许用户根据自己的需求选择显示哪些列。这种灵活性不仅提升了用户体验&#xff0c;还能适应不同的数据展示需求。今天&#xff0c;我们将通过一个具体的实现案例&#xff0c;展示如何使用 …

ASP.NET Core 8.0学习笔记(二十七)——数据迁移:Migrations深入与其他迁移命令

一、数据库架构的管理 1.EF Core提供两种方式来保持EF Core的模型与数据库保持同步。 (1)以数据库为准&#xff1a;反向工程&#xff08;Db First&#xff09;&#xff0c;适用于中大型工程 (2)以代码为准&#xff1a;数据迁移&#xff08;Code First&#xff09;&#xff0c;…

Python----数据分析(Numpy四:广播机制,数组的运算,统计计算,where函数)

一、数组的广播机制 通常情况下&#xff0c;为了进行元素级的算术运算&#xff0c;两个数组的形状必须完全一致&#xff0c;Numpy的广播机制&#xff0c;它提供了一种规则&#xff0c;能够将不同形状的两个计算数 组广播到相同形状&#xff0c;然后再去进行元素级的算术运算&am…

Vulhub靶机 Apache APISIX命令执行 (CVE-2020-13945)(渗透测试详解)

一、开启vulhub环境 docker-compose up -d 启动 docker ps 查看开放的端口 漏洞范围 Apache APISIX 1.2~1.5 二、访问靶机IP 9080端口 1、拼接apisix/admin/routes路由 发现其特征为failed to check token 2、抓取当前页面的包&#xff0c;并修改为post请求&#xff0c;添…

HGAME2025 Week1

目录 Level 24 PacmanLevel 47 BandBombLevel 25 双面人派对Level 69 MysteryMessageBoardLevel 38475 ⻆落 Level 24 Pacman 直接在js文件里面搜索score, 可以找到一个flag, 经过base64和栅栏解密可以发现是一个假的flag 在尝试搜索一下gift, 可以找到另一个flag, 依次解码就…

React + TypeScript 数据模型驱动数据字典生成示例

React TypeScript 数据模型驱动数据字典生成示例 引言&#xff1a;数据字典的工程价值 在现代化全栈开发中&#xff0c;数据字典作为业务实体与数据存储的映射桥梁&#xff0c;直接影响系统可维护性与团队协作效率。传统手动维护字典的方式存在同步成本高和版本管理混乱两大痛…

Uniapp 小程序:语音播放与暂停功能的实现及优化方案

界面部分 //开启语音 <button class"open" v-if"showPlayfalse" click"playText">这是开启播放的图片</button >//关闭语音 <button class"close" v-if"showPlaytrue" click"stopText">这是…

Java异常类型

一、异常体系架构 1.1 体系图解 1.2 Exception & Error Exception 表示程序可以处理的异常情况&#xff0c;通常是由于程序逻辑错误或运行时问题引起的&#xff0c;比如NullPointException、IOException等。这些异常是设计用来被程序捕获&#xff0c;并采取相应的恢复措施…