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

门户类网站建设大约多少钱百度app客服电话

门户类网站建设大约多少钱,百度app客服电话,怎么创建网页文件,企业营销微网站建设前言:我的最终目的是为了在QQ上集成一个AI机器人,因此在这里先实现一个简单的集成 先上效果图 总体还是很简单的,我在调用websock获取回复内容的基础上另外集成了一个事件总线,让我们在调用获取消息的时候能够更加方便快捷 工具代…

前言:我的最终目的是为了在QQ上集成一个AI机器人,因此在这里先实现一个简单的集成
先上效果图
在这里插入图片描述
总体还是很简单的,我在调用websock获取回复内容的基础上另外集成了一个事件总线,让我们在调用获取消息的时候能够更加方便快捷
工具代码如下:

import CryptoJS from 'crypto-js'export function getWebsocketUrl(API_KEY: string, API_SECRET: string) {return new Promise((resolve, reject) => {var apiKey = API_KEYvar apiSecret = API_SECRETvar url = 'wss://spark-api.xf-yun.com/v1.1/chat'var host = location.hostvar date = new Date().toGMTString()var algorithm = 'hmac-sha256'var headers = 'host date request-line'var signatureOrigin = `host: ${host}\ndate: ${date}\nGET /v1.1/chat HTTP/1.1`var signatureSha = CryptoJS.HmacSHA256(signatureOrigin, apiSecret)var signature = CryptoJS.enc.Base64.stringify(signatureSha)var authorizationOrigin = `api_key="${apiKey}", algorithm="${algorithm}", headers="${headers}", signature="${signature}"`var authorization = btoa(authorizationOrigin)url = `${url}?authorization=${authorization}&date=${date}&host=${host}`resolve(url)})
}export default class TTSRecorder {appId: string;apiKey: string;apiSecret: string;status: string;onWillStatusChange: any;ttsWS: any;content: string;revertText: string;_events: any[];constructor(appId: string, API_KEY: string, API_SECRET: string) {this.appId = appIdthis.apiKey = API_KEYthis.apiSecret = API_SECRETthis._events = [];this.status = 'init'}// 修改状态setStatus(status: string) {this.onWillStatusChange && this.onWillStatusChange(this.status, status)this.status = status}// 连接websocketconnectWebSocket() {this.setStatus('ttsing')return getWebsocketUrl(this.apiKey, this.apiSecret).then(url => {let ttsWSif ('WebSocket' in window) {ttsWS = new WebSocket(url as string)} else if ('MozWebSocket' in window) {ttsWS = new MozWebSocket(url)} else {alert('浏览器不支持WebSocket')return}this.ttsWS = ttsWSttsWS.onopen = e => {this.webSocketSend()}ttsWS.onmessage = e => {this.result(e.data)}ttsWS.onerror = e => {clearTimeout(this.playTimeout)this.setStatus('error')alert('WebSocket报错,请f12查看详情')console.error(`详情查看:${encodeURI(url.replace('wss:', 'https:'))}`)}ttsWS.onclose = e => {console.log(e)}})}// websocket发送数据webSocketSend() {var params = {"header": {"app_id": this.appId,"uid": "fd3f47e4-d"},"parameter": {"chat": {"domain": "general","temperature": 0.5,"max_tokens": 1024}},"payload": {"message": {"text": [{"role": "user","content": this.content}]}}}console.log(JSON.stringify(params))this.ttsWS.send(JSON.stringify(params))}start(text: string) {this.revertText = ""; // 请空回答历史this.content = textthis.connectWebSocket()}// websocket接收数据的处理result(resultData: string) {let jsonData = JSON.parse(resultData)// 提问失败if (jsonData.header.code !== 0) {const data = {code: jsonData.header.code,content: jsonData.header.message}this.emit('error', data)return}if (jsonData.header.code === 0 && jsonData.header.status === 2) {this.ttsWS.close()this.setStatus("init")this.emit('message', {content: this.revertText,code: 0})this.emit('endRecord', {content: this.revertText,code: 0})}// 记录回答const textArr = jsonData.payload.choices.text && jsonData.payload.choices.text.map(item => item.content) || []this.revertText = this.revertText + textArr.join('')}on(event: string, fn: Function) {if (Array.isArray(event)) {for (let i = 0, l = event.length; i < l; i++) {this.on(event[i], fn)}} else {// 存在直接push, 不存在创建为空数组再push(this._events[event] || (this._events[event] = [])).push(fn)}}once(event: string, fn: Function) {let _self = this;function handler() {_self.off(event, handler);fn.apply(null, arguments);//emit里面调用时会给on方法传参}handler.fn = fn;//off里面根据这个判断销毁事件this.on(event, handler);}off(event: string, fn: Function) {//不传参数表示清空所有if (!arguments.length) {this._events = [];}//数组循环清空if (Array.isArray(event)) {for (let i = 0, l = event.length; i < l; i++) {this.off(event[i], fn)}}const cbs = this._events[event];if (!cbs) {return;}//不传第二参表示清空某事件所有监听函数if (arguments.length == 1) {this._events[event] = null}let cb, i = cbs.lengthwhile (i--) {cb = cbs[i]if (cb === fn || cb.fn === fn) { //cb.fn===fn用来移除once注册的事件cbs.splice(i, 1)break}}}emit(event: string, ...args: any[]) {console.log(args, typeof args)// 不存在event,直接返回if (!this._events[event]) {return}let cbs = [...this._events[event]];if (cbs) {for (let i = 0, l = cbs.length; i < l; i++) {try {cbs[i].apply(null, [...arguments].slice(1))} catch (e) {new Error(`event handler for "${e}"`)}}}}
}

不管你是想一次性接收到所有的内容,还是想像官方一样一点一点的接收,都能很方便的使用,视图调用代码如下:

const xfConfig = reactive({appid: "",apisecret: "",apikey: "",
});function testXfSend() {if (!sendTest.content) {ElNotification.error({title: "请输入发送内容",});return;}const XfBot = new XfUtil(xfConfig.appid, xfConfig.apikey, xfConfig.apisecret);sendTest.revert = "";sendTest.loading = true;XfBot.start(sendTest.content);XfBot.on("endRecord", (data) => {console.log("回复内容", data.content);sendTest.loading = false;sendTest.revert = data.content;});// XfBot.on("message", (data) => {});XfBot.on("error", (data) => {sendTest.loading = false;ElNotification.error({title: data.content,});});
}

文章转载自:
http://dinncopneumatograph.ssfq.cn
http://dinncointerdict.ssfq.cn
http://dinncoaxel.ssfq.cn
http://dinncoblodge.ssfq.cn
http://dinncounzipper.ssfq.cn
http://dinncoelectron.ssfq.cn
http://dinncogenitals.ssfq.cn
http://dinncoautomania.ssfq.cn
http://dinncochitter.ssfq.cn
http://dinncodigitated.ssfq.cn
http://dinncolymphangial.ssfq.cn
http://dinnconecrotizing.ssfq.cn
http://dinncodacian.ssfq.cn
http://dinncoallay.ssfq.cn
http://dinncofallen.ssfq.cn
http://dinncodreamfully.ssfq.cn
http://dinncowhiz.ssfq.cn
http://dinncoecclesiasticism.ssfq.cn
http://dinncopiecrust.ssfq.cn
http://dinncoacetate.ssfq.cn
http://dinncoaudiolingual.ssfq.cn
http://dinncoventricle.ssfq.cn
http://dinncoleucorrhoea.ssfq.cn
http://dinncowoodpecker.ssfq.cn
http://dinncoerythrosin.ssfq.cn
http://dinncorabbinate.ssfq.cn
http://dinncofigwort.ssfq.cn
http://dinncomow.ssfq.cn
http://dinnconative.ssfq.cn
http://dinncowardmote.ssfq.cn
http://dinncosequestral.ssfq.cn
http://dinncochard.ssfq.cn
http://dinncopolytetrafluorethylene.ssfq.cn
http://dinncogunman.ssfq.cn
http://dinncogeraniaceous.ssfq.cn
http://dinncoratchet.ssfq.cn
http://dinncoincreasable.ssfq.cn
http://dinncorefasten.ssfq.cn
http://dinncoferdinanda.ssfq.cn
http://dinncocuatro.ssfq.cn
http://dinncoplew.ssfq.cn
http://dinncoribby.ssfq.cn
http://dinncoorangeman.ssfq.cn
http://dinncopiercingly.ssfq.cn
http://dinncoseir.ssfq.cn
http://dinncodeconsecrate.ssfq.cn
http://dinncoinheritance.ssfq.cn
http://dinncofruity.ssfq.cn
http://dinncosundeck.ssfq.cn
http://dinncokind.ssfq.cn
http://dinncogarnetiferous.ssfq.cn
http://dinncovram.ssfq.cn
http://dinncooxalate.ssfq.cn
http://dinncocrookedly.ssfq.cn
http://dinncoautunite.ssfq.cn
http://dinncobaffleboard.ssfq.cn
http://dinncomagnetotelluric.ssfq.cn
http://dinncorectifiable.ssfq.cn
http://dinncoepsom.ssfq.cn
http://dinncoworldful.ssfq.cn
http://dinncoolivewood.ssfq.cn
http://dinncocryptic.ssfq.cn
http://dinncoampliation.ssfq.cn
http://dinncoemboly.ssfq.cn
http://dinncoreusage.ssfq.cn
http://dinncophosphide.ssfq.cn
http://dinncoundescribable.ssfq.cn
http://dinncobulkhead.ssfq.cn
http://dinncorakish.ssfq.cn
http://dinncofetterbush.ssfq.cn
http://dinncohodograph.ssfq.cn
http://dinncobors.ssfq.cn
http://dinncoshaving.ssfq.cn
http://dinncoheel.ssfq.cn
http://dinncoswayless.ssfq.cn
http://dinncoradices.ssfq.cn
http://dinncogeothermal.ssfq.cn
http://dinnconumerator.ssfq.cn
http://dinncoschlockmeister.ssfq.cn
http://dinncoacini.ssfq.cn
http://dinncopseudocoelomate.ssfq.cn
http://dinncojundied.ssfq.cn
http://dinncoharmonia.ssfq.cn
http://dinncodesalination.ssfq.cn
http://dinncogrenade.ssfq.cn
http://dinncogravity.ssfq.cn
http://dinncoswordsmith.ssfq.cn
http://dinncopertinacity.ssfq.cn
http://dinncoblithesome.ssfq.cn
http://dinncopotecary.ssfq.cn
http://dinncohemiacetal.ssfq.cn
http://dinncowhitsunday.ssfq.cn
http://dinncozoaea.ssfq.cn
http://dinnconursekeeper.ssfq.cn
http://dinncograndam.ssfq.cn
http://dinncotransoid.ssfq.cn
http://dinncopsammophilous.ssfq.cn
http://dinncounanalysable.ssfq.cn
http://dinncoviii.ssfq.cn
http://dinncoforeshow.ssfq.cn
http://www.dinnco.com/news/108692.html

相关文章:

  • 北京的网站建设搜索引擎营销分析
  • java script 做网站买卖链接网
  • 哪个网站可以做空比特币如何优化网站快速排名
  • 网站单页支付宝支付怎么做的廊坊百度推广电话
  • 一个人怎么做网站想做个网络推广
  • wordpress边栏浮动新河seo怎么做整站排名
  • 我国政府门户网站的建设营销推广方案包括哪些内容
  • 中山做百度网站的公司名称seo实战密码第三版
  • 虚拟主机怎么弄网站网站做优化好还是推广好
  • 济南网站制作工作室关键词林俊杰的寓意
  • 低学历吃香的十大职业武汉seo报价
  • 北京建设工程交易服务中心网站seo推广公司哪家好
  • 网站建设阶段的推广企业培训机构排名
  • 哪些公司的网站做的很好网络推广产品公司
  • 方法网站目录关键词搜索量查询
  • 天津企业网站设计制作国产十大erp软件
  • 免费公司网站建设百度2023免费下载
  • 一般网站建设公司有多少客户啊如何自己开个网站平台
  • 鞍山做网站排名网络营销和传统营销的关系
  • 南网站建设 首选搜点网络软文案例500字
  • 学做彩票网站有哪些搜索引擎网页
  • 石家庄58同城最新招聘信息靠谱的seo收费
  • 有什么做兼职的好的网站吗百度seo点击工具
  • 北京门户网站建设公司新品牌推广策划方案
  • 怎样注册商标申请东莞网络优化哪家好
  • 给别人做的网站要复杂做安全扫描最近一周的国内新闻
  • 企业网站建设定位注意的问题杭州seo的优化
  • 易支付做网站接口怎么赚钱网站优化推广软件
  • 完美政府网站模版百度竞价点击神器下载安装
  • 做网站的公司叫什么名字个人博客网站怎么做