SpringAI 提供 DeepSeek 直连支持,现在就给你 Java 项目用上 DeepSeek!

基于 SpringAI 整合 DeepSeek 模型实现 AI 聊天对话 很多云平台都提供了一键部署大模型的功能,这里不再赘述(阿里云百炼平台、火山方舟-火山引擎等)Ollama。 阅读详情

学会这款 🔥全新设计的 Java 脚手架 ,从此面试不再怕!

在这里插入图片描述
在这里插入图片描述

当 Java 遇见国产大模型

SpringAI 作为 Spring 生态中面向 AI 能力的集成框架,近期正式宣布对国产大模型 DeepSeek 的直连支持——这意味着我们终于可以像使用 OpenAI 一样,以标准化方式在 Java 项目中调用国产大模型!

本文将手把手带你完成以下内容:

  1. 理解 SpringAI 的抽象设计哲学
  2. 配置 DeepSeek 直连通道
  3. 实现完整的对话与流式响应
  4. 生产环境最佳实践

一、SpringAI 的设计哲学

1.1 统一的 API 抽象

SpringAI 的核心价值在于统一不同 AI 供应商的差异化 API。无论是 OpenAI、Azure 还是 DeepSeek,开发者都通过同一套 ChatClient 接口进行操作:

public interface ChatClient {
   
   
    ChatResponse call(ChatRequest request);
    Flux<ChatResponse> stream(ChatRequest request);
}

这种设计完美契合六边形架构思想,将 AI 能力作为可插拔的端口(Port)接入系统,业务核心逻辑则通过适配器(Adapter)与具体实现解耦。

1.2 配置即连接

通过 Spring Boot 的 application.yml,我们可以灵活切换不同 AI 供应商:

spring:
  ai:
    provider: deepseek # 只需修改这个值即可切换供应商
    deepseek:
      base-url: https://api.deepseek.com/v1
      api-key: ${
   
   DEEPSEEK_API_KEY}

这种配置方式与 Spring Security 的认证体系、Spring Cloud 的微服务配置中心天然契合,特别适合需要动态切换模型供应商的企业场景。


二、快速接入 DeepSeek

2.1 添加依赖

在 pom.xml 中引入 SpringAI 的 DeepSeek 模块:

<dependency>
    <groupId>org.springframework.ai</groupId>
    <artifactId>spring-ai-deepseek</artifactId>
    <version>0.8.1</version
SpringAI与DeepSeek集成:Java项目AI化实战指南 大语言模型作为人工智能领域的核心技术,通过深度学习算法实现对自然语言的理解和生成。其原理基于Transformer架构,通过自注意力机制处理序列数据,具备强大的上下文理解能力。在技术价值层面,大语言模型能够显著提升开发效率,降低人工编码成本,实现智能化的代码生成与审查。在应用场景上,结合SpringAI框架的标准化接口设计,Java开发者可以快速集成AI能力,而DeepSeek作为国产大模型的代表,在代码生成和逻辑推理等场景表现出色。通过SpringAI与DeepSeek的技术组合,传统Java项目能够实现 阅读详情

相关推荐

SpringAI框架集成DeepSeek大模型:Java项目智能化转型实践指南

人工智能技术在现代软件开发中扮演着越来越重要的角色,其核心原理是通过机器学习算法模拟人类智能行为。在Java生态中,SpringAI框架作为官方推出的AI应用开发标准,通过统一的抽象层封装了不同大模型的差异,为开发者提供了便捷的AI能力接入方案。这种技术架构的价值在于能够显著降低AI集成的技术门槛,让传统Java项目快速获得智能化能力。在实际应用场景中,DeepSeek作为优秀的国产大模型代表,具备多模态能力和成本优势,特别适合中文内容处理、代码辅助等任务。通过SpringAI与DeepSeek的深度集成,

weixin_34269583的博客 333

SpringAI+DeepSeek:Java项目AI化改造实战指南

大语言模型作为人工智能领域的重要突破,通过深度学习技术实现了自然语言的理解与生成。其核心原理基于Transformer架构,通过海量数据训练获得强大的语义理解能力。在技术价值层面,大模型能够处理非结构化数据、支持智能决策、实现自动化流程,显著提升开发效率。在应用场景上,特别适合传统Java项目的智能化升级,比如智能客服、文档生成、代码审查等具体业务需求。SpringAI作为Java生态的AI集成框架,为开发者提供了统一的大模型调用接口,而DeepSeek作为国产大模型的优秀代表,在成本控制和中文处理方面具有

weixin_29058331的博客 338

SpringAI+DeepSeek:Java开发者AI应用开发实战指南

大语言模型作为人工智能领域的核心技术,通过深度学习算法实现对自然语言的理解和生成。其原理基于Transformer架构,通过预训练和微调获得强大的语言处理能力。在技术价值层面,大语言模型能够显著提升开发效率,实现智能代码生成、文档分析等核心功能。SpringAI框架作为Spring生态的AI标准化解决方案,为Java开发者提供了统一的大模型接入接口。结合DeepSeek这一高性价比的国产大模型,开发者可以在传统Java项目中快速集成AI能力。应用场景涵盖智能客服、代码辅助、文本生成等多个领域,特别适合企业级

weixin_30247307的博客 414

SpringAI集成DeepSeek:从Chat到RAG的完整实战指南

大模型API集成是现代应用开发的关键技术,它通过统一的接口抽象让开发者能够便捷地调用各类AI能力。其核心原理在于将复杂的模型调用封装为标准化服务,通过HTTP协议与云端或本地模型进行交互。这一技术的价值在于显著降低了AI能力集成的门槛,使开发者能够快速为应用添加智能对话、文本理解等高级功能。在实际应用场景中,开发者常面临成本控制、网络稳定性与合规性等挑战,特别是在企业级Java生态中。SpringAI作为Spring官方推出的AI集成框架,提供了与Spring Boot生态无缝融合的解决方案,通过ChatM

weixin_34109408的博客 456

机械臂视觉抓取避坑指南:如何正确计算手眼标定矩阵(附Numpy代码)

本文详细解析了机械臂视觉抓取中手眼标定矩阵的计算方法,特别针对'眼在手上'配置下的常见错误提供了解决方案。通过Numpy代码示例和坐标转换原理,帮助开发者避免矩阵计算错误和坐标转换偏差,提升工业自动化系统的精度和效率。

weixin_29081703的博客 247

Matlab实战:用递归最小二乘法(RLS)搞定动态系统参数辨识(附完整代码)

本文通过Matlab实战,详细介绍了如何利用递归最小二乘法(RLS)进行动态系统参数辨识。文章从理论优势切入,提供了完整的仿真数据生成、RLS算法核心实现代码,并对参数收敛过程、预测误差及不同遗忘因子的影响进行了可视化分析与性能评估,为工程实践提供了清晰的指南。

weixin_29035405的博客 508

PostgreSQL使用 pg_rman物理备份搭建流复制备库(streaming replication standby)

摘要:使用pg_rman备份搭建PostgreSQL流复制备库 本文详细介绍了利用pg_rman工具快速搭建PostgreSQL流复制备库的完整流程。该方法结合物理备份的高效性和流复制的实时性,特别适合大型数据库环境。主要内容包括:主库上的pg_rman安装配置、全量备份操作;备份文件传输至备库;备库数据目录准备及恢复;流复制参数配置;以及最终的启动验证步骤。文章还提供了架构示意图和关键配置示例,并包含常见问题排查建议,如备库无法启动或复制卡顿情况的处理方法。整个流程强调通过.pgpass文件管理密码的安全

liumangtuzi888的博客 1171

【QT】基于QSerialPort的跨平台串口通信实战指南

本文是一份基于Qt QSerialPort模块的跨平台串口通信实战指南。详细介绍了从硬件基础、QSerialPort核心类使用、参数配置、设备自动发现到数据异步读写和错误处理的完整流程,并通过构建一个功能齐全的串口调试助手实例,帮助开发者快速掌握在Windows、Linux和macOS系统下进行高效、稳定的串口应用开发。

a1b2c3d的博客 986

vTestStudio保姆教程之从0到1搭建软件环境

学习HIL测试的必经之路,保姆级教学VT从搭建到测试。

欢迎来到eee的博客 4197

【Python】no module named distutils问题怎么解决-Numpy 启动时报错:缺少 distutils 模块的解决方法

看distutils这个名字,似乎是什么通用模块,可能不一定是numpy的问题。

每日出拳老爷子的博客 6012

OpenClaw实战系列01:OpenClaw接入飞书机器人全接入指南 + Ollama本地大模型

通过 OpenClaw + Ollama + 飞书的组合,我们成功搭建了一个完全私有、免费、可定制的AI助理。它不仅能在日常聊天中提供帮助,还能通过OpenClaw强大的“技能”体系,真正去操作你的电脑、管理文件、甚至执行代码。这套方案将数据留在本地,既保证了隐私安全,又锻炼了动手能力。现在,去给你的AI助理添加更多酷炫的技能吧!

PeterPan的博客 1万+

【Python开发者必看】Windows下Python版本管理器Pyenv安装使用,轻松管理Python版本的入门与进阶指南,从此告别Python环境不兼容的噩梦

好了,关于 【Python开发者必看】Windows下Python版本管理器Pyenv安装使用,轻松管理Python版本的入门与进阶指南,从此告别Python环境不兼容的噩梦 就写到这儿了,如果还有什么疑问或遇到什么问题欢迎扫码提问,也可以给我留言哦,我会一一详细的解答的。1、手动下载对应版本到 pyenv-win\install_cache 目录(如上手动操作安装步骤,文件名需匹配,如 python-3.10.0-amd64.exe)。该指令会列出,pyenv包管理工具所支持的所有python版本,

Spring Boot-Common On With You 855

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

上一篇: 升级 SpringBoot3 全项目讲解 — 如何在 SpringBoot3 种用 JsonSchema 来验证 Json是否有效?
下一篇: 升级 SpringBoot3 全项目讲解 - 什么是 Mermaid?为什么大厂都用他画流程图?
ccmjga
博客等级 码龄3年 859粉丝 72原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值