@sinequa/assistant 3.1.1 → 3.2.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.
@@ -5,6 +5,8 @@ import { ChatContextAttachment, ChatMessage } from "../types";
5
5
  import { Processor } from "unified";
6
6
  import { Node } from "unist";
7
7
  import { UIService } from "@sinequa/components/utils";
8
+ import "prismjs-components-importer/esm";
9
+ import 'prismjs/plugins/autoloader/prism-autoloader';
8
10
  import * as i0 from "@angular/core";
9
11
  export declare class ChatMessageComponent implements OnChanges, AfterViewInit {
10
12
  searchService: SearchService;
@@ -143,6 +145,7 @@ export declare class ChatMessageComponent implements OnChanges, AfterViewInit {
143
145
  */
144
146
  referencePlugin: (tree: Node) => Node<import("unist").Data>;
145
147
  placeholderPlugin: (tree: Node) => Node<import("unist").Data>;
148
+ getLinkText(node: any): string;
146
149
  /**
147
150
  * Reformat [ids: 12.2, 42.5] to [12.2][42.5]
148
151
  */
@@ -9,12 +9,16 @@ import * as i0 from "@angular/core";
9
9
  export declare class ChatSettingsV3Component implements OnInit, OnDestroy {
10
10
  /** Define the key based on it, the appropriate chatService instance will be returned from instanceManagerService */
11
11
  instanceId: string;
12
- _update: EventEmitter<any>;
13
- _cancel: EventEmitter<any>;
12
+ _update: EventEmitter<ChatConfig>;
13
+ _cancel: EventEmitter<ChatConfig>;
14
14
  chatService: ChatService;
15
15
  config: ChatConfig;
16
16
  subscription: Subscription;
17
17
  selectedModel: GllmModelDescription | undefined;
18
+ functions: {
19
+ name: string;
20
+ enabled: boolean;
21
+ }[];
18
22
  isAdmin: boolean;
19
23
  loginService: LoginService;
20
24
  instanceManagerService: InstanceManagerService;
@@ -26,8 +30,9 @@ export declare class ChatSettingsV3Component implements OnInit, OnDestroy {
26
30
  get hasModel(): boolean;
27
31
  instantiateChatService(): void;
28
32
  onChatModelChange(selectedModel: GllmModelDescription): void;
33
+ getFunctionDescription(name: string): string;
29
34
  toggleFunctionsSelection(name: string): void;
30
- private updateFunctionsCheckboxes;
35
+ private initFunctionsList;
31
36
  /**
32
37
  * Save the new chat config in the chat service and the user preferences
33
38
  */
@@ -16,150 +16,6 @@ export interface InitChat {
16
16
  messages: RawMessage[];
17
17
  }
18
18
  export declare class ChatComponent extends AbstractFacet implements OnInit, OnChanges, OnDestroy {
19
- /** Define the key based on it, the chat service instance will be stored */
20
- instanceId: string;
21
- /** Define the query to use to fetch answers */
22
- query?: Query;
23
- /** Define the protocol to be used for this chat instance*/
24
- protocol: 'REST' | 'WEBSOCKET';
25
- /** Map of listeners overriding default registered ones*/
26
- messageHandlers: Map<string, MessageHandler<any>>;
27
- /** When the assistant answer a user question, automatically scroll down to the bottom of the discussion */
28
- automaticScrollToLastResponse: boolean;
29
- chat?: InitChat;
30
- enableChat: boolean;
31
- showCredits: boolean;
32
- customAssistantIcon: string;
33
- data: EventEmitter<ChatMessage[]>;
34
- referenceClicked: EventEmitter<{
35
- filename: string;
36
- id: string;
37
- title: string;
38
- text: string;
39
- size: number;
40
- $selected: boolean;
41
- matchlocations: string[];
42
- rank: number;
43
- databasealias: string;
44
- matchingpartnames: string[];
45
- matchlocationsperpartname: {
46
- matchlocations: {
47
- data: string;
48
- partname: string;
49
- }[];
50
- }[];
51
- documentlanguages: string[];
52
- documentweight: string;
53
- modified: string;
54
- indexationtime: string;
55
- version: string;
56
- treepath: string[];
57
- fileext: string;
58
- flags: string[];
59
- collection: string[];
60
- docformat: string;
61
- url1: string;
62
- authors: string[];
63
- rfmEnabled: boolean;
64
- termspresence: {
65
- term: string;
66
- presence: "found" | "missing";
67
- }[];
68
- $isDuplicate: boolean;
69
- $duplicateCount: number;
70
- globalrelevance?: number | undefined;
71
- displayTitle?: string | undefined;
72
- doctype?: string | undefined;
73
- url2?: string | undefined;
74
- relevantExtracts?: string | undefined;
75
- extracts?: {
76
- score: number;
77
- highlighted: string;
78
- locations: string;
79
- originalLocations: string;
80
- partname?: string | undefined;
81
- }[] | undefined;
82
- accesslists?: {
83
- accessListIndices: number[];
84
- authorizedLists: {
85
- id: string;
86
- domain: string;
87
- }[];
88
- deniedLists: {
89
- id: string;
90
- domain: string;
91
- }[];
92
- } | undefined;
93
- thumbnailUrl?: string | undefined;
94
- originalUrl?: string | undefined;
95
- pdfUrl?: string | undefined;
96
- rfm?: {
97
- click?: {
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
- like?: {
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
- important?: {
114
- image: import("@sinequa/core/web-services").RFMDisplay;
115
- status: import("@sinequa/core/web-services").RFMDisplay;
116
- eventCount: number;
117
- average: number;
118
- imageAction: import("@sinequa/core/web-services").RFMDisplay;
119
- availableActions: import("@sinequa/core/web-services").RFMDisplay;
120
- } | undefined;
121
- } | undefined;
122
- groupcount?: number | undefined;
123
- nearhash?: string | undefined;
124
- exacthash?: string | undefined;
125
- containerid?: string | undefined;
126
- $page?: number | undefined;
127
- matchingpassages?: {
128
- passages: {
129
- location: number[];
130
- id: number;
131
- score: number;
132
- rlocation: number[];
133
- highlightedText: string;
134
- $expanded?: boolean | undefined;
135
- }[];
136
- } | undefined;
137
- $hasPassages?: boolean | undefined;
138
- }>;
139
- openPreview: EventEmitter<ChatContextAttachment>;
140
- loading$: EventEmitter<boolean>;
141
- error: EventEmitter<any>;
142
- _config: EventEmitter<ChatConfig>;
143
- messageList?: ElementRef<HTMLUListElement>;
144
- questionInput?: ElementRef<HTMLInputElement>;
145
- loadingTpl?: TemplateRef<any>;
146
- chatService: ChatService;
147
- config: ChatConfig;
148
- messages$: BehaviorSubject<ChatMessage[] | undefined>;
149
- question: string;
150
- _actions: Action[];
151
- sub: Subscription;
152
- dataSubscription: Subscription | undefined;
153
- /** Variables that depend on the type of model in use */
154
- modelDescription?: GllmModelDescription;
155
- assistantIcon: string;
156
- privacyUrl: string;
157
- messageToEdit?: number;
158
- changes$: BehaviorSubject<SimpleChanges | undefined>;
159
- currentMessageIndex: number | undefined;
160
- handleFirstChanges: boolean;
161
- isAtBottom: boolean;
162
- initializationError: boolean;
163
19
  loginService: LoginService;
164
20
  websocketService: WebSocketChatService;
165
21
  restService: RestChatService;
@@ -1073,6 +929,156 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
1073
929
  }>;
1074
930
  principalService: PrincipalWebService;
1075
931
  cdr: ChangeDetectorRef;
932
+ /** Define the key based on it, the chat service instance will be stored */
933
+ instanceId: string;
934
+ /** Define the query to use to fetch answers */
935
+ query: Query;
936
+ /** Function that determines whether the chat should be reloaded after the query changes
937
+ * If not provided, the chat will be reloaded by default
938
+ * @param prevQuery The previous query
939
+ * @param newQuery The new query
940
+ * @returns true if the chat should be reloaded, false otherwise
941
+ */
942
+ queryChangeShouldTriggerReload: (prevQuery: any, newQuery: any) => boolean;
943
+ /** Define the protocol to be used for this chat instance*/
944
+ protocol: 'REST' | 'WEBSOCKET';
945
+ /** Map of listeners overriding default registered ones*/
946
+ messageHandlers: Map<string, MessageHandler<any>>;
947
+ /** When the assistant answer a user question, automatically scroll down to the bottom of the discussion */
948
+ automaticScrollToLastResponse: boolean;
949
+ chat?: InitChat;
950
+ customAssistantIcon: string;
951
+ data: EventEmitter<ChatMessage[]>;
952
+ referenceClicked: EventEmitter<{
953
+ filename: string;
954
+ id: string;
955
+ title: string;
956
+ text: string;
957
+ size: number;
958
+ $selected: boolean;
959
+ matchlocations: string[];
960
+ rank: number;
961
+ databasealias: string;
962
+ matchingpartnames: string[];
963
+ matchlocationsperpartname: {
964
+ matchlocations: {
965
+ data: string;
966
+ partname: string;
967
+ }[];
968
+ }[];
969
+ documentlanguages: string[];
970
+ documentweight: string;
971
+ modified: string;
972
+ indexationtime: string;
973
+ version: string;
974
+ treepath: string[];
975
+ fileext: string;
976
+ flags: string[];
977
+ collection: string[];
978
+ docformat: string;
979
+ url1: string;
980
+ authors: string[];
981
+ rfmEnabled: boolean;
982
+ termspresence: {
983
+ term: string;
984
+ presence: "found" | "missing";
985
+ }[];
986
+ $isDuplicate: boolean;
987
+ $duplicateCount: number;
988
+ globalrelevance?: number | undefined;
989
+ displayTitle?: string | undefined;
990
+ doctype?: string | undefined;
991
+ url2?: string | undefined;
992
+ relevantExtracts?: string | undefined;
993
+ extracts?: {
994
+ score: number;
995
+ highlighted: string;
996
+ locations: string;
997
+ originalLocations: string;
998
+ partname?: string | undefined;
999
+ }[] | undefined;
1000
+ accesslists?: {
1001
+ accessListIndices: number[];
1002
+ authorizedLists: {
1003
+ id: string;
1004
+ domain: string;
1005
+ }[];
1006
+ deniedLists: {
1007
+ id: string;
1008
+ domain: string;
1009
+ }[];
1010
+ } | undefined;
1011
+ thumbnailUrl?: string | undefined;
1012
+ originalUrl?: string | undefined;
1013
+ pdfUrl?: string | undefined;
1014
+ rfm?: {
1015
+ click?: {
1016
+ image: import("@sinequa/core/web-services").RFMDisplay;
1017
+ status: import("@sinequa/core/web-services").RFMDisplay;
1018
+ eventCount: number;
1019
+ average: number;
1020
+ imageAction: import("@sinequa/core/web-services").RFMDisplay;
1021
+ availableActions: import("@sinequa/core/web-services").RFMDisplay;
1022
+ } | undefined;
1023
+ like?: {
1024
+ image: import("@sinequa/core/web-services").RFMDisplay;
1025
+ status: import("@sinequa/core/web-services").RFMDisplay;
1026
+ eventCount: number;
1027
+ average: number;
1028
+ imageAction: import("@sinequa/core/web-services").RFMDisplay;
1029
+ availableActions: import("@sinequa/core/web-services").RFMDisplay;
1030
+ } | undefined;
1031
+ important?: {
1032
+ image: import("@sinequa/core/web-services").RFMDisplay;
1033
+ status: import("@sinequa/core/web-services").RFMDisplay;
1034
+ eventCount: number;
1035
+ average: number;
1036
+ imageAction: import("@sinequa/core/web-services").RFMDisplay;
1037
+ availableActions: import("@sinequa/core/web-services").RFMDisplay;
1038
+ } | undefined;
1039
+ } | undefined;
1040
+ groupcount?: number | undefined;
1041
+ nearhash?: string | undefined;
1042
+ exacthash?: string | undefined;
1043
+ containerid?: string | undefined;
1044
+ $page?: number | undefined;
1045
+ matchingpassages?: {
1046
+ passages: {
1047
+ location: number[];
1048
+ id: number;
1049
+ score: number;
1050
+ rlocation: number[];
1051
+ highlightedText: string;
1052
+ $expanded?: boolean | undefined;
1053
+ }[];
1054
+ } | undefined;
1055
+ $hasPassages?: boolean | undefined;
1056
+ }>;
1057
+ openPreview: EventEmitter<ChatContextAttachment>;
1058
+ loading$: EventEmitter<boolean>;
1059
+ error: EventEmitter<any>;
1060
+ _config: EventEmitter<ChatConfig>;
1061
+ messageList?: ElementRef<HTMLUListElement>;
1062
+ questionInput?: ElementRef<HTMLTextAreaElement>;
1063
+ loadingTpl?: TemplateRef<any>;
1064
+ chatService: ChatService;
1065
+ config: ChatConfig;
1066
+ messages$: BehaviorSubject<ChatMessage[] | undefined>;
1067
+ question: string;
1068
+ _actions: Action[];
1069
+ sub: Subscription;
1070
+ dataSubscription: Subscription | undefined;
1071
+ /** Variables that depend on the type of model in use */
1072
+ modelDescription?: GllmModelDescription;
1073
+ assistantIcon: string;
1074
+ privacyUrl: string;
1075
+ messageToEdit?: number;
1076
+ changes$: BehaviorSubject<SimpleChanges | undefined>;
1077
+ currentMessageIndex: number | undefined;
1078
+ firstChangesHandled: boolean;
1079
+ isAtBottom: boolean;
1080
+ initializationError: boolean;
1081
+ enabledUserInput: boolean;
1076
1082
  constructor();
1077
1083
  ngOnInit(): void;
1078
1084
  ngOnChanges(changes: SimpleChanges): void;
@@ -1080,6 +1086,7 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
1080
1086
  instantiateChatService(): void;
1081
1087
  get actions(): Action[];
1082
1088
  private handleChanges;
1089
+ private triggerReloadAfterQueryChange;
1083
1090
  private addScrollListener;
1084
1091
  updateModelDescription(): void;
1085
1092
  submitQuestion(): void;
@@ -1097,16 +1104,37 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
1097
1104
  updateData(messages: ChatMessage[]): void;
1098
1105
  private toggleScrollButtonVisibility;
1099
1106
  scrollDown(): void;
1107
+ /**
1108
+ * Start a new chat with the defaultValues settings
1109
+ * The savedChatId in the chat service will be reset, so that the upcoming saved chat operations will be performed on the fresh new chat
1110
+ * If the savedChat feature is enabled, the list of saved chats will be refreshed
1111
+ */
1100
1112
  newChat(): void;
1113
+ /**
1114
+ * Start the default chat with the defaultValues settings
1115
+ * If the chat is meant to be initialized with event === "Query", the corresponding user query message will be added to the chat history
1116
+ */
1101
1117
  loadDefaultChat(): void;
1118
+ /**
1119
+ * Start/open a new chat with the provided messages and chatId
1120
+ * If the last message is from the user, a request to the assistant is made to get an answer
1121
+ * If the last message is from the assistant, the conversation is loaded right away
1122
+ * @param messages The list of messages of the chat
1123
+ * @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
1124
+ */
1102
1125
  openChat(messages: RawMessage[], chatId?: string): void;
1126
+ /**
1127
+ * Reset the chat by clearing the messages and the chat history
1128
+ * The question input will be focused after the chat is reset
1129
+ * The fetch subscription will be terminated
1130
+ */
1103
1131
  resetChat(): void;
1104
1132
  onLoadChat(): void;
1105
1133
  terminateFetch(): void;
1106
1134
  editMessage(index: number): void;
1107
1135
  regenerateMessage(index: number): void;
1108
1136
  onKeyUp(event: KeyboardEvent): void;
1109
- private navigateMessage;
1137
+ calculateHeight(): void;
1110
1138
  static ɵfac: i0.ɵɵFactoryDeclaration<ChatComponent, never>;
1111
- static ɵcmp: i0.ɵɵComponentDeclaration<ChatComponent, "sq-chat-v3", never, { "instanceId": "instanceId"; "query": "query"; "protocol": "protocol"; "messageHandlers": "messageHandlers"; "automaticScrollToLastResponse": "automaticScrollToLastResponse"; "chat": "chat"; "enableChat": "enableChat"; "showCredits": "showCredits"; "customAssistantIcon": "customAssistantIcon"; }, { "data": "data"; "referenceClicked": "referenceClicked"; "openPreview": "openPreview"; "loading$": "loading"; "error": "error"; "_config": "config"; }, ["loadingTpl"], never, true>;
1139
+ static ɵcmp: i0.ɵɵComponentDeclaration<ChatComponent, "sq-chat-v3", never, { "instanceId": "instanceId"; "query": "query"; "queryChangeShouldTriggerReload": "queryChangeShouldTriggerReload"; "protocol": "protocol"; "messageHandlers": "messageHandlers"; "automaticScrollToLastResponse": "automaticScrollToLastResponse"; "chat": "chat"; "customAssistantIcon": "customAssistantIcon"; }, { "data": "data"; "referenceClicked": "referenceClicked"; "openPreview": "openPreview"; "loading$": "loading"; "error": "error"; "_config": "config"; }, ["loadingTpl"], never, true>;
1112
1140
  }