@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.
@@ -201,8 +201,7 @@ SocketService.ctorParameters = () => [
201
201
 
202
202
  // import { Platform } from '@angular/cdk/platform';
203
203
  class ChatDrawerComponent {
204
- constructor(cdr, http, sanitizer, elementRef, renderer, socketService, conversationService
205
- // private platform: Platform
204
+ constructor(cdr, http, sanitizer, elementRef, renderer, socketService, conversationService // private platform: Platform
206
205
  ) {
207
206
  this.cdr = cdr;
208
207
  this.http = http;
@@ -213,7 +212,7 @@ class ChatDrawerComponent {
213
212
  this.conversationService = conversationService;
214
213
  this.bodyOverflowClass = 'body-overflow-hidden';
215
214
  this.isCollapsedTrue = false;
216
- this.copilotName = "HiveXGPT";
215
+ this.copilotName = 'HiveXGPT';
217
216
  this.feedbackEvent = new EventEmitter();
218
217
  this.onCloseEvent = new EventEmitter();
219
218
  this.openPage = new EventEmitter();
@@ -222,10 +221,10 @@ class ChatDrawerComponent {
222
221
  this.connectWithUser = new EventEmitter();
223
222
  this.scheduleMeeting = new EventEmitter();
224
223
  this.refreshToken = new EventEmitter();
225
- this.autogenKey = "Autogen_eDJTtEU-NB0RtIpzq1w";
226
- this.addToMyAgendaAction = "add_to_my_agenda";
227
- this.myUpcomingSessionAction = "my_upcomming_session";
228
- this.connectOrFollowAction = "connect_or_follow";
224
+ this.autogenKey = 'Autogen_eDJTtEU-NB0RtIpzq1w';
225
+ this.addToMyAgendaAction = 'add_to_my_agenda';
226
+ this.myUpcomingSessionAction = 'my_upcomming_session';
227
+ this.connectOrFollowAction = 'connect_or_follow';
229
228
  this.aiResponse = '';
230
229
  this.chatLog = [];
231
230
  this.decoder = new TextDecoder();
@@ -349,7 +348,6 @@ class ChatDrawerComponent {
349
348
  }, 200);
350
349
  }
351
350
  initializeSocket() {
352
- ;
353
351
  const conversation_id = this.conversationService.getKey(this.botId);
354
352
  this.socketService.registerUserSpecificHiveSocket(this.botId, conversation_id);
355
353
  }
@@ -360,8 +358,8 @@ class ChatDrawerComponent {
360
358
  var _a, _b;
361
359
  // Check if OtherFields exists in the response
362
360
  if ((_a = res === null || res === void 0 ? void 0 : res.m) === null || _a === void 0 ? void 0 : _a.OtherFields) {
363
- const { conversation_id, bot_id, message_id, answer, web_results, graphs, execution_graphs, online_search_terms, suggestions } = (_b = res === null || res === void 0 ? void 0 : res.m) === null || _b === void 0 ? void 0 : _b.OtherFields;
364
- var currentChatMessage = this.chatLog.find(p => p._id == message_id);
361
+ const { conversation_id, bot_id, message_id, answer, web_results, graphs, execution_graphs, online_search_terms, suggestions, } = (_b = res === null || res === void 0 ? void 0 : res.m) === null || _b === void 0 ? void 0 : _b.OtherFields;
362
+ var currentChatMessage = this.chatLog.find((p) => p._id == message_id);
365
363
  if (!currentChatMessage) {
366
364
  currentChatMessage = {
367
365
  _id: message_id,
@@ -387,7 +385,8 @@ class ChatDrawerComponent {
387
385
  if (answer) {
388
386
  this.isChatingWithAi = false;
389
387
  console.log('Answer:', answer);
390
- currentChatMessage.message = this.processMessageForDisplay(answer);
388
+ currentChatMessage.message =
389
+ this.processMessageForDisplay(answer);
391
390
  this.cdr.markForCheck();
392
391
  this.scrollToBottom();
393
392
  }
@@ -417,8 +416,7 @@ class ChatDrawerComponent {
417
416
  console.error('Error in fetching data from socket', err);
418
417
  });
419
418
  }
420
- initializeSocketAndListen() {
421
- }
419
+ initializeSocketAndListen() { }
422
420
  handleEvent(data, type) {
423
421
  switch (type) {
424
422
  case 'webresult':
@@ -511,9 +509,11 @@ class ChatDrawerComponent {
511
509
  this.conversationKey = this.conversationService.getKey(this.botId);
512
510
  const url = `${this.environment.BASE_URL}/conversations/${this.conversationKey}`;
513
511
  const headers = new HttpHeaders({
514
- 'accept': 'application/json'
512
+ accept: 'application/json',
515
513
  });
516
- return this.http.get(url, { headers }).pipe(catchError(this.handleError('fetchConversation')));
514
+ return this.http
515
+ .get(url, { headers })
516
+ .pipe(catchError(this.handleError('fetchConversation')));
517
517
  }
518
518
  handleError(operation = 'operation', result) {
519
519
  return (error) => {
@@ -551,16 +551,16 @@ class ChatDrawerComponent {
551
551
  });
552
552
  if (chats && ((_a = chats === null || chats === void 0 ? void 0 : chats.Messages) === null || _a === void 0 ? void 0 : _a.length)) {
553
553
  chats === null || chats === void 0 ? void 0 : chats.Messages.forEach((chat) => {
554
- if (chat.Type == "user") {
554
+ if (chat.Type == 'user') {
555
555
  this.chatLog.push({
556
556
  type: 'user',
557
557
  message: this.processMessageForDisplay(chat.Text),
558
558
  time: formatTimeStamps(this.timezone, chat.InsertTimestamp),
559
559
  copied: false,
560
- isCollapsedTrue: false
560
+ isCollapsedTrue: false,
561
561
  });
562
562
  }
563
- if (chat.Type == "ai") {
563
+ if (chat.Type == 'ai') {
564
564
  var sourcesList = chat.WebLinks || [];
565
565
  var displayedSources = chat.WebLinks.slice(0, 3); // First 3 cards
566
566
  var remainingSources = chat.WebLinks.slice(3); // Remaining items
@@ -575,7 +575,7 @@ class ChatDrawerComponent {
575
575
  remainingSources: remainingSources,
576
576
  time: formatTimeStamps(this.timezone, chat.InsertTimestamp),
577
577
  copied: false,
578
- isCollapsedTrue: false
578
+ isCollapsedTrue: false,
579
579
  });
580
580
  this.showFeedBackIconsIndex = this.chatLog.length - 1;
581
581
  }
@@ -653,15 +653,14 @@ class ChatDrawerComponent {
653
653
  message: this.processMessageForDisplay(this.input),
654
654
  time: formatNow(this.timezone),
655
655
  copied: false,
656
- isCollapsedTrue: false
656
+ isCollapsedTrue: false,
657
657
  });
658
658
  try {
659
659
  const textarea = this.myInput.nativeElement;
660
660
  textarea.style.height = 'hidden'; // Reset the height
661
661
  textarea.style.height = `62px`;
662
662
  }
663
- catch (error) {
664
- }
663
+ catch (error) { }
665
664
  this.cdr.markForCheck();
666
665
  this.aiResponse = '';
667
666
  this.isChatingWithAi = true;
@@ -671,7 +670,7 @@ class ChatDrawerComponent {
671
670
  method: 'POST',
672
671
  headers: {
673
672
  'Content-Type': 'application/json',
674
- 'Authorization': 'Bearer ' + this.s27Token,
673
+ Authorization: 'Bearer ' + this.s27Token,
675
674
  'x-api-key': this.apiKey,
676
675
  },
677
676
  body: JSON.stringify({
@@ -679,7 +678,7 @@ class ChatDrawerComponent {
679
678
  user_id: this.userId,
680
679
  bot_id: this.botId,
681
680
  message_id: this.conversationService.generateKey(),
682
- agents: this.agents.filter(p => p.selected).map(p => p.id),
681
+ agents: this.agents.filter((p) => p.selected).map((p) => p.id),
683
682
  conversation_id: this.conversationKey,
684
683
  }),
685
684
  })
@@ -719,7 +718,7 @@ class ChatDrawerComponent {
719
718
  message: this.processMessageForDisplay(inputMsg),
720
719
  time: formatNow(this.timezone),
721
720
  copied: false,
722
- isCollapsedTrue: false
721
+ isCollapsedTrue: false,
723
722
  });
724
723
  this.cdr.markForCheck();
725
724
  this.aiResponse = '';
@@ -730,7 +729,7 @@ class ChatDrawerComponent {
730
729
  method: 'POST',
731
730
  headers: {
732
731
  'Content-Type': 'application/json',
733
- 'Authorization': 'Bearer ' + this.s27Token,
732
+ Authorization: 'Bearer ' + this.s27Token,
734
733
  'x-api-key': this.apiKey,
735
734
  },
736
735
  body: JSON.stringify({
@@ -738,7 +737,7 @@ class ChatDrawerComponent {
738
737
  user_id: this.userId,
739
738
  bot_id: this.botId,
740
739
  message_id: this.conversationService.generateKey(),
741
- agents: this.agents.filter(p => p.selected).map(p => p.id),
740
+ agents: this.agents.filter((p) => p.selected).map((p) => p.id),
742
741
  conversation_id: this.conversationKey,
743
742
  }),
744
743
  })
@@ -809,7 +808,7 @@ class ChatDrawerComponent {
809
808
  if (allSuggestions === null || allSuggestions === void 0 ? void 0 : allSuggestions.length) {
810
809
  this.chatLog.push({
811
810
  type: 'suggestions',
812
- suggestions: allSuggestions
811
+ suggestions: allSuggestions,
813
812
  });
814
813
  }
815
814
  controller.close();
@@ -828,8 +827,8 @@ class ChatDrawerComponent {
828
827
  const suggestionsMatch = this.aiResponse.match(/<sug>(.*?)<\/sug>/g);
829
828
  if (suggestionsMatch) {
830
829
  suggestionsMatch.forEach((match) => {
831
- this.aiResponse = this.aiResponse.replace(match, "");
832
- allSuggestions.push(match === null || match === void 0 ? void 0 : match.replace(/<\/?sug>/g, ""));
830
+ this.aiResponse = this.aiResponse.replace(match, '');
831
+ allSuggestions.push(match === null || match === void 0 ? void 0 : match.replace(/<\/?sug>/g, ''));
833
832
  });
834
833
  }
835
834
  lastItem.message = this.aiResponse;
@@ -851,60 +850,64 @@ class ChatDrawerComponent {
851
850
  }
852
851
  console.log('parsing json done');
853
852
  if (aiFormattedData && ((_a = aiFormattedData === null || aiFormattedData === void 0 ? void 0 : aiFormattedData.section_id) === null || _a === void 0 ? void 0 : _a.length) > 0) {
854
- if (aiFormattedData.section_id == 'company_search' || aiFormattedData.section_id == 'user_search' || aiFormattedData.section_id == 'industry_company_search') {
853
+ if (aiFormattedData.section_id == 'company_search' ||
854
+ aiFormattedData.section_id == 'user_search' ||
855
+ aiFormattedData.section_id == 'industry_company_search') {
855
856
  this.fetchMyConnections().subscribe();
856
857
  this.fetchPendingRequests().subscribe();
857
858
  }
858
859
  if (aiFormattedData.section_id == this.myUpcomingSessionAction) {
859
860
  var speakerIds = [];
860
- (_b = aiFormattedData.content) === null || _b === void 0 ? void 0 : _b.forEach(session => {
861
+ (_b = aiFormattedData.content) === null || _b === void 0 ? void 0 : _b.forEach((session) => {
861
862
  speakerIds = [...speakerIds, ...session.speakers];
862
863
  });
863
864
  if ((speakerIds === null || speakerIds === void 0 ? void 0 : speakerIds.length) > 0)
864
865
  this.getSpeakersByStaffIds(speakerIds);
865
866
  }
866
- if (aiFormattedData.section_id == this.addToMyAgendaAction && ((_c = aiFormattedData.content) === null || _c === void 0 ? void 0 : _c.length) > 0) {
867
+ if (aiFormattedData.section_id == this.addToMyAgendaAction &&
868
+ ((_c = aiFormattedData.content) === null || _c === void 0 ? void 0 : _c.length) > 0) {
867
869
  this.openPage.next({
868
870
  sectionId: aiFormattedData.section_id,
869
- sessionIds: aiFormattedData.content
871
+ sessionIds: aiFormattedData.content,
870
872
  });
871
873
  }
872
874
  if (aiFormattedData.section_id == this.connectOrFollowAction) {
873
875
  let usersLen = (_d = aiFormattedData.content) === null || _d === void 0 ? void 0 : _d.length;
874
876
  if (usersLen > 1) {
875
877
  this.openPage.next({
876
- sectionId: "open_networking_drawer",
877
- search: aiFormattedData.content
878
+ sectionId: 'open_networking_drawer',
879
+ search: aiFormattedData.content,
878
880
  });
879
881
  }
880
882
  else if (usersLen == 1) {
881
883
  this.openPage.next({
882
884
  sectionId: aiFormattedData.section_id,
883
- connetUserIds: [aiFormattedData.content[0].userId]
885
+ connetUserIds: [aiFormattedData.content[0].userId],
884
886
  });
885
887
  }
886
888
  }
887
- if (aiFormattedData.is_open_page == "true") {
889
+ if (aiFormattedData.is_open_page == 'true') {
888
890
  this.openPage.next({
889
891
  sectionId: aiFormattedData.section_id,
890
- search: aiFormattedData.content
892
+ search: aiFormattedData.content,
891
893
  });
892
894
  if (this.isMobileBrowser()) {
893
- aiFormattedData.message += "\n\n" + '<a id="closeBotNow">Click Here</a> to see results.';
895
+ aiFormattedData.message +=
896
+ '\n\n' + '<a id="closeBotNow">Click Here</a> to see results.';
894
897
  }
895
898
  }
896
899
  this.chatLog.push({
897
900
  type: 'ai',
898
901
  message: aiFormattedData.message,
899
902
  action: aiFormattedData,
900
- time: formatNow(this.timezone)
903
+ time: formatNow(this.timezone),
901
904
  });
902
905
  if (this.isMobileBrowser()) {
903
906
  setTimeout(() => {
904
907
  this.addCloseBotClickEvent();
905
908
  }, 500);
906
909
  }
907
- this.aiResponse = "";
910
+ this.aiResponse = '';
908
911
  }
909
912
  else {
910
913
  this.chatLog.push({
@@ -985,10 +988,33 @@ class ChatDrawerComponent {
985
988
  if (this.chatLog[idx].liked)
986
989
  this.chatLog[idx].liked = !this.chatLog[idx].liked;
987
990
  }
991
+ // handleCopyClick(index: any) {
992
+ // // Copy the message to the clipboard
993
+ // const contentToCopy = this.chatLog[index].message;
994
+ // console.log('contentToCopy');
995
+ // console.log(contentToCopy);
996
+ // navigator.clipboard.writeText(contentToCopy).then(() => {
997
+ // // Indicate that the message was copied
998
+ // this.chatLog[index].copied = true;
999
+ // this.cdr.detectChanges();
1000
+ // // Reset the copied state after a delay
1001
+ // setTimeout(() => {
1002
+ // this.chatLog[index].copied = false;
1003
+ // this.cdr.detectChanges();
1004
+ // }, 2000); // Reset after 2 seconds
1005
+ // });
1006
+ // }
988
1007
  handleCopyClick(index) {
989
- // Copy the message to the clipboard
1008
+ // Get the message content from the chat log (this can include HTML elements)
990
1009
  const contentToCopy = this.chatLog[index].message;
991
- navigator.clipboard.writeText(contentToCopy).then(() => {
1010
+ // Create a temporary DOM element to hold the content
1011
+ const tempElement = document.createElement('div');
1012
+ tempElement.innerHTML = contentToCopy;
1013
+ // Get the plain text content, preserving formatting (e.g., replacing <br> with new lines)
1014
+ const plainText = tempElement.innerText.replace(/\n/g, '\n');
1015
+ console.log('Content to Copy:', plainText);
1016
+ // Copy the plain text to the clipboard
1017
+ navigator.clipboard.writeText(plainText).then(() => {
992
1018
  // Indicate that the message was copied
993
1019
  this.chatLog[index].copied = true;
994
1020
  this.cdr.detectChanges();
@@ -1009,7 +1035,7 @@ class ChatDrawerComponent {
1009
1035
  }, 5);
1010
1036
  }
1011
1037
  handleAction(action) {
1012
- console.info("incoming action from the chatbot AI");
1038
+ console.info('incoming action from the chatbot AI');
1013
1039
  console.info(action);
1014
1040
  if (action === null || action === void 0 ? void 0 : action.content) {
1015
1041
  }
@@ -1050,7 +1076,7 @@ class ChatDrawerComponent {
1050
1076
  method: 'POST',
1051
1077
  headers: {
1052
1078
  'Content-Type': 'application/json',
1053
- 'Authorization': "Bearer " + "your_token_here",
1079
+ Authorization: 'Bearer ' + 'your_token_here',
1054
1080
  },
1055
1081
  body: JSON.stringify(ids),
1056
1082
  })
@@ -1064,7 +1090,7 @@ class ChatDrawerComponent {
1064
1090
  })
1065
1091
  .then((data) => {
1066
1092
  if ((data === null || data === void 0 ? void 0 : data.length) > 0) {
1067
- data.forEach(speaker => {
1093
+ data.forEach((speaker) => {
1068
1094
  this.speakers[speaker.id] = speaker;
1069
1095
  });
1070
1096
  this.cdr.markForCheck();
@@ -1078,7 +1104,7 @@ class ChatDrawerComponent {
1078
1104
  performSessionAction(sessionId, action) {
1079
1105
  this.sessionActions.next({
1080
1106
  sessionId,
1081
- action
1107
+ action,
1082
1108
  });
1083
1109
  }
1084
1110
  addCloseBotClickEvent() {
@@ -1095,13 +1121,13 @@ class ChatDrawerComponent {
1095
1121
  connectToUser(userId) {
1096
1122
  this.connectWithUser.emit({
1097
1123
  connect: !this.canDisconnect(userId),
1098
- userId
1124
+ userId,
1099
1125
  });
1100
1126
  setTimeout(() => {
1101
- this.fetchMyConnections().subscribe(res => {
1127
+ this.fetchMyConnections().subscribe((res) => {
1102
1128
  this.cdr.markForCheck();
1103
1129
  });
1104
- this.fetchPendingRequests().subscribe(res => {
1130
+ this.fetchPendingRequests().subscribe((res) => {
1105
1131
  this.cdr.markForCheck();
1106
1132
  });
1107
1133
  }, 500);
@@ -1110,15 +1136,16 @@ class ChatDrawerComponent {
1110
1136
  this.scheduleMeeting.emit(user);
1111
1137
  }
1112
1138
  canConnect(userId) {
1113
- return !(this.canDisconnect(userId) || this.pendingRequests.find(a => a == userId));
1139
+ return !(this.canDisconnect(userId) ||
1140
+ this.pendingRequests.find((a) => a == userId));
1114
1141
  }
1115
1142
  canDisconnect(userId) {
1116
- return this.myConnections.find(conn => conn.userId == userId);
1143
+ return this.myConnections.find((conn) => conn.userId == userId);
1117
1144
  }
1118
1145
  fetchPendingRequests() {
1119
1146
  const headers = new HttpHeaders({
1120
1147
  'Content-Type': 'application/json',
1121
- 'apiKey': this.autogenKey
1148
+ apiKey: this.autogenKey,
1122
1149
  });
1123
1150
  return this.http
1124
1151
  .get(`${this.environment.USERS_API}/events/${this.eventId}/connection-requests/autogen/pending-sent-requests?userId=${this.userId}`, { headers })
@@ -1134,7 +1161,7 @@ class ChatDrawerComponent {
1134
1161
  fetchMyConnections() {
1135
1162
  const headers = new HttpHeaders({
1136
1163
  'Content-Type': 'application/json',
1137
- 'apiKey': this.autogenKey
1164
+ apiKey: this.autogenKey,
1138
1165
  });
1139
1166
  return this.http
1140
1167
  .get(`${this.environment.USERS_API}/events/${this.eventId}/users-connections/autogen?userId=${this.userId}`, { headers })
@@ -1153,13 +1180,13 @@ class ChatDrawerComponent {
1153
1180
  }
1154
1181
  onSelectAll(event) {
1155
1182
  var _a;
1156
- (_a = this.agents) === null || _a === void 0 ? void 0 : _a.forEach(agent => agent.selected = false);
1183
+ (_a = this.agents) === null || _a === void 0 ? void 0 : _a.forEach((agent) => (agent.selected = false));
1157
1184
  this.cdr.detectChanges();
1158
1185
  }
1159
1186
  onAgentChange(agent) {
1160
1187
  //agent.selected = !agent.selected;
1161
1188
  //console.log(agent);
1162
- let agentFound = this.agents.filter(p => p.id == agent.id);
1189
+ let agentFound = this.agents.filter((p) => p.id == agent.id);
1163
1190
  if (agentFound && agentFound.length > 0) {
1164
1191
  agentFound[0].selected = !agentFound[0].selected;
1165
1192
  this.cdr.detectChanges();
@@ -1168,27 +1195,29 @@ class ChatDrawerComponent {
1168
1195
  }
1169
1196
  areAllSelected() {
1170
1197
  var _a;
1171
- return (_a = this.agents) === null || _a === void 0 ? void 0 : _a.every(agent => !agent.selected);
1198
+ return (_a = this.agents) === null || _a === void 0 ? void 0 : _a.every((agent) => !agent.selected);
1172
1199
  }
1173
1200
  getDropdownHeaderText() {
1174
1201
  var _a;
1175
- const selectedAgents = (_a = this.agents) === null || _a === void 0 ? void 0 : _a.filter(agent => agent.selected);
1202
+ const selectedAgents = (_a = this.agents) === null || _a === void 0 ? void 0 : _a.filter((agent) => agent.selected);
1176
1203
  if (selectedAgents && (selectedAgents === null || selectedAgents === void 0 ? void 0 : selectedAgents.length) === 0) {
1177
1204
  return 'All Agents';
1178
1205
  }
1179
1206
  else {
1180
- 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`;
1207
+ return (selectedAgents === null || selectedAgents === void 0 ? void 0 : selectedAgents.length) > 1
1208
+ ? `${selectedAgents === null || selectedAgents === void 0 ? void 0 : selectedAgents.length} Agents Selected`
1209
+ : `${selectedAgents === null || selectedAgents === void 0 ? void 0 : selectedAgents.length} Agent Selected`;
1181
1210
  }
1182
1211
  }
1183
1212
  fetchAgents_http() {
1184
1213
  this.loading = true;
1185
1214
  const url = `${this.environment.AGENTS_API}/CoPilot/${this.botId}/active-agents`;
1186
1215
  const headers = new HttpHeaders({
1187
- 'Content-Type': 'application/json'
1216
+ 'Content-Type': 'application/json',
1188
1217
  });
1189
1218
  return this.http.post(url, {}, { headers }).pipe(switchMap((res) => {
1190
1219
  if (res) {
1191
- this.agents = res.map(agent => (Object.assign(Object.assign({}, agent), { selected: false })));
1220
+ this.agents = res.map((agent) => (Object.assign(Object.assign({}, agent), { selected: false })));
1192
1221
  }
1193
1222
  this.cdr.markForCheck();
1194
1223
  return of(res);
@@ -1198,8 +1227,7 @@ class ChatDrawerComponent {
1198
1227
  }));
1199
1228
  }
1200
1229
  fetchAgents() {
1201
- this.fetchAgents_http()
1202
- .subscribe();
1230
+ this.fetchAgents_http().subscribe();
1203
1231
  }
1204
1232
  // events/${eventId}/users-connections
1205
1233
  processMessageForDisplay(markdown) {