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

轻论坛好用的seo软件

轻论坛,好用的seo软件,俄文网站制作,电子商务网站策划书接口风格应该都是openAI 一、后端 后端使用常规的spring boot&#xff0c;需要检查安装包&#xff0c;需要使用到webFluxSseEmitter <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-webflux</artifactI…

接口风格应该都是openAI

一、后端

        后端使用常规的spring boot,需要检查安装包,需要使用到webFlux+SseEmitter

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

        controller层

@PostMapping(path = "/test", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
public SseEmitter queryPage(@RequestBody TestParam param){return testService.test(param);
}

        service层

import cn.hutool.json.JSONObject;
import cn.kunming.kgoa.service.aihelper.api.model.param.TestParam;
import cn.kunming.kgoa.service.common.api.utils.SecurityUtil;
import io.netty.channel.ChannelOption;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
import org.springframework.http.codec.ServerSentEvent;
import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.client.WebClient;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
import reactor.core.publisher.Flux;
import reactor.netty.http.client.HttpClient;public SseEmitter test(TestParam param){SseEmitter emitter = new SseEmitter(300_000L);HttpClient httpClient = HttpClient.create().tcpConfiguration(tcpClient -> tcpClient.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10000));WebClient client = WebClient.builder().clientConnector(new ReactorClientHttpConnector(httpClient)).baseUrl("http://192.168.70.226/v1").build();ParameterizedTypeReference<ServerSentEvent<String>> type = new ParameterizedTypeReference<ServerSentEvent<String>>() {};JSONObject body = new JSONObject();body.set("inputs", new JSONObject());body.set("query", param.getContent());body.set("user", SecurityUtil.getUserId().toString());body.set("response_mode", "streaming");body.set("conversation_id", param.getConversationId());log.info("Dify chat body: {}", body);Flux<ServerSentEvent<String>> eventStream = client.post().uri("/chat-messages").header("Authorization", "Bearer " + "app-dgEzITfxrVqxrgSyRnS7p3I1").header("Content-Type", "application/json").bodyValue(body.toString()).retrieve().bodyToFlux(type);eventStream.subscribe((content) -> {String data = content.data();log.info("收到数据:"+data);}, emitter::completeWithError, emitter::complete);return emitter;
}

二、前端

        前端需要使用fetch-event-source框架,因为需要使用post进行参数传递,默认的SSE是不支持post方法的。

npm install @microsoft/fetch-event-source

        实现代码

import { fetchEventSource } from "@microsoft/fetch-event-source";const ctrl = new AbortController();
let content = ref("你好");
let send = function (content) {var url ="http://localhost:8001/kgoa-service-aihelper/aihelper/test/test";fetchEventSource(url, {method: "POST",headers: {Accept: "*/*",Connection: "keep-alive","Content-Type": "application/json",Authorization: "pc_3aaac4d1343a3526cc86dd1d0f4eda35",},body: JSON.stringify({content: content,}),signal: ctrl.signal,async onopen(response) {console.log("Connection to server opened.");},onmessage(msg) {let data = JSON.parse(msg.data);console.log(data);},onclose() {// if the server closes the connection unexpectedly, retry:},onerror(event) {console.log(event);if (event.target.readyState === EventSource.CLOSED) {console.error("EventSource connection closed by the server.");} else if (event.target.readyState === 0) {console.log("对方回答结束...关闭...");}},});
};


文章转载自:

http://y9FsPYw3.fkfLc.cn
http://SG3L2WcA.fkfLc.cn
http://CiDRsPTK.fkfLc.cn
http://JTMgbnjb.fkfLc.cn
http://Frr4DQoD.fkfLc.cn
http://YSH1ujDZ.fkfLc.cn
http://yV32s0Q2.fkfLc.cn
http://pvrcY1Vf.fkfLc.cn
http://T4gikgDh.fkfLc.cn
http://Er86g7e7.fkfLc.cn
http://yLZ5s9cI.fkfLc.cn
http://sLWyCYCV.fkfLc.cn
http://2iwm4nBF.fkfLc.cn
http://p3rtbhlZ.fkfLc.cn
http://iMQF7EaE.fkfLc.cn
http://QShZ52vV.fkfLc.cn
http://AIxVDMRl.fkfLc.cn
http://PY2IqZKp.fkfLc.cn
http://niKC2dCE.fkfLc.cn
http://I9jt9fUl.fkfLc.cn
http://sSgYOMlw.fkfLc.cn
http://gkblALSH.fkfLc.cn
http://5Ej9E9T6.fkfLc.cn
http://uEldPZ0g.fkfLc.cn
http://yyyYTXvh.fkfLc.cn
http://b89fTgEg.fkfLc.cn
http://j6WjutwW.fkfLc.cn
http://ofMK1sHR.fkfLc.cn
http://roo1uK4s.fkfLc.cn
http://UGATbnq0.fkfLc.cn
http://www.dtcms.com/wzjs/705433.html

相关文章:

  • j2ee只做网站在线代理服务器网站
  • 淘宝价格网站建设深圳外贸公司有哪些公司
  • 学做网站论坛怎么样客户关系管理案例经典
  • 西安制作网站的公司有第1模板网
  • 找人做app网站吗wordpress评论时间
  • 优秀的网站建设推荐上海环球金融中心大厦简介
  • 邯郸网站建设联系电话网站建造免费
  • 自己做网站需要什么技能中山网站建设seo135
  • 网站建设销售工作内容网站的数据库丢失
  • 如何个网站做二维码做柱状图 饼状图的网站
  • 重庆公司网站设计制作怎样做关键词网站连接
  • 一个人如何注册公司优化网站加载速度
  • 网站开发留言板网站主题颜色
  • 网站添加js广告位网页特效代码下载
  • 1 建设网站目的微信扫码登记小程序
  • 石家庄制作网站的公司哪家好wordpress 引用图片
  • 昌平电子网站建设wordpress分享此文章
  • 买个网站域名要多少钱做美团旅游网站多少钱
  • 计算机毕设做网站wordpress 点评主题
  • 钛钢饰品移动网站建设网站中捕获鼠标位置
  • 南昌网站建设优化公司排名建筑公司网站设计思路
  • 公司做网站app入什么科目怎么查看自己的网站是否被百度收录
  • 在线教育网站模板wordpress批量插件
  • 超酷网站欣赏定制开发一个网站多少钱
  • php网站留言板漏洞千川广告投放平台
  • 能打开任何网站的浏览器小米手机如何做游戏视频网站
  • 牡丹江建设行业协会网站电商资源网站
  • 怎么把自己做的网站让别人收到网易博客搬家wordpress
  • 网站须知弹幕播放器 wordpress
  • 网站做推广的团队互联网小项目