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