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

弹窗网站制作google网址直接打开

弹窗网站制作,google网址直接打开,自己怎么建设网站首页,微网站和h5有什么区别前言 最近我们公司也是在做认知助手,大模型相关的功能,正在做提示词,机器人对话相关功能。想要提高用户体验,使用SSE请求模式,在不等数据完全拿到的情况下边拿边返回。 之前做过一版,但不是流式返回&…

前言

最近我们公司也是在做认知助手,大模型相关的功能,正在做提示词,机器人对话相关功能。想要提高用户体验,使用SSE请求模式,在不等数据完全拿到的情况下边拿边返回。

之前做过一版,但不是流式返回,是等待全部结果再返回,不得不说确实等待过程挺长,然后就有了现在的优化。想着功能都写好了,只是改一下接口,应该是个简单的需求。

后端使用的post接口,经过一番搜索,最后使用的fetch。经过短短几个小时,配置写好,准备联调,以为需求就顺利完工了。奈何就这流式联调,还耗了两天。只因为后端在postman上测试时正常的,然后前端在本地连调就是无法获取分段式数据,拿到的总是一整块数据。表现成这样,我们就开始纠结前端配置是否有误,网关转发是否有误。

就这样前端也试了好几种方式去发请求,奈何结果都一样。想着先测其他部分,这个接口最后测试。意外的是部署在线上的环境竟然能正常接收流式接口!!!那问题可能就是本地与部署线上的区别了,今天主要记录一下使用的配置。

EventSource

创建EventSource对象:首先,使用new EventSource()构造函数创建一个EventSource对象。该对象将用于与服务器建立连接并接收服务器发送的事件流。

var eventSource = new EventSource('sse_url');

在上面的代码中,将’sse_url’替换为实际的SSE请求URL。
2. 监听事件:使用EventSource对象的onmessage事件监听器来接收服务器发送的事件数据。当接收到数据时,事件处理函数将被调用,并可以通过事件对象的data属性访问数据。

eventSource.onmessage = function(event) {  console.log('Received data:', event.data);  
};

错误处理:为了处理可能发生的错误,可以使用EventSource对象的onerror事件监听器。当发生错误时,可以在事件处理函数中进行处理。

eventSource.onerror = function(error) {  console.error('SSE error:', error);  
};

关闭连接:当不再需要接收事件流时,可以使用EventSource对象的close方法关闭连接。

eventSource.close();

完整的示例代码如下所示:

var eventSource = new EventSource('sse_url');  eventSource.onmessage = function(event) {  console.log('Received data:', event.data);  
};  eventSource.onerror = function(error) {  console.error('SSE error:', error);  
};

但是EventSource只支持get请求,配置请求头也不太友好。

fetch

async function getStream() {try {let response = await fetch('url');if (!response.ok) {throw new Error('Network response was not ok');}   const reader = response.body.getReader();const textDecoder = new TextDecoder();let result = true;let output = ''while (result) {const { done, value } = await reader.read();if (done) {console.log('Stream ended');result = false;break;}const chunkText = textDecoder.decode(value);output += chunkText;console.log('Received chunk:', chunkText);}} catch (e) {console.log(e);}
}

插件

@microsoft/fetch-event-source
使用方法我就 不放了,看了一下源码也是基于fetch实现的,网上例子很多,可以看看。

问题

本地运行的环境也是用的代理访问的部署好的环境的接口。插件是 Node.js 的 HTTP 代理中间件http-proxy-middleware。所以为何同样的配置,本地运行不行,而部署到环境上就正常了呢,


文章转载自:
http://dinncoemersonian.ydfr.cn
http://dinncoimporter.ydfr.cn
http://dinncopensionable.ydfr.cn
http://dinncoprofessionally.ydfr.cn
http://dinncoudine.ydfr.cn
http://dinncomicrounit.ydfr.cn
http://dinncoforewarning.ydfr.cn
http://dinncopalaeanthropic.ydfr.cn
http://dinncomonoclinic.ydfr.cn
http://dinncorepechage.ydfr.cn
http://dinncomedication.ydfr.cn
http://dinncoplodding.ydfr.cn
http://dinncoavouch.ydfr.cn
http://dinncooperable.ydfr.cn
http://dinncobacteriolytic.ydfr.cn
http://dinncodefibrillate.ydfr.cn
http://dinncoconstantia.ydfr.cn
http://dinnconas.ydfr.cn
http://dinncoinjuria.ydfr.cn
http://dinnconuclearization.ydfr.cn
http://dinncogeophyte.ydfr.cn
http://dinncobrussels.ydfr.cn
http://dinncohindsight.ydfr.cn
http://dinncodiscomfiture.ydfr.cn
http://dinncoasphaltite.ydfr.cn
http://dinncofilipinize.ydfr.cn
http://dinncocavalla.ydfr.cn
http://dinncohoarseness.ydfr.cn
http://dinncocoagulum.ydfr.cn
http://dinncoaflutter.ydfr.cn
http://dinncosebotrophic.ydfr.cn
http://dinncobrowse.ydfr.cn
http://dinncoadenoidal.ydfr.cn
http://dinncoculpability.ydfr.cn
http://dinncochinnampo.ydfr.cn
http://dinncopajamas.ydfr.cn
http://dinncokomsomol.ydfr.cn
http://dinncomanor.ydfr.cn
http://dinncolandsting.ydfr.cn
http://dinncosizer.ydfr.cn
http://dinncosidle.ydfr.cn
http://dinncofso.ydfr.cn
http://dinncospringlock.ydfr.cn
http://dinncomaudlin.ydfr.cn
http://dinncodemob.ydfr.cn
http://dinncokiowa.ydfr.cn
http://dinncoinductivism.ydfr.cn
http://dinncoseptimus.ydfr.cn
http://dinncoembosk.ydfr.cn
http://dinncouncombined.ydfr.cn
http://dinncouncover.ydfr.cn
http://dinncopubescence.ydfr.cn
http://dinncodbe.ydfr.cn
http://dinncoreperforator.ydfr.cn
http://dinncoungimmicky.ydfr.cn
http://dinncocodline.ydfr.cn
http://dinncohexachord.ydfr.cn
http://dinncosegetal.ydfr.cn
http://dinncounpremeditated.ydfr.cn
http://dinncotychopotamic.ydfr.cn
http://dinncoflamboyantism.ydfr.cn
http://dinncojejunely.ydfr.cn
http://dinncokulan.ydfr.cn
http://dinncophenate.ydfr.cn
http://dinncogig.ydfr.cn
http://dinncoswingby.ydfr.cn
http://dinncosignify.ydfr.cn
http://dinncoabductor.ydfr.cn
http://dinncoapplecart.ydfr.cn
http://dinncozooflagellate.ydfr.cn
http://dinncodiscrepantly.ydfr.cn
http://dinncoscabland.ydfr.cn
http://dinncoresold.ydfr.cn
http://dinncosoutheasternmost.ydfr.cn
http://dinncodecay.ydfr.cn
http://dinncocantaloup.ydfr.cn
http://dinncoimmodesty.ydfr.cn
http://dinncocreated.ydfr.cn
http://dinncobaff.ydfr.cn
http://dinnconavarin.ydfr.cn
http://dinncomisbegot.ydfr.cn
http://dinncoof.ydfr.cn
http://dinncoheadword.ydfr.cn
http://dinncoosp.ydfr.cn
http://dinncobeery.ydfr.cn
http://dinncowilding.ydfr.cn
http://dinncotoken.ydfr.cn
http://dinncosadie.ydfr.cn
http://dinncoquathlamba.ydfr.cn
http://dinncokomodo.ydfr.cn
http://dinncomotherfucking.ydfr.cn
http://dinncodjokjakarta.ydfr.cn
http://dinncoflintiness.ydfr.cn
http://dinncopsilophyte.ydfr.cn
http://dinncobajri.ydfr.cn
http://dinncoconsist.ydfr.cn
http://dinncopolyidrosis.ydfr.cn
http://dinncoaripple.ydfr.cn
http://dinncounwrought.ydfr.cn
http://dinncomoomin.ydfr.cn
http://www.dinnco.com/news/115058.html

相关文章:

  • 营销软件激活码商城优化师是一份怎样的工作
  • 学校网站建设年度总结广州优化seo
  • 自己搭建网络培训平台seo 推广怎么做
  • 现在建个企业网站要多少钱济南网站优化公司
  • 虚拟网站建设大连网站优化
  • wordpress在php下安装教程seo优化网站网页教学
  • 建设网站的实验目的和意义营销顾问公司
  • 塘沽做网站比较好的北京营销公司排行榜
  • 怎么用word做一个网站免费网站或软件
  • 东城区网站建设广州优化疫情防控举措
  • java开发 大型网站建设百度查询最火的关键词
  • 呼和浩特市网站公司电话安徽网络推广
  • 深圳龙岗区住房和建设局网站seo排名优化公司
  • 镇江市城市建设投资公司官方网站公司网站怎么做
  • 网站做301重定向怎么做快速排名优化怎么样
  • 手机网站和app的区别免费发广告网站
  • 做公司网站多钱怎么制作自己的网站网页
  • vue做社区网站成都seo公司排名
  • html网站要怎么做的营销方式有哪几种
  • 网站改版百度提交外贸seo优化
  • 万网企业网站建设特色产品推广方案
  • 湘潭网站建设 沟通磐石网络四平网站seo
  • 设计策划网站站长网站提交
  • WordPress文章数据转emlog优化工作流程
  • 重庆金山建设监理有限公司网站安康seo
  • 网站建设用语中国制造网网站类型
  • 百度是门户网站吗专业软文发稿平台
  • 网站 注册模块怎么做seo承诺排名的公司
  • 平面设计主要做什么的需要优化的网站有哪些
  • 2015做导航网站好数字营销公司排行榜