@sinequa/assistant 3.7.0 → 3.7.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.
@@ -1077,8 +1077,10 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
1077
1077
  suggestAction: EventEmitter<SuggestedAction>;
1078
1078
  /** Event emitter triggered when the user clicks on a chat starter */
1079
1079
  chatStarter: EventEmitter<ChatStarter>;
1080
+ /** ViewChild decorators to access the template elements */
1080
1081
  messageList?: ElementRef<HTMLUListElement>;
1081
1082
  questionInput?: ElementRef<HTMLTextAreaElement>;
1083
+ /** ContentChild decorators allowing the override of the default templates from the parent component */
1082
1084
  loadingTpl?: TemplateRef<any>;
1083
1085
  reportTpl?: TemplateRef<any>;
1084
1086
  tokenConsumptionTpl?: TemplateRef<any>;
@@ -1128,17 +1130,60 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
1128
1130
  */
1129
1131
  instantiateChatService(): void;
1130
1132
  get actions(): Action[];
1133
+ /**
1134
+ * Handles the changes in the chat component.
1135
+ * If the chat service is a WebSocketChatService, it handles the override of the message handlers if they exist.
1136
+ * Initializes the chat with the provided chat messages if they exist, otherwise loads the default chat.
1137
+ * If the chat is initialized, the initialization event is "Query", the query changes, and the queryChangeShouldTriggerReload function is provided,
1138
+ * then the chat should be reloaded if the function returns true. Otherwise, the chat should be reloaded by default.
1139
+ * It takes into account the ongoing streaming process and the ongoing stopping process to trigger that conditionally define the logic
1140
+ * of the reload :
1141
+ * - If the chat is streaming, then stop the generation and wait for the fetch to complete before reloading the chat.
1142
+ * - If the chat is stopping the generation, then wait for the fetch to complete before reloading the chat.
1143
+ */
1131
1144
  private _handleChanges;
1145
+ /**
1146
+ * Triggers a reload after the query change.
1147
+ * This method performs the necessary operations to reload the chat after a query change.
1148
+ * It sets the system and user messages, resets the savedChatId, generates a new chatId,
1149
+ * generates a new chat audit event, and handles the query mode.
1150
+ */
1132
1151
  private _triggerReloadAfterQueryChange;
1152
+ /**
1153
+ * Adds a scroll listener to the message list element.
1154
+ * The listener is triggered when any of the following events occur:
1155
+ * - Loading state changes
1156
+ * - Messages change
1157
+ * - Streaming state changes
1158
+ * - Scroll event occurs on the message list element
1159
+ *
1160
+ * When the listener is triggered, it updates the `isAtBottom` property.
1161
+ */
1133
1162
  private _addScrollListener;
1163
+ /**
1164
+ * Get the model description based on the defaultValues service_id and model_id
1165
+ */
1134
1166
  updateModelDescription(): void;
1167
+ /**
1168
+ * Submits a question from the user.
1169
+ * If the user is editing a previous message, removes all subsequent messages from the chat history.
1170
+ * Triggers the fetch of the answer for the submitted question by calling _fetchAnswer().
1171
+ * Clears the input value in the UI.
1172
+ */
1135
1173
  submitQuestion(): void;
1174
+ /**
1175
+ * Triggers the fetch of the answer for the given question and updates the conversation.
1176
+ * Generates an audit event for the user input.
1177
+ *
1178
+ * @param question - The question asked by the user.
1179
+ * @param conversation - The current conversation messages.
1180
+ */
1136
1181
  private _fetchAnswer;
1137
1182
  /**
1138
1183
  * Depending on the connection's state :
1139
1184
  * - If connected => given a list of messages, the chat endpoint is invoked for a continuation and updates the list of messages accordingly.
1140
1185
  * - If any other state => a connection error message is displayed in the chat.
1141
- * @param messages
1186
+ * @param messages The list of messages to invoke the chat endpoint with
1142
1187
  */
1143
1188
  fetch(messages: ChatMessage[]): void;
1144
1189
  /**
@@ -1159,7 +1204,13 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
1159
1204
  * @param messages
1160
1205
  */
1161
1206
  updateData(messages: ChatMessage[]): void;
1207
+ /**
1208
+ * @returns true if the chat discussion is scrolled down to the bottom, false otherwise
1209
+ */
1162
1210
  private _toggleScrollButtonVisibility;
1211
+ /**
1212
+ * Scroll down to the bottom of the chat discussion
1213
+ */
1163
1214
  scrollDown(): void;
1164
1215
  /**
1165
1216
  * Start a new chat with the defaultValues settings
@@ -1167,6 +1218,14 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
1167
1218
  * If the savedChat feature is enabled, the list of saved chats will be refreshed
1168
1219
  */
1169
1220
  newChat(): void;
1221
+ /**
1222
+ * Attaches the specified document IDs to the assistant.
1223
+ * If the chat is streaming or stopping the generation, the operation is not allowed.
1224
+ * If no document IDs are provided, the operation is not allowed.
1225
+ * If the action for attaching a document is not defined at the application customization level, an error is logged.
1226
+ * @param ids - An array of document IDs to attach.
1227
+ */
1228
+ attachToChat(ids: string[]): void;
1170
1229
  /**
1171
1230
  * Start the default chat with the defaultValues settings
1172
1231
  * If the chat is meant to be initialized with event === "Query", the corresponding user query message will be added to the chat history
@@ -1192,8 +1251,20 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
1192
1251
  * The fetch subscription will be terminated
1193
1252
  */
1194
1253
  resetChat(): void;
1254
+ /**
1255
+ * Fetch and Load the saved chat from the saved chat index.
1256
+ * If the saved chat is found, the chat discussion will be loaded with the provided messages and chatId
1257
+ */
1195
1258
  onLoadChat(): void;
1259
+ /**
1260
+ * Stop the generation of the current assistant's answer.
1261
+ * The fetch subscription will be terminated.
1262
+ */
1196
1263
  stopGeneration(): void;
1264
+ /**
1265
+ * Terminate the fetch process by unsubscribing from the data subscription and updating the loading status to false.
1266
+ * Additionally, focus on the chat input if the focusAfterResponse flag is set to true.
1267
+ */
1197
1268
  terminateFetch(): void;
1198
1269
  /**
1199
1270
  * Copy a previous user message of the chat history to the chat user input.
@@ -1222,7 +1293,16 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
1222
1293
  * @param index - The index to be remapped.
1223
1294
  */
1224
1295
  private _remapIndexInChatHistory;
1296
+ /**
1297
+ * Handles the key up event for 'Backspace' and 'Enter' keys.
1298
+ * @param event - The keyboard event.
1299
+ */
1225
1300
  onKeyUp(event: KeyboardEvent): void;
1301
+ /**
1302
+ * Calculates and adjusts the height of the question input element based on its content.
1303
+ * If the Enter key is pressed without the Shift key, it prevents the default behavior.
1304
+ * @param event The keyboard event
1305
+ */
1226
1306
  calculateHeight(event?: KeyboardEvent): void;
1227
1307
  /**
1228
1308
  * Send a "like" event on clicking on the thumb-up icon of an assistant's message
package/chat/types.d.ts CHANGED
@@ -29,6 +29,7 @@ export interface ChatMessage extends RawMessage {
29
29
  $suggestedAction?: SuggestedAction[];
30
30
  $debug?: DebugMessage[];
31
31
  forcedWorkflow?: string;
32
+ forcedWorkflowProperties?: any;
32
33
  query?: Query;
33
34
  isUserInput?: boolean;
34
35
  usageMetrics?: ChatUsageMetrics;
@@ -217,15 +218,6 @@ declare const uiSettingsSchema: z.ZodObject<{
217
218
  }>;
218
219
  export interface UiSettings extends z.infer<typeof uiSettingsSchema> {
219
220
  }
220
- declare const chatStarterSchema: z.ZodObject<{
221
- text: z.ZodString;
222
- }, "strip", z.ZodTypeAny, {
223
- text: string;
224
- }, {
225
- text: string;
226
- }>;
227
- export interface ChatStarter extends z.infer<typeof chatStarterSchema> {
228
- }
229
221
  declare const defaultValuesSchema: z.ZodObject<{
230
222
  service_id: z.ZodString;
231
223
  model_id: z.ZodString;
@@ -274,6 +266,15 @@ declare const defaultValuesSchema: z.ZodObject<{
274
266
  }>;
275
267
  export interface DefaultValues extends z.infer<typeof defaultValuesSchema> {
276
268
  }
269
+ declare const chatStarterSchema: z.ZodObject<{
270
+ text: z.ZodString;
271
+ }, "strip", z.ZodTypeAny, {
272
+ text: string;
273
+ }, {
274
+ text: string;
275
+ }>;
276
+ export interface ChatStarter extends z.infer<typeof chatStarterSchema> {
277
+ }
277
278
  declare const modeSettingsSchema: z.ZodEffects<z.ZodObject<{
278
279
  enabledUserInput: z.ZodBoolean;
279
280
  displayUserPrompt: z.ZodBoolean;
@@ -318,6 +319,16 @@ declare const modeSettingsSchema: z.ZodEffects<z.ZodObject<{
318
319
  text: string;
319
320
  }[] | undefined;
320
321
  }>;
322
+ actions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
323
+ forcedWorkflow: z.ZodString;
324
+ forcedWorkflowProperties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
325
+ }, "strip", z.ZodTypeAny, {
326
+ forcedWorkflow: string;
327
+ forcedWorkflowProperties?: globalThis.Record<string, unknown> | undefined;
328
+ }, {
329
+ forcedWorkflow: string;
330
+ forcedWorkflowProperties?: globalThis.Record<string, unknown> | undefined;
331
+ }>>>;
321
332
  }, "strip", z.ZodTypeAny, {
322
333
  displayUserPrompt: boolean;
323
334
  enabledUserInput: boolean;
@@ -330,6 +341,10 @@ declare const modeSettingsSchema: z.ZodEffects<z.ZodObject<{
330
341
  text: string;
331
342
  }[] | undefined;
332
343
  };
344
+ actions?: globalThis.Record<string, {
345
+ forcedWorkflow: string;
346
+ forcedWorkflowProperties?: globalThis.Record<string, unknown> | undefined;
347
+ }> | undefined;
333
348
  }, {
334
349
  displayUserPrompt: boolean;
335
350
  enabledUserInput: boolean;
@@ -342,6 +357,10 @@ declare const modeSettingsSchema: z.ZodEffects<z.ZodObject<{
342
357
  text: string;
343
358
  }[] | undefined;
344
359
  };
360
+ actions?: globalThis.Record<string, {
361
+ forcedWorkflow: string;
362
+ forcedWorkflowProperties?: globalThis.Record<string, unknown> | undefined;
363
+ }> | undefined;
345
364
  }>, {
346
365
  displayUserPrompt: boolean;
347
366
  enabledUserInput: boolean;
@@ -354,6 +373,10 @@ declare const modeSettingsSchema: z.ZodEffects<z.ZodObject<{
354
373
  text: string;
355
374
  }[] | undefined;
356
375
  };
376
+ actions?: globalThis.Record<string, {
377
+ forcedWorkflow: string;
378
+ forcedWorkflowProperties?: globalThis.Record<string, unknown> | undefined;
379
+ }> | undefined;
357
380
  }, {
358
381
  displayUserPrompt: boolean;
359
382
  enabledUserInput: boolean;
@@ -366,6 +389,10 @@ declare const modeSettingsSchema: z.ZodEffects<z.ZodObject<{
366
389
  text: string;
367
390
  }[] | undefined;
368
391
  };
392
+ actions?: globalThis.Record<string, {
393
+ forcedWorkflow: string;
394
+ forcedWorkflowProperties?: globalThis.Record<string, unknown> | undefined;
395
+ }> | undefined;
369
396
  }>;
370
397
  export interface ModeSettings extends z.infer<typeof modeSettingsSchema> {
371
398
  }
@@ -510,6 +537,16 @@ export declare const chatConfigSchema: z.ZodObject<{
510
537
  text: string;
511
538
  }[] | undefined;
512
539
  }>;
540
+ actions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
541
+ forcedWorkflow: z.ZodString;
542
+ forcedWorkflowProperties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
543
+ }, "strip", z.ZodTypeAny, {
544
+ forcedWorkflow: string;
545
+ forcedWorkflowProperties?: globalThis.Record<string, unknown> | undefined;
546
+ }, {
547
+ forcedWorkflow: string;
548
+ forcedWorkflowProperties?: globalThis.Record<string, unknown> | undefined;
549
+ }>>>;
513
550
  }, "strip", z.ZodTypeAny, {
514
551
  displayUserPrompt: boolean;
515
552
  enabledUserInput: boolean;
@@ -522,6 +559,10 @@ export declare const chatConfigSchema: z.ZodObject<{
522
559
  text: string;
523
560
  }[] | undefined;
524
561
  };
562
+ actions?: globalThis.Record<string, {
563
+ forcedWorkflow: string;
564
+ forcedWorkflowProperties?: globalThis.Record<string, unknown> | undefined;
565
+ }> | undefined;
525
566
  }, {
526
567
  displayUserPrompt: boolean;
527
568
  enabledUserInput: boolean;
@@ -534,6 +575,10 @@ export declare const chatConfigSchema: z.ZodObject<{
534
575
  text: string;
535
576
  }[] | undefined;
536
577
  };
578
+ actions?: globalThis.Record<string, {
579
+ forcedWorkflow: string;
580
+ forcedWorkflowProperties?: globalThis.Record<string, unknown> | undefined;
581
+ }> | undefined;
537
582
  }>, {
538
583
  displayUserPrompt: boolean;
539
584
  enabledUserInput: boolean;
@@ -546,6 +591,10 @@ export declare const chatConfigSchema: z.ZodObject<{
546
591
  text: string;
547
592
  }[] | undefined;
548
593
  };
594
+ actions?: globalThis.Record<string, {
595
+ forcedWorkflow: string;
596
+ forcedWorkflowProperties?: globalThis.Record<string, unknown> | undefined;
597
+ }> | undefined;
549
598
  }, {
550
599
  displayUserPrompt: boolean;
551
600
  enabledUserInput: boolean;
@@ -558,6 +607,10 @@ export declare const chatConfigSchema: z.ZodObject<{
558
607
  text: string;
559
608
  }[] | undefined;
560
609
  };
610
+ actions?: globalThis.Record<string, {
611
+ forcedWorkflow: string;
612
+ forcedWorkflowProperties?: globalThis.Record<string, unknown> | undefined;
613
+ }> | undefined;
561
614
  }>;
562
615
  uiSettings: z.ZodObject<{
563
616
  display: z.ZodBoolean;
@@ -664,6 +717,10 @@ export declare const chatConfigSchema: z.ZodObject<{
664
717
  text: string;
665
718
  }[] | undefined;
666
719
  };
720
+ actions?: globalThis.Record<string, {
721
+ forcedWorkflow: string;
722
+ forcedWorkflowProperties?: globalThis.Record<string, unknown> | undefined;
723
+ }> | undefined;
667
724
  };
668
725
  uiSettings: {
669
726
  display: boolean;
@@ -727,6 +784,10 @@ export declare const chatConfigSchema: z.ZodObject<{
727
784
  text: string;
728
785
  }[] | undefined;
729
786
  };
787
+ actions?: globalThis.Record<string, {
788
+ forcedWorkflow: string;
789
+ forcedWorkflowProperties?: globalThis.Record<string, unknown> | undefined;
790
+ }> | undefined;
730
791
  };
731
792
  uiSettings: {
732
793
  display: boolean;