@sinequa/assistant 3.7.8 → 3.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/chat/chat-settings-v3/chat-settings-v3.component.d.ts +6 -5
- package/chat/chat.component.d.ts +7 -15
- package/chat/chat.service.d.ts +5 -5
- package/chat/documents-upload/document-list/document-list.component.d.ts +77 -0
- package/chat/documents-upload/document-overview/document-overview.component.d.ts +41 -0
- package/chat/documents-upload/document-upload/document-upload.component.d.ts +98 -0
- package/chat/documents-upload/documents-upload.model.d.ts +66 -0
- package/chat/documents-upload/documents-upload.service.d.ts +174 -0
- package/chat/public-api.d.ts +5 -0
- package/chat/styles/assistant.scss +2 -0
- package/chat/types.d.ts +76 -20
- package/chat/websocket-chat.service.d.ts +1 -1
- package/esm2020/chat/chat-message/chat-message.component.mjs +3 -3
- package/esm2020/chat/chat-reference/chat-reference.component.mjs +3 -3
- package/esm2020/chat/chat-settings-v3/chat-settings-v3.component.mjs +13 -10
- package/esm2020/chat/chat.component.mjs +31 -34
- package/esm2020/chat/chat.service.mjs +9 -9
- package/esm2020/chat/documents-upload/document-list/document-list.component.mjs +191 -0
- package/esm2020/chat/documents-upload/document-overview/document-overview.component.mjs +80 -0
- package/esm2020/chat/documents-upload/document-upload/document-upload.component.mjs +258 -0
- package/esm2020/chat/documents-upload/documents-upload.model.mjs +2 -0
- package/esm2020/chat/documents-upload/documents-upload.service.mjs +289 -0
- package/esm2020/chat/public-api.mjs +6 -1
- package/esm2020/chat/saved-chats/saved-chats.component.mjs +4 -4
- package/esm2020/chat/token-progress-bar/token-progress-bar.component.mjs +3 -3
- package/esm2020/chat/types.mjs +17 -6
- package/esm2020/chat/websocket-chat.service.mjs +2 -2
- package/fesm2015/sinequa-assistant-chat.mjs +3648 -2864
- package/fesm2015/sinequa-assistant-chat.mjs.map +1 -1
- package/fesm2020/sinequa-assistant-chat.mjs +3626 -2843
- package/fesm2020/sinequa-assistant-chat.mjs.map +1 -1
- package/package.json +4 -2
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { EventEmitter, OnDestroy, OnInit } from "@angular/core";
|
|
2
|
-
import { ChatService } from "../chat.service";
|
|
3
|
-
import { ChatConfig, GllmModelDescription } from "../types";
|
|
4
2
|
import { Subscription } from "rxjs";
|
|
5
|
-
import { InstanceManagerService } from "../instance-manager.service";
|
|
6
|
-
import { PrincipalWebService } from "@sinequa/core/web-services";
|
|
7
|
-
import { LoginService } from "@sinequa/core/login";
|
|
8
3
|
import { AppService } from "@sinequa/core/app-utils";
|
|
4
|
+
import { LoginService } from "@sinequa/core/login";
|
|
5
|
+
import { PrincipalWebService } from "@sinequa/core/web-services";
|
|
6
|
+
import { ChatService } from "../chat.service";
|
|
7
|
+
import { InstanceManagerService } from "../instance-manager.service";
|
|
8
|
+
import { ChatConfig, GllmModelDescription } from "../types";
|
|
9
9
|
import * as i0 from "@angular/core";
|
|
10
10
|
export declare class ChatSettingsV3Component implements OnInit, OnDestroy {
|
|
11
11
|
/** Define the key based on it, the appropriate chatService instance will be returned from instanceManagerService */
|
|
@@ -21,6 +21,7 @@ export declare class ChatSettingsV3Component implements OnInit, OnDestroy {
|
|
|
21
21
|
enabled: boolean;
|
|
22
22
|
}[];
|
|
23
23
|
isAdmin: boolean;
|
|
24
|
+
showDebugToggle: boolean;
|
|
24
25
|
loginService: LoginService;
|
|
25
26
|
instanceManagerService: InstanceManagerService;
|
|
26
27
|
principalService: PrincipalWebService;
|
package/chat/chat.component.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { ChangeDetectorRef, ElementRef, EventEmitter, OnChanges, OnDestroy, OnInit, SimpleChanges, TemplateRef } from "@angular/core";
|
|
2
|
+
import { HubConnection } from "@microsoft/signalr";
|
|
3
|
+
import { BehaviorSubject } from "rxjs";
|
|
2
4
|
import { Action } from "@sinequa/components/action";
|
|
3
5
|
import { AbstractFacet } from "@sinequa/components/facet";
|
|
4
6
|
import { SearchService } from "@sinequa/components/search";
|
|
5
7
|
import { AppService, Query } from "@sinequa/core/app-utils";
|
|
8
|
+
import { LoginService } from "@sinequa/core/login";
|
|
9
|
+
import { NotificationsService } from "@sinequa/core/notification";
|
|
6
10
|
import { PrincipalWebService } from "@sinequa/core/web-services";
|
|
7
|
-
import { BehaviorSubject } from "rxjs";
|
|
8
11
|
import { ChatService } from "./chat.service";
|
|
9
|
-
import { ChatContextAttachment, ChatConfig, ChatMessage, GllmModelDescription, MessageHandler, RawMessage, SuggestedAction, InitChat, DebugMessage } from "./types";
|
|
10
12
|
import { InstanceManagerService } from "./instance-manager.service";
|
|
11
|
-
import { WebSocketChatService } from "./websocket-chat.service";
|
|
12
|
-
import { LoginService } from "@sinequa/core/login";
|
|
13
13
|
import { RestChatService } from "./rest-chat.service";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
14
|
+
import { ChatConfig, ChatContextAttachment, ChatMessage, DebugMessage, GllmModelDescription, InitChat, MessageHandler, RawMessage, SuggestedAction } from "./types";
|
|
15
|
+
import { WebSocketChatService } from "./websocket-chat.service";
|
|
16
16
|
import * as i0 from "@angular/core";
|
|
17
17
|
export declare class ChatComponent extends AbstractFacet implements OnInit, OnChanges, OnDestroy {
|
|
18
18
|
loginService: LoginService;
|
|
@@ -1088,6 +1088,7 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
|
|
|
1088
1088
|
chatService: ChatService;
|
|
1089
1089
|
config: ChatConfig;
|
|
1090
1090
|
messages$: BehaviorSubject<ChatMessage[] | undefined>;
|
|
1091
|
+
isAdminOrDeletedAdmin: boolean;
|
|
1091
1092
|
question: string;
|
|
1092
1093
|
_actions: Action[];
|
|
1093
1094
|
private _resetChatAction;
|
|
@@ -1159,15 +1160,6 @@ export declare class ChatComponent extends AbstractFacet implements OnInit, OnCh
|
|
|
1159
1160
|
* When the listener is triggered, it updates the `isAtBottom` property.
|
|
1160
1161
|
*/
|
|
1161
1162
|
private _addScrollListener;
|
|
1162
|
-
/**
|
|
1163
|
-
* Initializes a listener that updates the disabled state of the reset chat action
|
|
1164
|
-
* based on the streaming and stopping generation states from the chat service.
|
|
1165
|
-
*
|
|
1166
|
-
* The listener combines the `streaming$` and `stoppingGeneration$` observables
|
|
1167
|
-
* from the chat service, and determines if either of them is active. If either
|
|
1168
|
-
* is active, the reset chat action is disabled.
|
|
1169
|
-
*/
|
|
1170
|
-
private _addResetActionStateListener;
|
|
1171
1163
|
/**
|
|
1172
1164
|
* Get the model description based on the defaultValues service_id and model_id
|
|
1173
1165
|
*/
|
package/chat/chat.service.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { UserPreferences } from "@sinequa/components/user-settings";
|
|
2
|
-
import { LoginService } from "@sinequa/core/login";
|
|
3
|
-
import { NotificationsService } from "@sinequa/core/notification";
|
|
4
|
-
import { AuditWebService, UserSettingsWebService, PrincipalWebService } from "@sinequa/core/web-services";
|
|
5
1
|
import { BehaviorSubject, Observable } from "rxjs";
|
|
6
|
-
import {
|
|
2
|
+
import { UserPreferences } from "@sinequa/components/user-settings";
|
|
7
3
|
import { AppService, Query } from "@sinequa/core/app-utils";
|
|
8
4
|
import { IntlService } from "@sinequa/core/intl";
|
|
5
|
+
import { LoginService } from "@sinequa/core/login";
|
|
9
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
10
|
import * as i0 from "@angular/core";
|
|
11
11
|
export declare abstract class ChatService {
|
|
12
12
|
/** Name of the assistant plugin OR websocket endpoint. */
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { OnDestroy, OnInit } from "@angular/core";
|
|
2
|
+
import { BehaviorSubject } from "rxjs";
|
|
3
|
+
import { LoginService } from "@sinequa/core/login";
|
|
4
|
+
import { NotificationsService } from "@sinequa/core/notification";
|
|
5
|
+
import { AbstractFacet } from "@sinequa/components/facet";
|
|
6
|
+
import { Action } from "@sinequa/components/action";
|
|
7
|
+
import { InstanceManagerService } from "../../instance-manager.service";
|
|
8
|
+
import { ChatService } from "../../chat.service";
|
|
9
|
+
import { DocumentsUploadService } from "../documents-upload.service";
|
|
10
|
+
import { UploadedDocument } from "../documents-upload.model";
|
|
11
|
+
import * as i0 from "@angular/core";
|
|
12
|
+
export declare class DocumentListComponent extends AbstractFacet implements OnInit, OnDestroy {
|
|
13
|
+
/** Define the key based on it, the appropriate chatService instance will be returned from instanceManagerService */
|
|
14
|
+
instanceId: string;
|
|
15
|
+
chatService: ChatService;
|
|
16
|
+
groupedUploadedDocuments$: BehaviorSubject<{
|
|
17
|
+
key: string;
|
|
18
|
+
value: UploadedDocument[];
|
|
19
|
+
}[]>;
|
|
20
|
+
documentToDelete?: UploadedDocument;
|
|
21
|
+
deletingAll: boolean;
|
|
22
|
+
private _subscription;
|
|
23
|
+
private _actions;
|
|
24
|
+
private _updateDocumentsListAction;
|
|
25
|
+
private _deleteAllDocumentsAction;
|
|
26
|
+
loginService: LoginService;
|
|
27
|
+
instanceManagerService: InstanceManagerService;
|
|
28
|
+
documentsUploadService: DocumentsUploadService;
|
|
29
|
+
notificationsService: NotificationsService;
|
|
30
|
+
constructor();
|
|
31
|
+
ngOnInit(): void;
|
|
32
|
+
ngOnDestroy(): void;
|
|
33
|
+
get actions(): Action[];
|
|
34
|
+
instantiateChatService(): void;
|
|
35
|
+
/**
|
|
36
|
+
* Updates the list of uploaded documents by fetching the latest data from the service.
|
|
37
|
+
* The fetched documents are grouped by date.
|
|
38
|
+
*
|
|
39
|
+
* @returns {void}
|
|
40
|
+
*/
|
|
41
|
+
updateUploadedDocumentsList(): void;
|
|
42
|
+
deleteDocument(event: Event, doc: UploadedDocument): void;
|
|
43
|
+
/**
|
|
44
|
+
* Handles the deletion of an uploaded document. This method triggers a confirmation modal
|
|
45
|
+
* to ensure the user wants to proceed with the deletion. If confirmed, it sends a request
|
|
46
|
+
* to delete the document and provides feedback to the user upon success or failure.
|
|
47
|
+
*
|
|
48
|
+
* @param event - The event object associated with the delete action, used to stop propagation.
|
|
49
|
+
* @param doc - The document to be deleted, represented as an instance of `UploadedDocument`.
|
|
50
|
+
*
|
|
51
|
+
* @remarks
|
|
52
|
+
* - Displays a confirmation modal with a warning message.
|
|
53
|
+
* - On confirmation, deletes the document.
|
|
54
|
+
* - Shows a success notification upon successful deletion.
|
|
55
|
+
* - Logs and notifies the user of any errors encountered during the deletion process.
|
|
56
|
+
*/
|
|
57
|
+
performDeleteDocument(): void;
|
|
58
|
+
deleteAllDocuments(event?: Event): void;
|
|
59
|
+
/**
|
|
60
|
+
* Handles the deletion of all uploaded documents. This method triggers a confirmation modal
|
|
61
|
+
* to ensure the user wants to proceed with the deletion. If confirmed, it sends a request
|
|
62
|
+
* to delete the whole list of documents and provides feedback to the user upon success or failure.
|
|
63
|
+
*
|
|
64
|
+
* @param event - (Optional) The event object associated with the delete action, used to stop propagation.
|
|
65
|
+
*
|
|
66
|
+
* @remarks
|
|
67
|
+
* - Displays a confirmation modal with a warning message.
|
|
68
|
+
* - On confirmation, deletes all documents.
|
|
69
|
+
* - Shows a success notification upon successful deletion.
|
|
70
|
+
* - Logs and notifies the user of any errors encountered during the deletion process.
|
|
71
|
+
*/
|
|
72
|
+
performDeleteAllDocuments(): void;
|
|
73
|
+
private _groupUploadedDocumentsByDate;
|
|
74
|
+
private _getTimeKey;
|
|
75
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DocumentListComponent, never>;
|
|
76
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<DocumentListComponent, "sq-document-list", never, { "instanceId": "instanceId"; }, {}, never, never, true>;
|
|
77
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { EventEmitter, OnDestroy, OnInit } from "@angular/core";
|
|
2
|
+
import { BehaviorSubject } from "rxjs";
|
|
3
|
+
import { LoginService } from "@sinequa/core/login";
|
|
4
|
+
import { NotificationsService } from "@sinequa/core/notification";
|
|
5
|
+
import { AbstractFacet } from "@sinequa/components/facet";
|
|
6
|
+
import { Action } from "@sinequa/components/action";
|
|
7
|
+
import { ModalService } from "@sinequa/core/modal";
|
|
8
|
+
import { InstanceManagerService } from "../../instance-manager.service";
|
|
9
|
+
import { ChatService } from "../../chat.service";
|
|
10
|
+
import { DocumentsUploadService } from "../documents-upload.service";
|
|
11
|
+
import { UploadedDocument } from "../documents-upload.model";
|
|
12
|
+
import * as i0 from "@angular/core";
|
|
13
|
+
export declare class DocumentOverviewComponent extends AbstractFacet implements OnInit, OnDestroy {
|
|
14
|
+
/** Define the key based on it, the appropriate chatService instance will be returned from instanceManagerService */
|
|
15
|
+
instanceId: string;
|
|
16
|
+
disabledUpload: boolean;
|
|
17
|
+
onUpload: EventEmitter<any>;
|
|
18
|
+
chatService: ChatService;
|
|
19
|
+
uploadedDocuments$: BehaviorSubject<UploadedDocument[]>;
|
|
20
|
+
private _subscription;
|
|
21
|
+
private _actions;
|
|
22
|
+
private _updateDocumentsListAction;
|
|
23
|
+
loginService: LoginService;
|
|
24
|
+
instanceManagerService: InstanceManagerService;
|
|
25
|
+
documentsUploadService: DocumentsUploadService;
|
|
26
|
+
notificationsService: NotificationsService;
|
|
27
|
+
modalService: ModalService;
|
|
28
|
+
constructor();
|
|
29
|
+
ngOnInit(): void;
|
|
30
|
+
ngOnDestroy(): void;
|
|
31
|
+
get actions(): Action[];
|
|
32
|
+
instantiateChatService(): void;
|
|
33
|
+
/**
|
|
34
|
+
* Updates the list of uploaded documents by fetching the latest data from the service.
|
|
35
|
+
*
|
|
36
|
+
* @returns {void}
|
|
37
|
+
*/
|
|
38
|
+
updateUploadedDocumentsList(): void;
|
|
39
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DocumentOverviewComponent, never>;
|
|
40
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<DocumentOverviewComponent, "sq-document-overview", never, { "instanceId": "instanceId"; "disabledUpload": "disabledUpload"; }, { "onUpload": "onUpload"; }, never, never, true>;
|
|
41
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/// <reference types="flowjs" />
|
|
2
|
+
import { OnDestroy, OnInit } from "@angular/core";
|
|
3
|
+
import { FlowDirective, Transfer } from "@flowjs/ngx-flow";
|
|
4
|
+
import { BehaviorSubject } from "rxjs";
|
|
5
|
+
import { LoginService } from "@sinequa/core/login";
|
|
6
|
+
import { NotificationsService } from "@sinequa/core/notification";
|
|
7
|
+
import { InstanceManagerService } from "../../instance-manager.service";
|
|
8
|
+
import { ChatService } from "../../chat.service";
|
|
9
|
+
import { DocumentsUploadService } from "../documents-upload.service";
|
|
10
|
+
import { IndexingInfos, UploadingInfos } from "../documents-upload.model";
|
|
11
|
+
import * as i0 from "@angular/core";
|
|
12
|
+
export declare class DocumentUploadComponent implements OnInit, OnDestroy {
|
|
13
|
+
/** Define the key based on it, the appropriate chatService instance will be returned from instanceManagerService */
|
|
14
|
+
instanceId: string;
|
|
15
|
+
/** Polling interval in milliseconds to update the indexing status of the uploaded documents */
|
|
16
|
+
pollingInterval: number;
|
|
17
|
+
flow: FlowDirective;
|
|
18
|
+
chatService: ChatService;
|
|
19
|
+
readonly flowConfig: flowjs.FlowOptions;
|
|
20
|
+
errorAlerts: string[];
|
|
21
|
+
dragging$: BehaviorSubject<boolean>;
|
|
22
|
+
indexing$: BehaviorSubject<boolean>;
|
|
23
|
+
indexingInfos$: BehaviorSubject<IndexingInfos | undefined>;
|
|
24
|
+
uploading$: BehaviorSubject<boolean>;
|
|
25
|
+
uploadingInfos$: BehaviorSubject<UploadingInfos | undefined>;
|
|
26
|
+
private _subscription;
|
|
27
|
+
loginService: LoginService;
|
|
28
|
+
instanceManagerService: InstanceManagerService;
|
|
29
|
+
documentsUploadService: DocumentsUploadService;
|
|
30
|
+
notificationsService: NotificationsService;
|
|
31
|
+
ngOnInit(): void;
|
|
32
|
+
ngOnDestroy(): void;
|
|
33
|
+
instantiateChatService(): void;
|
|
34
|
+
/**
|
|
35
|
+
* Handles the submission of files.
|
|
36
|
+
*
|
|
37
|
+
* @remarks
|
|
38
|
+
* This method performs the following checks on the submitted files:
|
|
39
|
+
*
|
|
40
|
+
* 1. Checks if the number of files submitted exceeds the remainingFileCount defined in the constraints.
|
|
41
|
+
* - If the number of files exceeds the allowed count, all files are removed from the flow.
|
|
42
|
+
* - An error message is added to the error alerts.
|
|
43
|
+
*
|
|
44
|
+
* 2. Checks if the total size of the files submitted exceeds the remainingFileSize defined in the constraints.
|
|
45
|
+
* - If the total size exceeds the allowed size, all files are removed from the flow.
|
|
46
|
+
* - An error message is added to the error alerts.
|
|
47
|
+
*
|
|
48
|
+
* 3. Checks if the file extension of the files submitted is not allowed.
|
|
49
|
+
* - If the file extension is not allowed, the file is removed from the flow.
|
|
50
|
+
* - An error message is added to the error alerts.
|
|
51
|
+
*/
|
|
52
|
+
private _onFilesSubmitted;
|
|
53
|
+
private _onFilesAdded;
|
|
54
|
+
onDragenter(): void;
|
|
55
|
+
onDragleave(event: DragEvent): void;
|
|
56
|
+
onDrop(): void;
|
|
57
|
+
trackTransfer(transfer: Transfer): string;
|
|
58
|
+
/**
|
|
59
|
+
* Initiates the upload process by invoking the `upload` method
|
|
60
|
+
* of the `flow` instance.
|
|
61
|
+
* The `upload` method is overridden in the `ngOnInit` method to match the requirements of the assistant API.
|
|
62
|
+
*/
|
|
63
|
+
upload(): void;
|
|
64
|
+
/**
|
|
65
|
+
* Initiates the file upload process by preparing the form data,
|
|
66
|
+
* setting the uploading flag, and making an API call to upload the files.
|
|
67
|
+
*
|
|
68
|
+
* @remarks
|
|
69
|
+
* - Collects all files from the `flowJs` instance and appends them to a `FormData` object.
|
|
70
|
+
* - Subscribes to the upload process to handle progress updates, completion, and errors.
|
|
71
|
+
* - Triggers tracking the indexing process upon successful upload completion.
|
|
72
|
+
* - Cleans up the `flow` instance after the upload process is finalized.
|
|
73
|
+
*/
|
|
74
|
+
private startUpload;
|
|
75
|
+
/**
|
|
76
|
+
* Tracks the indexing process for a single documents upload session by polling the API for its status.
|
|
77
|
+
*
|
|
78
|
+
* @param token - A unique token representing the single documents upload session.
|
|
79
|
+
*
|
|
80
|
+
* @remarks
|
|
81
|
+
* - Clears the uploading flags and sets the indexing flag to true before starting the process.
|
|
82
|
+
* - Polls the API every second to retrieve the current indexing status.
|
|
83
|
+
* - Updates the `indexingInfos` property with the latest status.
|
|
84
|
+
* - Stops polling when the indexing process is completed or an error occurs.
|
|
85
|
+
* - Cleans up by resetting the indexing flags and clearing the `indexingInfos` property when the process is finalized.
|
|
86
|
+
*/
|
|
87
|
+
trackIndexingProcess(token: string): void;
|
|
88
|
+
/**
|
|
89
|
+
* Calculates the indexing progress as a percentage of completed documents.
|
|
90
|
+
*
|
|
91
|
+
* @param infos - The indexing information containing the list of documents and their statuses.
|
|
92
|
+
* @returns The progress as a number between 0 and 1, where 0 indicates no progress and 1 indicates all documents are processed (processed means either indexed or errored).
|
|
93
|
+
* Returns 0 if the input is invalid or there are no documents.
|
|
94
|
+
*/
|
|
95
|
+
getIndexingProgress(infos: IndexingInfos | undefined): number;
|
|
96
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DocumentUploadComponent, never>;
|
|
97
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<DocumentUploadComponent, "sq-document-upload", never, { "instanceId": "instanceId"; "pollingInterval": "pollingInterval"; }, {}, never, never, true>;
|
|
98
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export declare type UploadConfig = {
|
|
2
|
+
documentsUploadEnabled: boolean;
|
|
3
|
+
constraints: {
|
|
4
|
+
maxTotalFileSizeMB: number;
|
|
5
|
+
remainingFileSizeMB: number;
|
|
6
|
+
maxTotalFileCount: number;
|
|
7
|
+
remainingFileCount: number;
|
|
8
|
+
supportedFileExtensions: string[];
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export declare type UploadResponse = {
|
|
12
|
+
statusToken: string;
|
|
13
|
+
executionTime: string;
|
|
14
|
+
connectorResponse?: {
|
|
15
|
+
collection: string;
|
|
16
|
+
action: string;
|
|
17
|
+
stats: {
|
|
18
|
+
nbDocUpdated: number;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export declare type UploadingInfos = {
|
|
23
|
+
loaded: number;
|
|
24
|
+
total: number;
|
|
25
|
+
progress: number;
|
|
26
|
+
};
|
|
27
|
+
export declare type UploadProgressEvent = {
|
|
28
|
+
type: 'uploadProgress';
|
|
29
|
+
} & UploadingInfos;
|
|
30
|
+
export interface UploadResponseEvent {
|
|
31
|
+
type: 'response';
|
|
32
|
+
body: UploadResponse;
|
|
33
|
+
}
|
|
34
|
+
export declare type UploadEvent = UploadProgressEvent | UploadResponseEvent;
|
|
35
|
+
export declare type IndexingInfos = {
|
|
36
|
+
docs: {
|
|
37
|
+
id: string;
|
|
38
|
+
fileName: string;
|
|
39
|
+
operation: "Add" | "Update";
|
|
40
|
+
status: "Indexing" | "Indexed" | "Error";
|
|
41
|
+
previousIndexationTime: string | null;
|
|
42
|
+
currentIndexationTime: string | null;
|
|
43
|
+
}[];
|
|
44
|
+
isCompleted: boolean;
|
|
45
|
+
executionTime: string;
|
|
46
|
+
};
|
|
47
|
+
export interface UploadedDocuments {
|
|
48
|
+
docs: UploadedDocument[];
|
|
49
|
+
count: number;
|
|
50
|
+
totalCount: number;
|
|
51
|
+
executionTime: string;
|
|
52
|
+
}
|
|
53
|
+
export interface UploadedDocument {
|
|
54
|
+
id: string;
|
|
55
|
+
fileName: string;
|
|
56
|
+
title: string;
|
|
57
|
+
fileExt: string;
|
|
58
|
+
indexationTime: string;
|
|
59
|
+
size: string;
|
|
60
|
+
sizeDisplay: string;
|
|
61
|
+
[key: string]: any;
|
|
62
|
+
}
|
|
63
|
+
export interface deleteDocumentsResponse {
|
|
64
|
+
deletedCount: number;
|
|
65
|
+
executionTime: string;
|
|
66
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { LoginService } from '@sinequa/core/login';
|
|
2
|
+
import { JsonMethodPluginService } from '@sinequa/core/web-services';
|
|
3
|
+
import { ChatService } from '../chat.service';
|
|
4
|
+
import { BehaviorSubject, Observable } from 'rxjs';
|
|
5
|
+
import { deleteDocumentsResponse, IndexingInfos, UploadConfig, UploadedDocuments, UploadEvent } from './documents-upload.model';
|
|
6
|
+
import { HttpClient } from '@angular/common/http';
|
|
7
|
+
import { AppService } from '@sinequa/core/app-utils';
|
|
8
|
+
import * as i0 from "@angular/core";
|
|
9
|
+
export declare class DocumentsUploadService {
|
|
10
|
+
/** Name of the assistant plugin. */
|
|
11
|
+
REQUEST_URL: string;
|
|
12
|
+
/** Documents' upload configuration. */
|
|
13
|
+
uploadConfig$: BehaviorSubject<UploadConfig | undefined>;
|
|
14
|
+
chatService: ChatService;
|
|
15
|
+
jsonMethodWebService: JsonMethodPluginService;
|
|
16
|
+
loginService: LoginService;
|
|
17
|
+
appService: AppService;
|
|
18
|
+
http: HttpClient;
|
|
19
|
+
/**
|
|
20
|
+
* Initializes the file upload service with the provided chat service instance.
|
|
21
|
+
*
|
|
22
|
+
* @param chatService - An instance of ChatService. If not provided, an error is thrown.
|
|
23
|
+
* @throws {Error} If the chatService instance is not provided or if there is an error during initialization.
|
|
24
|
+
*/
|
|
25
|
+
init(chatService: ChatService | undefined): void;
|
|
26
|
+
/**
|
|
27
|
+
* Fetch the endpoint to use for the file upload related requests
|
|
28
|
+
* @throws {Error} If the property 'restEndpoint' is not provided in the assistant configuration
|
|
29
|
+
*/
|
|
30
|
+
getRequestsUrl(): void;
|
|
31
|
+
/**
|
|
32
|
+
* Retrieves the upload configuration for documents.
|
|
33
|
+
* The response, which contains the upload configuration, is emitted to the `uploadConfig$` observable.
|
|
34
|
+
*
|
|
35
|
+
* @throws {Error} If there is an error invoking the `documentsUploadConfigGet` action.
|
|
36
|
+
*/
|
|
37
|
+
getUploadConfig(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Uploads documents to the server.
|
|
40
|
+
*
|
|
41
|
+
* This method takes a FormData object which should contain all files to be uploaded.
|
|
42
|
+
* Each file should be appended to the FormData object with its original name.
|
|
43
|
+
*
|
|
44
|
+
* For example:
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const formData = new FormData();
|
|
47
|
+
* formData.append(file.name, file.file);
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @param formData - The FormData object containing the files to be uploaded.
|
|
51
|
+
* - Each file should be appended to the FormData object with its original name.
|
|
52
|
+
* For example:
|
|
53
|
+
* ```typescript
|
|
54
|
+
* const formData = new FormData();
|
|
55
|
+
* formData.append(file.name, file.file);
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @param enableProgress - (Optional) A boolean parameter that controls whether progress reporting is enabled.
|
|
59
|
+
* - Defaults to `true`.
|
|
60
|
+
* - If `true`, the `reportProgress` option is set in the request options, enabling the track of upload progress based on the underlying browser's progress events.
|
|
61
|
+
* - If `false`, progress events are not reported.
|
|
62
|
+
*
|
|
63
|
+
* @returns An Observable that emits events of type `UploadEvent`:
|
|
64
|
+
* - `UploadProgressEvent`: Emitted during the upload process, containing:
|
|
65
|
+
* - * `type`: "uploadProgress" - The type of the event.
|
|
66
|
+
* - * `loaded`: number - The number of bytes uploaded so far.
|
|
67
|
+
* - * `total`: number - The total number of bytes to be uploaded (if available).
|
|
68
|
+
* - * `progress`: number - The percentage of upload progress (calculated as `(loaded / total) * 100`).
|
|
69
|
+
* - `UploadResponseEvent`: Emitted when the upload is complete, containing:
|
|
70
|
+
* - * `type`: "response" - The type of the event.
|
|
71
|
+
* - * `body`: `UploadResponse` - The server's response, including:
|
|
72
|
+
* - * - * `statusToken`: string - A token to track the status of the indexing process.
|
|
73
|
+
* - * - * `executionTime`: string - The time taken to execute the upload.
|
|
74
|
+
* - * - * `connectorResponse` (optional): Additional response data from the connector, containing:
|
|
75
|
+
* - * - * - * `collection`: string - The collection name.
|
|
76
|
+
* - * - * - * `action`: string - The action performed.
|
|
77
|
+
* - * - * - * `stats`: object - Statistics about the upload, including:
|
|
78
|
+
* - * - * - * - * `nbDocUpdated`: number - The number of documents updated.
|
|
79
|
+
*
|
|
80
|
+
* @throws {Error} If there is an error invoking the `documentsupload` action.
|
|
81
|
+
*
|
|
82
|
+
* Example usage:
|
|
83
|
+
* ```typescript
|
|
84
|
+
* const formData = new FormData();
|
|
85
|
+
* formData.append(file.name, file.file);
|
|
86
|
+
* this.documentsUploadService.uploadDocuments(formData).subscribe(event => {
|
|
87
|
+
* if (event.type === 'uploadProgress') {
|
|
88
|
+
* console.log(`Progress: ${event.progress}%`);
|
|
89
|
+
* } else if (event.type === 'response') {
|
|
90
|
+
* console.log('Upload complete:', event.body);
|
|
91
|
+
* }
|
|
92
|
+
* });
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
uploadDocuments(formData: FormData, enableProgress?: boolean): Observable<UploadEvent>;
|
|
96
|
+
/**
|
|
97
|
+
* Retrieves the indexing status of a predefined uploaded document(s)
|
|
98
|
+
* based on the provided status token returned from the upload process.
|
|
99
|
+
*
|
|
100
|
+
* @param token - The status token used to track the indexing process.
|
|
101
|
+
* @returns An Observable that emits the server response of type `IndexingResponse`.
|
|
102
|
+
* The `IndexingResponse` object contains:
|
|
103
|
+
* - `docs`: array - An array of document status objects, each containing:
|
|
104
|
+
* - * `id`: string - The document ID.
|
|
105
|
+
* - * `fileName`: string - The name of the file.
|
|
106
|
+
* - * `operation`: "Add" | "Update" - The operation performed on the document.
|
|
107
|
+
* - * `status`: "Indexing" | "Indexed" | "Error" - The status of the document.
|
|
108
|
+
* - * `previousIndexationTime`: string | null - The previous indexation time.
|
|
109
|
+
* - * `currentIndexationTime`: string | null - The current indexation time.
|
|
110
|
+
* - `executionTime`: string - The time taken to retrieve the indexing status.
|
|
111
|
+
* @throws {Error} If there is an error invoking the `documentsUploadStatus` action.
|
|
112
|
+
*/
|
|
113
|
+
getIndexingStatus(token: string): Observable<IndexingInfos>;
|
|
114
|
+
/**
|
|
115
|
+
* Retrieves a list of uploaded documents.
|
|
116
|
+
*
|
|
117
|
+
* @param {string[]} [columns] - Optional array of additional index columns to include for each document.
|
|
118
|
+
* @param {number} [skip] - Optional number of documents to skip for pagination. If set, count also needs to be set. No skip if not set.
|
|
119
|
+
* @param {number} [count] - Optional number of documents to take for pagination (unlimited if not set).
|
|
120
|
+
* @returns {Observable<UploadedDocuments>} An observable that emits the list of uploaded documents.
|
|
121
|
+
* The `UploadedDocuments` object contains:
|
|
122
|
+
* - `docs`: array - An array of objects representing a single document with the following properties:
|
|
123
|
+
* - * `id`: string - A unique identifier for the document.
|
|
124
|
+
* - * `fileName`: string - The name of the file.
|
|
125
|
+
* - * `title`: string - The title of the document.
|
|
126
|
+
* - * `fileExt`: string - The file extension of the document.
|
|
127
|
+
* - * `indexationTime`: string - The time when the document was indexed.
|
|
128
|
+
* - * `size`: number - The size of the document.
|
|
129
|
+
* - * `sizeDisplay`: string - A human-readable representation of the document size.
|
|
130
|
+
* - * `[key: string]`: any - Additional columns asked in the request, value of the column for the document.
|
|
131
|
+
* - `count`: number - The count of documents in the current batch or subset.
|
|
132
|
+
* - `totalCount`: number - The total count of documents available.
|
|
133
|
+
* - `executionTime`: string - The time taken to process the documents.
|
|
134
|
+
* @throws {Error} Throws an error if the request fails.
|
|
135
|
+
*/
|
|
136
|
+
getDocumentsList(columns?: string[], skip?: number, count?: number): Observable<UploadedDocuments>;
|
|
137
|
+
/**
|
|
138
|
+
* Deletes the uploaded documents with the specified IDs.
|
|
139
|
+
*
|
|
140
|
+
* @param docIds - An array of document IDs to delete.
|
|
141
|
+
* @returns An observable that emits the server response of type `deleteDocumentsResponse`.
|
|
142
|
+
* The `deleteDocumentsResponse` object contains:
|
|
143
|
+
* - `deletedCount`: number - The number of deleted documents.
|
|
144
|
+
* - `executionTime`: string - The time taken to delete the documents.
|
|
145
|
+
* @throws {Error} If there is an error invoking the `documentsDelete` action.
|
|
146
|
+
*/
|
|
147
|
+
deleteDocuments(docIds: string[]): Observable<deleteDocumentsResponse>;
|
|
148
|
+
/**
|
|
149
|
+
* Deletes all uploaded documents.
|
|
150
|
+
*
|
|
151
|
+
* @returns An observable that emits the server response of type `deleteDocumentsResponse`.
|
|
152
|
+
* The `deleteDocumentsResponse` object contains:
|
|
153
|
+
* - `deletedCount`: number - The number of deleted documents.
|
|
154
|
+
* - `executionTime`: string - The time taken to delete the documents.
|
|
155
|
+
* @throws {Error} If there is an error invoking the `documentsDeleteAll` action.
|
|
156
|
+
*/
|
|
157
|
+
deleteAllDocuments(): Observable<deleteDocumentsResponse>;
|
|
158
|
+
/**
|
|
159
|
+
* Formats the given file size in bytes into a human-readable string.
|
|
160
|
+
*
|
|
161
|
+
* @param bytes - The size of the file in bytes.
|
|
162
|
+
* @returns A string representing the file size in a human-readable format (e.g., "10.24 KB", "1.00 MB").
|
|
163
|
+
*/
|
|
164
|
+
formatFileSize(bytes: number): string;
|
|
165
|
+
/**
|
|
166
|
+
* Converts the given file size in bytes into megabytes.
|
|
167
|
+
*
|
|
168
|
+
* @param bytes - The size of the file in bytes.
|
|
169
|
+
* @returns The size of the file in megabytes.
|
|
170
|
+
*/
|
|
171
|
+
convertBytesToMB(bytes: number): number;
|
|
172
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DocumentsUploadService, never>;
|
|
173
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<DocumentsUploadService>;
|
|
174
|
+
}
|
package/chat/public-api.d.ts
CHANGED
|
@@ -10,3 +10,8 @@ export * from './websocket-chat.service';
|
|
|
10
10
|
export * from './rest-chat.service';
|
|
11
11
|
export * from './instance-manager.service';
|
|
12
12
|
export * from './prompt.component';
|
|
13
|
+
export * from './documents-upload/document-upload/document-upload.component';
|
|
14
|
+
export * from './documents-upload/document-list/document-list.component';
|
|
15
|
+
export * from './documents-upload/documents-upload.service';
|
|
16
|
+
export * from './documents-upload/documents-upload.model';
|
|
17
|
+
export * from './documents-upload/document-overview/document-overview.component';
|
|
@@ -30,6 +30,7 @@ $ast-error-color: var(--ast-error-color, rgba(249, 58, 55, 0.7));
|
|
|
30
30
|
$ast-warning-bg: var(--ast-warning-bg, #fff1b8);
|
|
31
31
|
$ast-warning-color: var(--ast-warning-color, #fed86f);
|
|
32
32
|
$ast-saved-chat-hover-background: var(--ast-saved-chat-hover-background, #FFF8F1);
|
|
33
|
+
$ast-uploaded-doc-hover-background: var(--ast-uploaded-doc-hover-background, #f2f8fe);
|
|
33
34
|
$ast-input-bg: var(--ast-input-bg, #F8F8F8);
|
|
34
35
|
$ast-input-color: var(--ast-input-color, #B0B0B0);
|
|
35
36
|
$ast-muted-color: var(--ast-muted-color, rgba(33, 37, 41, 0.75));
|
|
@@ -86,6 +87,7 @@ $ast-report-bg: var(--ast-report-bg, white);
|
|
|
86
87
|
--ast-input-color: rgba(222, 218, 218, 0.75);
|
|
87
88
|
--ast-muted-color: rgba(222, 218, 218, 0.75);
|
|
88
89
|
--ast-saved-chat-hover-background: #262421;
|
|
90
|
+
--ast-uploaded-doc-hover-background: #262421;
|
|
89
91
|
--ast-message-table-border-color: #333333;
|
|
90
92
|
--ast-message-table-tr-bg: #070707;
|
|
91
93
|
--ast-message-table-tr-border-color: #222222;
|