@sinequa/assistant 3.9.1 → 3.9.3

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 (48) hide show
  1. package/chat/chat.component.d.ts +35 -38
  2. package/chat/chat.service.d.ts +192 -84
  3. package/chat/debug-message/debug-message-details/debug-message-details.component.d.ts +19 -0
  4. package/chat/debug-message/debug-message.component.d.ts +9 -12
  5. package/chat/debug-message/debug-message.service.d.ts +15 -0
  6. package/chat/documents-upload/document-list/document-list.component.d.ts +1 -0
  7. package/chat/public-api.d.ts +0 -2
  8. package/chat/saved-chats/i18n/en.json +2 -1
  9. package/chat/saved-chats/i18n/fr.json +2 -1
  10. package/chat/saved-chats/saved-chats.component.d.ts +1 -0
  11. package/chat/saved-chats/saved-chats.service.d.ts +27 -0
  12. package/chat/services/assistant-configuration.service.d.ts +34 -0
  13. package/chat/services/assistant-metadata.service.d.ts +18 -0
  14. package/chat/services/assistant-tokens-tracking.service.d.ts +23 -0
  15. package/chat/services/assistant-ws-frames.service.d.ts +50 -0
  16. package/chat/services/signalR-connection.service.d.ts +25 -0
  17. package/chat/services/signalR.web.service.d.ts +1 -0
  18. package/chat/types.d.ts +24 -3
  19. package/chat/utils/utils.service.d.ts +67 -0
  20. package/esm2022/chat/chat-message/chat-message.component.mjs +3 -3
  21. package/esm2022/chat/chat.component.mjs +199 -225
  22. package/esm2022/chat/chat.service.mjs +452 -267
  23. package/esm2022/chat/debug-message/debug-message-details/debug-message-details.component.mjs +43 -0
  24. package/esm2022/chat/debug-message/debug-message.component.mjs +27 -30
  25. package/esm2022/chat/debug-message/debug-message.service.mjs +52 -0
  26. package/esm2022/chat/dialogs/rename-saved-chat.component.mjs +6 -5
  27. package/esm2022/chat/documents-upload/document-list/document-list.component.mjs +4 -2
  28. package/esm2022/chat/documents-upload/document-upload/document-upload.component.mjs +3 -3
  29. package/esm2022/chat/pipes/message-content.pipe.mjs +5 -2
  30. package/esm2022/chat/public-api.mjs +1 -3
  31. package/esm2022/chat/saved-chats/saved-chats.component.mjs +11 -10
  32. package/esm2022/chat/saved-chats/saved-chats.service.mjs +165 -0
  33. package/esm2022/chat/services/assistant-configuration.service.mjs +171 -0
  34. package/esm2022/chat/services/assistant-metadata.service.mjs +67 -0
  35. package/esm2022/chat/services/assistant-tokens-tracking.service.mjs +57 -0
  36. package/esm2022/chat/services/assistant-ws-frames.service.mjs +392 -0
  37. package/esm2022/chat/services/signalR-connection.service.mjs +109 -0
  38. package/esm2022/chat/services/signalR.web.service.mjs +1 -1
  39. package/esm2022/chat/types.mjs +2 -1
  40. package/esm2022/chat/unified-plugins/embedded-image-reference.plugin.mjs +2 -3
  41. package/esm2022/chat/utils/utils.service.mjs +170 -0
  42. package/fesm2022/sinequa-assistant-chat.mjs +2037 -1647
  43. package/fesm2022/sinequa-assistant-chat.mjs.map +1 -1
  44. package/package.json +1 -1
  45. package/chat/rest-chat.service.d.ts +0 -31
  46. package/chat/websocket-chat.service.d.ts +0 -102
  47. package/esm2022/chat/rest-chat.service.mjs +0 -296
  48. package/esm2022/chat/websocket-chat.service.mjs +0 -654
@@ -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';
@@ -1,4 +1,5 @@
1
1
  {
2
2
  "rename": "Rename",
3
- "delete": "Delete"
3
+ "delete": "Delete",
4
+ "listError": "Oops! We're having trouble loading your past chats right now. Please try again later. If the problem persists, contact support for assistance."
4
5
  }
@@ -1,4 +1,5 @@
1
1
  {
2
2
  "rename": "Renommer",
3
- "delete": "Supprimer"
3
+ "delete": "Supprimer",
4
+ "listError": "Oups ! Nous avons un problème pour charger vos anciennes conversations. Veuillez réessayer plus tard. Si le problème persiste, contactez le support pour assistance."
4
5
  }
@@ -19,6 +19,7 @@ export declare class SavedChatsComponent implements OnInit, OnDestroy {
19
19
  instanceManagerService: InstanceManagerService;
20
20
  notificationsService: NotificationsService;
21
21
  private readonly transloco;
22
+ private readonly assistantUtils;
22
23
  ngOnInit(): void;
23
24
  ngOnDestroy(): void;
24
25
  instantiateChatService(): void;
@@ -0,0 +1,27 @@
1
+ import { Observable } from 'rxjs';
2
+ import { ChatMessage, SavedChat, SavedChatHistory, SavedChatResponse, DeleteSavedChatResponse } from '../types';
3
+ import * as i0 from "@angular/core";
4
+ export interface SavedChatsOperationConfig {
5
+ getAppName: () => string;
6
+ getInstanceId: () => string;
7
+ getRestUrl: () => string;
8
+ getDebugFlag: () => boolean;
9
+ isSavedChatsEnabled: () => boolean;
10
+ setSavedChatsErrorStatus: (hasError: boolean) => void;
11
+ updateSavedChatsList: (chats: SavedChat[]) => void;
12
+ generateAuditEvent: (type: string, details: Record<string, any>, id?: string) => Promise<void>;
13
+ }
14
+ export declare class SavedChatsService {
15
+ private operationConfig;
16
+ constructor();
17
+ init(config: SavedChatsOperationConfig): void;
18
+ private ensureInitialized;
19
+ listChats(): void;
20
+ getChatById(id: string): Observable<SavedChatHistory | undefined>;
21
+ addChat(id: string, messages: ChatMessage[]): Observable<SavedChatResponse>;
22
+ updateChat(id: string, name?: string, messages?: ChatMessage[]): Observable<SavedChatResponse>;
23
+ deleteChat(ids: string[]): Observable<DeleteSavedChatResponse>;
24
+ isExistingChat(id: string): Observable<boolean>;
25
+ static ɵfac: i0.ɵɵFactoryDeclaration<SavedChatsService, never>;
26
+ static ɵprov: i0.ɵɵInjectableDeclaration<SavedChatsService>;
27
+ }
@@ -0,0 +1,34 @@
1
+ import { ChatConfig } from '../types';
2
+ import * as i0 from "@angular/core";
3
+ export interface AssistantConfigurationOperationContext {
4
+ getChatInstanceId: () => string;
5
+ getChatId: () => string;
6
+ getAssistantConfigValue: () => ChatConfig | undefined;
7
+ setAssistantConfig: (config: ChatConfig | undefined) => void;
8
+ setWSRequestsUrl: (url: string) => void;
9
+ setRESTRequestsUrl: (url: string) => void;
10
+ setInitConfigStatus: (status: boolean) => void;
11
+ generateAuditEvent: (type: string, details: Record<string, any>, id?: string) => Promise<void>;
12
+ }
13
+ export declare class AssistantConfigurationService {
14
+ private context;
15
+ private appService;
16
+ private userSettingsService;
17
+ private principalService;
18
+ private modalService;
19
+ private notificationsService;
20
+ private transloco;
21
+ constructor();
22
+ init(context: AssistantConfigurationOperationContext): void;
23
+ private ensureInitialized;
24
+ getAssistantsSetting(): any;
25
+ initChatConfig(): Promise<void>;
26
+ updateChatConfig(config: ChatConfig, hashes?: {
27
+ "applied-defaultValues-hash"?: string;
28
+ "skipped-defaultValues-hash"?: string;
29
+ }, notify?: boolean, successCallback?: () => any, errorCallback?: () => any): void;
30
+ getWSRequestsUrl(): void;
31
+ getRESTRequestsUrl(): void;
32
+ static ɵfac: i0.ɵɵFactoryDeclaration<AssistantConfigurationService, never>;
33
+ static ɵprov: i0.ɵɵInjectableDeclaration<AssistantConfigurationService>;
34
+ }
@@ -0,0 +1,18 @@
1
+ import { Observable } from 'rxjs';
2
+ import { ChatConfig, GllmModelDescription, GllmFunction } from '../types';
3
+ import * as i0 from "@angular/core";
4
+ export interface AssistantMetadataOperationContext {
5
+ getRestUrl: () => string;
6
+ getAssistantConfigValue: () => ChatConfig | undefined;
7
+ setModels: (models: GllmModelDescription[] | undefined) => void;
8
+ setFunctions: (functions: GllmFunction[] | undefined) => void;
9
+ }
10
+ export declare class AssistantMetadataService {
11
+ private context;
12
+ init(context: AssistantMetadataOperationContext): void;
13
+ private ensureInitialized;
14
+ listModels(): Observable<GllmModelDescription[] | undefined>;
15
+ listFunctions(): Observable<GllmFunction[] | undefined>;
16
+ static ɵfac: i0.ɵɵFactoryDeclaration<AssistantMetadataService, never>;
17
+ static ɵprov: i0.ɵɵInjectableDeclaration<AssistantMetadataService>;
18
+ }
@@ -0,0 +1,23 @@
1
+ import { ChatConfig, ChatUsageMetrics, GllmModelDescription, Quota, TokenConsumption, UserTokenConsumption } from '../types';
2
+ import * as i0 from "@angular/core";
3
+ export interface AssistantTokensTrackingOperationContext {
4
+ getAssistantConfigValue: () => ChatConfig | undefined;
5
+ setQuota: (quota: Quota | undefined) => void;
6
+ setUserTokenConsumption: (consumption: UserTokenConsumption | undefined) => void;
7
+ setChatUsageMetrics: (metrics: ChatUsageMetrics | undefined) => void;
8
+ setChatTokenConsumption: (consumption: TokenConsumption | undefined) => void;
9
+ generateAuditEvent: (type: string, details: Record<string, any>, id?: string) => Promise<void>;
10
+ getModel: (serviceId: string, modelId: string) => GllmModelDescription | undefined;
11
+ }
12
+ export declare class AssistantTokensTrackingService {
13
+ private context;
14
+ private assistantUtils;
15
+ private notificationsService;
16
+ constructor();
17
+ init(context: AssistantTokensTrackingOperationContext): void;
18
+ private ensureInitialized;
19
+ updateQuota(quota: Quota, propagateError?: boolean): void;
20
+ updateChatUsageMetrics(chatUsageMetrics: ChatUsageMetrics): void;
21
+ static ɵfac: i0.ɵɵFactoryDeclaration<AssistantTokensTrackingService, never>;
22
+ static ɵprov: i0.ɵɵInjectableDeclaration<AssistantTokensTrackingService>;
23
+ }
@@ -0,0 +1,50 @@
1
+ import { HubConnection } from '@microsoft/signalr';
2
+ import { Observable } from 'rxjs';
3
+ import { Query } from "@sinequa/atomic";
4
+ import { ChatConfig, ChatMessage, ChatResponse, ChatUsageMetrics, MessageHandler, Quota, SavedChatResponse } from '../types';
5
+ import * as i0 from "@angular/core";
6
+ export interface AssistantWsFramesContext {
7
+ getAssistantConfig: () => ChatConfig | undefined;
8
+ getChatInstanceId: () => string;
9
+ getChatId: () => string;
10
+ getHubConnection: () => HubConnection | undefined;
11
+ getChatHistory: () => ChatMessage[] | undefined;
12
+ setStreamingStatus: (isStreaming: boolean) => void;
13
+ setChatHistory: (history: ChatMessage[] | undefined) => void;
14
+ setStoppingGenerationStatus: (isStopping: boolean) => void;
15
+ setSavedChatsErrorStatus: (hasError: boolean) => void;
16
+ updateQuota: (quota: Quota, propagateError?: boolean) => void;
17
+ updateChatUsageMetrics: (metrics: ChatUsageMetrics) => void;
18
+ generateAuditEvent: (type: string, details: Record<string, any>, id?: string) => Promise<void>;
19
+ addSavedChat: (id: string, messages: ChatMessage[]) => Observable<SavedChatResponse>;
20
+ updateSavedChat: (id: string, name?: string, messages?: ChatMessage[]) => Observable<SavedChatResponse>;
21
+ listSavedChat: () => void;
22
+ isExistingSavedChat: (id: string) => Observable<boolean>;
23
+ }
24
+ export declare class AssistantWsFramesService {
25
+ private context;
26
+ private appService;
27
+ private transloco;
28
+ private assistantUtils;
29
+ private notificationsService;
30
+ private _messageHandlers;
31
+ private _response;
32
+ private _actionMap;
33
+ private _progress;
34
+ private _executionTime;
35
+ private _executionTimeMilliseconds?;
36
+ private _attachments;
37
+ private _debugMessages;
38
+ init(context: AssistantWsFramesContext): void;
39
+ private ensureInitialized;
40
+ fetch(messages: ChatMessage[], query: Query): Observable<ChatResponse>;
41
+ initMessageHandlers(): void;
42
+ overrideMessageHandlers<T>(_messageHandlers: Map<string, MessageHandler<T>>): void;
43
+ addMessageHandler<T>(eventName: string, eventHandler: MessageHandler<T>): void;
44
+ registerMessageHandler<T>(eventName: string, eventHandler: MessageHandler<T>): void;
45
+ removeMessageHandler(eventName: string): void;
46
+ unsubscribeMessageHandler(eventName: string): void;
47
+ stopGeneration(): Observable<boolean>;
48
+ static ɵfac: i0.ɵɵFactoryDeclaration<AssistantWsFramesService, never>;
49
+ static ɵprov: i0.ɵɵInjectableDeclaration<AssistantWsFramesService>;
50
+ }
@@ -0,0 +1,25 @@
1
+ import { HubConnection } from '@microsoft/signalr';
2
+ import { ConnectionOptions } from './signalR.web.service';
3
+ import { ChatConfig } from '../types';
4
+ import * as i0 from "@angular/core";
5
+ export interface SignalRConnectionOperationConfig {
6
+ getWsRequestUrl: () => string;
7
+ getAssistantConfigValue: () => ChatConfig | undefined;
8
+ getHubConnection: () => HubConnection | undefined;
9
+ setHubConnection: (connection: HubConnection | undefined) => void;
10
+ }
11
+ export declare class SignalRConnectionService {
12
+ private operationConfig;
13
+ private signalRWebService;
14
+ private assistantUtils;
15
+ init(config: SignalRConnectionOperationConfig): void;
16
+ private ensureInitialized;
17
+ private _getLogLevel;
18
+ private _getTransports;
19
+ private getDefaultOptions;
20
+ buildConnection(options?: ConnectionOptions): Promise<void>;
21
+ startConnection(): Promise<void>;
22
+ stopConnection(): Promise<void>;
23
+ static ɵfac: i0.ɵɵFactoryDeclaration<SignalRConnectionService, never>;
24
+ static ɵprov: i0.ɵɵInjectableDeclaration<SignalRConnectionService>;
25
+ }
@@ -5,6 +5,7 @@ export interface ConnectionOptions {
5
5
  withCredentials?: boolean;
6
6
  headers?: MessageHeaders;
7
7
  transport?: HttpTransportType | ITransport;
8
+ skipNegotiation?: boolean;
8
9
  accessTokenFactory?: () => string | Promise<string>;
9
10
  }
10
11
  /** A token that is used to inject the transports allowed to use by hub connection.
package/chat/types.d.ts CHANGED
@@ -24,6 +24,7 @@ export interface RawMessage {
24
24
  */
25
25
  export interface ChatMessage extends RawMessage {
26
26
  additionalProperties: {
27
+ messageId: string;
27
28
  display?: boolean;
28
29
  $progress?: ChatProgress[];
29
30
  $attachment?: ChatContextAttachment[];
@@ -144,6 +145,7 @@ export declare const connectionSettingsSchema: z.ZodEffects<z.ZodObject<{
144
145
  connectionErrorMessage: z.ZodString;
145
146
  restEndpoint: z.ZodOptional<z.ZodString>;
146
147
  websocketEndpoint: z.ZodOptional<z.ZodString>;
148
+ signalRSkipNegotiation: z.ZodOptional<z.ZodBoolean>;
147
149
  signalRTransport: z.ZodEnum<["WebSockets", "ServerSentEvents", "LongPolling", "None"]>;
148
150
  signalRLogLevel: z.ZodEnum<["Critical", "Debug", "Error", "Information", "None", "Trace", "Warning"]>;
149
151
  signalRServerTimeoutInMilliseconds: z.ZodOptional<z.ZodNumber>;
@@ -153,6 +155,7 @@ export declare const connectionSettingsSchema: z.ZodEffects<z.ZodObject<{
153
155
  signalRLogLevel: "None" | "Critical" | "Debug" | "Error" | "Information" | "Trace" | "Warning";
154
156
  restEndpoint?: string | undefined;
155
157
  websocketEndpoint?: string | undefined;
158
+ signalRSkipNegotiation?: boolean | undefined;
156
159
  signalRServerTimeoutInMilliseconds?: number | undefined;
157
160
  }, {
158
161
  connectionErrorMessage: string;
@@ -160,6 +163,7 @@ export declare const connectionSettingsSchema: z.ZodEffects<z.ZodObject<{
160
163
  signalRLogLevel: "None" | "Critical" | "Debug" | "Error" | "Information" | "Trace" | "Warning";
161
164
  restEndpoint?: string | undefined;
162
165
  websocketEndpoint?: string | undefined;
166
+ signalRSkipNegotiation?: boolean | undefined;
163
167
  signalRServerTimeoutInMilliseconds?: number | undefined;
164
168
  }>, {
165
169
  connectionErrorMessage: string;
@@ -167,6 +171,7 @@ export declare const connectionSettingsSchema: z.ZodEffects<z.ZodObject<{
167
171
  signalRLogLevel: "None" | "Critical" | "Debug" | "Error" | "Information" | "Trace" | "Warning";
168
172
  restEndpoint?: string | undefined;
169
173
  websocketEndpoint?: string | undefined;
174
+ signalRSkipNegotiation?: boolean | undefined;
170
175
  signalRServerTimeoutInMilliseconds?: number | undefined;
171
176
  }, {
172
177
  connectionErrorMessage: string;
@@ -174,6 +179,7 @@ export declare const connectionSettingsSchema: z.ZodEffects<z.ZodObject<{
174
179
  signalRLogLevel: "None" | "Critical" | "Debug" | "Error" | "Information" | "Trace" | "Warning";
175
180
  restEndpoint?: string | undefined;
176
181
  websocketEndpoint?: string | undefined;
182
+ signalRSkipNegotiation?: boolean | undefined;
177
183
  signalRServerTimeoutInMilliseconds?: number | undefined;
178
184
  }>;
179
185
  export type ConnectionSettings = z.infer<typeof connectionSettingsSchema>;
@@ -395,6 +401,7 @@ export declare const chatConfigSchema: z.ZodObject<{
395
401
  connectionErrorMessage: z.ZodString;
396
402
  restEndpoint: z.ZodOptional<z.ZodString>;
397
403
  websocketEndpoint: z.ZodOptional<z.ZodString>;
404
+ signalRSkipNegotiation: z.ZodOptional<z.ZodBoolean>;
398
405
  signalRTransport: z.ZodEnum<["WebSockets", "ServerSentEvents", "LongPolling", "None"]>;
399
406
  signalRLogLevel: z.ZodEnum<["Critical", "Debug", "Error", "Information", "None", "Trace", "Warning"]>;
400
407
  signalRServerTimeoutInMilliseconds: z.ZodOptional<z.ZodNumber>;
@@ -404,6 +411,7 @@ export declare const chatConfigSchema: z.ZodObject<{
404
411
  signalRLogLevel: "None" | "Critical" | "Debug" | "Error" | "Information" | "Trace" | "Warning";
405
412
  restEndpoint?: string | undefined;
406
413
  websocketEndpoint?: string | undefined;
414
+ signalRSkipNegotiation?: boolean | undefined;
407
415
  signalRServerTimeoutInMilliseconds?: number | undefined;
408
416
  }, {
409
417
  connectionErrorMessage: string;
@@ -411,6 +419,7 @@ export declare const chatConfigSchema: z.ZodObject<{
411
419
  signalRLogLevel: "None" | "Critical" | "Debug" | "Error" | "Information" | "Trace" | "Warning";
412
420
  restEndpoint?: string | undefined;
413
421
  websocketEndpoint?: string | undefined;
422
+ signalRSkipNegotiation?: boolean | undefined;
414
423
  signalRServerTimeoutInMilliseconds?: number | undefined;
415
424
  }>, {
416
425
  connectionErrorMessage: string;
@@ -418,6 +427,7 @@ export declare const chatConfigSchema: z.ZodObject<{
418
427
  signalRLogLevel: "None" | "Critical" | "Debug" | "Error" | "Information" | "Trace" | "Warning";
419
428
  restEndpoint?: string | undefined;
420
429
  websocketEndpoint?: string | undefined;
430
+ signalRSkipNegotiation?: boolean | undefined;
421
431
  signalRServerTimeoutInMilliseconds?: number | undefined;
422
432
  }, {
423
433
  connectionErrorMessage: string;
@@ -425,6 +435,7 @@ export declare const chatConfigSchema: z.ZodObject<{
425
435
  signalRLogLevel: "None" | "Critical" | "Debug" | "Error" | "Information" | "Trace" | "Warning";
426
436
  restEndpoint?: string | undefined;
427
437
  websocketEndpoint?: string | undefined;
438
+ signalRSkipNegotiation?: boolean | undefined;
428
439
  signalRServerTimeoutInMilliseconds?: number | undefined;
429
440
  }>;
430
441
  defaultValues: z.ZodObject<{
@@ -642,6 +653,7 @@ export declare const chatConfigSchema: z.ZodObject<{
642
653
  signalRLogLevel: "None" | "Critical" | "Debug" | "Error" | "Information" | "Trace" | "Warning";
643
654
  restEndpoint?: string | undefined;
644
655
  websocketEndpoint?: string | undefined;
656
+ signalRSkipNegotiation?: boolean | undefined;
645
657
  signalRServerTimeoutInMilliseconds?: number | undefined;
646
658
  };
647
659
  defaultValues: {
@@ -708,6 +720,7 @@ export declare const chatConfigSchema: z.ZodObject<{
708
720
  signalRLogLevel: "None" | "Critical" | "Debug" | "Error" | "Information" | "Trace" | "Warning";
709
721
  restEndpoint?: string | undefined;
710
722
  websocketEndpoint?: string | undefined;
723
+ signalRSkipNegotiation?: boolean | undefined;
711
724
  signalRServerTimeoutInMilliseconds?: number | undefined;
712
725
  };
713
726
  defaultValues: {
@@ -780,8 +793,8 @@ export interface ChatPayload {
780
793
  targetUrl?: string;
781
794
  accessToken?: string;
782
795
  };
783
- instanceId?: string;
784
- savedChatId?: string;
796
+ instanceId: string;
797
+ chatId: string;
785
798
  genericChatErrorMessage?: string;
786
799
  }
787
800
  export type ActionMessage = {
@@ -892,7 +905,15 @@ export interface ListObject {
892
905
  items: (KvObject | ListObject)[];
893
906
  expanded: boolean;
894
907
  }
895
- export type DebugMessage = KvObject | ListObject;
908
+ export type DebugMessage = {
909
+ title: string;
910
+ chatId: string;
911
+ executionId: string;
912
+ debugMessageId: string;
913
+ $expanded?: boolean;
914
+ $loading?: boolean;
915
+ $details?: ListObject[];
916
+ };
896
917
  export type MessageHandler<T> = {
897
918
  handler: (data: T) => void;
898
919
  isGlobalHandler: boolean;
@@ -0,0 +1,67 @@
1
+ import { TranslocoService } from "@jsverse/transloco";
2
+ import { ChatMessage } from "../types";
3
+ import * as i0 from "@angular/core";
4
+ export declare class AssistantUtils {
5
+ readonly localID: string | null;
6
+ protected readonly transloco: TranslocoService;
7
+ /**
8
+ * Retrieves the rank (1-based index) of a message within a chat history array based on its message ID.
9
+ * If the message is not found, returns -1.
10
+ *
11
+ * @param array - An array of `ChatMessage` objects or `undefined`. Represents the chat history.
12
+ * @param messageId - The unique identifier of the message to locate.
13
+ * @returns The 1-based index of the message in the array, or -1 if the message is not found.
14
+ */
15
+ getMessageRankInChatHistory(array: ChatMessage[] | undefined, messageId: string): number;
16
+ /**
17
+ * Traverse the array from the end and track the first 'assistant' message among the last group of "assistant" messages where display is true
18
+ * @param array The array of ChatMessage to traverse
19
+ * @returns The index of the first visible assistant message among the last group of "assistant" messages in the array
20
+ */
21
+ firstVisibleAssistantMessageIndex(array: ChatMessage[] | undefined): number;
22
+ /**
23
+ * Traverse the array from the end and pick the last 'assistant' message among the last group of "assistant" messages where display is true
24
+ * @param array The array of ChatMessage to traverse
25
+ * @returns The index of the last visible assistant message among the last group of "assistant" messages in the array
26
+ */
27
+ lastVisibleAssistantMessageIndex(array: ChatMessage[] | undefined): number;
28
+ /**
29
+ * Format a date string in UTC to a local date string
30
+ * @param value Date string in UTC to format
31
+ * @returns A formatted local date string
32
+ */
33
+ formatDateTime(value: string): string;
34
+ /**
35
+ * Takes a text prompt that may contain placeholders for variables
36
+ * and replaces these placeholders if it finds a match in the given
37
+ * context object.
38
+ *
39
+ * @example
40
+ * const p = "Hello, [[user.name]]! You have [[user.notifications.length]] new notifications.";
41
+ * const context = {
42
+ * user: {
43
+ * name: "Alice",
44
+ * notifications: ["Message from Bob", "Reminder for meeting"]
45
+ * }
46
+ * };
47
+ * const formattedPrompt = formatPrompt(p, context);
48
+ * console.log(formattedPrompt); // Output: "Hello, Alice! You have 2 new notifications."
49
+ */
50
+ static formatPrompt(prompt: string, context: any): string;
51
+ /**
52
+ * Determines a time-based key for a given date to be used for translations or formatting.
53
+ * The key represents a relative time period such as "today", "yesterday", "this week", etc.
54
+ * If the date does not fall into any predefined relative time period, it returns the year as a string.
55
+ *
56
+ * @param date - The date for which the time key is to be determined.
57
+ * @returns A string representing the time key, which can be used for translation or display purposes.
58
+ */
59
+ getTimeKey(date: Date): string;
60
+ /**
61
+ * Get the current locale name.
62
+ * @returns The current locale name or an empty string if not available.
63
+ */
64
+ getCurrentLocaleName(): string;
65
+ static ɵfac: i0.ɵɵFactoryDeclaration<AssistantUtils, never>;
66
+ static ɵprov: i0.ɵɵInjectableDeclaration<AssistantUtils>;
67
+ }