isdata-customer-sdk 0.1.61 → 0.1.63

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}`;
@@ -30926,32 +30926,46 @@ class ChatClientMgr {
30926
30926
  });
30927
30927
  }
30928
30928
  getChatTypeKey(type) {
30929
- return type == 1 ? "IM_SINGLE_MODE" : "IM_MULTIPLE_MODE";
30929
+ switch (type) {
30930
+ case 0:
30931
+ return "IM_MULTIPLE_MODE";
30932
+ case 1:
30933
+ return "IM_SINGLE_MODE";
30934
+ case 2:
30935
+ return "IM_EMBED_MODE";
30936
+ default:
30937
+ return "IM_MULTIPLE_MODE";
30938
+ }
30930
30939
  }
30931
30940
  async initChatAIs() {
30932
30941
  this.chatAIClient = await this.handler.getChatClient({
30933
30942
  appSKID: this.appSKID,
30934
30943
  onReady: this.onChatAIReady.bind(this)
30935
30944
  });
30945
+ if (!this.chatAIClient.charAIs) {
30946
+ this.chatAIClient.charAIs = {};
30947
+ }
30936
30948
  let robotInfos = await this.handler.getAIRobotInfos(this.userID, this.groupID);
30937
30949
  if (robotInfos && robotInfos.length > 0) {
30938
30950
  robotInfos.forEach(async robot => {
30939
30951
  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);
30952
+ if (!this.chatAIClient.charAIs[robotKey]) {
30953
+ robot.chatID = robotKey;
30954
+ let userSig = await this.handler.getPortalUserSig(robotKey, this.imType, this.groupID);
30955
+ if (!userSig) {
30956
+ let sigIDObject = this.handler.genTestUserSig({
30957
+ SDKAppID: this.appSKID,
30958
+ userID: robotKey
30959
+ });
30960
+ userSig = sigIDObject.userSig;
30961
+ await this.handler.addIMMapping(robotKey, this.imType, userSig, this.groupID);
30962
+ }
30963
+ robot.userSig = userSig;
30964
+ this.chatAIClient.charAIs[robotKey] = {
30965
+ robot: robot,
30966
+ messageCache: []
30967
+ };
30949
30968
  }
30950
- robot.userSig = userSig;
30951
- this.charAIs[robotKey] = {
30952
- robot: robot,
30953
- messageCache: []
30954
- };
30955
30969
  });
30956
30970
  }
30957
30971
  }
@@ -30961,6 +30975,8 @@ class ChatClientMgr {
30961
30975
  console.log(`[AI chat] ${robotInfo.name}已经就绪:`, event);
30962
30976
  if (this.chatAIClient) {
30963
30977
  let messages = this.getAIRobotCacheMessagesByID(robotID);
30978
+ console.log(`[AI chat] ${robotInfo.name}就绪后查到的缓存信息:`, messages);
30979
+ console.log(`[AI chat] ${robotInfo.name}所有信息仓:`, this.chatAIClient.charAIs);
30964
30980
  if (messages && messages.length > 0) {
30965
30981
  const newMessages = [...messages];
30966
30982
  messages.splice(0, messages.length);
@@ -30973,16 +30989,16 @@ class ChatClientMgr {
30973
30989
  }
30974
30990
  getAIRobotInfos() {
30975
30991
  let resultRobots = [];
30976
- for (let key in this.charAIs) {
30977
- resultRobots.push(this.charAIs[key].robot);
30992
+ for (let key in this.chatAIClient.charAIs) {
30993
+ resultRobots.push(this.chatAIClient.charAIs[key].robot);
30978
30994
  }
30979
30995
  return resultRobots;
30980
30996
  }
30981
30997
  getAIRobotInfoByID(robotID) {
30982
- return this.charAIs[robotID] ? this.charAIs[robotID].robot : null;
30998
+ return this.chatAIClient.charAIs[robotID] ? this.chatAIClient.charAIs[robotID].robot : null;
30983
30999
  }
30984
31000
  getAIRobotCacheMessagesByID(robotID) {
30985
- return this.charAIs[robotID] ? this.charAIs[robotID].messageCache : [];
31001
+ return this.chatAIClient.charAIs[robotID] ? this.chatAIClient.charAIs[robotID].messageCache : [];
30986
31002
  }
30987
31003
  async sendMessageToChatServer(robotID, messageOption) {
30988
31004
  let robotInfo = this.getAIRobotInfoByID(robotID);
@@ -31005,9 +31021,9 @@ class ChatClientMgr {
31005
31021
  console.log(`[AI chat]${robotInfo.name}发送失败`, err);
31006
31022
  });
31007
31023
  } else {
31008
- console.log(`[AI chat]${robotInfo.name}未就绪,缓存消息:`, messageOption);
31009
31024
  let messageCache = this.getAIRobotCacheMessagesByID(robotID);
31010
31025
  messageCache.push(messageOption);
31026
+ console.log(`[AI chat]${robotInfo.name}未就绪,缓存后消息:`, messageCache);
31011
31027
  }
31012
31028
  }
31013
31029
  converToAIServerParams(message, robotInfo, param) {