当前位置: 首页 > news >正文

公司网站推广计划书出口外贸网站

公司网站推广计划书,出口外贸网站,wordpress清理网站缓存,福田网站建设费用预算先看效果 项目搭建 Spring AI 是 Spring 推出的一个项目,目标是提供统一的API抽象层,屏蔽不同AI模型和服务的底层差异,实现跨平台兼容性。 演示使用的模型是阿里的 qwq-32b。 环境要求: JDK :17以上(包括…

先看效果

项目搭建

Spring AI 是 Spring 推出的一个项目,目标是提供统一的API抽象层,屏蔽不同AI模型和服务的底层差异,实现跨平台兼容性。

演示使用的模型是阿里的 qwq-32b。

环境要求:

JDK :17以上(包括17)

Spring Boot 版本:目前支持 3.4.X,3.5.X 发布后也会同步支持。

主要的 maven 依赖

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

配置文件:

qwq-32b的接口类似于openai ,所以直接使用 openai 的配置即可,其他类 openai 的模型也是类似。

spring:ai:openai:api-key: #申请的 keybase-url: https://dashscope.aliyuncs.com/compatible-mode #api地址chat:options:model: qwq-32b # 模型名称

编写接口

创建 ChatClient。ChatClient 提供了与 AI 模型通信的 Fluent API,它支持同步和反应式(Reactive)编程模型。

this.chatClient = ChatClient.builder(chatModel).defaultSystem(DEFAULT_PROMPT).defaultAdvisors(new MessageChatMemoryAdvisor(new InMemoryChatMemory())).defaultAdvisors(new SimpleLoggerAdvisor()).defaultOptions(OpenAiChatOptions.builder().temperature(0.7d).build()).build();

创建接口,使用 SSE 响应结果,SSE 是一个单向的、从服务端向客户端推送数据的技术。使用SSE可以实时的将大模型的结果推送到前端。

@GetMapping
public SseEmitter chat(String message) {SseEmitter emitter = new SseEmitter();// 先把结果返回,后续逐渐响应结果CompletableFuture.runAsync(() -> {chatClient.prompt(message).stream().content().doOnComplete(emitter::complete).subscribe(result -> {try {emitter.send(result);} catch (IOException e) {throw new RuntimeException(e);}});});return emitter;
}

完整的接口代码如下:

package cn.salim.ai.controller;import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.client.advisor.MessageChatMemoryAdvisor;
import org.springframework.ai.chat.client.advisor.SimpleLoggerAdvisor;
import org.springframework.ai.chat.memory.InMemoryChatMemory;
import org.springframework.ai.openai.OpenAiChatModel;
import org.springframework.ai.openai.OpenAiChatOptions;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;import java.io.IOException;
import java.util.concurrent.CompletableFuture;@RestController
@RequestMapping("ai")
public class AiController {private static final String DEFAULT_PROMPT = "你是一个资深Java程序员,你熟悉各种JAVA框架,包括SpringBoot、Mybatis等等";private final ChatClient chatClient;public AiController(OpenAiChatModel chatModel) {this.chatClient = ChatClient.builder(chatModel).defaultSystem(DEFAULT_PROMPT).defaultAdvisors(new MessageChatMemoryAdvisor(new InMemoryChatMemory())).defaultAdvisors(new SimpleLoggerAdvisor()).defaultOptions(OpenAiChatOptions.builder().temperature(0.7d).build()).build();}@GetMappingpublic SseEmitter chat(String message) {SseEmitter emitter = new SseEmitter();CompletableFuture.runAsync(() -> {chatClient.prompt(message).stream().content().doOnComplete(emitter::complete).subscribe(result -> {try {emitter.send(result);} catch (IOException e) {throw new RuntimeException(e);}});});return emitter;}}

http://www.dtcms.com/a/411323.html

相关文章:

  • 学习React-17-useMemo
  • 【开题答辩过程】以《宠物犬食品的数据分析与推荐系统》为例,不会开题答辩的可以进来看看
  • wordpress建电商网站wordpress 分页文章数
  • Vue3 新项目架构简单解析
  • 网站建设加网络营销上传的网站打不开怎么办
  • 南京网站建设公司哪家好seo专业课程
  • 网线制作工具seo报告
  • Python写入PostgreSQL表的三种实现方法
  • 聊聊UI自动化测试有哪些优势
  • 想自己做网站推广淘宝做动效代码的网站
  • 做一个能注册用户的网站空间设计师工资一般多少
  • 【精品资料鉴赏】解读145页 PPT汽车集团数字化转型互联网+顶层战略设计方案
  • 环签名:AOS Borromean
  • 自适应平台(Adaptive Platform)标准——Specification of Time Synchronization
  • 制作网站的知识网站访客qq获取系统 报价
  • tcpdump 使用详解
  • 新余 网站建设公司上海黄浦网站建设
  • 数据采集技术:02 有关离线采集
  • 【SCI一区】模糊斜率熵 Fuzzy Slope Entropy+状态分类、故障诊断!
  • 品牌网站解决方案vr全景网站怎么做
  • 科技有限公司 网站制作poedit2 汉化wordpress
  • 视频融合平台EasyCVR 构筑智慧交通可视化管理与智能决策中枢
  • 一个商城网站开发要多少时间内蒙中国建设银行招聘网站
  • 从图像到精准文字:基于PyTorch与CTC的端到端手写文本识别实战
  • 使用 PyTorch 实现 CIFAR-10 图像分类:从数据加载到模型训练全流程
  • 网站开发公司能否挣钱怎么在网站空间上传文件
  • 亭湖区建设局网站楼盘网站开发报价
  • java后端工程师进修ing(研一版‖day49)
  • opendds初入门之对inforepo模式运行探索
  • 简单公司网站最全的域名后缀