@sinequa/assistant 3.8.0 → 3.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/chat/charts/chart/chart.component.d.ts +13 -13
  2. package/chat/chat-message/chat-message.component.d.ts +85 -81
  3. package/chat/chat-message/i18n/en.json +11 -0
  4. package/chat/chat-message/i18n/fr.json +11 -0
  5. package/chat/chat-reference/chat-reference.component.d.ts +14 -14
  6. package/chat/chat-reference/i18n/en.json +4 -0
  7. package/chat/chat-reference/i18n/fr.json +4 -0
  8. package/chat/chat-settings-v3/chat-settings-v3.component.d.ts +48 -50
  9. package/chat/chat-settings-v3/i18n/en.json +14 -0
  10. package/chat/chat-settings-v3/i18n/fr.json +14 -0
  11. package/chat/chat.component.d.ts +388 -1405
  12. package/chat/chat.service.d.ts +247 -228
  13. package/chat/debug-message/debug-message.component.d.ts +17 -17
  14. package/chat/debug-message/i18n/en.json +3 -0
  15. package/chat/debug-message/i18n/fr.json +3 -0
  16. package/chat/dialogs/delete-saved-chat.component.d.ts +22 -0
  17. package/chat/dialogs/i18n/en.json +19 -0
  18. package/chat/dialogs/i18n/fr.json +19 -0
  19. package/chat/dialogs/rename-saved-chat.component.d.ts +21 -0
  20. package/chat/dialogs/updates.component.d.ts +15 -0
  21. package/chat/documents-upload/document-list/document-list.component.d.ts +68 -77
  22. package/chat/documents-upload/document-overview/document-overview.component.d.ts +31 -41
  23. package/chat/documents-upload/document-upload/document-upload.component.d.ts +96 -98
  24. package/chat/documents-upload/documents-upload.model.d.ts +66 -66
  25. package/chat/documents-upload/documents-upload.service.d.ts +170 -174
  26. package/chat/documents-upload/i18n/en.json +24 -0
  27. package/chat/documents-upload/i18n/fr.json +24 -0
  28. package/chat/format-icon/format-icon.component.d.ts +10 -10
  29. package/chat/format-icon/icons.d.ts +5 -5
  30. package/chat/i18n/en.json +42 -0
  31. package/chat/i18n/fr.json +42 -0
  32. package/chat/index.d.ts +5 -5
  33. package/chat/initials-avatar/initials-avatar.component.d.ts +35 -35
  34. package/chat/instance-manager.service.d.ts +28 -28
  35. package/chat/pipes/message-content.pipe.d.ts +16 -0
  36. package/chat/prompt.component.d.ts +25 -21
  37. package/chat/public-api.d.ts +17 -17
  38. package/chat/references/i18n/en.json +6 -0
  39. package/chat/references/i18n/fr.json +6 -0
  40. package/chat/references/inline-image-reference.d.ts +21 -0
  41. package/chat/references/inline-page-reference.d.ts +21 -0
  42. package/chat/rest-chat.service.d.ts +31 -33
  43. package/chat/saved-chats/i18n/en.json +4 -0
  44. package/chat/saved-chats/i18n/fr.json +4 -0
  45. package/chat/saved-chats/saved-chats.component.d.ts +30 -36
  46. package/chat/services/app.service.d.ts +8 -0
  47. package/chat/services/dialog.service.d.ts +12 -0
  48. package/chat/services/notification.service.d.ts +10 -0
  49. package/chat/services/principal.service.d.ts +7 -0
  50. package/chat/services/search.service.d.ts +7 -0
  51. package/chat/services/signalR.web.service.d.ts +45 -0
  52. package/chat/services/ui.service.d.ts +13 -0
  53. package/chat/services/user-settings.service.d.ts +7 -0
  54. package/chat/token-progress-bar/i18n/en.json +4 -0
  55. package/chat/token-progress-bar/i18n/fr.json +4 -0
  56. package/chat/token-progress-bar/token-progress-bar.component.d.ts +24 -27
  57. package/chat/tooltip/tooltip.component.d.ts +12 -0
  58. package/chat/tooltip/tooltip.directive.d.ts +81 -0
  59. package/chat/types/message-content.types.d.ts +54 -0
  60. package/chat/types/message-reference.types.d.ts +11 -0
  61. package/chat/types.d.ts +913 -873
  62. package/chat/unified-plugins/embedded-image-reference.plugin.d.ts +3 -0
  63. package/chat/unified-plugins/embedded-page-reference.plugin.d.ts +3 -0
  64. package/chat/utils/assistant-json.d.ts +2 -0
  65. package/chat/websocket-chat.service.d.ts +102 -103
  66. package/esm2022/chat/charts/chart/chart.component.mjs +40 -0
  67. package/esm2022/chat/chat-message/chat-message.component.mjs +351 -0
  68. package/esm2022/chat/chat-reference/chat-reference.component.mjs +40 -0
  69. package/esm2022/chat/chat-settings-v3/chat-settings-v3.component.mjs +118 -0
  70. package/esm2022/chat/chat.component.mjs +1090 -0
  71. package/esm2022/chat/chat.service.mjs +417 -0
  72. package/esm2022/chat/debug-message/debug-message.component.mjs +43 -0
  73. package/esm2022/chat/dialogs/delete-saved-chat.component.mjs +81 -0
  74. package/esm2022/chat/dialogs/rename-saved-chat.component.mjs +84 -0
  75. package/esm2022/chat/dialogs/updates.component.mjs +61 -0
  76. package/esm2022/chat/documents-upload/document-list/document-list.component.mjs +140 -0
  77. package/esm2022/chat/documents-upload/document-overview/document-overview.component.mjs +65 -0
  78. package/esm2022/chat/documents-upload/document-upload/document-upload.component.mjs +256 -0
  79. package/{esm2020 → esm2022}/chat/documents-upload/documents-upload.model.mjs +1 -1
  80. package/esm2022/chat/documents-upload/documents-upload.service.mjs +291 -0
  81. package/{esm2020 → esm2022}/chat/format-icon/format-icon.component.mjs +23 -23
  82. package/{esm2020 → esm2022}/chat/format-icon/icons.mjs +137 -137
  83. package/{esm2020 → esm2022}/chat/initials-avatar/initials-avatar.component.mjs +60 -60
  84. package/esm2022/chat/instance-manager.service.mjs +46 -0
  85. package/esm2022/chat/pipes/message-content.pipe.mjs +34 -0
  86. package/esm2022/chat/prompt.component.mjs +88 -0
  87. package/{esm2020 → esm2022}/chat/public-api.mjs +18 -18
  88. package/esm2022/chat/references/inline-image-reference.mjs +110 -0
  89. package/esm2022/chat/references/inline-page-reference.mjs +110 -0
  90. package/esm2022/chat/rest-chat.service.mjs +296 -0
  91. package/esm2022/chat/saved-chats/saved-chats.component.mjs +82 -0
  92. package/esm2022/chat/services/app.service.mjs +19 -0
  93. package/esm2022/chat/services/dialog.service.mjs +40 -0
  94. package/esm2022/chat/services/notification.service.mjs +25 -0
  95. package/esm2022/chat/services/principal.service.mjs +16 -0
  96. package/esm2022/chat/services/search.service.mjs +13 -0
  97. package/esm2022/chat/services/signalR.web.service.mjs +79 -0
  98. package/esm2022/chat/services/ui.service.mjs +61 -0
  99. package/esm2022/chat/services/user-settings.service.mjs +22 -0
  100. package/{esm2020 → esm2022}/chat/sinequa-assistant-chat.mjs +4 -4
  101. package/esm2022/chat/token-progress-bar/token-progress-bar.component.mjs +52 -0
  102. package/esm2022/chat/tooltip/tooltip.component.mjs +44 -0
  103. package/esm2022/chat/tooltip/tooltip.directive.mjs +203 -0
  104. package/esm2022/chat/types/message-content.types.mjs +2 -0
  105. package/esm2022/chat/types/message-reference.types.mjs +2 -0
  106. package/esm2022/chat/types.mjs +130 -0
  107. package/esm2022/chat/unified-plugins/embedded-image-reference.plugin.mjs +57 -0
  108. package/esm2022/chat/unified-plugins/embedded-page-reference.plugin.mjs +57 -0
  109. package/esm2022/chat/utils/assistant-json.mjs +12 -0
  110. package/esm2022/chat/websocket-chat.service.mjs +654 -0
  111. package/{esm2020 → esm2022}/public-api.mjs +2 -2
  112. package/{esm2020 → esm2022}/sinequa-assistant.mjs +4 -4
  113. package/fesm2022/sinequa-assistant-chat.mjs +5340 -0
  114. package/fesm2022/sinequa-assistant-chat.mjs.map +1 -0
  115. package/{fesm2015 → fesm2022}/sinequa-assistant.mjs +3 -3
  116. package/index.d.ts +5 -5
  117. package/package.json +52 -25
  118. package/public-api.d.ts +1 -1
  119. package/chat/messages/de.d.ts +0 -4
  120. package/chat/messages/en.d.ts +0 -4
  121. package/chat/messages/fr.d.ts +0 -4
  122. package/chat/messages/index.d.ts +0 -4
  123. package/esm2020/chat/charts/chart/chart.component.mjs +0 -40
  124. package/esm2020/chat/chat-message/chat-message.component.mjs +0 -263
  125. package/esm2020/chat/chat-reference/chat-reference.component.mjs +0 -40
  126. package/esm2020/chat/chat-settings-v3/chat-settings-v3.component.mjs +0 -117
  127. package/esm2020/chat/chat.component.mjs +0 -1069
  128. package/esm2020/chat/chat.service.mjs +0 -333
  129. package/esm2020/chat/debug-message/debug-message.component.mjs +0 -43
  130. package/esm2020/chat/documents-upload/document-list/document-list.component.mjs +0 -191
  131. package/esm2020/chat/documents-upload/document-overview/document-overview.component.mjs +0 -80
  132. package/esm2020/chat/documents-upload/document-upload/document-upload.component.mjs +0 -258
  133. package/esm2020/chat/documents-upload/documents-upload.service.mjs +0 -289
  134. package/esm2020/chat/instance-manager.service.mjs +0 -46
  135. package/esm2020/chat/messages/de.mjs +0 -4
  136. package/esm2020/chat/messages/en.mjs +0 -4
  137. package/esm2020/chat/messages/fr.mjs +0 -4
  138. package/esm2020/chat/messages/index.mjs +0 -9
  139. package/esm2020/chat/prompt.component.mjs +0 -88
  140. package/esm2020/chat/rest-chat.service.mjs +0 -241
  141. package/esm2020/chat/saved-chats/saved-chats.component.mjs +0 -175
  142. package/esm2020/chat/token-progress-bar/token-progress-bar.component.mjs +0 -54
  143. package/esm2020/chat/types.mjs +0 -112
  144. package/esm2020/chat/websocket-chat.service.mjs +0 -641
  145. package/fesm2015/sinequa-assistant-chat.mjs +0 -4200
  146. package/fesm2015/sinequa-assistant-chat.mjs.map +0 -1
  147. package/fesm2020/sinequa-assistant-chat.mjs +0 -4171
  148. package/fesm2020/sinequa-assistant-chat.mjs.map +0 -1
  149. package/fesm2020/sinequa-assistant.mjs +0 -9
  150. package/fesm2020/sinequa-assistant.mjs.map +0 -1
  151. /package/{fesm2015 → fesm2022}/sinequa-assistant.mjs.map +0 -0
@@ -1,228 +1,247 @@
1
- import { BehaviorSubject, Observable } from "rxjs";
2
- import { UserPreferences } from "@sinequa/components/user-settings";
3
- import { AppService, Query } from "@sinequa/core/app-utils";
4
- import { IntlService } from "@sinequa/core/intl";
5
- import { LoginService } from "@sinequa/core/login";
6
- import { ModalService } from "@sinequa/core/modal";
7
- import { NotificationsService } from "@sinequa/core/notification";
8
- import { AuditWebService, PrincipalWebService, UserSettingsWebService } from "@sinequa/core/web-services";
9
- import { ChatConfig, ChatMessage, ChatResponse, ChatUsageMetrics, GllmFunction, GllmModelDescription, Quota, SavedChat, SavedChatHistory, TokenConsumption, UserTokenConsumption } from "./types";
10
- import * as i0 from "@angular/core";
11
- export declare abstract class ChatService {
12
- /** Name of the assistant plugin OR websocket endpoint. */
13
- REQUEST_URL: string;
14
- /** Emit true once the initialization of the assistant process is done. */
15
- initProcess$: BehaviorSubject<boolean>;
16
- /** Emit true once the initialization of the assistant config is done. */
17
- initConfig$: BehaviorSubject<boolean>;
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>;
22
- /**
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).
24
- * This is used to prevent multiple fetches at the same time.
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.
26
- */
27
- streaming$: BehaviorSubject<boolean>;
28
- /** Store the messages history of the current chat. */
29
- chatHistory: ChatMessage[] | undefined;
30
- /** List of models available on the server. */
31
- models: GllmModelDescription[] | undefined;
32
- /** List of functions available on the server. */
33
- functions: GllmFunction[] | undefined;
34
- /** List of saved chats. */
35
- savedChats$: BehaviorSubject<SavedChat[]>;
36
- /** Emit the saved chat to load. */
37
- loadSavedChat$: BehaviorSubject<SavedChat | undefined>;
38
- /** Emit the quota each time the chat is invoked. */
39
- quota$: BehaviorSubject<Quota | undefined>;
40
- /** Emit the calculated user's token consumption based on the quota. */
41
- userTokenConsumption$: BehaviorSubject<UserTokenConsumption | undefined>;
42
- /** Emit the chat usage metrics each time the generation of the assistant response is completed. */
43
- chatUsageMetrics$: BehaviorSubject<ChatUsageMetrics | undefined>;
44
- /** Emit the calculated chat's token consumption based on the chat usage metrics. */
45
- chatTokenConsumption$: BehaviorSubject<TokenConsumption | undefined>;
46
- /** Emit true if "CancelTasks" is ongoing. */
47
- stoppingGeneration$: BehaviorSubject<boolean>;
48
- /** Instance ID of the chat service defining the assistant instance. */
49
- private _chatInstanceId;
50
- /** ID of the current **saved chat** discussion which is used to update/get/delete it. */
51
- private _savedChatId;
52
- /** Generated GUID for the current non-saved chat discussion used to identify audit events.
53
- * If the chat is saved, the savedChatId is initialized with the value of this chatId.
54
- */
55
- private _chatId;
56
- userSettingsService: UserSettingsWebService;
57
- notificationsService: NotificationsService;
58
- auditService: AuditWebService;
59
- prefs: UserPreferences;
60
- loginService: LoginService;
61
- appService: AppService;
62
- intlService: IntlService;
63
- modalService: ModalService;
64
- principalService: PrincipalWebService;
65
- /**
66
- * Initialize the chat process
67
- */
68
- abstract init(): Observable<boolean>;
69
- /**
70
- * Initialize the REQUEST_URL
71
- */
72
- abstract getRequestsUrl(): void;
73
- get assistants(): any;
74
- /**
75
- * Get the instance ID of the chat service
76
- * @returns The instance ID of the chat service
77
- */
78
- get chatInstanceId(): string;
79
- /**
80
- * Persist the instance ID of the chat service
81
- * @param instanceId The instance ID of the chat service
82
- */
83
- setChatInstanceId(instanceId: string): void;
84
- /**
85
- * Get the ID of the current chat discussion which is used to save/get/delete it
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
96
- * @returns The ID of the current chat discussion
97
- */
98
- get chatId(): string;
99
- /**
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
102
- * @param chatId if provided, it will be considered as the ID of the current chat discussion which is used to identify audit events
103
- */
104
- generateChatId(chatId?: string): void;
105
- /**
106
- * Initialize the chat config by managing ONLY sub-object **defaultValues** configs of the standard app config (defined in the customization json tab ) and the user preferences.
107
- * To do so, a tracking mechanism is implemented to notify the user about the available updates in the defaultValues object of the standard app config.
108
- * The rest of the config object coming from "standard app config" is used as it is without any override.
109
- * Thus, the user preferences are used only for the defaultValues object.
110
- * This provide a centralized way to manage the rest of the config object by admins and ensure a unique common behavior for all users.
111
- */
112
- initChatConfig(): void;
113
- /**
114
- * Update the chat config and store its defaultValues in the user preferences
115
- * @param config The updated chat config
116
- * @param hashes The updated hashes to store in the user preferences
117
- * @param notify Whether to notify the user about the update
118
- * @param successCallback The callback to execute if the update is successful
119
- * @param errorCallback The callback to execute if the update fails
120
- */
121
- updateChatConfig(config: ChatConfig, hashes?: {
122
- "applied-defaultValues-hash"?: string;
123
- "skipped-defaultValues-hash"?: string;
124
- }, notify?: boolean, successCallback?: () => any, errorCallback?: () => any): void;
125
- /**
126
- * Overrides the logged in user
127
- */
128
- abstract overrideUser(): void;
129
- /**
130
- * Calls the Fetch API to retrieve a new message given all previous messages
131
- */
132
- abstract fetch(messages: ChatMessage[], query: Query): Observable<ChatResponse>;
133
- /**
134
- * Return the list of models available on the server
135
- */
136
- abstract listModels(): Observable<GllmModelDescription[] | undefined>;
137
- /**
138
- * Return the list of functions available on the server AND matching enabled functions in the chat config
139
- */
140
- abstract listFunctions(): Observable<GllmFunction[] | undefined>;
141
- /**
142
- * Stops the assistant answer generation and cancels all the ongoing and pending related tasks
143
- */
144
- abstract stopGeneration(): Observable<any>;
145
- /**
146
- * A handler for quota updates each time the chat is invoked.
147
- * 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.
148
- * @param quota The updated quota
149
- * @param propagateError Whether to propagate the error to the caller
150
- */
151
- updateQuota(quota: Quota, propagateError?: boolean): void;
152
- /**
153
- * A handler for chat usage metrics each time the generation of the assistant response is completed.
154
- * It emits the chat usage metrics to the chatUsageMetrics$ subject, emits accordingly the updated chat's tokens consumption
155
- * @param chatUsageMetrics The chat usage metrics
156
- */
157
- updateChatUsageMetrics(chatUsageMetrics: ChatUsageMetrics): void;
158
- /**
159
- * Get the model description for the given (serviceId + modelId)
160
- * If a model is not found, an error message is returned
161
- * @param serviceId The serviceId of the model
162
- * @param modelId The modelId of the model
163
- * @returns The model description
164
- */
165
- getModel(serviceId: string, modelId: string): GllmModelDescription | undefined;
166
- /**
167
- * Fetch the list saved chats belonging to a specific instance of the assistant
168
- */
169
- abstract listSavedChat(): void;
170
- /**
171
- * Return the saved chat with the given id, if exists. Otherwise, return undefined
172
- * @param id The id of the saved chat
173
- */
174
- abstract getSavedChat(id: string): Observable<SavedChatHistory | undefined>;
175
- /**
176
- * Save a chat with the given messages
177
- * @param messages The messages to add to the saved chat index
178
- * @returns The saved chat
179
- */
180
- abstract addSavedChat(messages: ChatMessage[]): Observable<SavedChat>;
181
- /**
182
- * Update a saved chat with the given id.
183
- * @param id The id of the saved chat
184
- * @param name The new name of the saved chat, if provided
185
- * @param messages The messages to update the saved chat history, if provided
186
- * @returns True if the saved chat has been successfully updated
187
- */
188
- abstract updateSavedChat(id: string, name?: string, messages?: ChatMessage[]): Observable<SavedChat>;
189
- /**
190
- * Bulk delete of saved chats matching the given ids
191
- * @param ids List of ids of the saved chats to delete
192
- * @returns The number of deleted chats
193
- */
194
- abstract deleteSavedChat(ids: string[]): Observable<number>;
195
- /**
196
- * Generate an audit event with the given type and details. The generated audit event is sent afterwards via the AuditWebService
197
- * @param type Audit event type
198
- * @param details Audit event details
199
- * @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
- */
201
- generateAuditEvent(type: string, details: Record<string, any>, id?: string): 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
- static formatPrompt(prompt: string, context: any): string;
226
- static ɵfac: i0.ɵɵFactoryDeclaration<ChatService, never>;
227
- static ɵprov: i0.ɵɵInjectableDeclaration<ChatService>;
228
- }
1
+ import { TranslocoService } from "@jsverse/transloco";
2
+ import { BehaviorSubject, Observable } from "rxjs";
3
+ import { Query } from "@sinequa/atomic";
4
+ import { AppService } from "./services/app.service";
5
+ import { DialogService } from "./services/dialog.service";
6
+ import { NotificationsService } from "./services/notification.service";
7
+ import { PrincipalService } from "./services/principal.service";
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";
10
+ import * as i0 from "@angular/core";
11
+ export declare abstract class ChatService {
12
+ readonly localID: string | null;
13
+ /** Name of the assistant plugin OR websocket endpoint. */
14
+ REQUEST_URL: string;
15
+ /** Emit true once the initialization of the assistant process is done. */
16
+ initProcess$: BehaviorSubject<boolean>;
17
+ /** Emit true once the initialization of the assistant config is done. */
18
+ initConfig$: BehaviorSubject<boolean>;
19
+ /** Emit the global configuration of the assistant. */
20
+ assistantConfig$: BehaviorSubject<ChatConfig | undefined>;
21
+ /** Emit true if the user has been overridden, false otherwise. */
22
+ userOverride$: BehaviorSubject<boolean | undefined>;
23
+ /**
24
+ * 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).
25
+ * This is used to prevent multiple fetches at the same time.
26
+ * 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.
27
+ */
28
+ streaming$: BehaviorSubject<boolean>;
29
+ /** Store the messages history of the current chat. */
30
+ chatHistory: ChatMessage[] | undefined;
31
+ /** List of models available on the server. */
32
+ models: GllmModelDescription[] | undefined;
33
+ /** List of functions available on the server. */
34
+ functions: GllmFunction[] | undefined;
35
+ /** List of saved chats. */
36
+ savedChats$: BehaviorSubject<SavedChat[]>;
37
+ /** Emit the saved chat to load. */
38
+ loadSavedChat$: BehaviorSubject<SavedChat | undefined>;
39
+ /** Emit the quota each time the chat is invoked. */
40
+ quota$: BehaviorSubject<Quota | undefined>;
41
+ /** Emit the calculated user's token consumption based on the quota. */
42
+ userTokenConsumption$: BehaviorSubject<UserTokenConsumption | undefined>;
43
+ /** Emit the chat usage metrics each time the generation of the assistant response is completed. */
44
+ chatUsageMetrics$: BehaviorSubject<ChatUsageMetrics | undefined>;
45
+ /** Emit the calculated chat's token consumption based on the chat usage metrics. */
46
+ chatTokenConsumption$: BehaviorSubject<TokenConsumption | undefined>;
47
+ /** Emit true if "CancelTasks" is ongoing. */
48
+ stoppingGeneration$: BehaviorSubject<boolean>;
49
+ /** Instance ID of the chat service defining the assistant instance. */
50
+ private _chatInstanceId;
51
+ /** ID of the current **saved chat** discussion which is used to update/get/delete it. */
52
+ private _savedChatId;
53
+ /** Generated GUID for the current non-saved chat discussion used to identify audit events.
54
+ * If the chat is saved, the savedChatId is initialized with the value of this chatId.
55
+ */
56
+ private _chatId;
57
+ userSettingsService: UserSettingsWebService;
58
+ notificationsService: NotificationsService;
59
+ appService: AppService;
60
+ modalService: DialogService;
61
+ principalService: PrincipalService;
62
+ protected readonly transloco: TranslocoService;
63
+ /**
64
+ * Initialize the chat process
65
+ */
66
+ abstract init(): Observable<boolean>;
67
+ /**
68
+ * Initialize the REQUEST_URL
69
+ */
70
+ abstract getRequestsUrl(): void;
71
+ get assistants(): any;
72
+ /**
73
+ * Get the instance ID of the chat service
74
+ * @returns The instance ID of the chat service
75
+ */
76
+ get chatInstanceId(): string;
77
+ /**
78
+ * Persist the instance ID of the chat service
79
+ * @param instanceId The instance ID of the chat service
80
+ */
81
+ setChatInstanceId(instanceId: string): void;
82
+ /**
83
+ * Get the ID of the current chat discussion which is used to save/get/delete it
84
+ * @returns The ID of the current chat discussion
85
+ */
86
+ get savedChatId(): string | undefined;
87
+ /**
88
+ * Persist the ID of the current chat discussion which is used to save/get/delete it
89
+ * @param savedChatId The ID of the current chat discussion which is used to save/get/delete it
90
+ */
91
+ setSavedChatId(savedChatId: string | undefined): void;
92
+ /**
93
+ * Get the ID of the current chat discussion which is used to identify audit events
94
+ * @returns The ID of the current chat discussion
95
+ */
96
+ get chatId(): string;
97
+ /**
98
+ * Generate an GUID for the current chat discussion which is used to identify audit events
99
+ * If the discussion is saved, the savedChatId is initialized with the value of this chatId
100
+ * @param chatId if provided, it will be considered as the ID of the current chat discussion which is used to identify audit events
101
+ */
102
+ generateChatId(chatId?: string): void;
103
+ /**
104
+ * Initialize the chat config by managing ONLY sub-object **defaultValues** configs of the standard app config (defined in the customization json tab ) and the user preferences.
105
+ * To do so, a tracking mechanism is implemented to notify the user about the available updates in the defaultValues object of the standard app config.
106
+ * The rest of the config object coming from "standard app config" is used as it is without any override.
107
+ * Thus, the user preferences are used only for the defaultValues object.
108
+ * This provide a centralized way to manage the rest of the config object by admins and ensure a unique common behavior for all users.
109
+ */
110
+ initChatConfig(): Promise<void>;
111
+ /**
112
+ * Update the chat config and store its defaultValues in the user preferences
113
+ * @param config The updated chat config
114
+ * @param hashes The updated hashes to store in the user preferences
115
+ * @param notify Whether to notify the user about the update
116
+ * @param successCallback The callback to execute if the update is successful
117
+ * @param errorCallback The callback to execute if the update fails
118
+ */
119
+ updateChatConfig(config: ChatConfig, hashes?: {
120
+ "applied-defaultValues-hash"?: string;
121
+ "skipped-defaultValues-hash"?: string;
122
+ }, notify?: boolean, successCallback?: () => any, errorCallback?: () => any): void;
123
+ /**
124
+ * Overrides the logged in user
125
+ */
126
+ abstract overrideUser(): void;
127
+ /**
128
+ * Calls the Fetch API to retrieve a new message given all previous messages
129
+ */
130
+ abstract fetch(messages: ChatMessage[], query: Query): Observable<ChatResponse>;
131
+ /**
132
+ * Return the list of models available on the server
133
+ */
134
+ abstract listModels(): Observable<GllmModelDescription[] | undefined>;
135
+ /**
136
+ * Return the list of functions available on the server AND matching enabled functions in the chat config
137
+ */
138
+ abstract listFunctions(): Observable<GllmFunction[] | undefined>;
139
+ /**
140
+ * Stops the assistant answer generation and cancels all the ongoing and pending related tasks
141
+ */
142
+ abstract stopGeneration(): Observable<any>;
143
+ /**
144
+ * A handler for quota updates each time the chat is invoked.
145
+ * 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.
146
+ * @param quota The updated quota
147
+ * @param propagateError Whether to propagate the error to the caller
148
+ */
149
+ updateQuota(quota: Quota, propagateError?: boolean): void;
150
+ /**
151
+ * A handler for chat usage metrics each time the generation of the assistant response is completed.
152
+ * It emits the chat usage metrics to the chatUsageMetrics$ subject, emits accordingly the updated chat's tokens consumption
153
+ * @param chatUsageMetrics The chat usage metrics
154
+ */
155
+ updateChatUsageMetrics(chatUsageMetrics: ChatUsageMetrics): void;
156
+ /**
157
+ * Get the model description for the given (serviceId + modelId)
158
+ * If a model is not found, an error message is returned
159
+ * @param serviceId The serviceId of the model
160
+ * @param modelId The modelId of the model
161
+ * @returns The model description
162
+ */
163
+ getModel(serviceId: string, modelId: string): GllmModelDescription | undefined;
164
+ /**
165
+ * Fetch the list saved chats belonging to a specific instance of the assistant
166
+ */
167
+ abstract listSavedChat(): void;
168
+ /**
169
+ * Return the saved chat with the given id, if exists. Otherwise, return undefined
170
+ * @param id The id of the saved chat
171
+ */
172
+ abstract getSavedChat(id: string): Observable<SavedChatHistory | undefined>;
173
+ /**
174
+ * Save a chat with the given messages
175
+ * @param messages The messages to add to the saved chat index
176
+ * @returns The saved chat
177
+ */
178
+ abstract addSavedChat(messages: ChatMessage[]): Observable<SavedChatResponse>;
179
+ /**
180
+ * Update a saved chat with the given id.
181
+ * @param id The id of the saved chat
182
+ * @param name The new name of the saved chat, if provided
183
+ * @param messages The messages to update the saved chat history, if provided
184
+ * @returns True if the saved chat has been successfully updated
185
+ */
186
+ abstract updateSavedChat(id: string, name?: string, messages?: ChatMessage[]): Observable<SavedChatResponse>;
187
+ /**
188
+ * Bulk delete of saved chats matching the given ids
189
+ * @param ids List of ids of the saved chats to delete
190
+ * @returns The number of deleted chats
191
+ */
192
+ abstract deleteSavedChat(ids: string[]): Observable<DeleteSavedChatResponse>;
193
+ /**
194
+ * Generate an audit event with the given type and details. The generated audit event is sent afterwards via the AuditWebService
195
+ * @param type Audit event type
196
+ * @param details Audit event details
197
+ * @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
198
+ */
199
+ generateAuditEvent(type: string, details: Record<string, any>, id?: string): Promise<void>;
200
+ /**
201
+ * Traverse the array from the end and track the first 'assistant' message among the last group of "assistant" messages where display is true
202
+ * @param array The array of ChatMessage to traverse
203
+ * @returns The index of the first visible assistant message among the last group of "assistant" messages in the array
204
+ */
205
+ firstVisibleAssistantMessageIndex(array: ChatMessage[] | undefined): number;
206
+ /**
207
+ * Traverse the array from the end and pick the last 'assistant' message among the last group of "assistant" messages where display is true
208
+ * @param array The array of ChatMessage to traverse
209
+ * @returns The index of the last visible assistant message among the last group of "assistant" messages in the array
210
+ */
211
+ lastVisibleAssistantMessageIndex(array: ChatMessage[] | undefined): number;
212
+ /**
213
+ * Format a date string in UTC to a local date string
214
+ * @param value Date string in UTC to format
215
+ * @returns A formatted local date string
216
+ */
217
+ protected formatDateTime(value: string): string;
218
+ /**
219
+ * Takes a text prompt that may contain placeholders for variables
220
+ * and replaces these placeholders if it finds a match in the given
221
+ * context object.
222
+ *
223
+ * @example
224
+ * const p = "Hello, [[user.name]]! You have [[user.notifications.length]] new notifications.";
225
+ * const context = {
226
+ * user: {
227
+ * name: "Alice",
228
+ * notifications: ["Message from Bob", "Reminder for meeting"]
229
+ * }
230
+ * };
231
+ * const formattedPrompt = formatPrompt(p, context);
232
+ * console.log(formattedPrompt); // Output: "Hello, Alice! You have 2 new notifications."
233
+ */
234
+ static formatPrompt(prompt: string, context: any): string;
235
+ /**
236
+ * Determines a time-based key for a given date to be used for translations or formatting.
237
+ * The key represents a relative time period such as "today", "yesterday", "this week", etc.
238
+ * If the date does not fall into any predefined relative time period, it returns the year as a string.
239
+ *
240
+ * @param date - The date for which the time key is to be determined.
241
+ * @returns A string representing the time key, which can be used for translation or display purposes.
242
+ */
243
+ getTimeKey(date: Date): string;
244
+ getCurrentLocaleName(): string;
245
+ static ɵfac: i0.ɵɵFactoryDeclaration<ChatService, never>;
246
+ static ɵprov: i0.ɵɵInjectableDeclaration<ChatService>;
247
+ }
@@ -1,17 +1,17 @@
1
- import { AfterViewInit } from "@angular/core";
2
- import { DebugMessage } from "../types";
3
- import { UIService } from "@sinequa/components/utils";
4
- import * as i0 from "@angular/core";
5
- export declare class DebugMessageComponent implements AfterViewInit {
6
- ui: UIService;
7
- data: DebugMessage[] | undefined;
8
- level: number;
9
- parentColor: string;
10
- constructor(ui: UIService);
11
- ngAfterViewInit(): void;
12
- isObject(value: any): boolean;
13
- getRowClass(item: DebugMessage, index: number): string;
14
- copyToClipboard(code: any): void;
15
- static ɵfac: i0.ɵɵFactoryDeclaration<DebugMessageComponent, never>;
16
- static ɵcmp: i0.ɵɵComponentDeclaration<DebugMessageComponent, "sq-debug-message", never, { "data": "data"; "level": "level"; "parentColor": "parentColor"; }, {}, never, never, true>;
17
- }
1
+ import { AfterViewInit } from "@angular/core";
2
+ import { DebugMessage } from "../types";
3
+ import { UIService } from "../services/ui.service";
4
+ import * as i0 from "@angular/core";
5
+ export declare class DebugMessageComponent implements AfterViewInit {
6
+ ui: UIService;
7
+ data: DebugMessage[] | undefined;
8
+ level: number;
9
+ parentColor: string;
10
+ constructor(ui: UIService);
11
+ ngAfterViewInit(): void;
12
+ isObject(value: any): boolean;
13
+ getRowClass(item: DebugMessage, index: number): string;
14
+ copyToClipboard(code: any): void;
15
+ static ɵfac: i0.ɵɵFactoryDeclaration<DebugMessageComponent, never>;
16
+ static ɵcmp: i0.ɵɵComponentDeclaration<DebugMessageComponent, "sq-debug-message", never, { "data": { "alias": "data"; "required": false; }; "level": { "alias": "level"; "required": false; }; "parentColor": { "alias": "parentColor"; "required": false; }; }, {}, never, never, true, never>;
17
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "copyCode": "Copy code"
3
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "copyCode": "Copier le code"
3
+ }
@@ -0,0 +1,22 @@
1
+ import { ElementRef } from "@angular/core";
2
+ import { Subscription } from "rxjs";
3
+ import { ChatService } from "../chat.service";
4
+ import { NotificationsService } from "../services/notification.service";
5
+ import { SavedChat } from "../types";
6
+ import * as i0 from "@angular/core";
7
+ export type SavedChatEdit = SavedChat & {
8
+ currentTitle: string;
9
+ };
10
+ export declare class DialogDeleteSavedChatComponent {
11
+ deleteDialog: import("@angular/core").Signal<ElementRef<HTMLDialogElement> | undefined>;
12
+ notificationsService: NotificationsService;
13
+ private readonly transloco;
14
+ chatService: import("@angular/core").InputSignal<ChatService>;
15
+ delete: import("@angular/core").OutputEmitterRef<SavedChat>;
16
+ savedChat: import("@angular/core").WritableSignal<SavedChatEdit>;
17
+ subscription: Subscription;
18
+ showModal(event: Event, savedChat: SavedChat): void;
19
+ protected onDelete(event: Event, savedChat: SavedChat): void;
20
+ static ɵfac: i0.ɵɵFactoryDeclaration<DialogDeleteSavedChatComponent, never>;
21
+ static ɵcmp: i0.ɵɵComponentDeclaration<DialogDeleteSavedChatComponent, "sq-dialog-delete-saved-chat", never, { "chatService": { "alias": "chatService"; "required": true; "isSignal": true; }; }, { "delete": "delete"; }, never, never, true, never>;
22
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "deleteSavedDiscussion": "Delete discussion",
3
+ "deleteSavedDiscussionText": "You are about to delete the discussion",
4
+ "deleteSavedDiscussionConfirm": "Do you want to continue?",
5
+ "cancel": "Cancel",
6
+ "confirm": "Confirm",
7
+ "deleteSavedDiscussionSuccess": "The discussion '{{title}}' has been successfully deleted.",
8
+ "deleteSavedDiscussionError": "An error occurred while deleting the discussion '{{title}}'.",
9
+ "renameSavedDiscussion": "Rename discussion",
10
+ "renameSavedDiscussionText": "Please enter a new name for the discussion",
11
+ "rename": "Rename",
12
+ "renameSavedDiscussionSuccess": "The discussion '{{currentTitle}}' has been successfully renamed to '{{title}}'.",
13
+ "renameSavedDiscussionError": "An error occurred while renaming the discussion '{{currentTitle}}'.",
14
+ "availableUpdates": "Available updates!",
15
+ "availableUpdatesText": "Changes have been made to the default configuration. Do you want to update your own version?",
16
+ "seeNoMore": "See no more",
17
+ "remindMeLater": "Remind me later",
18
+ "update": "Update"
19
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "deleteSavedDiscussion": "Supprimer la discussion",
3
+ "deleteSavedDiscussionText": "Vous êtes sur le point de supprimer la discussion",
4
+ "deleteSavedDiscussionConfirm": "Voulez-vous continuer ?",
5
+ "cancel": "Annuler",
6
+ "confirm": "Confirmer",
7
+ "deleteSavedDiscussionSuccess": "La discussion '{{title}}' a été supprimée avec succès.",
8
+ "deleteSavedDiscussionError": "Une erreur s'est produite lors de la suppression de la discussion '{{title}}'.",
9
+ "renameSavedDiscussion": "Renommer la discussion",
10
+ "renameSavedDiscussionText": "Veuillez entrer un nouveau nom pour la discussion",
11
+ "rename": "Renommer",
12
+ "renameSavedDiscussionSuccess": "La discussion '{{currentTitle}}' a été renommée avec succès en '{{title}}'.",
13
+ "renameSavedDiscussionError": "Une erreur s'est produite lors du renommage de la discussion '{{currentTitle}}'.",
14
+ "availableUpdates": "Mises à jour disponibles!",
15
+ "availableUpdatesText": "Des modifications ont été apportées à la configuration par défaut. Voulez-vous mettre à jour votre propre version?",
16
+ "seeNoMore": "Ne plus voir",
17
+ "remindMeLater": "Me le rappeler plus tard",
18
+ "update": "Mettre à jour"
19
+ }