isdata-customer-sdk 0.1.61 → 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.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,25 +30933,30 @@ 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
- robot.chatID = robotKey;
30941
- let userSig = await this.handler.getPortalUserSig(robotKey, this.imType, this.groupID);
30942
- if (!userSig) {
30943
- let sigIDObject = this.handler.genTestUserSig({
30944
- SDKAppID: this.appSKID,
30945
- userID: robotKey
30946
- });
30947
- userSig = sigIDObject.userSig;
30948
- await this.handler.addIMMapping(robotKey, this.imType, userSig, this.groupID);
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
  }
@@ -30961,6 +30966,8 @@ class ChatClientMgr {
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,16 +30980,16 @@ 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);
@@ -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) {