@hivegpt/hiveai-angular 0.0.231 → 0.0.233

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.
@@ -666,8 +666,7 @@
666
666
  ]; };
667
667
 
668
668
  var ChatDrawerComponent = /** @class */ (function () {
669
- function ChatDrawerComponent(cdr, http, sanitizer, elementRef, renderer, socketService, conversationService
670
- // private platform: Platform
669
+ function ChatDrawerComponent(cdr, http, sanitizer, elementRef, renderer, socketService, conversationService // private platform: Platform
671
670
  ) {
672
671
  var _this = this;
673
672
  this.cdr = cdr;
@@ -679,7 +678,7 @@
679
678
  this.conversationService = conversationService;
680
679
  this.bodyOverflowClass = 'body-overflow-hidden';
681
680
  this.isCollapsedTrue = false;
682
- this.copilotName = "HiveXGPT";
681
+ this.copilotName = 'HiveXGPT';
683
682
  this.feedbackEvent = new i0.EventEmitter();
684
683
  this.onCloseEvent = new i0.EventEmitter();
685
684
  this.openPage = new i0.EventEmitter();
@@ -688,10 +687,10 @@
688
687
  this.connectWithUser = new i0.EventEmitter();
689
688
  this.scheduleMeeting = new i0.EventEmitter();
690
689
  this.refreshToken = new i0.EventEmitter();
691
- this.autogenKey = "Autogen_eDJTtEU-NB0RtIpzq1w";
692
- this.addToMyAgendaAction = "add_to_my_agenda";
693
- this.myUpcomingSessionAction = "my_upcomming_session";
694
- this.connectOrFollowAction = "connect_or_follow";
690
+ this.autogenKey = 'Autogen_eDJTtEU-NB0RtIpzq1w';
691
+ this.addToMyAgendaAction = 'add_to_my_agenda';
692
+ this.myUpcomingSessionAction = 'my_upcomming_session';
693
+ this.connectOrFollowAction = 'connect_or_follow';
695
694
  this.aiResponse = '';
696
695
  this.chatLog = [];
697
696
  this.decoder = new TextDecoder();
@@ -816,7 +815,6 @@
816
815
  }, 200);
817
816
  };
818
817
  ChatDrawerComponent.prototype.initializeSocket = function () {
819
- ;
820
818
  var conversation_id = this.conversationService.getKey(this.botId);
821
819
  this.socketService.registerUserSpecificHiveSocket(this.botId, conversation_id);
822
820
  };
@@ -855,7 +853,8 @@
855
853
  if (answer) {
856
854
  _this.isChatingWithAi = false;
857
855
  console.log('Answer:', answer);
858
- currentChatMessage.message = _this.processMessageForDisplay(answer);
856
+ currentChatMessage.message =
857
+ _this.processMessageForDisplay(answer);
859
858
  _this.cdr.markForCheck();
860
859
  _this.scrollToBottom();
861
860
  }
@@ -885,8 +884,7 @@
885
884
  console.error('Error in fetching data from socket', err);
886
885
  });
887
886
  };
888
- ChatDrawerComponent.prototype.initializeSocketAndListen = function () {
889
- };
887
+ ChatDrawerComponent.prototype.initializeSocketAndListen = function () { };
890
888
  ChatDrawerComponent.prototype.handleEvent = function (data, type) {
891
889
  switch (type) {
892
890
  case 'webresult':
@@ -980,9 +978,11 @@
980
978
  this.conversationKey = this.conversationService.getKey(this.botId);
981
979
  var url = this.environment.BASE_URL + "/conversations/" + this.conversationKey;
982
980
  var headers = new http.HttpHeaders({
983
- 'accept': 'application/json'
981
+ accept: 'application/json',
984
982
  });
985
- return this.http.get(url, { headers: headers }).pipe(operators.catchError(this.handleError('fetchConversation')));
983
+ return this.http
984
+ .get(url, { headers: headers })
985
+ .pipe(operators.catchError(this.handleError('fetchConversation')));
986
986
  };
987
987
  ChatDrawerComponent.prototype.handleError = function (operation, result) {
988
988
  if (operation === void 0) { operation = 'operation'; }
@@ -1022,16 +1022,16 @@
1022
1022
  });
1023
1023
  if (chats && ((_a = chats === null || chats === void 0 ? void 0 : chats.Messages) === null || _a === void 0 ? void 0 : _a.length)) {
1024
1024
  chats === null || chats === void 0 ? void 0 : chats.Messages.forEach(function (chat) {
1025
- if (chat.Type == "user") {
1025
+ if (chat.Type == 'user') {
1026
1026
  _this.chatLog.push({
1027
1027
  type: 'user',
1028
1028
  message: _this.processMessageForDisplay(chat.Text),
1029
1029
  time: formatTimeStamps(_this.timezone, chat.InsertTimestamp),
1030
1030
  copied: false,
1031
- isCollapsedTrue: false
1031
+ isCollapsedTrue: false,
1032
1032
  });
1033
1033
  }
1034
- if (chat.Type == "ai") {
1034
+ if (chat.Type == 'ai') {
1035
1035
  var sourcesList = chat.WebLinks || [];
1036
1036
  var displayedSources = chat.WebLinks.slice(0, 3); // First 3 cards
1037
1037
  var remainingSources = chat.WebLinks.slice(3); // Remaining items
@@ -1046,7 +1046,7 @@
1046
1046
  remainingSources: remainingSources,
1047
1047
  time: formatTimeStamps(_this.timezone, chat.InsertTimestamp),
1048
1048
  copied: false,
1049
- isCollapsedTrue: false
1049
+ isCollapsedTrue: false,
1050
1050
  });
1051
1051
  _this.showFeedBackIconsIndex = _this.chatLog.length - 1;
1052
1052
  }
@@ -1127,15 +1127,14 @@
1127
1127
  message: this.processMessageForDisplay(this.input),
1128
1128
  time: formatNow(this.timezone),
1129
1129
  copied: false,
1130
- isCollapsedTrue: false
1130
+ isCollapsedTrue: false,
1131
1131
  });
1132
1132
  try {
1133
1133
  var textarea = this.myInput.nativeElement;
1134
1134
  textarea.style.height = 'hidden'; // Reset the height
1135
1135
  textarea.style.height = "62px";
1136
1136
  }
1137
- catch (error) {
1138
- }
1137
+ catch (error) { }
1139
1138
  this.cdr.markForCheck();
1140
1139
  this.aiResponse = '';
1141
1140
  this.isChatingWithAi = true;
@@ -1145,7 +1144,7 @@
1145
1144
  method: 'POST',
1146
1145
  headers: {
1147
1146
  'Content-Type': 'application/json',
1148
- 'Authorization': 'Bearer ' + this.s27Token,
1147
+ Authorization: 'Bearer ' + this.s27Token,
1149
1148
  'x-api-key': this.apiKey,
1150
1149
  },
1151
1150
  body: JSON.stringify({
@@ -1194,7 +1193,7 @@
1194
1193
  message: this.processMessageForDisplay(inputMsg),
1195
1194
  time: formatNow(this.timezone),
1196
1195
  copied: false,
1197
- isCollapsedTrue: false
1196
+ isCollapsedTrue: false,
1198
1197
  });
1199
1198
  this.cdr.markForCheck();
1200
1199
  this.aiResponse = '';
@@ -1205,7 +1204,7 @@
1205
1204
  method: 'POST',
1206
1205
  headers: {
1207
1206
  'Content-Type': 'application/json',
1208
- 'Authorization': 'Bearer ' + this.s27Token,
1207
+ Authorization: 'Bearer ' + this.s27Token,
1209
1208
  'x-api-key': this.apiKey,
1210
1209
  },
1211
1210
  body: JSON.stringify({
@@ -1287,7 +1286,7 @@
1287
1286
  if (allSuggestions === null || allSuggestions === void 0 ? void 0 : allSuggestions.length) {
1288
1287
  _this.chatLog.push({
1289
1288
  type: 'suggestions',
1290
- suggestions: allSuggestions
1289
+ suggestions: allSuggestions,
1291
1290
  });
1292
1291
  }
1293
1292
  controller.close();
@@ -1306,8 +1305,8 @@
1306
1305
  var suggestionsMatch = _this.aiResponse.match(/<sug>(.*?)<\/sug>/g);
1307
1306
  if (suggestionsMatch) {
1308
1307
  suggestionsMatch.forEach(function (match) {
1309
- _this.aiResponse = _this.aiResponse.replace(match, "");
1310
- allSuggestions.push(match === null || match === void 0 ? void 0 : match.replace(/<\/?sug>/g, ""));
1308
+ _this.aiResponse = _this.aiResponse.replace(match, '');
1309
+ allSuggestions.push(match === null || match === void 0 ? void 0 : match.replace(/<\/?sug>/g, ''));
1311
1310
  });
1312
1311
  }
1313
1312
  lastItem.message = _this.aiResponse;
@@ -1329,7 +1328,9 @@
1329
1328
  }
1330
1329
  console.log('parsing json done');
1331
1330
  if (aiFormattedData && ((_a = aiFormattedData === null || aiFormattedData === void 0 ? void 0 : aiFormattedData.section_id) === null || _a === void 0 ? void 0 : _a.length) > 0) {
1332
- if (aiFormattedData.section_id == 'company_search' || aiFormattedData.section_id == 'user_search' || aiFormattedData.section_id == 'industry_company_search') {
1331
+ if (aiFormattedData.section_id == 'company_search' ||
1332
+ aiFormattedData.section_id == 'user_search' ||
1333
+ aiFormattedData.section_id == 'industry_company_search') {
1333
1334
  _this.fetchMyConnections().subscribe();
1334
1335
  _this.fetchPendingRequests().subscribe();
1335
1336
  }
@@ -1341,48 +1342,50 @@
1341
1342
  if ((speakerIds === null || speakerIds === void 0 ? void 0 : speakerIds.length) > 0)
1342
1343
  _this.getSpeakersByStaffIds(speakerIds);
1343
1344
  }
1344
- if (aiFormattedData.section_id == _this.addToMyAgendaAction && ((_c = aiFormattedData.content) === null || _c === void 0 ? void 0 : _c.length) > 0) {
1345
+ if (aiFormattedData.section_id == _this.addToMyAgendaAction &&
1346
+ ((_c = aiFormattedData.content) === null || _c === void 0 ? void 0 : _c.length) > 0) {
1345
1347
  _this.openPage.next({
1346
1348
  sectionId: aiFormattedData.section_id,
1347
- sessionIds: aiFormattedData.content
1349
+ sessionIds: aiFormattedData.content,
1348
1350
  });
1349
1351
  }
1350
1352
  if (aiFormattedData.section_id == _this.connectOrFollowAction) {
1351
1353
  var usersLen = (_d = aiFormattedData.content) === null || _d === void 0 ? void 0 : _d.length;
1352
1354
  if (usersLen > 1) {
1353
1355
  _this.openPage.next({
1354
- sectionId: "open_networking_drawer",
1355
- search: aiFormattedData.content
1356
+ sectionId: 'open_networking_drawer',
1357
+ search: aiFormattedData.content,
1356
1358
  });
1357
1359
  }
1358
1360
  else if (usersLen == 1) {
1359
1361
  _this.openPage.next({
1360
1362
  sectionId: aiFormattedData.section_id,
1361
- connetUserIds: [aiFormattedData.content[0].userId]
1363
+ connetUserIds: [aiFormattedData.content[0].userId],
1362
1364
  });
1363
1365
  }
1364
1366
  }
1365
- if (aiFormattedData.is_open_page == "true") {
1367
+ if (aiFormattedData.is_open_page == 'true') {
1366
1368
  _this.openPage.next({
1367
1369
  sectionId: aiFormattedData.section_id,
1368
- search: aiFormattedData.content
1370
+ search: aiFormattedData.content,
1369
1371
  });
1370
1372
  if (_this.isMobileBrowser()) {
1371
- aiFormattedData.message += "\n\n" + '<a id="closeBotNow">Click Here</a> to see results.';
1373
+ aiFormattedData.message +=
1374
+ '\n\n' + '<a id="closeBotNow">Click Here</a> to see results.';
1372
1375
  }
1373
1376
  }
1374
1377
  _this.chatLog.push({
1375
1378
  type: 'ai',
1376
1379
  message: aiFormattedData.message,
1377
1380
  action: aiFormattedData,
1378
- time: formatNow(_this.timezone)
1381
+ time: formatNow(_this.timezone),
1379
1382
  });
1380
1383
  if (_this.isMobileBrowser()) {
1381
1384
  setTimeout(function () {
1382
1385
  _this.addCloseBotClickEvent();
1383
1386
  }, 500);
1384
1387
  }
1385
- _this.aiResponse = "";
1388
+ _this.aiResponse = '';
1386
1389
  }
1387
1390
  else {
1388
1391
  _this.chatLog.push({
@@ -1464,11 +1467,34 @@
1464
1467
  if (this.chatLog[idx].liked)
1465
1468
  this.chatLog[idx].liked = !this.chatLog[idx].liked;
1466
1469
  };
1470
+ // handleCopyClick(index: any) {
1471
+ // // Copy the message to the clipboard
1472
+ // const contentToCopy = this.chatLog[index].message;
1473
+ // console.log('contentToCopy');
1474
+ // console.log(contentToCopy);
1475
+ // navigator.clipboard.writeText(contentToCopy).then(() => {
1476
+ // // Indicate that the message was copied
1477
+ // this.chatLog[index].copied = true;
1478
+ // this.cdr.detectChanges();
1479
+ // // Reset the copied state after a delay
1480
+ // setTimeout(() => {
1481
+ // this.chatLog[index].copied = false;
1482
+ // this.cdr.detectChanges();
1483
+ // }, 2000); // Reset after 2 seconds
1484
+ // });
1485
+ // }
1467
1486
  ChatDrawerComponent.prototype.handleCopyClick = function (index) {
1468
1487
  var _this = this;
1469
- // Copy the message to the clipboard
1488
+ // Get the message content from the chat log (this can include HTML elements)
1470
1489
  var contentToCopy = this.chatLog[index].message;
1471
- navigator.clipboard.writeText(contentToCopy).then(function () {
1490
+ // Create a temporary DOM element to hold the content
1491
+ var tempElement = document.createElement('div');
1492
+ tempElement.innerHTML = contentToCopy;
1493
+ // Get the plain text content, preserving formatting (e.g., replacing <br> with new lines)
1494
+ var plainText = tempElement.innerText.replace(/\n/g, '\n');
1495
+ console.log('Content to Copy:', plainText);
1496
+ // Copy the plain text to the clipboard
1497
+ navigator.clipboard.writeText(plainText).then(function () {
1472
1498
  // Indicate that the message was copied
1473
1499
  _this.chatLog[index].copied = true;
1474
1500
  _this.cdr.detectChanges();
@@ -1490,7 +1516,7 @@
1490
1516
  }, 5);
1491
1517
  };
1492
1518
  ChatDrawerComponent.prototype.handleAction = function (action) {
1493
- console.info("incoming action from the chatbot AI");
1519
+ console.info('incoming action from the chatbot AI');
1494
1520
  console.info(action);
1495
1521
  if (action === null || action === void 0 ? void 0 : action.content) {
1496
1522
  }
@@ -1533,7 +1559,7 @@
1533
1559
  method: 'POST',
1534
1560
  headers: {
1535
1561
  'Content-Type': 'application/json',
1536
- 'Authorization': "Bearer " + "your_token_here",
1562
+ Authorization: 'Bearer ' + 'your_token_here',
1537
1563
  },
1538
1564
  body: JSON.stringify(ids),
1539
1565
  })
@@ -1561,7 +1587,7 @@
1561
1587
  ChatDrawerComponent.prototype.performSessionAction = function (sessionId, action) {
1562
1588
  this.sessionActions.next({
1563
1589
  sessionId: sessionId,
1564
- action: action
1590
+ action: action,
1565
1591
  });
1566
1592
  };
1567
1593
  ChatDrawerComponent.prototype.addCloseBotClickEvent = function () {
@@ -1580,7 +1606,7 @@
1580
1606
  var _this = this;
1581
1607
  this.connectWithUser.emit({
1582
1608
  connect: !this.canDisconnect(userId),
1583
- userId: userId
1609
+ userId: userId,
1584
1610
  });
1585
1611
  setTimeout(function () {
1586
1612
  _this.fetchMyConnections().subscribe(function (res) {
@@ -1595,7 +1621,8 @@
1595
1621
  this.scheduleMeeting.emit(user);
1596
1622
  };
1597
1623
  ChatDrawerComponent.prototype.canConnect = function (userId) {
1598
- return !(this.canDisconnect(userId) || this.pendingRequests.find(function (a) { return a == userId; }));
1624
+ return !(this.canDisconnect(userId) ||
1625
+ this.pendingRequests.find(function (a) { return a == userId; }));
1599
1626
  };
1600
1627
  ChatDrawerComponent.prototype.canDisconnect = function (userId) {
1601
1628
  return this.myConnections.find(function (conn) { return conn.userId == userId; });
@@ -1604,7 +1631,7 @@
1604
1631
  var _this = this;
1605
1632
  var headers = new http.HttpHeaders({
1606
1633
  'Content-Type': 'application/json',
1607
- 'apiKey': this.autogenKey
1634
+ apiKey: this.autogenKey,
1608
1635
  });
1609
1636
  return this.http
1610
1637
  .get(this.environment.USERS_API + "/events/" + this.eventId + "/connection-requests/autogen/pending-sent-requests?userId=" + this.userId, { headers: headers })
@@ -1621,7 +1648,7 @@
1621
1648
  var _this = this;
1622
1649
  var headers = new http.HttpHeaders({
1623
1650
  'Content-Type': 'application/json',
1624
- 'apiKey': this.autogenKey
1651
+ apiKey: this.autogenKey,
1625
1652
  });
1626
1653
  return this.http
1627
1654
  .get(this.environment.USERS_API + "/events/" + this.eventId + "/users-connections/autogen?userId=" + this.userId, { headers: headers })
@@ -1640,7 +1667,7 @@
1640
1667
  };
1641
1668
  ChatDrawerComponent.prototype.onSelectAll = function (event) {
1642
1669
  var _a;
1643
- (_a = this.agents) === null || _a === void 0 ? void 0 : _a.forEach(function (agent) { return agent.selected = false; });
1670
+ (_a = this.agents) === null || _a === void 0 ? void 0 : _a.forEach(function (agent) { return (agent.selected = false); });
1644
1671
  this.cdr.detectChanges();
1645
1672
  };
1646
1673
  ChatDrawerComponent.prototype.onAgentChange = function (agent) {
@@ -1664,7 +1691,9 @@
1664
1691
  return 'All Agents';
1665
1692
  }
1666
1693
  else {
1667
- return (selectedAgents === null || selectedAgents === void 0 ? void 0 : selectedAgents.length) > 1 ? (selectedAgents === null || selectedAgents === void 0 ? void 0 : selectedAgents.length) + " Agents Selected" : (selectedAgents === null || selectedAgents === void 0 ? void 0 : selectedAgents.length) + " Agent Selected";
1694
+ return (selectedAgents === null || selectedAgents === void 0 ? void 0 : selectedAgents.length) > 1
1695
+ ? (selectedAgents === null || selectedAgents === void 0 ? void 0 : selectedAgents.length) + " Agents Selected"
1696
+ : (selectedAgents === null || selectedAgents === void 0 ? void 0 : selectedAgents.length) + " Agent Selected";
1668
1697
  }
1669
1698
  };
1670
1699
  ChatDrawerComponent.prototype.fetchAgents_http = function () {
@@ -1672,7 +1701,7 @@
1672
1701
  this.loading = true;
1673
1702
  var url = this.environment.AGENTS_API + "/CoPilot/" + this.botId + "/active-agents";
1674
1703
  var headers = new http.HttpHeaders({
1675
- 'Content-Type': 'application/json'
1704
+ 'Content-Type': 'application/json',
1676
1705
  });
1677
1706
  return this.http.post(url, {}, { headers: headers }).pipe(operators.switchMap(function (res) {
1678
1707
  if (res) {
@@ -1686,8 +1715,7 @@
1686
1715
  }));
1687
1716
  };
1688
1717
  ChatDrawerComponent.prototype.fetchAgents = function () {
1689
- this.fetchAgents_http()
1690
- .subscribe();
1718
+ this.fetchAgents_http().subscribe();
1691
1719
  };
1692
1720
  // events/${eventId}/users-connections
1693
1721
  ChatDrawerComponent.prototype.processMessageForDisplay = function (markdown) {