@sinequa/assistant 3.3.1 → 3.4.0

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.
@@ -24,120 +24,27 @@ export declare class ChatMessageComponent implements OnChanges, AfterViewInit {
24
24
  canRegenerate: boolean;
25
25
  canCopy: boolean;
26
26
  openDocument: EventEmitter<{
27
- filename: string;
28
- id: string;
29
- title: string;
30
- text: string;
31
- size: number;
32
- $selected: boolean;
33
- matchlocations: string[];
34
- rank: number;
35
- databasealias: string;
36
- matchingpartnames: string[];
37
- matchlocationsperpartname: {
38
- matchlocations: {
39
- data: string;
40
- partname: string;
41
- }[];
42
- }[];
43
- documentlanguages: string[];
44
- documentweight: string;
45
- modified: string;
46
- indexationtime: string;
47
- version: string;
48
- treepath: string[];
49
- fileext: string;
50
- flags: string[];
51
- collection: string[];
52
- docformat: string;
53
- url1: string;
54
- authors: string[];
55
- rfmEnabled: boolean;
56
- termspresence: {
57
- term: string;
58
- presence: "found" | "missing";
59
- }[];
60
- $isDuplicate: boolean;
61
- $duplicateCount: number;
62
- globalrelevance?: number | undefined;
63
- displayTitle?: string | undefined;
64
- doctype?: string | undefined;
65
- url2?: string | undefined;
66
- relevantExtracts?: string | undefined;
67
- extracts?: {
68
- score: number;
69
- highlighted: string;
70
- locations: string;
71
- originalLocations: string;
72
- partname?: string | undefined;
73
- }[] | undefined;
74
- accesslists?: {
75
- accessListIndices: number[];
76
- authorizedLists: {
77
- id: string;
78
- domain: string;
79
- }[];
80
- deniedLists: {
81
- id: string;
82
- domain: string;
83
- }[];
84
- } | undefined;
85
- thumbnailUrl?: string | undefined;
86
- originalUrl?: string | undefined;
87
- pdfUrl?: string | undefined;
88
- rfm?: {
89
- click?: {
90
- image: import("@sinequa/core/web-services").RFMDisplay;
91
- status: import("@sinequa/core/web-services").RFMDisplay;
92
- eventCount: number;
93
- average: number;
94
- imageAction: import("@sinequa/core/web-services").RFMDisplay;
95
- availableActions: import("@sinequa/core/web-services").RFMDisplay;
96
- } | undefined;
97
- like?: {
98
- image: import("@sinequa/core/web-services").RFMDisplay;
99
- status: import("@sinequa/core/web-services").RFMDisplay;
100
- eventCount: number;
101
- average: number;
102
- imageAction: import("@sinequa/core/web-services").RFMDisplay;
103
- availableActions: import("@sinequa/core/web-services").RFMDisplay;
104
- } | undefined;
105
- important?: {
106
- image: import("@sinequa/core/web-services").RFMDisplay;
107
- status: import("@sinequa/core/web-services").RFMDisplay;
108
- eventCount: number;
109
- average: number;
110
- imageAction: import("@sinequa/core/web-services").RFMDisplay;
111
- availableActions: import("@sinequa/core/web-services").RFMDisplay;
112
- } | undefined;
113
- } | undefined;
114
- groupcount?: number | undefined;
115
- nearhash?: string | undefined;
116
- exacthash?: string | undefined;
117
- containerid?: string | undefined;
118
- $page?: number | undefined;
119
- matchingpassages?: {
120
- passages: {
121
- location: number[];
122
- id: number;
123
- score: number;
124
- rlocation: number[];
125
- highlightedText: string;
126
- $expanded?: boolean | undefined;
127
- }[];
128
- } | undefined;
129
- $hasPassages?: boolean | undefined;
27
+ reference: ChatContextAttachment;
28
+ partId?: number | undefined;
29
+ }>;
30
+ openPreview: EventEmitter<{
31
+ reference: ChatContextAttachment;
32
+ partId?: number | undefined;
130
33
  }>;
131
- openPreview: EventEmitter<ChatContextAttachment>;
132
34
  suggestAction: EventEmitter<SuggestedAction>;
133
35
  edit: EventEmitter<ChatMessage>;
36
+ copy: EventEmitter<ChatMessage>;
134
37
  regenerate: EventEmitter<ChatMessage>;
38
+ like: EventEmitter<ChatMessage>;
39
+ dislike: EventEmitter<ChatMessage>;
135
40
  processor: Processor;
136
41
  references: string[];
137
42
  referenceMap: Map<string, ChatContextAttachment>;
138
43
  showReferences: boolean;
139
44
  collapseProgress: boolean;
140
45
  iconSize: number;
46
+ liked: boolean;
47
+ disliked: boolean;
141
48
  get name(): string;
142
49
  constructor(searchService: SearchService, ui: UIService, principalService: PrincipalWebService, cdr: ChangeDetectorRef, el: ElementRef);
143
50
  ngOnChanges(changes: SimpleChanges): void;
@@ -157,7 +64,9 @@ export declare class ChatMessageComponent implements OnChanges, AfterViewInit {
157
64
  * Match all references in a given message
158
65
  */
159
66
  getReferenceMatches(content: string): RegExpMatchArray[];
160
- copyToClipboard(text: string): void;
67
+ copyToClipboard(message: ChatMessage): void;
68
+ openAttachmentPreview(attachment: ChatContextAttachment, partId?: number): void;
69
+ openOriginalAttachment(attachment: ChatContextAttachment, partId?: number): void;
161
70
  static ɵfac: i0.ɵɵFactoryDeclaration<ChatMessageComponent, never>;
162
- 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"; }, { "openDocument": "openDocument"; "openPreview": "openPreview"; "suggestAction": "suggestAction"; "edit": "edit"; "regenerate": "regenerate"; }, never, never, true>;
71
+ 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"; }, { "openDocument": "openDocument"; "openPreview": "openPreview"; "suggestAction": "suggestAction"; "edit": "edit"; "copy": "copy"; "regenerate": "regenerate"; "like": "like"; "dislike": "dislike"; }, never, never, true>;
163
72
  }
@@ -5,111 +5,7 @@ export declare class ChatReferenceComponent {
5
5
  reference: string;
6
6
  attachment: ChatContextAttachment;
7
7
  partId?: number;
8
- openDocument: EventEmitter<{
9
- filename: string;
10
- id: string;
11
- title: string;
12
- text: string;
13
- size: number;
14
- $selected: boolean;
15
- matchlocations: string[];
16
- rank: number;
17
- databasealias: string;
18
- matchingpartnames: string[];
19
- matchlocationsperpartname: {
20
- matchlocations: {
21
- data: string;
22
- partname: string;
23
- }[];
24
- }[];
25
- documentlanguages: string[];
26
- documentweight: string;
27
- modified: string;
28
- indexationtime: string;
29
- version: string;
30
- treepath: string[];
31
- fileext: string;
32
- flags: string[];
33
- collection: string[];
34
- docformat: string;
35
- url1: string;
36
- authors: string[];
37
- rfmEnabled: boolean;
38
- termspresence: {
39
- term: string;
40
- presence: "found" | "missing";
41
- }[];
42
- $isDuplicate: boolean;
43
- $duplicateCount: number;
44
- globalrelevance?: number | undefined;
45
- displayTitle?: string | undefined;
46
- doctype?: string | undefined;
47
- url2?: string | undefined;
48
- relevantExtracts?: string | undefined;
49
- extracts?: {
50
- score: number;
51
- highlighted: string;
52
- locations: string;
53
- originalLocations: string;
54
- partname?: string | undefined;
55
- }[] | undefined;
56
- accesslists?: {
57
- accessListIndices: number[];
58
- authorizedLists: {
59
- id: string;
60
- domain: string;
61
- }[];
62
- deniedLists: {
63
- id: string;
64
- domain: string;
65
- }[];
66
- } | undefined;
67
- thumbnailUrl?: string | undefined;
68
- originalUrl?: string | undefined;
69
- pdfUrl?: string | undefined;
70
- rfm?: {
71
- click?: {
72
- image: import("@sinequa/core/web-services").RFMDisplay;
73
- status: import("@sinequa/core/web-services").RFMDisplay;
74
- eventCount: number;
75
- average: number;
76
- imageAction: import("@sinequa/core/web-services").RFMDisplay;
77
- availableActions: import("@sinequa/core/web-services").RFMDisplay;
78
- } | undefined;
79
- like?: {
80
- image: import("@sinequa/core/web-services").RFMDisplay;
81
- status: import("@sinequa/core/web-services").RFMDisplay;
82
- eventCount: number;
83
- average: number;
84
- imageAction: import("@sinequa/core/web-services").RFMDisplay;
85
- availableActions: import("@sinequa/core/web-services").RFMDisplay;
86
- } | undefined;
87
- important?: {
88
- image: import("@sinequa/core/web-services").RFMDisplay;
89
- status: import("@sinequa/core/web-services").RFMDisplay;
90
- eventCount: number;
91
- average: number;
92
- imageAction: import("@sinequa/core/web-services").RFMDisplay;
93
- availableActions: import("@sinequa/core/web-services").RFMDisplay;
94
- } | undefined;
95
- } | undefined;
96
- groupcount?: number | undefined;
97
- nearhash?: string | undefined;
98
- exacthash?: string | undefined;
99
- containerid?: string | undefined;
100
- $page?: number | undefined;
101
- matchingpassages?: {
102
- passages: {
103
- location: number[];
104
- id: number;
105
- score: number;
106
- rlocation: number[];
107
- highlightedText: string;
108
- $expanded?: boolean | undefined;
109
- }[];
110
- } | undefined;
111
- $hasPassages?: boolean | undefined;
112
- }>;
8
+ openDocument: EventEmitter<ChatContextAttachment>;
113
9
  openPreview: EventEmitter<ChatContextAttachment>;
114
10
  get parts(): DocumentPart[];
115
11
  expandAttachment(): void;
@@ -2,7 +2,7 @@ import { ChangeDetectorRef, ElementRef, EventEmitter, OnChanges, OnDestroy, OnIn
2
2
  import { Action } from "@sinequa/components/action";
3
3
  import { AbstractFacet } from "@sinequa/components/facet";
4
4
  import { SearchService } from "@sinequa/components/search";
5
- import { Query } from "@sinequa/core/app-utils";
5
+ import { AppService, Query } from "@sinequa/core/app-utils";
6
6
  import { PrincipalWebService } from "@sinequa/core/web-services";
7
7
  import { BehaviorSubject, Subscription } from "rxjs";
8
8
  import { ChatService } from "./chat.service";
@@ -45,7 +45,7 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
45
45
  count: number;
46
46
  display?: string | undefined;
47
47
  score?: number | undefined;
48
- operatorResults?: Partial<globalThis.Record<"max" | "min" | "sum" | "avg" | "stddev" | "variance", number | Date>> | undefined;
48
+ operatorResults?: Partial<Record<"max" | "min" | "sum" | "avg" | "stddev" | "variance", number | Date>> | undefined;
49
49
  $selected?: boolean | undefined;
50
50
  $excluded?: boolean | undefined;
51
51
  $filtered?: boolean | undefined;
@@ -68,7 +68,7 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
68
68
  count: number;
69
69
  display?: string | undefined;
70
70
  score?: number | undefined;
71
- operatorResults?: Partial<globalThis.Record<"max" | "min" | "sum" | "avg" | "stddev" | "variance", number | Date>> | undefined;
71
+ operatorResults?: Partial<Record<"max" | "min" | "sum" | "avg" | "stddev" | "variance", number | Date>> | undefined;
72
72
  $selected?: boolean | undefined;
73
73
  $excluded?: boolean | undefined;
74
74
  $filtered?: boolean | undefined;
@@ -100,7 +100,7 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
100
100
  count: number;
101
101
  display?: string | undefined;
102
102
  score?: number | undefined;
103
- operatorResults?: Partial<globalThis.Record<"max" | "min" | "sum" | "avg" | "stddev" | "variance", number | Date>> | undefined;
103
+ operatorResults?: Partial<Record<"max" | "min" | "sum" | "avg" | "stddev" | "variance", number | Date>> | undefined;
104
104
  $selected?: boolean | undefined;
105
105
  $excluded?: boolean | undefined;
106
106
  $filtered?: boolean | undefined;
@@ -125,7 +125,7 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
125
125
  count: number;
126
126
  display?: string | undefined;
127
127
  score?: number | undefined;
128
- operatorResults?: Partial<globalThis.Record<"max" | "min" | "sum" | "avg" | "stddev" | "variance", number | Date>> | undefined;
128
+ operatorResults?: Partial<Record<"max" | "min" | "sum" | "avg" | "stddev" | "variance", number | Date>> | undefined;
129
129
  $selected?: boolean | undefined;
130
130
  $excluded?: boolean | undefined;
131
131
  $filtered?: boolean | undefined;
@@ -181,7 +181,7 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
181
181
  count: number;
182
182
  display?: string | undefined;
183
183
  score?: number | undefined;
184
- operatorResults?: Partial<globalThis.Record<"max" | "min" | "sum" | "avg" | "stddev" | "variance", number | Date>> | undefined;
184
+ operatorResults?: Partial<Record<"max" | "min" | "sum" | "avg" | "stddev" | "variance", number | Date>> | undefined;
185
185
  $selected?: boolean | undefined;
186
186
  $excluded?: boolean | undefined;
187
187
  $filtered?: boolean | undefined;
@@ -213,7 +213,7 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
213
213
  count: number;
214
214
  display?: string | undefined;
215
215
  score?: number | undefined;
216
- operatorResults?: Partial<globalThis.Record<"max" | "min" | "sum" | "avg" | "stddev" | "variance", number | Date>> | undefined;
216
+ operatorResults?: Partial<Record<"max" | "min" | "sum" | "avg" | "stddev" | "variance", number | Date>> | undefined;
217
217
  $selected?: boolean | undefined;
218
218
  $excluded?: boolean | undefined;
219
219
  $filtered?: boolean | undefined;
@@ -245,7 +245,7 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
245
245
  count: number;
246
246
  display?: string | undefined;
247
247
  score?: number | undefined;
248
- operatorResults?: Partial<globalThis.Record<"max" | "min" | "sum" | "avg" | "stddev" | "variance", number | Date>> | undefined;
248
+ operatorResults?: Partial<Record<"max" | "min" | "sum" | "avg" | "stddev" | "variance", number | Date>> | undefined;
249
249
  $selected?: boolean | undefined;
250
250
  $excluded?: boolean | undefined;
251
251
  $filtered?: boolean | undefined;
@@ -665,14 +665,14 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
665
665
  }[] | undefined;
666
666
  } | null | undefined;
667
667
  } & {
668
- $aggregationMap: globalThis.Record<string, {
668
+ $aggregationMap: Record<string, {
669
669
  name: string;
670
670
  items: ({
671
671
  value: string | number | boolean | null;
672
672
  count: number;
673
673
  display?: string | undefined;
674
674
  score?: number | undefined;
675
- operatorResults?: Partial<globalThis.Record<"max" | "min" | "sum" | "avg" | "stddev" | "variance", number | Date>> | undefined;
675
+ operatorResults?: Partial<Record<"max" | "min" | "sum" | "avg" | "stddev" | "variance", number | Date>> | undefined;
676
676
  $selected?: boolean | undefined;
677
677
  $excluded?: boolean | undefined;
678
678
  $filtered?: boolean | undefined;
@@ -695,7 +695,7 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
695
695
  count: number;
696
696
  display?: string | undefined;
697
697
  score?: number | undefined;
698
- operatorResults?: Partial<globalThis.Record<"max" | "min" | "sum" | "avg" | "stddev" | "variance", number | Date>> | undefined;
698
+ operatorResults?: Partial<Record<"max" | "min" | "sum" | "avg" | "stddev" | "variance", number | Date>> | undefined;
699
699
  $selected?: boolean | undefined;
700
700
  $excluded?: boolean | undefined;
701
701
  $filtered?: boolean | undefined;
@@ -727,7 +727,7 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
727
727
  count: number;
728
728
  display?: string | undefined;
729
729
  score?: number | undefined;
730
- operatorResults?: Partial<globalThis.Record<"max" | "min" | "sum" | "avg" | "stddev" | "variance", number | Date>> | undefined;
730
+ operatorResults?: Partial<Record<"max" | "min" | "sum" | "avg" | "stddev" | "variance", number | Date>> | undefined;
731
731
  $selected?: boolean | undefined;
732
732
  $excluded?: boolean | undefined;
733
733
  $filtered?: boolean | undefined;
@@ -752,7 +752,7 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
752
752
  count: number;
753
753
  display?: string | undefined;
754
754
  score?: number | undefined;
755
- operatorResults?: Partial<globalThis.Record<"max" | "min" | "sum" | "avg" | "stddev" | "variance", number | Date>> | undefined;
755
+ operatorResults?: Partial<Record<"max" | "min" | "sum" | "avg" | "stddev" | "variance", number | Date>> | undefined;
756
756
  $selected?: boolean | undefined;
757
757
  $excluded?: boolean | undefined;
758
758
  $filtered?: boolean | undefined;
@@ -808,7 +808,7 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
808
808
  count: number;
809
809
  display?: string | undefined;
810
810
  score?: number | undefined;
811
- operatorResults?: Partial<globalThis.Record<"max" | "min" | "sum" | "avg" | "stddev" | "variance", number | Date>> | undefined;
811
+ operatorResults?: Partial<Record<"max" | "min" | "sum" | "avg" | "stddev" | "variance", number | Date>> | undefined;
812
812
  $selected?: boolean | undefined;
813
813
  $excluded?: boolean | undefined;
814
814
  $filtered?: boolean | undefined;
@@ -840,7 +840,7 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
840
840
  count: number;
841
841
  display?: string | undefined;
842
842
  score?: number | undefined;
843
- operatorResults?: Partial<globalThis.Record<"max" | "min" | "sum" | "avg" | "stddev" | "variance", number | Date>> | undefined;
843
+ operatorResults?: Partial<Record<"max" | "min" | "sum" | "avg" | "stddev" | "variance", number | Date>> | undefined;
844
844
  $selected?: boolean | undefined;
845
845
  $excluded?: boolean | undefined;
846
846
  $filtered?: boolean | undefined;
@@ -872,7 +872,7 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
872
872
  count: number;
873
873
  display?: string | undefined;
874
874
  score?: number | undefined;
875
- operatorResults?: Partial<globalThis.Record<"max" | "min" | "sum" | "avg" | "stddev" | "variance", number | Date>> | undefined;
875
+ operatorResults?: Partial<Record<"max" | "min" | "sum" | "avg" | "stddev" | "variance", number | Date>> | undefined;
876
876
  $selected?: boolean | undefined;
877
877
  $excluded?: boolean | undefined;
878
878
  $filtered?: boolean | undefined;
@@ -926,6 +926,7 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
926
926
  }>;
927
927
  principalService: PrincipalWebService;
928
928
  cdr: ChangeDetectorRef;
929
+ appService: AppService;
929
930
  /** Define the key based on it, the chat service instance will be stored */
930
931
  instanceId: string;
931
932
  /** Define the query to use to fetch answers */
@@ -969,7 +970,10 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
969
970
  partname: string;
970
971
  }[];
971
972
  }[];
972
- documentlanguages: string[];
973
+ documentlanguages: string[]; /**
974
+ * Send a "like" event on clicking on the thumb-up icon of an assistant's message
975
+ * @param rank The rank of the message to like
976
+ */
973
977
  documentweight: string;
974
978
  modified: string;
975
979
  indexationtime: string;
@@ -1068,6 +1072,7 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
1068
1072
  messageList?: ElementRef<HTMLUListElement>;
1069
1073
  questionInput?: ElementRef<HTMLTextAreaElement>;
1070
1074
  loadingTpl?: TemplateRef<any>;
1075
+ reportIssueTpl?: TemplateRef<any>;
1071
1076
  chatService: ChatService;
1072
1077
  config: ChatConfig;
1073
1078
  messages$: BehaviorSubject<ChatMessage[] | undefined>;
@@ -1084,6 +1089,12 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
1084
1089
  isAtBottom: boolean;
1085
1090
  initializationError: boolean;
1086
1091
  enabledUserInput: boolean;
1092
+ issueTypes: string[];
1093
+ issueType: string;
1094
+ issueComment?: string;
1095
+ messageRelatedIssue?: ChatMessage;
1096
+ issueRank?: number;
1097
+ showReportIssue: boolean;
1087
1098
  private _previousQuery;
1088
1099
  constructor();
1089
1100
  ngOnInit(): void;
@@ -1091,12 +1102,12 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
1091
1102
  ngOnDestroy(): void;
1092
1103
  /**
1093
1104
  * Instantiate the chat service based on the provided @input protocol
1094
- * The chat service instance will then be stored in the instanceManagerService with provided @input instanceId as a key
1105
+ * This chat service instance will then be stored in the instanceManagerService with provided @input instanceId as a key
1095
1106
  */
1096
1107
  instantiateChatService(): void;
1097
1108
  get actions(): Action[];
1098
1109
  private handleChanges;
1099
- private triggerReloadAfterQueryChange;
1110
+ private _triggerReloadAfterQueryChange;
1100
1111
  private addScrollListener;
1101
1112
  updateModelDescription(): void;
1102
1113
  submitQuestion(): void;
@@ -1124,14 +1135,20 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
1124
1135
  * If the chat is meant to be initialized with event === "Query", the corresponding user query message will be added to the chat history
1125
1136
  */
1126
1137
  loadDefaultChat(): void;
1138
+ /**
1139
+ * If the provided query text is not empty, then add the user query message to the chat history and invoke the assistant
1140
+ * Otherwise, just start a new chat with a warning message inviting the user to perform a full text search to retrieve some results
1141
+ */
1142
+ private _handleQueryMode;
1143
+ private _defineMessageAuditDetails;
1127
1144
  /**
1128
1145
  * Start/open a new chat with the provided messages and chatId
1129
1146
  * If the last message is from the user, a request to the assistant is made to get an answer
1130
1147
  * If the last message is from the assistant, the conversation is loaded right away
1131
1148
  * @param messages The list of messages of the chat
1132
- * @param chatId The id of the chat. If provided (ie. an existing discussion in the saved chat index), update the savedChatId in the chat service for the upcoming saved chat operations
1149
+ * @param savedChatId The id of the saved chat. If provided (ie. an existing discussion in the saved chat index), update the savedChatId in the chat service for the upcoming saved chat operations
1133
1150
  */
1134
- openChat(messages: RawMessage[], chatId?: string): void;
1151
+ openChat(messages: RawMessage[], savedChatId?: string): void;
1135
1152
  /**
1136
1153
  * Reset the chat by clearing the chat history and the UI accordingly
1137
1154
  * The user input will be cleared
@@ -1148,6 +1165,11 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
1148
1165
  * @param index The index of the user's message to edit
1149
1166
  */
1150
1167
  editMessage(index: number): void;
1168
+ /**
1169
+ * Copy a previous assistant message of the chat history to the clipboard.
1170
+ * @param index The index of the assistant's message to edit
1171
+ */
1172
+ copyMessage(index: number): void;
1151
1173
  /**
1152
1174
  * Starting from the provided index, remove all subsequent messages from the chat history and the UI accordingly.
1153
1175
  * The assistant will regenerate a new answer based on the updated chat history.
@@ -1156,6 +1178,34 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
1156
1178
  regenerateMessage(index: number): void;
1157
1179
  onKeyUp(event: KeyboardEvent): void;
1158
1180
  calculateHeight(): void;
1181
+ /**
1182
+ * Send a "like" event on clicking on the thumb-up icon of an assistant's message
1183
+ * @param rank The rank of the message to like
1184
+ */
1185
+ onLike(rank: number): void;
1186
+ /**
1187
+ * Send a "dislike" event on clicking on the thumb-down icon of an assistant's message.
1188
+ * It also opens the issue reporting dialog.
1189
+ * @param message The assistant message to dislike
1190
+ * @param rank The rank of the message to dislike
1191
+ */
1192
+ onDislike(message: ChatMessage, rank: number): void;
1193
+ /**
1194
+ * Report an issue related to the assistant's message.
1195
+ */
1196
+ sendIssue(): void;
1197
+ /**
1198
+ * Close the issue reporting dialog.
1199
+ */
1200
+ ignoreIssue(): void;
1201
+ openAttachmentPreview(data: {
1202
+ reference: ChatContextAttachment;
1203
+ partId?: number;
1204
+ }): void;
1205
+ openOriginalAttachment(data: {
1206
+ reference: ChatContextAttachment;
1207
+ partId?: number;
1208
+ }): void;
1159
1209
  static ɵfac: i0.ɵɵFactoryDeclaration<ChatComponent, never>;
1160
- 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"], never, true>;
1210
+ 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"], never, true>;
1161
1211
  }
@@ -1,7 +1,7 @@
1
1
  import { UserPreferences } from "@sinequa/components/user-settings";
2
2
  import { LoginService } from "@sinequa/core/login";
3
3
  import { NotificationsService } from "@sinequa/core/notification";
4
- import { AuditWebService, UserSettingsWebService } from "@sinequa/core/web-services";
4
+ import { AuditWebService, UserSettingsWebService, PrincipalWebService } from "@sinequa/core/web-services";
5
5
  import { BehaviorSubject, Observable } from "rxjs";
6
6
  import { ChatConfig, ChatMessage, ChatResponse, ChatUsageMetrics, GllmFunction, GllmModelDescription, Quota, SavedChat, SavedChatHistory, TokenConsumption, UserTokenConsumption } from "./types";
7
7
  import { AppService, Query } from "@sinequa/core/app-utils";
@@ -9,38 +9,42 @@ import { IntlService } from "@sinequa/core/intl";
9
9
  import { ModalService } from "@sinequa/core/modal";
10
10
  import * as i0 from "@angular/core";
11
11
  export declare abstract class ChatService {
12
- /** Name of the assistant plugin OR websocket endpoint */
12
+ /** Name of the assistant plugin OR websocket endpoint. */
13
13
  REQUEST_URL: string;
14
- /** Emit true once the initialization of the chat process is done*/
14
+ /** Emit true once the initialization of the chat process is done. */
15
15
  initProcess$: BehaviorSubject<boolean>;
16
- /** Emit true once the initialization of the chat config is done*/
16
+ /** Emit true once the initialization of the chat config is done. */
17
17
  initConfig$: BehaviorSubject<boolean>;
18
- /** Global configuration of the chat */
18
+ /** Global configuration of the chat. */
19
19
  chatConfig$: BehaviorSubject<ChatConfig | undefined>;
20
- /** Streaming status of the chat endpoint */
20
+ /** Streaming status of the chat endpoint. */
21
21
  streaming$: BehaviorSubject<boolean>;
22
- /** Store the messages history of the current chat */
22
+ /** Store the messages history of the current chat. */
23
23
  chatHistory: ChatMessage[] | undefined;
24
- /** List of models available on the server */
24
+ /** List of models available on the server. */
25
25
  models: GllmModelDescription[] | undefined;
26
- /** List of functions available on the server */
26
+ /** List of functions available on the server. */
27
27
  functions: GllmFunction[] | undefined;
28
- /** List of saved chats */
28
+ /** List of saved chats. */
29
29
  savedChats$: BehaviorSubject<SavedChat[]>;
30
- /** Emit the saved chat to load */
30
+ /** Emit the saved chat to load. */
31
31
  loadSavedChat$: BehaviorSubject<SavedChat | undefined>;
32
- /** Emit the quota each time the chat is invoked */
32
+ /** Emit the quota each time the chat is invoked. */
33
33
  quota$: BehaviorSubject<Quota | undefined>;
34
- /** Emit the calculated user's token consumption based on the quota */
34
+ /** Emit the calculated user's token consumption based on the quota. */
35
35
  userTokenConsumption$: BehaviorSubject<UserTokenConsumption | undefined>;
36
- /** Emit the chat usage metrics each time the generation of the assistant response is completed */
36
+ /** Emit the chat usage metrics each time the generation of the assistant response is completed. */
37
37
  chatUsageMetrics$: BehaviorSubject<ChatUsageMetrics | undefined>;
38
- /** Emit the calculated chat's token consumption based on the chat usage metrics */
38
+ /** Emit the calculated chat's token consumption based on the chat usage metrics. */
39
39
  chatTokenConsumption$: BehaviorSubject<TokenConsumption | undefined>;
40
- /** Instance ID of the chat service defining the assistant instance */
40
+ /** Instance ID of the chat service defining the assistant instance. */
41
41
  private _chatInstanceId;
42
- /** ID of the current chat discussion which is used to update/get/delete it */
42
+ /** ID of the current **saved chat** discussion which is used to update/get/delete it. */
43
43
  private _savedChatId;
44
+ /** Generated GUID for the current non-saved chat discussion used to identify audit events.
45
+ * If the chat is saved, the savedChatId is initialized with the value of this chatId.
46
+ */
47
+ private _chatId;
44
48
  userSettingsService: UserSettingsWebService;
45
49
  notificationsService: NotificationsService;
46
50
  auditService: AuditWebService;
@@ -49,6 +53,7 @@ export declare abstract class ChatService {
49
53
  appService: AppService;
50
54
  intlService: IntlService;
51
55
  modalService: ModalService;
56
+ principalService: PrincipalWebService;
52
57
  /**
53
58
  * Initialize the chat process
54
59
  */
@@ -78,6 +83,17 @@ export declare abstract class ChatService {
78
83
  * @param savedChatId The ID of the current chat discussion which is used to save/get/delete it
79
84
  */
80
85
  setSavedChatId(savedChatId: string | undefined): void;
86
+ /**
87
+ * Get the ID of the current chat discussion which is used to identify audit events
88
+ * @returns The ID of the current chat discussion
89
+ */
90
+ get chatId(): string;
91
+ /**
92
+ * Generate an GUID for the current chat discussion which is used to identify audit events
93
+ * If the discussion is saved, the savedChatId is initialized with the value of this chatId
94
+ * @param chatId if provided, it will be considered as the ID of the current chat discussion which is used to identify audit events
95
+ */
96
+ generateChatId(chatId?: string): void;
81
97
  /**
82
98
  * Initialize the chat config by managing ONLY sub-object **defaultValues** configs of the standard app config (defined in the customization json tab ) and the user preferences.
83
99
  * To do so, a tracking mechanism is implemented to notify the user about the available updates in the defaultValues object of the standard app config.
@@ -160,7 +176,13 @@ export declare abstract class ChatService {
160
176
  * @returns The number of deleted chats
161
177
  */
162
178
  abstract deleteSavedChat(ids: string[]): Observable<number>;
163
- notifyAudit(messagesHistory: ChatMessage[], model: string): void;
179
+ /**
180
+ * Generate an audit event with the given type and details. The generated audit event is sent afterwards via the AuditWebService
181
+ * @param type Audit event type
182
+ * @param details Audit event details
183
+ * @param id Actions (savedChat delete/rename/...) may occur on a specific chat different than the current one stored in this service, so the chat id can be provided
184
+ */
185
+ generateAuditEvent(type: string, details: Record<string, any>, id?: string): void;
164
186
  /**
165
187
  * Format a date string in UTC to a local date string
166
188
  * @param value Date string in UTC to format
@@ -173,10 +195,6 @@ export declare abstract class ChatService {
173
195
  * context object.
174
196
  */
175
197
  static formatPrompt(prompt: string, context: any): string;
176
- /**
177
- * @returns A Globally Unique Identifier
178
- */
179
- static generateGUID(): string;
180
198
  static ɵfac: i0.ɵɵFactoryDeclaration<ChatService, never>;
181
199
  static ɵprov: i0.ɵɵInjectableDeclaration<ChatService>;
182
200
  }
package/chat/types.d.ts CHANGED
@@ -60,7 +60,7 @@ export interface ChatContextAttachment extends RawAttachment {
60
60
  contextId: number;
61
61
  /** Parts of the record that the assistant uses to answer */
62
62
  parts: DocumentPart[];
63
- /** The specific id of used the referenced part */
63
+ /** The specific id used of the referenced part */
64
64
  $partId?: number;
65
65
  }
66
66
  /**