mirror of
https://github.com/torappinfo/uweb.git
synced 2024-08-14 23:54:59 +00:00
sync bingAI
This commit is contained in:
parent
a81920a1a5
commit
577cf5c6f6
2 changed files with 107 additions and 113 deletions
|
@ -1,30 +1,12 @@
|
||||||
var expUrl = new RegExp('^(https?://)([-a-zA-z0-9]+\\.)+([-a-zA-z0-9]+)+\\S*$');
|
var expUrl = new RegExp('^(https?://)([-a-zA-z0-9]+\\.)+([-a-zA-z0-9]+)+\\S*$');
|
||||||
function timeString() {
|
|
||||||
var d = new Date();
|
|
||||||
var year = d.getFullYear();
|
|
||||||
var month = (d.getMonth() + 1).toString().padStart(2, "0");
|
|
||||||
var date = d.getDate().toString().padStart(2, "0");
|
|
||||||
var hour = d.getHours().toString().padStart(2, "0");
|
|
||||||
var minute = d.getMinutes().toString().padStart(2, "0");
|
|
||||||
var second = d.getSeconds().toString().padStart(2, "0");
|
|
||||||
var offset = "+08:00"; // 你可以根据需要修改这个值
|
|
||||||
var s = year + "-" + month + "-" + date + "T" + hour + ":" + minute + ":" + second + offset;
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getUuidNojian() {
|
function getUuidNojian() {
|
||||||
return URL.createObjectURL(new Blob()).split('/')[3].replace(/-/g, '');
|
return URL.createObjectURL(new Blob()).split('/')[3].replace(/-/g, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUuid() {
|
|
||||||
return URL.createObjectURL(new Blob()).split('/')[3];
|
|
||||||
}
|
|
||||||
|
|
||||||
class SendMessageManager {
|
class SendMessageManager {
|
||||||
//(会话id,客户端id,签名id,是否是开始)
|
//(会话id,客户端id,签名id,是否是开始)
|
||||||
//(string,string,string,boolena)
|
//(string,string,string,boolena)
|
||||||
constructor(conversationId, clientId, conversationSignature,invocationId) {
|
constructor(conversationId, clientId, conversationSignature,invocationId) {
|
||||||
this.startTime = timeString();
|
|
||||||
this.invocationId = invocationId==undefined?1:invocationId;
|
this.invocationId = invocationId==undefined?1:invocationId;
|
||||||
this.conversationId = conversationId;
|
this.conversationId = conversationId;
|
||||||
this.clientId = clientId;
|
this.clientId = clientId;
|
||||||
|
@ -53,80 +35,18 @@ class SendMessageManager {
|
||||||
}
|
}
|
||||||
//获取用于发送的聊天数据
|
//获取用于发送的聊天数据
|
||||||
//(WebSocket,sreing)
|
//(WebSocket,sreing)
|
||||||
sendChatMessage(chatWebSocket, chat) {
|
async sendChatMessage(chatWebSocket, chat) {
|
||||||
let pos = ['','','']; //initial 3 suggestions
|
let optionsSets = chatTypes[this.optionsSets];
|
||||||
let previousMessages = [{
|
|
||||||
"text": '',
|
|
||||||
"author": "bot",
|
|
||||||
"adaptiveCards": [],
|
|
||||||
"suggestedResponses": [{
|
|
||||||
"text": pos[0],
|
|
||||||
"contentOrigin": "DeepLeo",
|
|
||||||
"messageType": "Suggestion",
|
|
||||||
"messageId": getUuid(),
|
|
||||||
"offense": "Unknown"
|
|
||||||
}, {
|
|
||||||
"text": pos[1],
|
|
||||||
"contentOrigin": "DeepLeo",
|
|
||||||
"messageType": "Suggestion",
|
|
||||||
"messageId": getUuid(),
|
|
||||||
"offense": "Unknown"
|
|
||||||
}, {
|
|
||||||
"text": pos[2],
|
|
||||||
"contentOrigin": "DeepLeo",
|
|
||||||
"messageType": "Suggestion",
|
|
||||||
"messageId": getUuid(),
|
|
||||||
"offense": "Unknown"
|
|
||||||
}],
|
|
||||||
"messageId": getUuid(),
|
|
||||||
"messageType": "Chat"
|
|
||||||
}];
|
|
||||||
let json = {
|
let json = {
|
||||||
"arguments": [{
|
"arguments": [{
|
||||||
"source": "cib",
|
"source": source,
|
||||||
"optionsSets": this.optionsSets,
|
"optionsSets": optionsSets,
|
||||||
"allowedMessageTypes": allowedMessageTypes,
|
"allowedMessageTypes": allowedMessageTypes,
|
||||||
"sliceIds": sliceIds,
|
"sliceIds": sliceIds,
|
||||||
"verbosity": "verbose",
|
"verbosity": "verbose",
|
||||||
"traceId": getUuidNojian(),
|
"traceId": getUuidNojian(),
|
||||||
"isStartOfSession": (this.invocationId <= 1) ? true : false,
|
"isStartOfSession": (this.invocationId <= 1) ? true : false,
|
||||||
"message": {
|
"message": await generateMessages(this,chat),
|
||||||
"locale": "zh-CN",
|
|
||||||
"market": "zh-CN",
|
|
||||||
"region": "US",
|
|
||||||
"location": "lat:47.639557;long:-122.128159;re=1000m;",
|
|
||||||
"locationHints": [
|
|
||||||
{
|
|
||||||
"Center": {
|
|
||||||
"Latitude": 30.474109798833613,
|
|
||||||
"Longitude": 114.39626256171093
|
|
||||||
},
|
|
||||||
"RegionType": 2,
|
|
||||||
"SourceType": 11
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"country": "United States",
|
|
||||||
"state": "California",
|
|
||||||
"city": "Los Angeles",
|
|
||||||
"zipcode": "90060",
|
|
||||||
"timezoneoffset": -8,
|
|
||||||
"dma": 803,
|
|
||||||
"countryConfidence": 8,
|
|
||||||
"cityConfidence": 5,
|
|
||||||
"Center": {
|
|
||||||
"Latitude": 33.9757,
|
|
||||||
"Longitude": -118.2564
|
|
||||||
},
|
|
||||||
"RegionType": 2,
|
|
||||||
"SourceType": 1
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"timestamp": this.startTime,
|
|
||||||
"author": "user",
|
|
||||||
"inputMethod": "Keyboard",
|
|
||||||
"text": chat,
|
|
||||||
"messageType": "Chat"
|
|
||||||
},
|
|
||||||
"conversationSignature": this.conversationSignature,
|
"conversationSignature": this.conversationSignature,
|
||||||
"participant": {
|
"participant": {
|
||||||
"id": this.clientId
|
"id": this.clientId
|
||||||
|
@ -140,7 +60,6 @@ class SendMessageManager {
|
||||||
};
|
};
|
||||||
this.sendJson(chatWebSocket, json);
|
this.sendJson(chatWebSocket, json);
|
||||||
this.invocationId++;
|
this.invocationId++;
|
||||||
setLastInvocationId(this.invocationId);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,11 @@ let chatTypes = {
|
||||||
"responsible_ai_policy_235",
|
"responsible_ai_policy_235",
|
||||||
"enablemm",
|
"enablemm",
|
||||||
"h3imaginative",
|
"h3imaginative",
|
||||||
"jbf101",
|
"responseos",
|
||||||
"cachewriteext",
|
"cachewriteext",
|
||||||
"e2ecachewrite",
|
"e2ecachewrite",
|
||||||
"nodlcpcwrite",
|
"nodlcpcwrite",
|
||||||
|
"travelansgnd",
|
||||||
"dv3sugg",
|
"dv3sugg",
|
||||||
"clgalileo",
|
"clgalileo",
|
||||||
"gencontentv3"
|
"gencontentv3"
|
||||||
|
@ -24,31 +25,39 @@ let chatTypes = {
|
||||||
"responsible_ai_policy_235",
|
"responsible_ai_policy_235",
|
||||||
"enablemm",
|
"enablemm",
|
||||||
"galileo",
|
"galileo",
|
||||||
"jbf101",
|
"responseos",
|
||||||
"cachewriteext",
|
"cachewriteext",
|
||||||
"e2ecachewrite",
|
"e2ecachewrite",
|
||||||
"nodlcpcwrite",
|
"nodlcpcwrite",
|
||||||
"dv3sugg",
|
"travelansgnd",
|
||||||
"dlwebtrunc",
|
"dv3sugg"
|
||||||
"glpromptv6"
|
|
||||||
],
|
],
|
||||||
//精准选项
|
//精准选项
|
||||||
accurate: [
|
accurate: [
|
||||||
"nlu_direct_response_filter",
|
"chk1cf",
|
||||||
"deepleo",
|
"nopreloadsscf",
|
||||||
"disable_emoji_spoken_text",
|
"winlongmsg2tf",
|
||||||
"responsible_ai_policy_235",
|
"perfimpcomb",
|
||||||
"enablemm",
|
"sugdivdis",
|
||||||
"h3precise",
|
"sydnoinputt",
|
||||||
"clgalileo",
|
"wpcssopt",
|
||||||
"jbf101",
|
"wintone2tf",
|
||||||
"cachewriteext",
|
"0404sydicnbs0",
|
||||||
"e2ecachewrite",
|
"405suggbs0",
|
||||||
"nodlcpcwrite",
|
"scctl",
|
||||||
"dv3sugg"
|
"330uaugs0",
|
||||||
|
"0329resp",
|
||||||
|
"udscahrfon",
|
||||||
|
"udstrblm5",
|
||||||
|
"404e2ewrt",
|
||||||
|
"408nodedups0",
|
||||||
|
"403tvlansgnd"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//消息来源
|
||||||
|
let source = "cib";
|
||||||
|
|
||||||
//接收消息类型
|
//接收消息类型
|
||||||
let allowedMessageTypes = [
|
let allowedMessageTypes = [
|
||||||
"Chat",
|
"Chat",
|
||||||
|
@ -65,21 +74,87 @@ let allowedMessageTypes = [
|
||||||
|
|
||||||
//切片id,也不知道是啥意思,反正官网的更新了
|
//切片id,也不知道是啥意思,反正官网的更新了
|
||||||
let sliceIds = [
|
let sliceIds = [
|
||||||
"audseq",
|
"chk1cf",
|
||||||
"chk1cln",
|
"nopreloadsscf",
|
||||||
"nofbkcf",
|
"winlongmsg2tf",
|
||||||
"nosharepre",
|
"perfimpcomb",
|
||||||
"fixsacodecf",
|
"sugdivdis",
|
||||||
|
"sydnoinputt",
|
||||||
|
"wpcssopt",
|
||||||
|
"wintone2tf",
|
||||||
|
"0404sydicnbs0",
|
||||||
"405suggbs0",
|
"405suggbs0",
|
||||||
"scctl",
|
"scctl",
|
||||||
"403jbf101",
|
"330uaugs0",
|
||||||
"udstrclm8cmp",
|
"0329resp",
|
||||||
"udstrclm8",
|
"udscahrfon",
|
||||||
"329v6webtrunc",
|
"udstrblm5",
|
||||||
"404e2ewrt"
|
"404e2ewrt",
|
||||||
|
"408nodedups0",
|
||||||
|
"403tvlansgnd"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//生成消息对象
|
||||||
|
async function generateMessages(sendMessageManager/*消息管理器*/,chatMessageText/*要发送的消息文本*/){
|
||||||
|
function timeString() {
|
||||||
|
var d = new Date();
|
||||||
|
var year = d.getFullYear();
|
||||||
|
var month = (d.getMonth() + 1).toString().padStart(2, "0");
|
||||||
|
var date = d.getDate().toString().padStart(2, "0");
|
||||||
|
var hour = d.getHours().toString().padStart(2, "0");
|
||||||
|
var minute = d.getMinutes().toString().padStart(2, "0");
|
||||||
|
var second = d.getSeconds().toString().padStart(2, "0");
|
||||||
|
var offset = "+08:00"; // 你可以根据需要修改这个值
|
||||||
|
var s = year + "-" + month + "-" + date + "T" + hour + ":" + minute + ":" + second + offset;
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!sendMessageManager.startTime){
|
||||||
|
sendMessageManager.startTime = timeString();
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
"locale": "zh-CN",
|
||||||
|
"market": "zh-CN",
|
||||||
|
"region": "US",
|
||||||
|
"location": "lat:47.639557;long:-122.128159;re=1000m;",
|
||||||
|
"locationHints": [
|
||||||
|
{
|
||||||
|
"Center": {
|
||||||
|
"Latitude": 30.474109798833613,
|
||||||
|
"Longitude": 114.39626256171093
|
||||||
|
},
|
||||||
|
"RegionType": 2,
|
||||||
|
"SourceType": 11
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"country": "United States",
|
||||||
|
"state": "California",
|
||||||
|
"city": "Los Angeles",
|
||||||
|
"zipcode": "90060",
|
||||||
|
"timezoneoffset": -8,
|
||||||
|
"dma": 803,
|
||||||
|
"countryConfidence": 8,
|
||||||
|
"cityConfidence": 5,
|
||||||
|
"Center": {
|
||||||
|
"Latitude": 33.9757,
|
||||||
|
"Longitude": -118.2564
|
||||||
|
},
|
||||||
|
"RegionType": 2,
|
||||||
|
"SourceType": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"timestamp": sendMessageManager.startTime,
|
||||||
|
"author": "user",
|
||||||
|
"inputMethod": "Keyboard",
|
||||||
|
"text": chatMessageText,
|
||||||
|
"messageType": "Chat"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
async function getPreviousMessages(){
|
async function getPreviousMessages(){
|
||||||
function getUuid() {
|
function getUuid() {
|
||||||
return URL.createObjectURL(new Blob()).split('/')[3];
|
return URL.createObjectURL(new Blob()).split('/')[3];
|
||||||
|
|
Loading…
Reference in a new issue