@sinequa/assistant 3.9.2 → 3.9.4
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.component.d.ts +35 -38
- package/chat/chat.service.d.ts +190 -84
- package/chat/debug-message/debug-message-details/debug-message-details.component.d.ts +19 -0
- package/chat/debug-message/debug-message.component.d.ts +9 -12
- package/chat/debug-message/debug-message.service.d.ts +15 -0
- package/chat/documents-upload/document-list/document-list.component.d.ts +1 -0
- package/chat/public-api.d.ts +0 -2
- package/chat/saved-chats/i18n/en.json +1 -1
- package/chat/saved-chats/i18n/fr.json +1 -1
- package/chat/saved-chats/saved-chats.component.d.ts +1 -0
- package/chat/saved-chats/saved-chats.service.d.ts +27 -0
- package/chat/services/assistant-configuration.service.d.ts +34 -0
- package/chat/services/assistant-metadata.service.d.ts +18 -0
- package/chat/services/assistant-tokens-tracking.service.d.ts +23 -0
- package/chat/services/assistant-ws-frames.service.d.ts +50 -0
- package/chat/services/signalR-connection.service.d.ts +25 -0
- package/chat/types.d.ts +12 -3
- package/chat/utils/utils.service.d.ts +67 -0
- package/esm2022/chat/chat.component.mjs +198 -227
- package/esm2022/chat/chat.service.mjs +450 -267
- package/esm2022/chat/debug-message/debug-message-details/debug-message-details.component.mjs +43 -0
- package/esm2022/chat/debug-message/debug-message.component.mjs +27 -30
- package/esm2022/chat/debug-message/debug-message.service.mjs +52 -0
- package/esm2022/chat/dialogs/rename-saved-chat.component.mjs +6 -5
- package/esm2022/chat/documents-upload/document-list/document-list.component.mjs +4 -2
- package/esm2022/chat/public-api.mjs +1 -3
- package/esm2022/chat/saved-chats/saved-chats.component.mjs +11 -10
- package/esm2022/chat/saved-chats/saved-chats.service.mjs +161 -0
- package/esm2022/chat/services/assistant-configuration.service.mjs +167 -0
- package/esm2022/chat/services/assistant-metadata.service.mjs +63 -0
- package/esm2022/chat/services/assistant-tokens-tracking.service.mjs +53 -0
- package/esm2022/chat/services/assistant-ws-frames.service.mjs +388 -0
- package/esm2022/chat/services/signalR-connection.service.mjs +105 -0
- package/esm2022/chat/types.mjs +1 -1
- package/esm2022/chat/unified-plugins/embedded-image-reference.plugin.mjs +2 -3
- package/esm2022/chat/utils/utils.service.mjs +170 -0
- package/fesm2022/sinequa-assistant-chat.mjs +2000 -1652
- package/fesm2022/sinequa-assistant-chat.mjs.map +1 -1
- package/package.json +1 -1
- package/chat/rest-chat.service.d.ts +0 -31
- package/chat/websocket-chat.service.d.ts +0 -102
- package/esm2022/chat/rest-chat.service.mjs +0 -300
- package/esm2022/chat/websocket-chat.service.mjs +0 -659
package/chat/chat.component.d.ts
CHANGED
|
@@ -4,22 +4,20 @@ import { BehaviorSubject } from "rxjs";
|
|
|
4
4
|
import { AppGlobalConfig, Article, Query } from "@sinequa/atomic";
|
|
5
5
|
import { ChatService } from "./chat.service";
|
|
6
6
|
import { InstanceManagerService } from "./instance-manager.service";
|
|
7
|
-
import { RestChatService } from "./rest-chat.service";
|
|
8
7
|
import { NotificationsService } from "./services/notification.service";
|
|
9
8
|
import { PrincipalService } from "./services/principal.service";
|
|
10
9
|
import { SearchService } from "./services/search.service";
|
|
11
10
|
import { ChatConfig, ChatContextAttachment, ChatMessage, DebugMessage, GllmModelDescription, InitChat, MessageHandler, RawMessage, SuggestedAction } from "./types";
|
|
12
|
-
import { WebSocketChatService } from "./websocket-chat.service";
|
|
13
11
|
import * as i0 from "@angular/core";
|
|
14
12
|
export declare class ChatComponent implements OnInit, OnChanges, OnDestroy {
|
|
15
|
-
|
|
16
|
-
restService: RestChatService;
|
|
13
|
+
chatService: ChatService;
|
|
17
14
|
instanceManagerService: InstanceManagerService;
|
|
18
15
|
searchService: SearchService;
|
|
19
16
|
principalService: PrincipalService;
|
|
20
17
|
cdr: ChangeDetectorRef;
|
|
21
18
|
notificationsService: NotificationsService;
|
|
22
19
|
private readonly transloco;
|
|
20
|
+
private readonly assistantUtils;
|
|
23
21
|
/** Define the key based on it, the chat service instance will be stored */
|
|
24
22
|
instanceId: string;
|
|
25
23
|
/** Define the query to use to fetch answers */
|
|
@@ -31,8 +29,6 @@ export declare class ChatComponent implements OnInit, OnChanges, OnDestroy {
|
|
|
31
29
|
* @returns true if the chat should be reloaded, false otherwise
|
|
32
30
|
*/
|
|
33
31
|
queryChangeShouldTriggerReload: (prevQuery: Query, newQuery: Query) => boolean;
|
|
34
|
-
/** Define the protocol to be used for this chat instance*/
|
|
35
|
-
protocol: 'REST' | 'WEBSOCKET';
|
|
36
32
|
/** Map of listeners overriding default registered ones*/
|
|
37
33
|
messageHandlers: Map<string, MessageHandler<any>>;
|
|
38
34
|
/** When the assistant answer a user question, automatically scroll down to the bottom of the discussion */
|
|
@@ -73,7 +69,6 @@ export declare class ChatComponent implements OnInit, OnChanges, OnDestroy {
|
|
|
73
69
|
tokenConsumptionTpl?: TemplateRef<any>;
|
|
74
70
|
debugMessagesTpl?: TemplateRef<any>;
|
|
75
71
|
appConfig: AppGlobalConfig;
|
|
76
|
-
chatService: ChatService;
|
|
77
72
|
config: ChatConfig;
|
|
78
73
|
messages$: BehaviorSubject<ChatMessage[] | undefined>;
|
|
79
74
|
isAdminOrDeletedAdmin: boolean;
|
|
@@ -82,8 +77,8 @@ export declare class ChatComponent implements OnInit, OnChanges, OnDestroy {
|
|
|
82
77
|
private _dataSubscription;
|
|
83
78
|
/** Variables that depend on the type of model in use */
|
|
84
79
|
modelDescription?: GllmModelDescription;
|
|
85
|
-
|
|
86
|
-
|
|
80
|
+
indexMessageToEdit?: number;
|
|
81
|
+
rankMessageToEdit?: number;
|
|
87
82
|
changes$: BehaviorSubject<SimpleChanges | undefined>;
|
|
88
83
|
currentMessageIndex: number | undefined;
|
|
89
84
|
firstChangesHandled: boolean;
|
|
@@ -103,7 +98,6 @@ export declare class ChatComponent implements OnInit, OnChanges, OnDestroy {
|
|
|
103
98
|
showReport: boolean;
|
|
104
99
|
debugMessages: DebugMessage[] | undefined;
|
|
105
100
|
showDebugMessages: boolean;
|
|
106
|
-
lastFetchDuration?: number;
|
|
107
101
|
private _previousQuery;
|
|
108
102
|
private _reloadSubscription;
|
|
109
103
|
ngOnInit(): void;
|
|
@@ -111,8 +105,7 @@ export declare class ChatComponent implements OnInit, OnChanges, OnDestroy {
|
|
|
111
105
|
ngOnDestroy(): void;
|
|
112
106
|
get isAdmin(): boolean;
|
|
113
107
|
/**
|
|
114
|
-
*
|
|
115
|
-
* This chat service instance will then be stored in the instanceManagerService with provided @input instanceId as a key
|
|
108
|
+
* This chat service instance is stored in the instanceManagerService with provided @input instanceId as a key
|
|
116
109
|
*/
|
|
117
110
|
instantiateChatService(): void;
|
|
118
111
|
/**
|
|
@@ -244,9 +237,9 @@ export declare class ChatComponent implements OnInit, OnChanges, OnDestroy {
|
|
|
244
237
|
* If the last message is from the user, a request to the assistant is made to get an answer
|
|
245
238
|
* If the last message is from the assistant, the conversation is loaded right away
|
|
246
239
|
* @param messages The list of messages of the chat
|
|
247
|
-
* @param
|
|
240
|
+
* @param chatId The id of the discussion. If provided (ie. an existing discussion in the saved chat index), update the chatId in the chat service for the upcoming saved chat operations
|
|
248
241
|
*/
|
|
249
|
-
openChat(messages: RawMessage[],
|
|
242
|
+
openChat(messages: RawMessage[], chatId?: string): void;
|
|
250
243
|
/**
|
|
251
244
|
* Reset the chat by clearing the chat history and the UI accordingly
|
|
252
245
|
* The user input will be cleared
|
|
@@ -274,29 +267,26 @@ export declare class ChatComponent implements OnInit, OnChanges, OnDestroy {
|
|
|
274
267
|
* 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.
|
|
275
268
|
* The assistant will regenerate a new answer based on the updated chat history.
|
|
276
269
|
* ⚠️ If the assistant is streaming or stopping the generation, the operation is not allowed.
|
|
270
|
+
* @param message The user's message to edit
|
|
277
271
|
* @param index The index of the user's message to edit
|
|
272
|
+
* @returns void
|
|
278
273
|
*/
|
|
279
|
-
editMessage(index: number): void;
|
|
274
|
+
editMessage(message: ChatMessage, index: number): void;
|
|
280
275
|
/**
|
|
281
276
|
* Copy a previous assistant message of the chat history to the clipboard.
|
|
282
|
-
* @param
|
|
277
|
+
* @param message The message to copy
|
|
278
|
+
* @param index The index of the message to copy
|
|
279
|
+
* @returns void
|
|
283
280
|
*/
|
|
284
|
-
copyMessage(index: number): void;
|
|
281
|
+
copyMessage(message: ChatMessage, index: number): void;
|
|
285
282
|
/**
|
|
286
283
|
* Starting from the provided index, remove all subsequent messages from the chat history and the UI accordingly.
|
|
287
284
|
* The assistant will regenerate a new answer based on the updated chat history.
|
|
288
285
|
* ⚠️ If the assistant is streaming or stopping the generation, the operation is not allowed.
|
|
286
|
+
* @param message The assistant's message to regenerate
|
|
289
287
|
* @param index The index of the assistant's message to regenerate
|
|
290
288
|
*/
|
|
291
|
-
regenerateMessage(index: number): void;
|
|
292
|
-
/**
|
|
293
|
-
* Remaps the index in the chat history.
|
|
294
|
-
* The chat history is a list of messages where some messages can be hidden (display set to false).
|
|
295
|
-
* The index provided as input is the index of the message in the chat history displayed in the UI.
|
|
296
|
-
* This function should be removed once the backend is updated to add the ids of the messages in the chat history
|
|
297
|
-
* @param index - The index to be remapped.
|
|
298
|
-
*/
|
|
299
|
-
private _remapIndexInChatHistory;
|
|
289
|
+
regenerateMessage(message: ChatMessage, index: number): void;
|
|
300
290
|
/**
|
|
301
291
|
* Handles the key up event for 'Backspace' and 'Enter' keys.
|
|
302
292
|
* @param event - The keyboard event.
|
|
@@ -311,16 +301,16 @@ export declare class ChatComponent implements OnInit, OnChanges, OnDestroy {
|
|
|
311
301
|
/**
|
|
312
302
|
* Send a "like" event on clicking on the thumb-up icon of an assistant's message
|
|
313
303
|
* @param message The assistant message to like
|
|
314
|
-
* @param
|
|
304
|
+
* @param index The index of the message to like
|
|
315
305
|
*/
|
|
316
|
-
onLike(message: ChatMessage,
|
|
306
|
+
onLike(message: ChatMessage, index: number): void;
|
|
317
307
|
/**
|
|
318
308
|
* Send a "dislike" event on clicking on the thumb-down icon of an assistant's message.
|
|
319
309
|
* It also opens the issue reporting dialog.
|
|
320
310
|
* @param message The assistant message to dislike
|
|
321
311
|
* @param index The rank of the message to dislike
|
|
322
312
|
*/
|
|
323
|
-
onDislike(message: ChatMessage,
|
|
313
|
+
onDislike(message: ChatMessage, index: number): void;
|
|
324
314
|
private _updateChatHistory;
|
|
325
315
|
/**
|
|
326
316
|
* Report an issue related to the assistant's message.
|
|
@@ -333,20 +323,25 @@ export declare class ChatComponent implements OnInit, OnChanges, OnDestroy {
|
|
|
333
323
|
/**
|
|
334
324
|
* Handle the click on a reference's 'open preview'.
|
|
335
325
|
* @param data
|
|
336
|
-
* @param
|
|
326
|
+
* @param message the message containing the reference
|
|
327
|
+
* @param index index of the message containing the reference
|
|
328
|
+
* @returns void
|
|
337
329
|
*/
|
|
338
330
|
openAttachmentPreview(data: {
|
|
339
331
|
reference: ChatContextAttachment;
|
|
340
332
|
partId?: number;
|
|
341
|
-
},
|
|
333
|
+
}, message: ChatMessage, index: number): void;
|
|
342
334
|
/**
|
|
343
335
|
* Handle the click on a reference's 'open original document'.
|
|
344
336
|
* @param data
|
|
337
|
+
* @param message the message containing the reference
|
|
338
|
+
* @param index index of the message containing the reference
|
|
339
|
+
* @returns void
|
|
345
340
|
*/
|
|
346
341
|
openOriginalAttachment(data: {
|
|
347
342
|
reference: ChatContextAttachment;
|
|
348
343
|
partId?: number;
|
|
349
|
-
},
|
|
344
|
+
}, message: ChatMessage, index: number): void;
|
|
350
345
|
/**
|
|
351
346
|
* Handle the click on a suggested action.
|
|
352
347
|
* @param action Suggested action.
|
|
@@ -355,16 +350,18 @@ export declare class ChatComponent implements OnInit, OnChanges, OnDestroy {
|
|
|
355
350
|
suggestActionClick(action: SuggestedAction, index: number): void;
|
|
356
351
|
/**
|
|
357
352
|
* It looks for the debug messages available in the current group of "assistant" messages.
|
|
358
|
-
* By design, the debug messages are only available in the first visible message among the group "assistant" messages.
|
|
359
|
-
* @param
|
|
353
|
+
* By design, the debug messages are only available in the first visible message among the group of "assistant" messages.
|
|
354
|
+
* @param message The message containing the debug information
|
|
355
|
+
* @param index The index of the message
|
|
360
356
|
* @returns The debug messages available in the current group of "assistant" messages
|
|
361
357
|
*/
|
|
362
|
-
getDebugMessages(index: number): DebugMessage[];
|
|
358
|
+
getDebugMessages(message: ChatMessage, index: number): DebugMessage[];
|
|
363
359
|
/**
|
|
364
360
|
* Handle the click on the 'show log info' button of a message.
|
|
365
|
-
* @param
|
|
361
|
+
* @param message The message containing the debug information
|
|
362
|
+
* @param index The index of the message
|
|
366
363
|
*/
|
|
367
|
-
showDebug(index: number): void;
|
|
364
|
+
showDebug(message: ChatMessage, index: number): void;
|
|
368
365
|
/**
|
|
369
366
|
* Verify whether the current message is an assistant message and that all following messages are assistant ones
|
|
370
367
|
* Used to keep the "View progress" opened even though the assistant is sending additional messages after the current one
|
|
@@ -384,5 +381,5 @@ export declare class ChatComponent implements OnInit, OnChanges, OnDestroy {
|
|
|
384
381
|
*/
|
|
385
382
|
isEmptyAssistantMessage(message: ChatMessage | undefined): boolean;
|
|
386
383
|
static ɵfac: i0.ɵɵFactoryDeclaration<ChatComponent, never>;
|
|
387
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<ChatComponent, "sq-chat-v3", never, { "instanceId": { "alias": "instanceId"; "required": false; }; "query": { "alias": "query"; "required": false; }; "queryChangeShouldTriggerReload": { "alias": "queryChangeShouldTriggerReload"; "required": false; }; "
|
|
384
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<ChatComponent, "sq-chat-v3", never, { "instanceId": { "alias": "instanceId"; "required": false; }; "query": { "alias": "query"; "required": false; }; "queryChangeShouldTriggerReload": { "alias": "queryChangeShouldTriggerReload"; "required": false; }; "messageHandlers": { "alias": "messageHandlers"; "required": false; }; "automaticScrollToLastResponse": { "alias": "automaticScrollToLastResponse"; "required": false; }; "focusAfterResponse": { "alias": "focusAfterResponse"; "required": false; }; "chat": { "alias": "chat"; "required": false; }; "assistantMessageIcon": { "alias": "assistantMessageIcon"; "required": false; }; "userMessageIcon": { "alias": "userMessageIcon"; "required": false; }; "connectionErrorMessageIcon": { "alias": "connectionErrorMessageIcon"; "required": false; }; "searchWarningMessageIcon": { "alias": "searchWarningMessageIcon"; "required": false; }; "additionalWorkflowProperties": { "alias": "additionalWorkflowProperties"; "required": false; }; "appConfig": { "alias": "appConfig"; "required": false; }; }, { "connection": "connection"; "loading$": "loading"; "_config": "config"; "data": "data"; "openDocument": "openDocument"; "openPreview": "openPreview"; "suggestAction": "suggestAction"; }, ["loadingTpl", "reportTpl", "tokenConsumptionTpl", "debugMessagesTpl"], never, true, never>;
|
|
388
385
|
}
|
package/chat/chat.service.d.ts
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
import { TranslocoService } from "@jsverse/transloco";
|
|
2
2
|
import { BehaviorSubject, Observable } from "rxjs";
|
|
3
|
+
import { HubConnection } from "@microsoft/signalr";
|
|
3
4
|
import { Query } from "@sinequa/atomic";
|
|
4
5
|
import { AppService } from "./services/app.service";
|
|
5
|
-
import { DialogService } from "./services/dialog.service";
|
|
6
6
|
import { NotificationsService } from "./services/notification.service";
|
|
7
7
|
import { PrincipalService } from "./services/principal.service";
|
|
8
8
|
import { UserSettingsWebService } from "./services/user-settings.service";
|
|
9
|
-
import { ChatConfig, ChatMessage, ChatResponse, ChatUsageMetrics, DeleteSavedChatResponse, GllmFunction, GllmModelDescription, Quota, SavedChat, SavedChatHistory, SavedChatResponse, TokenConsumption, UserTokenConsumption } from "./types";
|
|
9
|
+
import { ChatConfig, ChatMessage, ChatResponse, ChatUsageMetrics, DebugMessage, DeleteSavedChatResponse, GllmFunction, GllmModelDescription, KvObject, ListObject, MessageHandler, Quota, SavedChat, SavedChatHistory, SavedChatResponse, TokenConsumption, UserTokenConsumption } from "./types";
|
|
10
|
+
import { ConnectionOptions } from "./services/signalR.web.service";
|
|
11
|
+
import { AssistantUtils } from "./utils/utils.service";
|
|
10
12
|
import * as i0 from "@angular/core";
|
|
11
|
-
export declare
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
export declare class ChatService {
|
|
14
|
+
/** Name of the assistant websocket endpoint. */
|
|
15
|
+
WS_REQUEST_URL: string;
|
|
16
|
+
/** Name of the assistant REST endpoint. */
|
|
17
|
+
REST_REQUEST_URL: string;
|
|
18
|
+
/** SignalR connection instance */
|
|
19
|
+
connection: HubConnection | undefined;
|
|
15
20
|
/** Emit true once the initialization of the assistant process is done. */
|
|
16
21
|
initProcess$: BehaviorSubject<boolean>;
|
|
17
22
|
/** Emit true once the initialization of the assistant config is done. */
|
|
@@ -50,26 +55,136 @@ export declare abstract class ChatService {
|
|
|
50
55
|
stoppingGeneration$: BehaviorSubject<boolean>;
|
|
51
56
|
/** Instance ID of the chat service defining the assistant instance. */
|
|
52
57
|
private _chatInstanceId;
|
|
53
|
-
/**
|
|
54
|
-
private _savedChatId;
|
|
55
|
-
/** Generated GUID for the current non-saved chat discussion used to identify audit events.
|
|
56
|
-
* If the chat is saved, the savedChatId is initialized with the value of this chatId.
|
|
57
|
-
*/
|
|
58
|
+
/** Generated GUID for the current chat discussion used to save/get/delete it and identify audit events. */
|
|
58
59
|
private _chatId;
|
|
59
60
|
userSettingsService: UserSettingsWebService;
|
|
60
61
|
notificationsService: NotificationsService;
|
|
61
62
|
appService: AppService;
|
|
62
|
-
modalService: DialogService;
|
|
63
63
|
principalService: PrincipalService;
|
|
64
|
+
assistantUtils: AssistantUtils;
|
|
65
|
+
private savedChatsService;
|
|
66
|
+
private signalRConnectionService;
|
|
67
|
+
private assistantConfigurationService;
|
|
68
|
+
private assistantMetadataService;
|
|
69
|
+
private assistantTokensTrackingService;
|
|
70
|
+
private debugMessageService;
|
|
71
|
+
private assistantWsFramesService;
|
|
64
72
|
protected readonly transloco: TranslocoService;
|
|
65
73
|
/**
|
|
66
|
-
* Initialize the
|
|
74
|
+
* Initialize the assistant process.
|
|
75
|
+
* It includes building and starting a connection, executing parallel requests for models and functions, and handling errors during the process.
|
|
76
|
+
* ⚠️ This method MUST be called ONLY if the user is loggedIn and once when the assistant is initialized.
|
|
77
|
+
*
|
|
78
|
+
* @returns An Observable<boolean> indicating the success of the initialization process.
|
|
79
|
+
*/
|
|
80
|
+
init(): Observable<boolean>;
|
|
81
|
+
/**
|
|
82
|
+
* Define the endpoint to use for the websocket requests
|
|
83
|
+
* It can be overridden by the app config
|
|
67
84
|
*/
|
|
68
|
-
|
|
85
|
+
getWSRequestsUrl(): void;
|
|
69
86
|
/**
|
|
70
|
-
*
|
|
87
|
+
* Define the endpoint to use for the http requests
|
|
88
|
+
* It can be overridden by the app config
|
|
89
|
+
*/
|
|
90
|
+
getRESTRequestsUrl(): void;
|
|
91
|
+
/**
|
|
92
|
+
* Initializes the SavedChatsService with the necessary configuration.
|
|
93
|
+
*
|
|
94
|
+
* This method sets up the `SavedChatsService` by providing it with a configuration object
|
|
95
|
+
* (`SavedChatsOperationConfig`) that includes various callbacks and properties required
|
|
96
|
+
* for its operation. The initialization will only proceed if both `assistantConfig$` and
|
|
97
|
+
* `REST_REQUEST_URL` are available.
|
|
98
|
+
*
|
|
99
|
+
* The configuration object includes:
|
|
100
|
+
* - Application name retrieval.
|
|
101
|
+
* - Instance ID retrieval.
|
|
102
|
+
* - REST API URL retrieval.
|
|
103
|
+
* - Debug flag retrieval.
|
|
104
|
+
* - Chat ID for new saves.
|
|
105
|
+
* - Saved chats enablement check.
|
|
106
|
+
* - Methods for setting a saved chat ID, updating the saved chats list, and generating audit events.
|
|
107
|
+
*
|
|
108
|
+
* If the required dependencies are not ready, an error is logged to the console.
|
|
109
|
+
*
|
|
110
|
+
* @private
|
|
111
|
+
*/
|
|
112
|
+
private _initSavedChatsService;
|
|
113
|
+
/**
|
|
114
|
+
* Initializes the SignalR connection service with the necessary configuration.
|
|
115
|
+
*
|
|
116
|
+
* This method ensures that the SignalR connection service is properly set up
|
|
117
|
+
* by providing it with the required configuration values, such as the WebSocket
|
|
118
|
+
* request URL and assistant configuration. It also manages the SignalR hub connection
|
|
119
|
+
* instance.
|
|
120
|
+
*
|
|
121
|
+
* Preconditions:
|
|
122
|
+
* - `assistantConfig$.value` must be available.
|
|
123
|
+
* - `WS_REQUEST_URL` must be defined.
|
|
124
|
+
*
|
|
125
|
+
* If these preconditions are not met, an error is logged to the console.
|
|
126
|
+
*
|
|
127
|
+
* @private
|
|
128
|
+
*/
|
|
129
|
+
private _initSignalRConnectionService;
|
|
130
|
+
/**
|
|
131
|
+
* Initializes the Assistant Configuration Service with the necessary operation context.
|
|
132
|
+
* This method sets up the configuration context by providing various utility functions
|
|
133
|
+
* and state management mechanisms required for the assistant's configuration operations.
|
|
134
|
+
*
|
|
135
|
+
* The operation context includes:
|
|
136
|
+
* - Methods to retrieve chat instance and chat IDs.
|
|
137
|
+
* - Methods to get and set assistant configuration values.
|
|
138
|
+
* - Methods to set WebSocket and REST request URLs.
|
|
139
|
+
* - Methods to update the initialization configuration status.
|
|
140
|
+
* - A method to generate audit events for tracking operations.
|
|
141
|
+
*
|
|
142
|
+
* @private
|
|
143
|
+
*/
|
|
144
|
+
private _initAssistantConfigurationService;
|
|
145
|
+
/**
|
|
146
|
+
* Initializes the AssistantMetadataService with the necessary operation context.
|
|
147
|
+
*
|
|
148
|
+
* This method checks if the `assistantConfig$` value and `REST_REQUEST_URL` are available.
|
|
149
|
+
* If both are ready, it creates an `AssistantMetadataOperationContext` object and
|
|
150
|
+
* initializes the `assistantMetadataService` with it. The operation context provides
|
|
151
|
+
* methods to retrieve the REST URL, assistant configuration, and to set models and functions.
|
|
152
|
+
*
|
|
153
|
+
* If the required values are not ready, an error is logged to the console.
|
|
154
|
+
*
|
|
155
|
+
* @private
|
|
156
|
+
*/
|
|
157
|
+
private _initAssistantMetadataService;
|
|
158
|
+
/**
|
|
159
|
+
* Initializes the Assistant Tokens Tracking Service with the necessary operation context.
|
|
160
|
+
* This method sets up the service by providing it with functions to manage quotas,
|
|
161
|
+
* token consumption, usage metrics, and audit events, as well as access to assistant configuration
|
|
162
|
+
* and model retrieval.
|
|
163
|
+
*
|
|
164
|
+
* The initialization will only proceed if the assistant configuration is available.
|
|
165
|
+
* If the configuration is not ready, an error message is logged to the console.
|
|
166
|
+
*
|
|
167
|
+
* @private
|
|
71
168
|
*/
|
|
72
|
-
|
|
169
|
+
private _initAssistantTokensTrackingService;
|
|
170
|
+
/**
|
|
171
|
+
* Initializes the Assistant WebSocket Frames Service with the necessary operation context.
|
|
172
|
+
* This method sets up the required dependencies and configuration for the service to function properly.
|
|
173
|
+
* It ensures that the assistant configuration and connection are available before initializing the service.
|
|
174
|
+
*
|
|
175
|
+
* The operation context provides various utility functions and state management methods, including:
|
|
176
|
+
* - Accessing the assistant configuration, chat instance ID, saved chat ID, and chat history.
|
|
177
|
+
* - Managing streaming and stopping generation statuses.
|
|
178
|
+
* - Updating quota and chat usage metrics.
|
|
179
|
+
* - Generating audit events.
|
|
180
|
+
* - Managing saved chats (adding, updating, and listing).
|
|
181
|
+
*
|
|
182
|
+
* If the required dependencies (`assistantConfig$` and `connection`) are not ready, an error is logged.
|
|
183
|
+
*
|
|
184
|
+
* @private
|
|
185
|
+
*/
|
|
186
|
+
private _initAssistantWsFramesService;
|
|
187
|
+
private _initDebugMessageService;
|
|
73
188
|
get assistants(): any;
|
|
74
189
|
/**
|
|
75
190
|
* Get the instance ID of the chat service
|
|
@@ -82,23 +197,12 @@ export declare abstract class ChatService {
|
|
|
82
197
|
*/
|
|
83
198
|
setChatInstanceId(instanceId: string): void;
|
|
84
199
|
/**
|
|
85
|
-
* Get the ID of the current chat discussion which is used to save/get/delete
|
|
86
|
-
* @returns The ID of the current chat discussion
|
|
87
|
-
*/
|
|
88
|
-
get savedChatId(): string | undefined;
|
|
89
|
-
/**
|
|
90
|
-
* Persist the ID of the current chat discussion which is used to save/get/delete it
|
|
91
|
-
* @param savedChatId The ID of the current chat discussion which is used to save/get/delete it
|
|
92
|
-
*/
|
|
93
|
-
setSavedChatId(savedChatId: string | undefined): void;
|
|
94
|
-
/**
|
|
95
|
-
* Get the ID of the current chat discussion which is used to identify audit events
|
|
200
|
+
* Get the ID of the current chat discussion which is used to save/get/delete the discussion and identify audit events
|
|
96
201
|
* @returns The ID of the current chat discussion
|
|
97
202
|
*/
|
|
98
203
|
get chatId(): string;
|
|
99
204
|
/**
|
|
100
|
-
* Generate an GUID for the current chat discussion which is used to identify audit events
|
|
101
|
-
* If the discussion is saved, the savedChatId is initialized with the value of this chatId
|
|
205
|
+
* Generate an GUID for the current chat discussion which is used to save/get/delete it and identify audit events
|
|
102
206
|
* @param chatId if provided, it will be considered as the ID of the current chat discussion which is used to identify audit events
|
|
103
207
|
*/
|
|
104
208
|
generateChatId(chatId?: string): void;
|
|
@@ -125,23 +229,23 @@ export declare abstract class ChatService {
|
|
|
125
229
|
/**
|
|
126
230
|
* Overrides the logged in user
|
|
127
231
|
*/
|
|
128
|
-
|
|
232
|
+
overrideUser(): void;
|
|
129
233
|
/**
|
|
130
234
|
* Calls the Fetch API to retrieve a new message given all previous messages
|
|
131
235
|
*/
|
|
132
|
-
|
|
236
|
+
fetch(messages: ChatMessage[], query: Query): Observable<ChatResponse>;
|
|
133
237
|
/**
|
|
134
238
|
* Return the list of models available on the server
|
|
135
239
|
*/
|
|
136
|
-
|
|
240
|
+
listModels(): Observable<GllmModelDescription[] | undefined>;
|
|
137
241
|
/**
|
|
138
242
|
* Return the list of functions available on the server AND matching enabled functions in the chat config
|
|
139
243
|
*/
|
|
140
|
-
|
|
244
|
+
listFunctions(): Observable<GllmFunction[] | undefined>;
|
|
141
245
|
/**
|
|
142
246
|
* Stops the assistant answer generation and cancels all the ongoing and pending related tasks
|
|
143
247
|
*/
|
|
144
|
-
|
|
248
|
+
stopGeneration(): Observable<boolean>;
|
|
145
249
|
/**
|
|
146
250
|
* A handler for quota updates each time the chat is invoked.
|
|
147
251
|
* It emits the updated quota to the quota$ subject, emits accordingly the updated user's tokens consumption and notifies the user if the max quota is reached.
|
|
@@ -166,18 +270,24 @@ export declare abstract class ChatService {
|
|
|
166
270
|
/**
|
|
167
271
|
* Fetch the list saved chats belonging to a specific instance of the assistant
|
|
168
272
|
*/
|
|
169
|
-
|
|
273
|
+
listSavedChat(): void;
|
|
170
274
|
/**
|
|
171
275
|
* Return the saved chat with the given id, if exists. Otherwise, return undefined
|
|
172
276
|
* @param id The id of the saved chat
|
|
173
277
|
*/
|
|
174
|
-
|
|
278
|
+
getSavedChat(id: string): Observable<SavedChatHistory | undefined>;
|
|
279
|
+
/**
|
|
280
|
+
* Check if a saved chat with the given id already exists
|
|
281
|
+
* @param id The id of the saved chat
|
|
282
|
+
* @returns True if the saved chat exists, false otherwise
|
|
283
|
+
*/
|
|
284
|
+
isExistingSavedChat(id: string): Observable<boolean>;
|
|
175
285
|
/**
|
|
176
286
|
* Save a chat with the given messages
|
|
177
287
|
* @param messages The messages to add to the saved chat index
|
|
178
288
|
* @returns The saved chat
|
|
179
289
|
*/
|
|
180
|
-
|
|
290
|
+
addSavedChat(id: string, messages: ChatMessage[]): Observable<SavedChatResponse>;
|
|
181
291
|
/**
|
|
182
292
|
* Update a saved chat with the given id.
|
|
183
293
|
* @param id The id of the saved chat
|
|
@@ -185,13 +295,54 @@ export declare abstract class ChatService {
|
|
|
185
295
|
* @param messages The messages to update the saved chat history, if provided
|
|
186
296
|
* @returns True if the saved chat has been successfully updated
|
|
187
297
|
*/
|
|
188
|
-
|
|
298
|
+
updateSavedChat(id: string, name?: string, messages?: ChatMessage[]): Observable<SavedChatResponse>;
|
|
189
299
|
/**
|
|
190
300
|
* Bulk delete of saved chats matching the given ids
|
|
191
301
|
* @param ids List of ids of the saved chats to delete
|
|
192
302
|
* @returns The number of deleted chats
|
|
193
303
|
*/
|
|
194
|
-
|
|
304
|
+
deleteSavedChat(ids: string[]): Observable<DeleteSavedChatResponse>;
|
|
305
|
+
getDebugMessage(message: DebugMessage): Observable<KvObject | ListObject | undefined>;
|
|
306
|
+
/**
|
|
307
|
+
* Initialize out-of-the-box handlers
|
|
308
|
+
* It is a placeholder for non-streaming scenarios, where you invoke a specific hub method, and the server responds with frame message(s)
|
|
309
|
+
*/
|
|
310
|
+
initMessageHandlers(): void;
|
|
311
|
+
/**
|
|
312
|
+
* Override and register the entire _messageHandlers map by merging the provided map with the default one
|
|
313
|
+
* @param _messageHandlers
|
|
314
|
+
*/
|
|
315
|
+
overrideMessageHandlers<T>(_messageHandlers: Map<string, MessageHandler<T>>): void;
|
|
316
|
+
/**
|
|
317
|
+
* Add a listener for a specific event.
|
|
318
|
+
* If a listener for this same event already exists, it will be overridden.
|
|
319
|
+
* If the listener has "isGlobalHandler" set to true, it will be registered to the hub connection.
|
|
320
|
+
* @param eventName Name of the event to register a listener for
|
|
321
|
+
* @param eventHandler The handler to be called when the event is received
|
|
322
|
+
*/
|
|
323
|
+
addMessageHandler<T>(eventName: string, eventHandler: MessageHandler<T>): void;
|
|
324
|
+
/**
|
|
325
|
+
* Remove a listener for a specific event from the _messageHandlers map and unsubscribe from receiving messages for this event from the SignalR hub.
|
|
326
|
+
* @param eventName Name of the event to remove the listener for
|
|
327
|
+
*/
|
|
328
|
+
removeMessageHandler(eventName: string): void;
|
|
329
|
+
/**
|
|
330
|
+
* Build a connection to the signalR websocket and register default listeners to the methods defined in the server hub class
|
|
331
|
+
* @param options The options for the connection. It overrides the default options
|
|
332
|
+
* @param logLevel Define the log level displayed in the console
|
|
333
|
+
* @returns Promise that resolves when the connection is built
|
|
334
|
+
*/
|
|
335
|
+
buildConnection(options?: ConnectionOptions): Promise<void>;
|
|
336
|
+
/**
|
|
337
|
+
* Start the connection
|
|
338
|
+
* @returns Promise that resolves when the connection is started
|
|
339
|
+
*/
|
|
340
|
+
startConnection(): Promise<void>;
|
|
341
|
+
/**
|
|
342
|
+
* Stop the connection
|
|
343
|
+
* @returns Promise that resolves when the connection is stopped
|
|
344
|
+
*/
|
|
345
|
+
stopConnection(): Promise<void>;
|
|
195
346
|
/**
|
|
196
347
|
* Generate an audit event with the given type and details. The generated audit event is sent afterwards via the AuditWebService
|
|
197
348
|
* @param type Audit event type
|
|
@@ -199,51 +350,6 @@ export declare abstract class ChatService {
|
|
|
199
350
|
* @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
|
|
200
351
|
*/
|
|
201
352
|
generateAuditEvent(type: string, details: Record<string, any>, id?: string): Promise<void>;
|
|
202
|
-
/**
|
|
203
|
-
* Traverse the array from the end and track the first 'assistant' message among the last group of "assistant" messages where display is true
|
|
204
|
-
* @param array The array of ChatMessage to traverse
|
|
205
|
-
* @returns The index of the first visible assistant message among the last group of "assistant" messages in the array
|
|
206
|
-
*/
|
|
207
|
-
firstVisibleAssistantMessageIndex(array: ChatMessage[] | undefined): number;
|
|
208
|
-
/**
|
|
209
|
-
* Traverse the array from the end and pick the last 'assistant' message among the last group of "assistant" messages where display is true
|
|
210
|
-
* @param array The array of ChatMessage to traverse
|
|
211
|
-
* @returns The index of the last visible assistant message among the last group of "assistant" messages in the array
|
|
212
|
-
*/
|
|
213
|
-
lastVisibleAssistantMessageIndex(array: ChatMessage[] | undefined): number;
|
|
214
|
-
/**
|
|
215
|
-
* Format a date string in UTC to a local date string
|
|
216
|
-
* @param value Date string in UTC to format
|
|
217
|
-
* @returns A formatted local date string
|
|
218
|
-
*/
|
|
219
|
-
protected formatDateTime(value: string): string;
|
|
220
|
-
/**
|
|
221
|
-
* Takes a text prompt that may contain placeholders for variables
|
|
222
|
-
* and replaces these placeholders if it finds a match in the given
|
|
223
|
-
* context object.
|
|
224
|
-
*
|
|
225
|
-
* @example
|
|
226
|
-
* const p = "Hello, [[user.name]]! You have [[user.notifications.length]] new notifications.";
|
|
227
|
-
* const context = {
|
|
228
|
-
* user: {
|
|
229
|
-
* name: "Alice",
|
|
230
|
-
* notifications: ["Message from Bob", "Reminder for meeting"]
|
|
231
|
-
* }
|
|
232
|
-
* };
|
|
233
|
-
* const formattedPrompt = formatPrompt(p, context);
|
|
234
|
-
* console.log(formattedPrompt); // Output: "Hello, Alice! You have 2 new notifications."
|
|
235
|
-
*/
|
|
236
|
-
static formatPrompt(prompt: string, context: any): string;
|
|
237
|
-
/**
|
|
238
|
-
* Determines a time-based key for a given date to be used for translations or formatting.
|
|
239
|
-
* The key represents a relative time period such as "today", "yesterday", "this week", etc.
|
|
240
|
-
* If the date does not fall into any predefined relative time period, it returns the year as a string.
|
|
241
|
-
*
|
|
242
|
-
* @param date - The date for which the time key is to be determined.
|
|
243
|
-
* @returns A string representing the time key, which can be used for translation or display purposes.
|
|
244
|
-
*/
|
|
245
|
-
getTimeKey(date: Date): string;
|
|
246
|
-
getCurrentLocaleName(): string;
|
|
247
353
|
static ɵfac: i0.ɵɵFactoryDeclaration<ChatService, never>;
|
|
248
354
|
static ɵprov: i0.ɵɵInjectableDeclaration<ChatService>;
|
|
249
355
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AfterViewInit } from "@angular/core";
|
|
2
|
+
import { KvObject, ListObject } from "../../types";
|
|
3
|
+
import { UIService } from "../../services/ui.service";
|
|
4
|
+
import { DebugMessageService } from "../debug-message.service";
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
export declare class DebugMessageDetailsComponent implements AfterViewInit {
|
|
7
|
+
ui: UIService;
|
|
8
|
+
debugMessageService: DebugMessageService;
|
|
9
|
+
data: (KvObject | ListObject)[] | undefined;
|
|
10
|
+
level: number;
|
|
11
|
+
parentColor: string;
|
|
12
|
+
constructor(ui: UIService, debugMessageService: DebugMessageService);
|
|
13
|
+
ngAfterViewInit(): void;
|
|
14
|
+
isObject(value: any): boolean;
|
|
15
|
+
getRowClass(item: KvObject | ListObject): string;
|
|
16
|
+
copyToClipboard(code: any): void;
|
|
17
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DebugMessageDetailsComponent, never>;
|
|
18
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<DebugMessageDetailsComponent, "sq-debug-message-details", never, { "data": { "alias": "data"; "required": false; }; "level": { "alias": "level"; "required": false; }; "parentColor": { "alias": "parentColor"; "required": false; }; }, {}, never, never, true, never>;
|
|
19
|
+
}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ChangeDetectorRef } from "@angular/core";
|
|
2
2
|
import { DebugMessage } from "../types";
|
|
3
|
-
import {
|
|
3
|
+
import { DebugMessageService } from "./debug-message.service";
|
|
4
4
|
import * as i0 from "@angular/core";
|
|
5
|
-
export declare class DebugMessageComponent
|
|
6
|
-
|
|
5
|
+
export declare class DebugMessageComponent {
|
|
6
|
+
debugMessageService: DebugMessageService;
|
|
7
|
+
cdr: ChangeDetectorRef;
|
|
7
8
|
data: DebugMessage[] | undefined;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
ngAfterViewInit(): void;
|
|
12
|
-
isObject(value: any): boolean;
|
|
13
|
-
getRowClass(item: DebugMessage, index: number): string;
|
|
14
|
-
copyToClipboard(code: any): void;
|
|
9
|
+
constructor(debugMessageService: DebugMessageService, cdr: ChangeDetectorRef);
|
|
10
|
+
getRowClass(index: number): string;
|
|
11
|
+
toggleExpand(item: DebugMessage): void;
|
|
15
12
|
static ɵfac: i0.ɵɵFactoryDeclaration<DebugMessageComponent, never>;
|
|
16
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<DebugMessageComponent, "sq-debug-message", never, { "data": { "alias": "data"; "required": false; };
|
|
13
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<DebugMessageComponent, "sq-debug-message", never, { "data": { "alias": "data"; "required": false; }; }, {}, never, never, true, never>;
|
|
17
14
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { DebugMessage, ListObject } from '../types';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
export interface DebugMessageOperationConfig {
|
|
5
|
+
getRestUrl: () => string;
|
|
6
|
+
}
|
|
7
|
+
export declare class DebugMessageService {
|
|
8
|
+
private operationConfig;
|
|
9
|
+
constructor();
|
|
10
|
+
init(config: DebugMessageOperationConfig): void;
|
|
11
|
+
private ensureInitialized;
|
|
12
|
+
getDebugMessage(message: DebugMessage): Observable<ListObject | undefined>;
|
|
13
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DebugMessageService, never>;
|
|
14
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<DebugMessageService>;
|
|
15
|
+
}
|
|
@@ -21,6 +21,7 @@ export declare class DocumentListComponent implements OnInit, OnDestroy {
|
|
|
21
21
|
documentsUploadService: DocumentsUploadService;
|
|
22
22
|
notificationsService: NotificationsService;
|
|
23
23
|
private readonly transloco;
|
|
24
|
+
private readonly assistantUtils;
|
|
24
25
|
ngOnInit(): void;
|
|
25
26
|
ngOnDestroy(): void;
|
|
26
27
|
instantiateChatService(): void;
|
package/chat/public-api.d.ts
CHANGED
|
@@ -5,8 +5,6 @@ export * from './saved-chats/saved-chats.component';
|
|
|
5
5
|
export * from './initials-avatar/initials-avatar.component';
|
|
6
6
|
export * from './format-icon/format-icon.component';
|
|
7
7
|
export * from './types';
|
|
8
|
-
export * from './websocket-chat.service';
|
|
9
|
-
export * from './rest-chat.service';
|
|
10
8
|
export * from './instance-manager.service';
|
|
11
9
|
export * from './prompt.component';
|
|
12
10
|
export * from './documents-upload/document-upload/document-upload.component';
|