isdata-customer-sdk 0.1.60 → 0.1.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.common.js +31 -24
- package/dist/index.common.js.map +1 -1
- package/dist/index.umd.js +31 -24
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +3 -3
- package/dist/index.umd.min.js.map +1 -1
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -30846,7 +30846,7 @@ class ChatClientMgr {
|
|
|
30846
30846
|
this.chatType = params.chatType || 0;
|
|
30847
30847
|
this.singleChatID = params.singleChatID || "";
|
|
30848
30848
|
this.chartOrigin = params.chartOrigin;
|
|
30849
|
-
this.charAIs = {};
|
|
30849
|
+
// this.charAIs = {};
|
|
30850
30850
|
}
|
|
30851
30851
|
makeKey(key) {
|
|
30852
30852
|
return `${key}-${this.actionKey}`;
|
|
@@ -30933,34 +30933,41 @@ class ChatClientMgr {
|
|
|
30933
30933
|
appSKID: this.appSKID,
|
|
30934
30934
|
onReady: this.onChatAIReady.bind(this)
|
|
30935
30935
|
});
|
|
30936
|
+
if (!this.chatAIClient.charAIs) {
|
|
30937
|
+
this.chatAIClient.charAIs = {};
|
|
30938
|
+
}
|
|
30936
30939
|
let robotInfos = await this.handler.getAIRobotInfos(this.userID, this.groupID);
|
|
30937
30940
|
if (robotInfos && robotInfos.length > 0) {
|
|
30938
30941
|
robotInfos.forEach(async robot => {
|
|
30939
30942
|
let robotKey = robot.id;
|
|
30940
|
-
|
|
30941
|
-
|
|
30942
|
-
|
|
30943
|
-
|
|
30944
|
-
|
|
30945
|
-
|
|
30946
|
-
|
|
30947
|
-
|
|
30948
|
-
|
|
30943
|
+
if (!this.chatAIClient.charAIs[robotKey]) {
|
|
30944
|
+
robot.chatID = robotKey;
|
|
30945
|
+
let userSig = await this.handler.getPortalUserSig(robotKey, this.imType, this.groupID);
|
|
30946
|
+
if (!userSig) {
|
|
30947
|
+
let sigIDObject = this.handler.genTestUserSig({
|
|
30948
|
+
SDKAppID: this.appSKID,
|
|
30949
|
+
userID: robotKey
|
|
30950
|
+
});
|
|
30951
|
+
userSig = sigIDObject.userSig;
|
|
30952
|
+
await this.handler.addIMMapping(robotKey, this.imType, userSig, this.groupID);
|
|
30953
|
+
}
|
|
30954
|
+
robot.userSig = userSig;
|
|
30955
|
+
this.chatAIClient.charAIs[robotKey] = {
|
|
30956
|
+
robot: robot,
|
|
30957
|
+
messageCache: []
|
|
30958
|
+
};
|
|
30949
30959
|
}
|
|
30950
|
-
robot.userSig = userSig;
|
|
30951
|
-
this.charAIs[robotKey] = {
|
|
30952
|
-
robot: robot,
|
|
30953
|
-
messageCache: []
|
|
30954
|
-
};
|
|
30955
30960
|
});
|
|
30956
30961
|
}
|
|
30957
30962
|
}
|
|
30958
30963
|
onChatAIReady(event) {
|
|
30959
|
-
let robotID = this.lastRobotID;
|
|
30964
|
+
let robotID = this.chatAIClient.lastRobotID;
|
|
30960
30965
|
let robotInfo = this.getAIRobotInfoByID(robotID);
|
|
30961
30966
|
console.log(`[AI chat] ${robotInfo.name}已经就绪:`, event);
|
|
30962
30967
|
if (this.chatAIClient) {
|
|
30963
30968
|
let messages = this.getAIRobotCacheMessagesByID(robotID);
|
|
30969
|
+
console.log(`[AI chat] ${robotInfo.name}就绪后查到的缓存信息:`, messages);
|
|
30970
|
+
console.log(`[AI chat] ${robotInfo.name}所有信息仓:`, this.chatAIClient.charAIs);
|
|
30964
30971
|
if (messages && messages.length > 0) {
|
|
30965
30972
|
const newMessages = [...messages];
|
|
30966
30973
|
messages.splice(0, messages.length);
|
|
@@ -30973,22 +30980,22 @@ class ChatClientMgr {
|
|
|
30973
30980
|
}
|
|
30974
30981
|
getAIRobotInfos() {
|
|
30975
30982
|
let resultRobots = [];
|
|
30976
|
-
for (let key in this.charAIs) {
|
|
30977
|
-
resultRobots.push(this.charAIs[key].robot);
|
|
30983
|
+
for (let key in this.chatAIClient.charAIs) {
|
|
30984
|
+
resultRobots.push(this.chatAIClient.charAIs[key].robot);
|
|
30978
30985
|
}
|
|
30979
30986
|
return resultRobots;
|
|
30980
30987
|
}
|
|
30981
30988
|
getAIRobotInfoByID(robotID) {
|
|
30982
|
-
return this.charAIs[robotID] ? this.charAIs[robotID].robot : null;
|
|
30989
|
+
return this.chatAIClient.charAIs[robotID] ? this.chatAIClient.charAIs[robotID].robot : null;
|
|
30983
30990
|
}
|
|
30984
30991
|
getAIRobotCacheMessagesByID(robotID) {
|
|
30985
|
-
return this.charAIs[robotID] ? this.charAIs[robotID].messageCache : [];
|
|
30992
|
+
return this.chatAIClient.charAIs[robotID] ? this.chatAIClient.charAIs[robotID].messageCache : [];
|
|
30986
30993
|
}
|
|
30987
30994
|
async sendMessageToChatServer(robotID, messageOption) {
|
|
30988
30995
|
let robotInfo = this.getAIRobotInfoByID(robotID);
|
|
30989
|
-
if (this.lastRobotID != robotID) {
|
|
30996
|
+
if (this.chatAIClient.lastRobotID != robotID) {
|
|
30990
30997
|
console.log(`[AI chat]需要新机器人回答,切换到新机器人${robotInfo.name}`);
|
|
30991
|
-
if (this.lastRobotID) {
|
|
30998
|
+
if (this.chatAIClient.lastRobotID) {
|
|
30992
30999
|
await this.chatAIClient.logout();
|
|
30993
31000
|
}
|
|
30994
31001
|
await this.chatAIClient.login({
|
|
@@ -30996,7 +31003,7 @@ class ChatClientMgr {
|
|
|
30996
31003
|
userSig: robotInfo.userSig
|
|
30997
31004
|
});
|
|
30998
31005
|
}
|
|
30999
|
-
this.lastRobotID = robotID;
|
|
31006
|
+
this.chatAIClient.lastRobotID = robotID;
|
|
31000
31007
|
if (this.chatAIClient && this.chatAIClient.isReady()) {
|
|
31001
31008
|
let new_message = await this.chatAIClient.createTextMessage(messageOption);
|
|
31002
31009
|
this.chatAIClient.sendMessage(new_message).then(res => {
|
|
@@ -31005,9 +31012,9 @@ class ChatClientMgr {
|
|
|
31005
31012
|
console.log(`[AI chat]${robotInfo.name}发送失败`, err);
|
|
31006
31013
|
});
|
|
31007
31014
|
} else {
|
|
31008
|
-
console.log(`[AI chat]${robotInfo.name}未就绪,缓存消息:`, messageOption);
|
|
31009
31015
|
let messageCache = this.getAIRobotCacheMessagesByID(robotID);
|
|
31010
31016
|
messageCache.push(messageOption);
|
|
31017
|
+
console.log(`[AI chat]${robotInfo.name}未就绪,缓存后消息:`, messageCache);
|
|
31011
31018
|
}
|
|
31012
31019
|
}
|
|
31013
31020
|
converToAIServerParams(message, robotInfo, param) {
|