@sinequa/assistant 3.7.0 → 3.7.2
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.
- package/chat/chat-message/chat-message.component.d.ts +4 -8
- package/chat/chat.component.d.ts +118 -14
- package/chat/chat.service.d.ts +11 -5
- package/chat/rest-chat.service.d.ts +1 -0
- package/chat/styles/assistant.scss +2 -0
- package/chat/types.d.ts +49 -115
- package/chat/websocket-chat.service.d.ts +3 -1
- package/esm2020/chat/chat-message/chat-message.component.mjs +3 -10
- package/esm2020/chat/chat-reference/chat-reference.component.mjs +3 -3
- package/esm2020/chat/chat-settings-v3/chat-settings-v3.component.mjs +3 -3
- package/esm2020/chat/chat.component.mjs +206 -39
- package/esm2020/chat/chat.service.mjs +15 -13
- package/esm2020/chat/instance-manager.service.mjs +2 -2
- package/esm2020/chat/rest-chat.service.mjs +27 -23
- package/esm2020/chat/saved-chats/saved-chats.component.mjs +4 -4
- package/esm2020/chat/token-progress-bar/token-progress-bar.component.mjs +4 -4
- package/esm2020/chat/types.mjs +9 -10
- package/esm2020/chat/websocket-chat.service.mjs +70 -50
- package/fesm2015/sinequa-assistant-chat.mjs +328 -143
- package/fesm2015/sinequa-assistant-chat.mjs.map +1 -1
- package/fesm2020/sinequa-assistant-chat.mjs +334 -150
- package/fesm2020/sinequa-assistant-chat.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EventEmitter, OnChanges, SimpleChanges, ChangeDetectorRef, AfterViewInit, ElementRef } from "@angular/core";
|
|
2
2
|
import { PrincipalWebService } from "@sinequa/core/web-services";
|
|
3
3
|
import { SearchService } from "@sinequa/components/search";
|
|
4
|
-
import { ChatContextAttachment, ChatMessage,
|
|
4
|
+
import { ChatContextAttachment, ChatMessage, SuggestedAction } from "../types";
|
|
5
5
|
import { Processor } from "unified";
|
|
6
6
|
import { Node } from "unist";
|
|
7
7
|
import { UIService } from "@sinequa/components/utils";
|
|
@@ -17,7 +17,6 @@ export declare class ChatMessageComponent implements OnChanges, AfterViewInit {
|
|
|
17
17
|
message: ChatMessage;
|
|
18
18
|
conversation: ChatMessage[];
|
|
19
19
|
suggestedActions: SuggestedAction[] | undefined;
|
|
20
|
-
chatStarters: ChatStarter[] | undefined;
|
|
21
20
|
assistantMessageIcon: string;
|
|
22
21
|
userMessageIcon: string;
|
|
23
22
|
connectionErrorMessageIcon: string;
|
|
@@ -38,12 +37,11 @@ export declare class ChatMessageComponent implements OnChanges, AfterViewInit {
|
|
|
38
37
|
partId?: number | undefined;
|
|
39
38
|
}>;
|
|
40
39
|
suggestAction: EventEmitter<SuggestedAction>;
|
|
41
|
-
chatStarterClicked: EventEmitter<ChatStarter>;
|
|
42
40
|
edit: EventEmitter<ChatMessage>;
|
|
43
41
|
copy: EventEmitter<ChatMessage>;
|
|
44
42
|
regenerate: EventEmitter<ChatMessage>;
|
|
45
|
-
like: EventEmitter<
|
|
46
|
-
dislike: EventEmitter<
|
|
43
|
+
like: EventEmitter<any>;
|
|
44
|
+
dislike: EventEmitter<any>;
|
|
47
45
|
debug: EventEmitter<ChatMessage>;
|
|
48
46
|
processor: Processor;
|
|
49
47
|
references: string[];
|
|
@@ -51,8 +49,6 @@ export declare class ChatMessageComponent implements OnChanges, AfterViewInit {
|
|
|
51
49
|
showReferences: boolean;
|
|
52
50
|
collapseProgress: boolean;
|
|
53
51
|
iconSize: number;
|
|
54
|
-
liked: boolean;
|
|
55
|
-
disliked: boolean;
|
|
56
52
|
hiddenTooltip: boolean;
|
|
57
53
|
constructor(searchService: SearchService, ui: UIService, principalService: PrincipalWebService, cdr: ChangeDetectorRef, el: ElementRef);
|
|
58
54
|
ngOnChanges(changes: SimpleChanges): void;
|
|
@@ -81,5 +77,5 @@ export declare class ChatMessageComponent implements OnChanges, AfterViewInit {
|
|
|
81
77
|
openOriginalAttachment(attachment: ChatContextAttachment, partId?: number): void;
|
|
82
78
|
hideTooltip(): void;
|
|
83
79
|
static ɵfac: i0.ɵɵFactoryDeclaration<ChatMessageComponent, never>;
|
|
84
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<ChatMessageComponent, "sq-chat-message", never, { "message": "message"; "conversation": "conversation"; "suggestedActions": "suggestedActions"; "
|
|
80
|
+
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>;
|
|
85
81
|
}
|
package/chat/chat.component.d.ts
CHANGED
|
@@ -6,12 +6,13 @@ import { AppService, Query } from "@sinequa/core/app-utils";
|
|
|
6
6
|
import { PrincipalWebService } from "@sinequa/core/web-services";
|
|
7
7
|
import { BehaviorSubject } from "rxjs";
|
|
8
8
|
import { ChatService } from "./chat.service";
|
|
9
|
-
import { ChatContextAttachment, ChatConfig, ChatMessage, GllmModelDescription, MessageHandler, RawMessage, SuggestedAction, InitChat, DebugMessage
|
|
9
|
+
import { ChatContextAttachment, ChatConfig, ChatMessage, GllmModelDescription, MessageHandler, RawMessage, SuggestedAction, InitChat, DebugMessage } from "./types";
|
|
10
10
|
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
14
|
import { HubConnection } from "@microsoft/signalr";
|
|
15
|
+
import { NotificationsService } from "@sinequa/core/notification";
|
|
15
16
|
import * as i0 from "@angular/core";
|
|
16
17
|
export declare class ChatComponent extends AbstractFacet implements OnInit, OnChanges, OnDestroy {
|
|
17
18
|
loginService: LoginService;
|
|
@@ -928,6 +929,7 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
|
|
|
928
929
|
principalService: PrincipalWebService;
|
|
929
930
|
cdr: ChangeDetectorRef;
|
|
930
931
|
appService: AppService;
|
|
932
|
+
notificationsService: NotificationsService;
|
|
931
933
|
/** Define the key based on it, the chat service instance will be stored */
|
|
932
934
|
instanceId: string;
|
|
933
935
|
/** Define the query to use to fetch answers */
|
|
@@ -1075,10 +1077,10 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
|
|
|
1075
1077
|
openPreview: EventEmitter<ChatContextAttachment>;
|
|
1076
1078
|
/** Event emitter triggered when the user clicks on a suggested action */
|
|
1077
1079
|
suggestAction: EventEmitter<SuggestedAction>;
|
|
1078
|
-
/**
|
|
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>;
|
|
@@ -1121,24 +1123,68 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
|
|
|
1121
1123
|
ngOnChanges(changes: SimpleChanges): void;
|
|
1122
1124
|
ngOnDestroy(): void;
|
|
1123
1125
|
get isAdmin(): boolean;
|
|
1124
|
-
get visibleMessagesCount(): number;
|
|
1125
1126
|
/**
|
|
1126
1127
|
* Instantiate the chat service based on the provided @input protocol
|
|
1127
1128
|
* This chat service instance will then be stored in the instanceManagerService with provided @input instanceId as a key
|
|
1128
1129
|
*/
|
|
1129
1130
|
instantiateChatService(): void;
|
|
1130
1131
|
get actions(): Action[];
|
|
1132
|
+
/**
|
|
1133
|
+
* Handles the changes in the chat component.
|
|
1134
|
+
* If the chat service is a WebSocketChatService, it handles the override of the message handlers if they exist.
|
|
1135
|
+
* Initializes the chat with the provided chat messages if they exist, otherwise loads the default chat.
|
|
1136
|
+
* If the chat is initialized, the initialization event is "Query", the query changes, and the queryChangeShouldTriggerReload function is provided,
|
|
1137
|
+
* then the chat should be reloaded if the function returns true. Otherwise, the chat should be reloaded by default.
|
|
1138
|
+
* It takes into account the ongoing streaming process and the ongoing stopping process to trigger that conditionally define the logic
|
|
1139
|
+
* of the reload :
|
|
1140
|
+
* - If the chat is streaming, then stop the generation and wait for the fetch to complete before reloading the chat.
|
|
1141
|
+
* - If the chat is stopping the generation, then wait for the fetch to complete before reloading the chat.
|
|
1142
|
+
*/
|
|
1131
1143
|
private _handleChanges;
|
|
1144
|
+
/**
|
|
1145
|
+
* Triggers a reload after the query change.
|
|
1146
|
+
* This method performs the necessary operations to reload the chat after a query change.
|
|
1147
|
+
* It sets the system and user messages, resets the savedChatId, generates a new chatId,
|
|
1148
|
+
* generates a new chat audit event, and handles the query mode.
|
|
1149
|
+
*/
|
|
1132
1150
|
private _triggerReloadAfterQueryChange;
|
|
1151
|
+
/**
|
|
1152
|
+
* Adds a scroll listener to the message list element.
|
|
1153
|
+
* The listener is triggered when any of the following events occur:
|
|
1154
|
+
* - Loading state changes
|
|
1155
|
+
* - Messages change
|
|
1156
|
+
* - Streaming state changes
|
|
1157
|
+
* - Scroll event occurs on the message list element
|
|
1158
|
+
*
|
|
1159
|
+
* When the listener is triggered, it updates the `isAtBottom` property.
|
|
1160
|
+
*/
|
|
1133
1161
|
private _addScrollListener;
|
|
1162
|
+
/**
|
|
1163
|
+
* Get the model description based on the defaultValues service_id and model_id
|
|
1164
|
+
*/
|
|
1134
1165
|
updateModelDescription(): void;
|
|
1166
|
+
/**
|
|
1167
|
+
* Submits a question from the user.
|
|
1168
|
+
* If the user is editing a previous message, removes all subsequent messages from the chat history.
|
|
1169
|
+
* Triggers the fetch of the answer for the submitted question by calling _fetchAnswer().
|
|
1170
|
+
* Clears the input value in the UI.
|
|
1171
|
+
* ⚠️ If the chat is streaming or stopping the generation, the operation is not allowed.
|
|
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
|
-
*
|
|
1186
|
+
* ⚠️ If the assistant is streaming or stopping the generation, the operation is not allowed.
|
|
1187
|
+
* @param messages The list of messages to invoke the chat endpoint with
|
|
1142
1188
|
*/
|
|
1143
1189
|
fetch(messages: ChatMessage[]): void;
|
|
1144
1190
|
/**
|
|
@@ -1159,22 +1205,51 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
|
|
|
1159
1205
|
* @param messages
|
|
1160
1206
|
*/
|
|
1161
1207
|
updateData(messages: ChatMessage[]): void;
|
|
1208
|
+
/**
|
|
1209
|
+
* @returns true if the chat discussion is scrolled down to the bottom, false otherwise
|
|
1210
|
+
*/
|
|
1162
1211
|
private _toggleScrollButtonVisibility;
|
|
1212
|
+
/**
|
|
1213
|
+
* Scroll down to the bottom of the chat discussion
|
|
1214
|
+
*/
|
|
1163
1215
|
scrollDown(): void;
|
|
1164
1216
|
/**
|
|
1165
|
-
* Start a new chat with the defaultValues settings
|
|
1166
|
-
* The savedChatId in the chat service will be reset, so that the upcoming saved chat operations will be performed on the fresh new chat
|
|
1167
|
-
* If the savedChat feature is enabled, the list of saved chats will be refreshed
|
|
1217
|
+
* Start a new chat with the defaultValues settings.
|
|
1218
|
+
* The savedChatId in the chat service will be reset, so that the upcoming saved chat operations will be performed on the fresh new chat.
|
|
1219
|
+
* If the savedChat feature is enabled, the list of saved chats will be refreshed.
|
|
1220
|
+
* ⚠️ If the assistant is streaming or stopping the generation, the operation is not allowed.
|
|
1168
1221
|
*/
|
|
1169
1222
|
newChat(): void;
|
|
1223
|
+
/**
|
|
1224
|
+
* Attaches the specified document IDs to the assistant.
|
|
1225
|
+
* If no document IDs are provided, the operation is not allowed.
|
|
1226
|
+
* If the action for attaching a document is not defined at the application customization level, an error is logged.
|
|
1227
|
+
* ⚠️ If the assistant is streaming or stopping the generation, the operation is not allowed.
|
|
1228
|
+
* @param ids - An array of document IDs to attach.
|
|
1229
|
+
*/
|
|
1230
|
+
attachToChat(ids: string[]): void;
|
|
1170
1231
|
/**
|
|
1171
1232
|
* Start the default chat with the defaultValues settings
|
|
1172
1233
|
* If the chat is meant to be initialized with event === "Query", the corresponding user query message will be added to the chat history
|
|
1173
1234
|
*/
|
|
1174
1235
|
loadDefaultChat(): void;
|
|
1175
1236
|
/**
|
|
1237
|
+
* Handles the prompt mode of the chat component.
|
|
1238
|
+
* If `sendUserPrompt` is true, it opens the chat with both system and user messages,
|
|
1239
|
+
* and generates audit events for both messages.
|
|
1240
|
+
* If `sendUserPrompt` is false, it opens the chat with only the system message,
|
|
1241
|
+
* and generates an audit event for the system message.
|
|
1242
|
+
*
|
|
1243
|
+
* @param systemMsg - The system message to be displayed in the chat.
|
|
1244
|
+
* @param userMsg - The user message to be displayed in the chat (optional).
|
|
1245
|
+
*/
|
|
1246
|
+
private _handlePromptMode;
|
|
1247
|
+
/**
|
|
1248
|
+
* Handles the query mode by displaying the system message, user message, and user query message.
|
|
1176
1249
|
* If the provided query text is not empty, then add the user query message to the chat history and invoke the assistant
|
|
1177
1250
|
* Otherwise, just start a new chat with a warning message inviting the user to perform a full text search to retrieve some results
|
|
1251
|
+
* @param systemMsg - The system message to be displayed.
|
|
1252
|
+
* @param userMsg - The user message to be displayed.
|
|
1178
1253
|
*/
|
|
1179
1254
|
private _handleQueryMode;
|
|
1180
1255
|
private _defineMessageAuditDetails;
|
|
@@ -1192,14 +1267,27 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
|
|
|
1192
1267
|
* The fetch subscription will be terminated
|
|
1193
1268
|
*/
|
|
1194
1269
|
resetChat(): void;
|
|
1270
|
+
/**
|
|
1271
|
+
* Fetch and Load the saved chat from the saved chat index.
|
|
1272
|
+
* If the saved chat is found, the chat discussion will be loaded with the provided messages and chatId
|
|
1273
|
+
*/
|
|
1195
1274
|
onLoadChat(): void;
|
|
1275
|
+
/**
|
|
1276
|
+
* Stop the generation of the current assistant's answer.
|
|
1277
|
+
* The fetch subscription will be terminated.
|
|
1278
|
+
*/
|
|
1196
1279
|
stopGeneration(): void;
|
|
1280
|
+
/**
|
|
1281
|
+
* Terminate the fetch process by unsubscribing from the data subscription and updating the loading status to false.
|
|
1282
|
+
* Additionally, focus on the chat input if the focusAfterResponse flag is set to true.
|
|
1283
|
+
*/
|
|
1197
1284
|
terminateFetch(): void;
|
|
1198
1285
|
/**
|
|
1199
1286
|
* Copy a previous user message of the chat history to the chat user input.
|
|
1200
1287
|
* Thus, the user can edit and resubmit the message.
|
|
1201
1288
|
* Once the edited message is submitted, all subsequent messages starting from @param index will be removed from the history and the UI will be updated accordingly.
|
|
1202
1289
|
* The assistant will regenerate a new answer based on the updated chat history.
|
|
1290
|
+
* ⚠️ If the assistant is streaming or stopping the generation, the operation is not allowed.
|
|
1203
1291
|
* @param index The index of the user's message to edit
|
|
1204
1292
|
*/
|
|
1205
1293
|
editMessage(index: number): void;
|
|
@@ -1211,6 +1299,7 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
|
|
|
1211
1299
|
/**
|
|
1212
1300
|
* Starting from the provided index, remove all subsequent messages from the chat history and the UI accordingly.
|
|
1213
1301
|
* The assistant will regenerate a new answer based on the updated chat history.
|
|
1302
|
+
* ⚠️ If the assistant is streaming or stopping the generation, the operation is not allowed.
|
|
1214
1303
|
* @param index The index of the assistant's message to regenerate
|
|
1215
1304
|
*/
|
|
1216
1305
|
regenerateMessage(index: number): void;
|
|
@@ -1222,7 +1311,16 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
|
|
|
1222
1311
|
* @param index - The index to be remapped.
|
|
1223
1312
|
*/
|
|
1224
1313
|
private _remapIndexInChatHistory;
|
|
1314
|
+
/**
|
|
1315
|
+
* Handles the key up event for 'Backspace' and 'Enter' keys.
|
|
1316
|
+
* @param event - The keyboard event.
|
|
1317
|
+
*/
|
|
1225
1318
|
onKeyUp(event: KeyboardEvent): void;
|
|
1319
|
+
/**
|
|
1320
|
+
* Calculates and adjusts the height of the question input element based on its content.
|
|
1321
|
+
* If the Enter key is pressed without the Shift key, it prevents the default behavior.
|
|
1322
|
+
* @param event The keyboard event
|
|
1323
|
+
*/
|
|
1226
1324
|
calculateHeight(event?: KeyboardEvent): void;
|
|
1227
1325
|
/**
|
|
1228
1326
|
* Send a "like" event on clicking on the thumb-up icon of an assistant's message
|
|
@@ -1237,6 +1335,7 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
|
|
|
1237
1335
|
* @param index The rank of the message to dislike
|
|
1238
1336
|
*/
|
|
1239
1337
|
onDislike(message: ChatMessage, rank: number): void;
|
|
1338
|
+
private _updateChatHistory;
|
|
1240
1339
|
/**
|
|
1241
1340
|
* Report an issue related to the assistant's message.
|
|
1242
1341
|
*/
|
|
@@ -1267,11 +1366,6 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
|
|
|
1267
1366
|
* @param index Rank of the message in the chatHistory related to the suggested action.
|
|
1268
1367
|
*/
|
|
1269
1368
|
suggestActionClick(action: SuggestedAction, index: number): void;
|
|
1270
|
-
/**
|
|
1271
|
-
* Handle the click on a chat starter.
|
|
1272
|
-
* @param starter the chat starter.
|
|
1273
|
-
*/
|
|
1274
|
-
chatStarterClick(starter: ChatStarter): void;
|
|
1275
1369
|
/**
|
|
1276
1370
|
* It looks for the debug messages available in the current group of "assistant" messages.
|
|
1277
1371
|
* By design, the debug messages are only available in the first visible message among the group "assistant" messages.
|
|
@@ -1292,6 +1386,16 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
|
|
|
1292
1386
|
* @returns if this messages and the following ones (if any) are the last ones
|
|
1293
1387
|
*/
|
|
1294
1388
|
isAssistantLastMessages(messages: ChatMessage[], index: number): boolean;
|
|
1389
|
+
/**
|
|
1390
|
+
* Checks if the given message is an empty assistant message.
|
|
1391
|
+
* An empty assistant message is defined as a message with the role 'assistant',
|
|
1392
|
+
* an empty content, and no additional properties such as attachments, progress,
|
|
1393
|
+
* debug information, or suggested actions.
|
|
1394
|
+
*
|
|
1395
|
+
* @param message - The message to check.
|
|
1396
|
+
* @returns `true` if the message is an empty assistant message, `false` otherwise.
|
|
1397
|
+
*/
|
|
1398
|
+
isEmptyAssistantMessage(message: ChatMessage | undefined): boolean;
|
|
1295
1399
|
static ɵfac: i0.ɵɵFactoryDeclaration<ChatComponent, never>;
|
|
1296
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<ChatComponent, "sq-chat-v3", never, { "instanceId": "instanceId"; "query": "query"; "queryChangeShouldTriggerReload": "queryChangeShouldTriggerReload"; "protocol": "protocol"; "messageHandlers": "messageHandlers"; "automaticScrollToLastResponse": "automaticScrollToLastResponse"; "focusAfterResponse": "focusAfterResponse"; "chat": "chat"; "assistantMessageIcon": "assistantMessageIcon"; "userMessageIcon": "userMessageIcon"; "connectionErrorMessageIcon": "connectionErrorMessageIcon"; "searchWarningMessageIcon": "searchWarningMessageIcon"; }, { "connection": "connection"; "loading$": "loading"; "_config": "config"; "data": "data"; "openDocument": "openDocument"; "openPreview": "openPreview"; "suggestAction": "suggestAction";
|
|
1400
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<ChatComponent, "sq-chat-v3", never, { "instanceId": "instanceId"; "query": "query"; "queryChangeShouldTriggerReload": "queryChangeShouldTriggerReload"; "protocol": "protocol"; "messageHandlers": "messageHandlers"; "automaticScrollToLastResponse": "automaticScrollToLastResponse"; "focusAfterResponse": "focusAfterResponse"; "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", "reportTpl", "tokenConsumptionTpl", "debugMessagesTpl"], never, true>;
|
|
1297
1401
|
}
|
package/chat/chat.service.d.ts
CHANGED
|
@@ -11,14 +11,16 @@ import * as i0 from "@angular/core";
|
|
|
11
11
|
export declare abstract class ChatService {
|
|
12
12
|
/** Name of the assistant plugin OR websocket endpoint. */
|
|
13
13
|
REQUEST_URL: string;
|
|
14
|
-
/** Emit true once the initialization of the
|
|
14
|
+
/** Emit true once the initialization of the assistant process is done. */
|
|
15
15
|
initProcess$: BehaviorSubject<boolean>;
|
|
16
|
-
/** Emit true once the initialization of the
|
|
16
|
+
/** Emit true once the initialization of the assistant config is done. */
|
|
17
17
|
initConfig$: BehaviorSubject<boolean>;
|
|
18
|
-
/**
|
|
19
|
-
|
|
18
|
+
/** Emit the global configuration of the assistant. */
|
|
19
|
+
assistantConfig$: BehaviorSubject<ChatConfig | undefined>;
|
|
20
|
+
/** Emit true if the user has been overridden, false otherwise. */
|
|
21
|
+
userOverride$: BehaviorSubject<boolean | undefined>;
|
|
20
22
|
/**
|
|
21
|
-
* Emit true if the fetch of an assistant's response is ongoing (it includes Streaming status of the
|
|
23
|
+
* Emit true if the fetch of an assistant's response is ongoing (it includes Streaming status of the assistant endpoint AND saving the discussion if save Chat is enabled).
|
|
22
24
|
* This is used to prevent multiple fetches at the same time.
|
|
23
25
|
* Typically, there is no problem chaining fetches, but when forcing a reload after query changes cases, it can't be allowed because it breaks the whole business logic.
|
|
24
26
|
*/
|
|
@@ -120,6 +122,10 @@ export declare abstract class ChatService {
|
|
|
120
122
|
"applied-defaultValues-hash"?: string;
|
|
121
123
|
"skipped-defaultValues-hash"?: string;
|
|
122
124
|
}, notify?: boolean, successCallback?: () => any, errorCallback?: () => any): void;
|
|
125
|
+
/**
|
|
126
|
+
* Overrides the logged in user
|
|
127
|
+
*/
|
|
128
|
+
abstract overrideUser(): void;
|
|
123
129
|
/**
|
|
124
130
|
* Calls the Fetch API to retrieve a new message given all previous messages
|
|
125
131
|
*/
|
|
@@ -18,6 +18,7 @@ export declare class RestChatService extends ChatService {
|
|
|
18
18
|
* It can be overridden by the app config
|
|
19
19
|
*/
|
|
20
20
|
getRequestsUrl(): void;
|
|
21
|
+
overrideUser(): void;
|
|
21
22
|
listModels(): Observable<GllmModelDescription[] | undefined>;
|
|
22
23
|
listFunctions(): Observable<GllmFunction[] | undefined>;
|
|
23
24
|
fetch(messages: ChatMessage[], query: Query): Observable<ChatResponse>;
|
|
@@ -35,6 +35,7 @@ $ast-input-color: var(--ast-input-color, #B0B0B0);
|
|
|
35
35
|
$ast-muted-color: var(--ast-muted-color, rgba(33, 37, 41, 0.75));
|
|
36
36
|
$ast-action-buttons-color: var(--ast-action-buttons-color, #212529);
|
|
37
37
|
$ast-action-buttons-hover-color: var(--ast-action-buttons-hover-color, var(--ast-primary-color, #005DA7));
|
|
38
|
+
$ast-report-bg: var(--ast-report-bg, white);
|
|
38
39
|
|
|
39
40
|
/****************************************************
|
|
40
41
|
classes
|
|
@@ -95,4 +96,5 @@ $ast-action-buttons-hover-color: var(--ast-action-buttons-hover-color, var(--ast
|
|
|
95
96
|
--ast-message-reference-color: black;
|
|
96
97
|
--ast-action-buttons-color: white;
|
|
97
98
|
--ast-action-buttons-hover-color: #6dbee6;
|
|
99
|
+
--ast-report-bg: #070707;
|
|
98
100
|
}
|
package/chat/types.d.ts
CHANGED
|
@@ -29,10 +29,13 @@ 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;
|
|
35
36
|
additionalWorkflowProperties?: any;
|
|
37
|
+
$liked?: boolean;
|
|
38
|
+
$disliked?: boolean;
|
|
36
39
|
[key: string]: any;
|
|
37
40
|
};
|
|
38
41
|
}
|
|
@@ -217,15 +220,6 @@ declare const uiSettingsSchema: z.ZodObject<{
|
|
|
217
220
|
}>;
|
|
218
221
|
export interface UiSettings extends z.infer<typeof uiSettingsSchema> {
|
|
219
222
|
}
|
|
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
223
|
declare const defaultValuesSchema: z.ZodObject<{
|
|
230
224
|
service_id: z.ZodString;
|
|
231
225
|
model_id: z.ZodString;
|
|
@@ -274,7 +268,7 @@ declare const defaultValuesSchema: z.ZodObject<{
|
|
|
274
268
|
}>;
|
|
275
269
|
export interface DefaultValues extends z.infer<typeof defaultValuesSchema> {
|
|
276
270
|
}
|
|
277
|
-
declare const modeSettingsSchema: z.
|
|
271
|
+
declare const modeSettingsSchema: z.ZodObject<{
|
|
278
272
|
enabledUserInput: z.ZodBoolean;
|
|
279
273
|
displayUserPrompt: z.ZodBoolean;
|
|
280
274
|
sendUserPrompt: z.ZodBoolean;
|
|
@@ -282,42 +276,33 @@ declare const modeSettingsSchema: z.ZodEffects<z.ZodObject<{
|
|
|
282
276
|
event: z.ZodEnum<["Query", "Prompt"]>;
|
|
283
277
|
forcedWorkflow: z.ZodOptional<z.ZodString>;
|
|
284
278
|
displayUserQuery: z.ZodOptional<z.ZodBoolean>;
|
|
285
|
-
chatStarters: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
286
|
-
text: z.ZodString;
|
|
287
|
-
}, "strip", z.ZodTypeAny, {
|
|
288
|
-
text: string;
|
|
289
|
-
}, {
|
|
290
|
-
text: string;
|
|
291
|
-
}>, "many">>;
|
|
292
279
|
}, "strip", z.ZodTypeAny, {
|
|
293
280
|
event: "Query" | "Prompt";
|
|
294
281
|
forcedWorkflow?: string | undefined;
|
|
295
282
|
displayUserQuery?: boolean | undefined;
|
|
296
|
-
chatStarters?: {
|
|
297
|
-
text: string;
|
|
298
|
-
}[] | undefined;
|
|
299
283
|
}, {
|
|
300
284
|
event: "Query" | "Prompt";
|
|
301
285
|
forcedWorkflow?: string | undefined;
|
|
302
286
|
displayUserQuery?: boolean | undefined;
|
|
303
|
-
chatStarters?: {
|
|
304
|
-
text: string;
|
|
305
|
-
}[] | undefined;
|
|
306
287
|
}>, {
|
|
307
288
|
event: "Query" | "Prompt";
|
|
308
289
|
forcedWorkflow?: string | undefined;
|
|
309
290
|
displayUserQuery?: boolean | undefined;
|
|
310
|
-
chatStarters?: {
|
|
311
|
-
text: string;
|
|
312
|
-
}[] | undefined;
|
|
313
291
|
}, {
|
|
314
292
|
event: "Query" | "Prompt";
|
|
315
293
|
forcedWorkflow?: string | undefined;
|
|
316
294
|
displayUserQuery?: boolean | undefined;
|
|
317
|
-
chatStarters?: {
|
|
318
|
-
text: string;
|
|
319
|
-
}[] | undefined;
|
|
320
295
|
}>;
|
|
296
|
+
actions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
297
|
+
forcedWorkflow: z.ZodString;
|
|
298
|
+
forcedWorkflowProperties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
299
|
+
}, "strip", z.ZodTypeAny, {
|
|
300
|
+
forcedWorkflow: string;
|
|
301
|
+
forcedWorkflowProperties?: globalThis.Record<string, unknown> | undefined;
|
|
302
|
+
}, {
|
|
303
|
+
forcedWorkflow: string;
|
|
304
|
+
forcedWorkflowProperties?: globalThis.Record<string, unknown> | undefined;
|
|
305
|
+
}>>>;
|
|
321
306
|
}, "strip", z.ZodTypeAny, {
|
|
322
307
|
displayUserPrompt: boolean;
|
|
323
308
|
enabledUserInput: boolean;
|
|
@@ -326,34 +311,11 @@ declare const modeSettingsSchema: z.ZodEffects<z.ZodObject<{
|
|
|
326
311
|
event: "Query" | "Prompt";
|
|
327
312
|
forcedWorkflow?: string | undefined;
|
|
328
313
|
displayUserQuery?: boolean | undefined;
|
|
329
|
-
chatStarters?: {
|
|
330
|
-
text: string;
|
|
331
|
-
}[] | undefined;
|
|
332
|
-
};
|
|
333
|
-
}, {
|
|
334
|
-
displayUserPrompt: boolean;
|
|
335
|
-
enabledUserInput: boolean;
|
|
336
|
-
sendUserPrompt: boolean;
|
|
337
|
-
initialization: {
|
|
338
|
-
event: "Query" | "Prompt";
|
|
339
|
-
forcedWorkflow?: string | undefined;
|
|
340
|
-
displayUserQuery?: boolean | undefined;
|
|
341
|
-
chatStarters?: {
|
|
342
|
-
text: string;
|
|
343
|
-
}[] | undefined;
|
|
344
|
-
};
|
|
345
|
-
}>, {
|
|
346
|
-
displayUserPrompt: boolean;
|
|
347
|
-
enabledUserInput: boolean;
|
|
348
|
-
sendUserPrompt: boolean;
|
|
349
|
-
initialization: {
|
|
350
|
-
event: "Query" | "Prompt";
|
|
351
|
-
forcedWorkflow?: string | undefined;
|
|
352
|
-
displayUserQuery?: boolean | undefined;
|
|
353
|
-
chatStarters?: {
|
|
354
|
-
text: string;
|
|
355
|
-
}[] | undefined;
|
|
356
314
|
};
|
|
315
|
+
actions?: globalThis.Record<string, {
|
|
316
|
+
forcedWorkflow: string;
|
|
317
|
+
forcedWorkflowProperties?: globalThis.Record<string, unknown> | undefined;
|
|
318
|
+
}> | undefined;
|
|
357
319
|
}, {
|
|
358
320
|
displayUserPrompt: boolean;
|
|
359
321
|
enabledUserInput: boolean;
|
|
@@ -362,10 +324,11 @@ declare const modeSettingsSchema: z.ZodEffects<z.ZodObject<{
|
|
|
362
324
|
event: "Query" | "Prompt";
|
|
363
325
|
forcedWorkflow?: string | undefined;
|
|
364
326
|
displayUserQuery?: boolean | undefined;
|
|
365
|
-
chatStarters?: {
|
|
366
|
-
text: string;
|
|
367
|
-
}[] | undefined;
|
|
368
327
|
};
|
|
328
|
+
actions?: globalThis.Record<string, {
|
|
329
|
+
forcedWorkflow: string;
|
|
330
|
+
forcedWorkflowProperties?: globalThis.Record<string, unknown> | undefined;
|
|
331
|
+
}> | undefined;
|
|
369
332
|
}>;
|
|
370
333
|
export interface ModeSettings extends z.infer<typeof modeSettingsSchema> {
|
|
371
334
|
}
|
|
@@ -466,7 +429,7 @@ export declare const chatConfigSchema: z.ZodObject<{
|
|
|
466
429
|
systemPrompt: string;
|
|
467
430
|
userPrompt: string;
|
|
468
431
|
}>;
|
|
469
|
-
modeSettings: z.
|
|
432
|
+
modeSettings: z.ZodObject<{
|
|
470
433
|
enabledUserInput: z.ZodBoolean;
|
|
471
434
|
displayUserPrompt: z.ZodBoolean;
|
|
472
435
|
sendUserPrompt: z.ZodBoolean;
|
|
@@ -474,42 +437,33 @@ export declare const chatConfigSchema: z.ZodObject<{
|
|
|
474
437
|
event: z.ZodEnum<["Query", "Prompt"]>;
|
|
475
438
|
forcedWorkflow: z.ZodOptional<z.ZodString>;
|
|
476
439
|
displayUserQuery: z.ZodOptional<z.ZodBoolean>;
|
|
477
|
-
chatStarters: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
478
|
-
text: z.ZodString;
|
|
479
|
-
}, "strip", z.ZodTypeAny, {
|
|
480
|
-
text: string;
|
|
481
|
-
}, {
|
|
482
|
-
text: string;
|
|
483
|
-
}>, "many">>;
|
|
484
440
|
}, "strip", z.ZodTypeAny, {
|
|
485
441
|
event: "Query" | "Prompt";
|
|
486
442
|
forcedWorkflow?: string | undefined;
|
|
487
443
|
displayUserQuery?: boolean | undefined;
|
|
488
|
-
chatStarters?: {
|
|
489
|
-
text: string;
|
|
490
|
-
}[] | undefined;
|
|
491
444
|
}, {
|
|
492
445
|
event: "Query" | "Prompt";
|
|
493
446
|
forcedWorkflow?: string | undefined;
|
|
494
447
|
displayUserQuery?: boolean | undefined;
|
|
495
|
-
chatStarters?: {
|
|
496
|
-
text: string;
|
|
497
|
-
}[] | undefined;
|
|
498
448
|
}>, {
|
|
499
449
|
event: "Query" | "Prompt";
|
|
500
450
|
forcedWorkflow?: string | undefined;
|
|
501
451
|
displayUserQuery?: boolean | undefined;
|
|
502
|
-
chatStarters?: {
|
|
503
|
-
text: string;
|
|
504
|
-
}[] | undefined;
|
|
505
452
|
}, {
|
|
506
453
|
event: "Query" | "Prompt";
|
|
507
454
|
forcedWorkflow?: string | undefined;
|
|
508
455
|
displayUserQuery?: boolean | undefined;
|
|
509
|
-
chatStarters?: {
|
|
510
|
-
text: string;
|
|
511
|
-
}[] | undefined;
|
|
512
456
|
}>;
|
|
457
|
+
actions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
458
|
+
forcedWorkflow: z.ZodString;
|
|
459
|
+
forcedWorkflowProperties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
460
|
+
}, "strip", z.ZodTypeAny, {
|
|
461
|
+
forcedWorkflow: string;
|
|
462
|
+
forcedWorkflowProperties?: globalThis.Record<string, unknown> | undefined;
|
|
463
|
+
}, {
|
|
464
|
+
forcedWorkflow: string;
|
|
465
|
+
forcedWorkflowProperties?: globalThis.Record<string, unknown> | undefined;
|
|
466
|
+
}>>>;
|
|
513
467
|
}, "strip", z.ZodTypeAny, {
|
|
514
468
|
displayUserPrompt: boolean;
|
|
515
469
|
enabledUserInput: boolean;
|
|
@@ -518,34 +472,11 @@ export declare const chatConfigSchema: z.ZodObject<{
|
|
|
518
472
|
event: "Query" | "Prompt";
|
|
519
473
|
forcedWorkflow?: string | undefined;
|
|
520
474
|
displayUserQuery?: boolean | undefined;
|
|
521
|
-
chatStarters?: {
|
|
522
|
-
text: string;
|
|
523
|
-
}[] | undefined;
|
|
524
|
-
};
|
|
525
|
-
}, {
|
|
526
|
-
displayUserPrompt: boolean;
|
|
527
|
-
enabledUserInput: boolean;
|
|
528
|
-
sendUserPrompt: boolean;
|
|
529
|
-
initialization: {
|
|
530
|
-
event: "Query" | "Prompt";
|
|
531
|
-
forcedWorkflow?: string | undefined;
|
|
532
|
-
displayUserQuery?: boolean | undefined;
|
|
533
|
-
chatStarters?: {
|
|
534
|
-
text: string;
|
|
535
|
-
}[] | undefined;
|
|
536
|
-
};
|
|
537
|
-
}>, {
|
|
538
|
-
displayUserPrompt: boolean;
|
|
539
|
-
enabledUserInput: boolean;
|
|
540
|
-
sendUserPrompt: boolean;
|
|
541
|
-
initialization: {
|
|
542
|
-
event: "Query" | "Prompt";
|
|
543
|
-
forcedWorkflow?: string | undefined;
|
|
544
|
-
displayUserQuery?: boolean | undefined;
|
|
545
|
-
chatStarters?: {
|
|
546
|
-
text: string;
|
|
547
|
-
}[] | undefined;
|
|
548
475
|
};
|
|
476
|
+
actions?: globalThis.Record<string, {
|
|
477
|
+
forcedWorkflow: string;
|
|
478
|
+
forcedWorkflowProperties?: globalThis.Record<string, unknown> | undefined;
|
|
479
|
+
}> | undefined;
|
|
549
480
|
}, {
|
|
550
481
|
displayUserPrompt: boolean;
|
|
551
482
|
enabledUserInput: boolean;
|
|
@@ -554,10 +485,11 @@ export declare const chatConfigSchema: z.ZodObject<{
|
|
|
554
485
|
event: "Query" | "Prompt";
|
|
555
486
|
forcedWorkflow?: string | undefined;
|
|
556
487
|
displayUserQuery?: boolean | undefined;
|
|
557
|
-
chatStarters?: {
|
|
558
|
-
text: string;
|
|
559
|
-
}[] | undefined;
|
|
560
488
|
};
|
|
489
|
+
actions?: globalThis.Record<string, {
|
|
490
|
+
forcedWorkflow: string;
|
|
491
|
+
forcedWorkflowProperties?: globalThis.Record<string, unknown> | undefined;
|
|
492
|
+
}> | undefined;
|
|
561
493
|
}>;
|
|
562
494
|
uiSettings: z.ZodObject<{
|
|
563
495
|
display: z.ZodBoolean;
|
|
@@ -660,10 +592,11 @@ export declare const chatConfigSchema: z.ZodObject<{
|
|
|
660
592
|
event: "Query" | "Prompt";
|
|
661
593
|
forcedWorkflow?: string | undefined;
|
|
662
594
|
displayUserQuery?: boolean | undefined;
|
|
663
|
-
chatStarters?: {
|
|
664
|
-
text: string;
|
|
665
|
-
}[] | undefined;
|
|
666
595
|
};
|
|
596
|
+
actions?: globalThis.Record<string, {
|
|
597
|
+
forcedWorkflow: string;
|
|
598
|
+
forcedWorkflowProperties?: globalThis.Record<string, unknown> | undefined;
|
|
599
|
+
}> | undefined;
|
|
667
600
|
};
|
|
668
601
|
uiSettings: {
|
|
669
602
|
display: boolean;
|
|
@@ -723,10 +656,11 @@ export declare const chatConfigSchema: z.ZodObject<{
|
|
|
723
656
|
event: "Query" | "Prompt";
|
|
724
657
|
forcedWorkflow?: string | undefined;
|
|
725
658
|
displayUserQuery?: boolean | undefined;
|
|
726
|
-
chatStarters?: {
|
|
727
|
-
text: string;
|
|
728
|
-
}[] | undefined;
|
|
729
659
|
};
|
|
660
|
+
actions?: globalThis.Record<string, {
|
|
661
|
+
forcedWorkflow: string;
|
|
662
|
+
forcedWorkflowProperties?: globalThis.Record<string, unknown> | undefined;
|
|
663
|
+
}> | undefined;
|
|
730
664
|
};
|
|
731
665
|
uiSettings: {
|
|
732
666
|
display: boolean;
|
|
@@ -19,8 +19,9 @@ export declare class WebSocketChatService extends ChatService {
|
|
|
19
19
|
authenticationService: AuthenticationService;
|
|
20
20
|
constructor();
|
|
21
21
|
/**
|
|
22
|
-
* Initialize the
|
|
22
|
+
* Initialize the assistant process.
|
|
23
23
|
* It includes building and starting a connection, executing parallel requests for models and functions, and handling errors during the process.
|
|
24
|
+
* ⚠️ This method MUST be called ONLY if the user is loggedIn and once when the assistant is initialized.
|
|
24
25
|
*
|
|
25
26
|
* @returns An Observable<boolean> indicating the success of the initialization process.
|
|
26
27
|
*/
|
|
@@ -30,6 +31,7 @@ export declare class WebSocketChatService extends ChatService {
|
|
|
30
31
|
* It can be overridden by the app config
|
|
31
32
|
*/
|
|
32
33
|
getRequestsUrl(): void;
|
|
34
|
+
overrideUser(): void;
|
|
33
35
|
listModels(): Observable<GllmModelDescription[] | undefined>;
|
|
34
36
|
listFunctions(): Observable<GllmFunction[] | undefined>;
|
|
35
37
|
fetch(messages: ChatMessage[], query: Query): Observable<ChatResponse>;
|