@sinequa/assistant 3.5.4 → 3.6.1

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.
@@ -19,6 +19,8 @@ export declare class ChatMessageComponent implements OnChanges, AfterViewInit {
19
19
  suggestedActions: SuggestedAction[] | undefined;
20
20
  assistantMessageIcon: string;
21
21
  userMessageIcon: string;
22
+ connectionErrorMessageIcon: string;
23
+ searchWarningMessageIcon: string;
22
24
  streaming: boolean;
23
25
  canEdit: boolean;
24
26
  canRegenerate: boolean;
@@ -77,5 +79,5 @@ export declare class ChatMessageComponent implements OnChanges, AfterViewInit {
77
79
  openOriginalAttachment(attachment: ChatContextAttachment, partId?: number): void;
78
80
  hideTooltip(): void;
79
81
  static ɵfac: i0.ɵɵFactoryDeclaration<ChatMessageComponent, never>;
80
- static ɵcmp: i0.ɵɵComponentDeclaration<ChatMessageComponent, "sq-chat-message", never, { "message": "message"; "conversation": "conversation"; "suggestedActions": "suggestedActions"; "assistantMessageIcon": "assistantMessageIcon"; "userMessageIcon": "userMessageIcon"; "streaming": "streaming"; "canEdit": "canEdit"; "canRegenerate": "canRegenerate"; "canCopy": "canCopy"; "canDebug": "canDebug"; "canLike": "canLike"; "canDislike": "canDislike"; }, { "openDocument": "openDocument"; "openPreview": "openPreview"; "suggestAction": "suggestAction"; "edit": "edit"; "copy": "copy"; "regenerate": "regenerate"; "like": "like"; "dislike": "dislike"; "debug": "debug"; }, never, never, true>;
82
+ static ɵcmp: i0.ɵɵComponentDeclaration<ChatMessageComponent, "sq-chat-message", never, { "message": "message"; "conversation": "conversation"; "suggestedActions": "suggestedActions"; "assistantMessageIcon": "assistantMessageIcon"; "userMessageIcon": "userMessageIcon"; "connectionErrorMessageIcon": "connectionErrorMessageIcon"; "searchWarningMessageIcon": "searchWarningMessageIcon"; "streaming": "streaming"; "canEdit": "canEdit"; "canRegenerate": "canRegenerate"; "canCopy": "canCopy"; "canDebug": "canDebug"; "canLike": "canLike"; "canDislike": "canDislike"; }, { "openDocument": "openDocument"; "openPreview": "openPreview"; "suggestAction": "suggestAction"; "edit": "edit"; "copy": "copy"; "regenerate": "regenerate"; "like": "like"; "dislike": "dislike"; "debug": "debug"; }, never, never, true>;
81
83
  }
@@ -11,6 +11,7 @@ import { InstanceManagerService } from "./instance-manager.service";
11
11
  import { WebSocketChatService } from "./websocket-chat.service";
12
12
  import { LoginService } from "@sinequa/core/login";
13
13
  import { RestChatService } from "./rest-chat.service";
14
+ import { HubConnection } from "@microsoft/signalr";
14
15
  import * as i0 from "@angular/core";
15
16
  export declare class ChatComponent extends AbstractFacet implements OnInit, OnChanges, OnDestroy {
16
17
  loginService: LoginService;
@@ -950,7 +951,17 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
950
951
  assistantMessageIcon: string;
951
952
  /** Icon to use for the user messages */
952
953
  userMessageIcon: string;
954
+ /** Icon to use for the connection error messages */
955
+ connectionErrorMessageIcon: string;
956
+ /** Icon to use for the search warning messages */
957
+ searchWarningMessageIcon: string;
958
+ /** Event emitter triggered once the signalR connection is established */
959
+ connection: EventEmitter<HubConnection>;
953
960
  /** Event emitter triggered each time the assistant updates the current chat */
961
+ /** Event emitter triggered when the chat is loading new content */
962
+ loading$: EventEmitter<boolean>;
963
+ /** Emits the assistant configuration used when instantiating the component */
964
+ _config: EventEmitter<ChatConfig>;
954
965
  data: EventEmitter<ChatMessage[]>;
955
966
  /** Event emitter triggered when the user clicks to open the original document representing the context attachment*/
956
967
  openDocument: EventEmitter<{
@@ -958,11 +969,7 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
958
969
  id: string;
959
970
  title: string;
960
971
  text: string;
961
- size: number; /**
962
- * Starting from the provided index, remove all subsequent messages from the chat history and the UI accordingly.
963
- * The assistant will regenerate a new answer based on the updated chat history.
964
- * @param index The index of the assistant's message to regenerate
965
- */
972
+ size: number;
966
973
  $selected: boolean;
967
974
  matchlocations: string[];
968
975
  rank: number;
@@ -1060,19 +1067,12 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
1060
1067
  $expanded?: boolean | undefined;
1061
1068
  }[];
1062
1069
  } | undefined;
1063
- $hasPassages?: boolean | undefined; /**
1064
- * Handle the click on a reference's 'open original document'.
1065
- * @param data
1066
- */
1070
+ $hasPassages?: boolean | undefined;
1067
1071
  }>;
1068
1072
  /** Event emitter triggered when the user clicks to open the preview of a document representing the context attachment */
1069
1073
  openPreview: EventEmitter<ChatContextAttachment>;
1070
1074
  /** Event emitter triggered when the user clicks on a suggested action */
1071
1075
  suggestAction: EventEmitter<SuggestedAction>;
1072
- /** Event emitter triggered when the chat is loading new content */
1073
- loading$: EventEmitter<boolean>;
1074
- /** Emits the assistant configuration used when instantiating the component */
1075
- _config: EventEmitter<ChatConfig>;
1076
1076
  messageList?: ElementRef<HTMLUListElement>;
1077
1077
  questionInput?: ElementRef<HTMLTextAreaElement>;
1078
1078
  loadingTpl?: TemplateRef<any>;
@@ -1095,7 +1095,11 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
1095
1095
  isAtBottom: boolean;
1096
1096
  initializationError: boolean;
1097
1097
  enabledUserInput: boolean;
1098
- issueTypes: string[];
1098
+ isConnected: boolean;
1099
+ retrialAttempts: number | undefined;
1100
+ private _isReconnectedListenerRegistered;
1101
+ issueTypes?: string[];
1102
+ defaultIssueTypes: string[];
1099
1103
  issueType: string;
1100
1104
  issueComment?: string;
1101
1105
  messageRelatedIssue?: ChatMessage;
@@ -1115,23 +1119,38 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
1115
1119
  */
1116
1120
  instantiateChatService(): void;
1117
1121
  get actions(): Action[];
1118
- private handleChanges;
1122
+ private _handleChanges;
1119
1123
  private _triggerReloadAfterQueryChange;
1120
- private addScrollListener;
1124
+ private _addScrollListener;
1121
1125
  updateModelDescription(): void;
1122
1126
  submitQuestion(): void;
1123
- private fetchAnswer;
1127
+ private _fetchAnswer;
1124
1128
  /**
1125
- * Given a list of messages, the chat endpoint is invoked for a continuation and updates the list of messages accordingly.
1129
+ * Depending on the connection's state :
1130
+ * - If connected => given a list of messages, the chat endpoint is invoked for a continuation and updates the list of messages accordingly.
1131
+ * - If any other state => a connection error message is displayed in the chat.
1126
1132
  * @param messages
1127
1133
  */
1128
1134
  fetch(messages: ChatMessage[]): void;
1135
+ /**
1136
+ * Retry to fetch the messages if the connection issues.
1137
+ * - If reconnecting => keep display the connection error message even when clicking on the "retry" button and increasing the number of retrial attempts, until the connection is re-established
1138
+ * - If disconnected => On click on the "retry" button, start the connection process while displaying the connection error message :
1139
+ * * If successful => given a list of messages, the chat endpoint is invoked for a continuation and updates the list of messages accordingly.
1140
+ * * If failed => increase the number of retrial attempts
1141
+ */
1142
+ retryFetch(): void;
1143
+ /**
1144
+ * Check if the signalR connection is connected.
1145
+ * For the REST protocol, the connection is always considered connected (for the moment).
1146
+ */
1147
+ private _updateConnectionStatus;
1129
1148
  /**
1130
1149
  * Update the UI with the new messages
1131
1150
  * @param messages
1132
1151
  */
1133
1152
  updateData(messages: ChatMessage[]): void;
1134
- private toggleScrollButtonVisibility;
1153
+ private _toggleScrollButtonVisibility;
1135
1154
  scrollDown(): void;
1136
1155
  /**
1137
1156
  * Start a new chat with the defaultValues settings
@@ -1186,7 +1205,7 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
1186
1205
  */
1187
1206
  regenerateMessage(index: number): void;
1188
1207
  onKeyUp(event: KeyboardEvent): void;
1189
- calculateHeight(): void;
1208
+ calculateHeight(event?: KeyboardEvent): void;
1190
1209
  /**
1191
1210
  * Send a "like" event on clicking on the thumb-up icon of an assistant's message
1192
1211
  * @param rank The rank of the message to like
@@ -1235,5 +1254,5 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
1235
1254
  */
1236
1255
  showDebug(message: ChatMessage): void;
1237
1256
  static ɵfac: i0.ɵɵFactoryDeclaration<ChatComponent, never>;
1238
- static ɵcmp: i0.ɵɵComponentDeclaration<ChatComponent, "sq-chat-v3", never, { "instanceId": "instanceId"; "query": "query"; "queryChangeShouldTriggerReload": "queryChangeShouldTriggerReload"; "protocol": "protocol"; "messageHandlers": "messageHandlers"; "automaticScrollToLastResponse": "automaticScrollToLastResponse"; "chat": "chat"; "assistantMessageIcon": "assistantMessageIcon"; "userMessageIcon": "userMessageIcon"; }, { "data": "data"; "openDocument": "openDocument"; "openPreview": "openPreview"; "suggestAction": "suggestAction"; "loading$": "loading"; "_config": "config"; }, ["loadingTpl", "reportIssueTpl", "tokenConsumptionTpl", "debugMessagesTpl"], never, true>;
1257
+ static ɵcmp: i0.ɵɵComponentDeclaration<ChatComponent, "sq-chat-v3", never, { "instanceId": "instanceId"; "query": "query"; "queryChangeShouldTriggerReload": "queryChangeShouldTriggerReload"; "protocol": "protocol"; "messageHandlers": "messageHandlers"; "automaticScrollToLastResponse": "automaticScrollToLastResponse"; "chat": "chat"; "assistantMessageIcon": "assistantMessageIcon"; "userMessageIcon": "userMessageIcon"; "connectionErrorMessageIcon": "connectionErrorMessageIcon"; "searchWarningMessageIcon": "searchWarningMessageIcon"; }, { "connection": "connection"; "loading$": "loading"; "_config": "config"; "data": "data"; "openDocument": "openDocument"; "openPreview": "openPreview"; "suggestAction": "suggestAction"; }, ["loadingTpl", "reportIssueTpl", "tokenConsumptionTpl", "debugMessagesTpl"], never, true>;
1239
1258
  }
@@ -25,6 +25,10 @@ $ast-primary-bg: var(--ast-primary-bg, #f2f8fe);
25
25
  $ast-primary-color: var(--ast-primary-color, #005DA7);
26
26
  $ast-secondary-bg: var(--ast-secondary-bg, #FFF8F1);
27
27
  $ast-secondary-color: var(--ast-secondary-color, #FF732E);
28
+ $ast-error-bg: var(--ast-error-bg, rgba(249, 58, 55, 0.2));
29
+ $ast-error-color: var(--ast-error-color, rgba(249, 58, 55, 0.7));
30
+ $ast-warning-bg: var(--ast-warning-bg, #fff1b8);
31
+ $ast-warning-color: var(--ast-warning-color, #fed86f);
28
32
  $ast-saved-chat-hover-background: var(--ast-saved-chat-hover-background, #FFF8F1);
29
33
  $ast-input-bg: var(--ast-input-bg, #F8F8F8);
30
34
  $ast-input-color: var(--ast-input-color, #B0B0B0);
@@ -52,6 +56,14 @@ $ast-muted-color: var(--ast-muted-color, rgba(33, 37, 41, 0.75));
52
56
  background-color: $ast-secondary-bg;
53
57
  }
54
58
 
59
+ .ast-error {
60
+ background-color: $ast-error-bg;
61
+
62
+ &:hover {
63
+ color: $ast-error-color;
64
+ }
65
+ }
66
+
55
67
  .ast-btn {
56
68
  border: 0;
57
69
  text-align: left;
@@ -78,4 +90,4 @@ $ast-muted-color: var(--ast-muted-color, rgba(33, 37, 41, 0.75));
78
90
  --ast-reference-passages-color: white;
79
91
  --ast-reference-expanded-hover-bg: #262421;
80
92
  --ast-message-reference-color: black;
81
- }
93
+ }
package/chat/types.d.ts CHANGED
@@ -121,26 +121,31 @@ export interface SavedChatHistory extends SavedChat {
121
121
  history: ChatMessage[];
122
122
  }
123
123
  export declare const connectionSettingsSchema: z.ZodEffects<z.ZodObject<{
124
+ connectionErrorMessage: z.ZodString;
124
125
  restEndpoint: z.ZodOptional<z.ZodString>;
125
126
  websocketEndpoint: z.ZodOptional<z.ZodString>;
126
127
  signalRTransport: z.ZodEnum<["WebSockets", "ServerSentEvents", "LongPolling", "None"]>;
127
128
  signalRLogLevel: z.ZodEnum<["Critical", "Debug", "Error", "Information", "None", "Trace", "Warning"]>;
128
129
  }, "strip", z.ZodTypeAny, {
130
+ connectionErrorMessage: string;
129
131
  signalRTransport: "None" | "WebSockets" | "ServerSentEvents" | "LongPolling";
130
132
  signalRLogLevel: "None" | "Critical" | "Debug" | "Error" | "Information" | "Trace" | "Warning";
131
133
  restEndpoint?: string | undefined;
132
134
  websocketEndpoint?: string | undefined;
133
135
  }, {
136
+ connectionErrorMessage: string;
134
137
  signalRTransport: "None" | "WebSockets" | "ServerSentEvents" | "LongPolling";
135
138
  signalRLogLevel: "None" | "Critical" | "Debug" | "Error" | "Information" | "Trace" | "Warning";
136
139
  restEndpoint?: string | undefined;
137
140
  websocketEndpoint?: string | undefined;
138
141
  }>, {
142
+ connectionErrorMessage: string;
139
143
  signalRTransport: "None" | "WebSockets" | "ServerSentEvents" | "LongPolling";
140
144
  signalRLogLevel: "None" | "Critical" | "Debug" | "Error" | "Information" | "Trace" | "Warning";
141
145
  restEndpoint?: string | undefined;
142
146
  websocketEndpoint?: string | undefined;
143
147
  }, {
148
+ connectionErrorMessage: string;
144
149
  signalRTransport: "None" | "WebSockets" | "ServerSentEvents" | "LongPolling";
145
150
  signalRLogLevel: "None" | "Critical" | "Debug" | "Error" | "Information" | "Trace" | "Warning";
146
151
  restEndpoint?: string | undefined;
@@ -317,26 +322,31 @@ export interface SavedChatSettings extends z.infer<typeof savedChatSettingsSchem
317
322
  }
318
323
  export declare const chatConfigSchema: z.ZodObject<{
319
324
  connectionSettings: z.ZodEffects<z.ZodObject<{
325
+ connectionErrorMessage: z.ZodString;
320
326
  restEndpoint: z.ZodOptional<z.ZodString>;
321
327
  websocketEndpoint: z.ZodOptional<z.ZodString>;
322
328
  signalRTransport: z.ZodEnum<["WebSockets", "ServerSentEvents", "LongPolling", "None"]>;
323
329
  signalRLogLevel: z.ZodEnum<["Critical", "Debug", "Error", "Information", "None", "Trace", "Warning"]>;
324
330
  }, "strip", z.ZodTypeAny, {
331
+ connectionErrorMessage: string;
325
332
  signalRTransport: "None" | "WebSockets" | "ServerSentEvents" | "LongPolling";
326
333
  signalRLogLevel: "None" | "Critical" | "Debug" | "Error" | "Information" | "Trace" | "Warning";
327
334
  restEndpoint?: string | undefined;
328
335
  websocketEndpoint?: string | undefined;
329
336
  }, {
337
+ connectionErrorMessage: string;
330
338
  signalRTransport: "None" | "WebSockets" | "ServerSentEvents" | "LongPolling";
331
339
  signalRLogLevel: "None" | "Critical" | "Debug" | "Error" | "Information" | "Trace" | "Warning";
332
340
  restEndpoint?: string | undefined;
333
341
  websocketEndpoint?: string | undefined;
334
342
  }>, {
343
+ connectionErrorMessage: string;
335
344
  signalRTransport: "None" | "WebSockets" | "ServerSentEvents" | "LongPolling";
336
345
  signalRLogLevel: "None" | "Critical" | "Debug" | "Error" | "Information" | "Trace" | "Warning";
337
346
  restEndpoint?: string | undefined;
338
347
  websocketEndpoint?: string | undefined;
339
348
  }, {
349
+ connectionErrorMessage: string;
340
350
  signalRTransport: "None" | "WebSockets" | "ServerSentEvents" | "LongPolling";
341
351
  signalRLogLevel: "None" | "Critical" | "Debug" | "Error" | "Information" | "Trace" | "Warning";
342
352
  restEndpoint?: string | undefined;
@@ -474,23 +484,37 @@ export declare const chatConfigSchema: z.ZodObject<{
474
484
  enabled: boolean;
475
485
  }>;
476
486
  globalSettings: z.ZodObject<{
487
+ searchWarningMessage: z.ZodString;
477
488
  disclaimer: z.ZodOptional<z.ZodString>;
489
+ genericChatErrorMessage: z.ZodOptional<z.ZodString>;
478
490
  displayUserQuotaConsumption: z.ZodOptional<z.ZodBoolean>;
479
491
  displayChatTokensConsumption: z.ZodOptional<z.ZodBoolean>;
480
492
  }, "strip", z.ZodTypeAny, {
493
+ searchWarningMessage: string;
481
494
  disclaimer?: string | undefined;
495
+ genericChatErrorMessage?: string | undefined;
482
496
  displayUserQuotaConsumption?: boolean | undefined;
483
497
  displayChatTokensConsumption?: boolean | undefined;
484
498
  }, {
499
+ searchWarningMessage: string;
485
500
  disclaimer?: string | undefined;
501
+ genericChatErrorMessage?: string | undefined;
486
502
  displayUserQuotaConsumption?: boolean | undefined;
487
503
  displayChatTokensConsumption?: boolean | undefined;
488
504
  }>;
505
+ auditSettings: z.ZodOptional<z.ZodObject<{
506
+ issueTypes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
507
+ }, "strip", z.ZodTypeAny, {
508
+ issueTypes?: string[] | undefined;
509
+ }, {
510
+ issueTypes?: string[] | undefined;
511
+ }>>;
489
512
  additionalServiceSettings: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
490
513
  additionalWorkflowProperties: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
491
514
  }, "strip", z.ZodTypeAny, {
492
515
  additionalWorkflowProperties: {};
493
516
  connectionSettings: {
517
+ connectionErrorMessage: string;
494
518
  signalRTransport: "None" | "WebSockets" | "ServerSentEvents" | "LongPolling";
495
519
  signalRLogLevel: "None" | "Critical" | "Debug" | "Error" | "Information" | "Trace" | "Warning";
496
520
  restEndpoint?: string | undefined;
@@ -536,14 +560,20 @@ export declare const chatConfigSchema: z.ZodObject<{
536
560
  enabled: boolean;
537
561
  };
538
562
  globalSettings: {
563
+ searchWarningMessage: string;
539
564
  disclaimer?: string | undefined;
565
+ genericChatErrorMessage?: string | undefined;
540
566
  displayUserQuotaConsumption?: boolean | undefined;
541
567
  displayChatTokensConsumption?: boolean | undefined;
542
568
  };
543
569
  additionalServiceSettings: {};
570
+ auditSettings?: {
571
+ issueTypes?: string[] | undefined;
572
+ } | undefined;
544
573
  }, {
545
574
  additionalWorkflowProperties: {};
546
575
  connectionSettings: {
576
+ connectionErrorMessage: string;
547
577
  signalRTransport: "None" | "WebSockets" | "ServerSentEvents" | "LongPolling";
548
578
  signalRLogLevel: "None" | "Critical" | "Debug" | "Error" | "Information" | "Trace" | "Warning";
549
579
  restEndpoint?: string | undefined;
@@ -589,11 +619,16 @@ export declare const chatConfigSchema: z.ZodObject<{
589
619
  enabled: boolean;
590
620
  };
591
621
  globalSettings: {
622
+ searchWarningMessage: string;
592
623
  disclaimer?: string | undefined;
624
+ genericChatErrorMessage?: string | undefined;
593
625
  displayUserQuotaConsumption?: boolean | undefined;
594
626
  displayChatTokensConsumption?: boolean | undefined;
595
627
  };
596
628
  additionalServiceSettings: {};
629
+ auditSettings?: {
630
+ issueTypes?: string[] | undefined;
631
+ } | undefined;
597
632
  }>;
598
633
  export interface ChatConfig extends z.infer<typeof chatConfigSchema> {
599
634
  }
@@ -610,6 +645,7 @@ export interface ChatPayload {
610
645
  };
611
646
  instanceId?: string;
612
647
  savedChatId?: string;
648
+ genericChatErrorMessage?: string;
613
649
  }
614
650
  export declare type ActionMessage = {
615
651
  guid: string;
@@ -4,12 +4,10 @@ import { Query } from "@sinequa/core/app-utils";
4
4
  import { HubConnection } from "@microsoft/signalr";
5
5
  import { ChatMessage, ChatResponse, GllmFunction, GllmModelDescription, MessageHandler, SavedChatHistory, SavedChat } from "./types";
6
6
  import { ChatService } from "./chat.service";
7
- import { Observable, Subject } from "rxjs";
7
+ import { Observable } from "rxjs";
8
8
  import * as i0 from "@angular/core";
9
9
  export declare class WebSocketChatService extends ChatService {
10
10
  connection: HubConnection | undefined;
11
- connectionBuilt$: Subject<void>;
12
- connectionStarted$: Subject<void>;
13
11
  private _messageHandlers;
14
12
  private _actionMap;
15
13
  private _progress;