@apia/ai 4.0.8 → 4.0.11
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/dist/index.d.ts +266 -18
- package/dist/index.js +1193 -285
- package/dist/index.js.map +1 -1
- package/index.ts/index.d.ts +343 -0
- package/index.ts/index.d.ts.map +1 -0
- package/index.ts/index.js +1898 -0
- package/index.ts/index.js.map +1 -0
- package/package.json +7 -6
package/dist/index.d.ts
CHANGED
|
@@ -3,12 +3,37 @@ import { ReactNode, FC, ReactElement } from 'react';
|
|
|
3
3
|
import * as _apia_util from '@apia/util';
|
|
4
4
|
import { EventEmitter, AudioRecorder } from '@apia/util';
|
|
5
5
|
import { CollectorField } from '@apia/validations';
|
|
6
|
-
import {
|
|
6
|
+
import { FilterDTO } from '@apia/components';
|
|
7
|
+
import { TActionDispatcher } from '@apia/dashboard-controller';
|
|
8
|
+
import { ThemeUIStyleObject } from '@apia/theme';
|
|
7
9
|
|
|
8
10
|
declare const AutoscrollContainer: ({ children }: {
|
|
9
11
|
children: ReactNode;
|
|
10
12
|
}) => react.JSX.Element;
|
|
11
13
|
|
|
14
|
+
declare const AIFileContentAllowedExtensions: {
|
|
15
|
+
readonly svg: "svg";
|
|
16
|
+
readonly png: "png";
|
|
17
|
+
readonly jpg: "jpg";
|
|
18
|
+
readonly jpeg: "jpeg";
|
|
19
|
+
readonly txt: "txt";
|
|
20
|
+
readonly doc: "doc";
|
|
21
|
+
readonly pdf: "pdf";
|
|
22
|
+
readonly docx: "docx";
|
|
23
|
+
readonly csv: "csv";
|
|
24
|
+
readonly xlsx: "xlsx";
|
|
25
|
+
readonly xls: "xls";
|
|
26
|
+
readonly mp3: "mp3";
|
|
27
|
+
readonly wav: "wav";
|
|
28
|
+
};
|
|
29
|
+
type AIFileContentAllowedExtension = keyof typeof AIFileContentAllowedExtensions;
|
|
30
|
+
type TAttachmentErrorCallback = 'fileExtension' | 'blobGeneration';
|
|
31
|
+
declare enum FileType {
|
|
32
|
+
DOCUMENT = "DOCUMENT",
|
|
33
|
+
IMAGE = "IMAGE",
|
|
34
|
+
AUDIO = "AUDIO",
|
|
35
|
+
SHEET = "SHEET"
|
|
36
|
+
}
|
|
12
37
|
declare enum AIMessageRole {
|
|
13
38
|
USER = "USER",
|
|
14
39
|
SYSTEM = "SYSTEM"
|
|
@@ -16,6 +41,81 @@ declare enum AIMessageRole {
|
|
|
16
41
|
interface Reactive {
|
|
17
42
|
Component: FC<any>;
|
|
18
43
|
}
|
|
44
|
+
interface Cloneable {
|
|
45
|
+
clone: () => Cloneable;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
interface IAttachment {
|
|
49
|
+
name: string;
|
|
50
|
+
id: string;
|
|
51
|
+
value: string;
|
|
52
|
+
}
|
|
53
|
+
type TChatControllerState = {
|
|
54
|
+
isVisible: boolean;
|
|
55
|
+
isLoading: boolean;
|
|
56
|
+
canRecord: boolean;
|
|
57
|
+
canAttach: boolean;
|
|
58
|
+
canAddSystemMessage: boolean;
|
|
59
|
+
canAddUserMessage: boolean;
|
|
60
|
+
hideDeleteButton: boolean;
|
|
61
|
+
maxAttachmentsSize: number;
|
|
62
|
+
messages: ChatMessage[];
|
|
63
|
+
currentMessage: ChatMessage;
|
|
64
|
+
};
|
|
65
|
+
type MessageCallback = (props: {
|
|
66
|
+
message: ChatMessage;
|
|
67
|
+
}) => Promise<any>;
|
|
68
|
+
declare class ChatController2 {
|
|
69
|
+
private onMessageSubmit;
|
|
70
|
+
id: string;
|
|
71
|
+
currentIndex: number;
|
|
72
|
+
needsControlExtension: boolean;
|
|
73
|
+
state: TChatControllerState;
|
|
74
|
+
private internalAudioRecorder;
|
|
75
|
+
private internalCameraRecorder;
|
|
76
|
+
private maxId;
|
|
77
|
+
audioRecorder: {
|
|
78
|
+
start: () => void;
|
|
79
|
+
stop: () => Promise<void>;
|
|
80
|
+
record: number;
|
|
81
|
+
state: _apia_util.AudioRecorderState;
|
|
82
|
+
};
|
|
83
|
+
constructor(props: Partial<TChatControllerState>, onMessageSubmit: MessageCallback, id: string);
|
|
84
|
+
removeMessage(idx: number): void;
|
|
85
|
+
addMessage(message: ChatMessage): void;
|
|
86
|
+
clearHistory(): void;
|
|
87
|
+
clearMessage(): void;
|
|
88
|
+
removeAttachment(attachment: IAttachment): void;
|
|
89
|
+
nextMessage(): void;
|
|
90
|
+
prevMessage(): void;
|
|
91
|
+
History: (() => react.JSX.Element) & {
|
|
92
|
+
displayName: string;
|
|
93
|
+
};
|
|
94
|
+
Attachments: (() => react.JSX.Element) & {
|
|
95
|
+
displayName: string;
|
|
96
|
+
};
|
|
97
|
+
TextArea: (() => react.JSX.Element) & {
|
|
98
|
+
displayName: string;
|
|
99
|
+
};
|
|
100
|
+
Renderer: () => react.JSX.Element;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
declare class ChatMessage implements Reactive, Cloneable {
|
|
104
|
+
message: ReactNode;
|
|
105
|
+
messageType: TMessageType;
|
|
106
|
+
attachments: IAttachment[];
|
|
107
|
+
reference: ReactNode;
|
|
108
|
+
id: number;
|
|
109
|
+
parseMessage(message: string): string;
|
|
110
|
+
constructor(message?: ReactNode, messageType?: TMessageType, attachments?: IAttachment[], reference?: ReactNode);
|
|
111
|
+
clone: () => ChatMessage;
|
|
112
|
+
removeAttachment(idx: number): void;
|
|
113
|
+
Component: (({ className }: {
|
|
114
|
+
className?: string | undefined;
|
|
115
|
+
}) => react.JSX.Element) & {
|
|
116
|
+
displayName: string;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
19
119
|
|
|
20
120
|
declare class AIContent extends CollectorField implements Reactive {
|
|
21
121
|
type: string;
|
|
@@ -32,23 +132,13 @@ declare class AIMessageAttachments implements Reactive {
|
|
|
32
132
|
customDescription: boolean;
|
|
33
133
|
constructor(role: AIMessageRole, content: AIContent, close?: (() => void) | undefined);
|
|
34
134
|
addDescription: () => Promise<void>;
|
|
135
|
+
getId(): string;
|
|
35
136
|
Component: (props: {
|
|
36
137
|
closeButton?: boolean;
|
|
37
138
|
canAddDescription?: boolean;
|
|
38
139
|
}) => react.JSX.Element;
|
|
39
140
|
}
|
|
40
141
|
|
|
41
|
-
declare class ChatMessage {
|
|
42
|
-
message: ReactNode;
|
|
43
|
-
messageType: TMessageType;
|
|
44
|
-
attachments: AIMessageAttachments[];
|
|
45
|
-
id: number;
|
|
46
|
-
parseMessage(message: string): string;
|
|
47
|
-
constructor(message?: ReactNode, messageType?: TMessageType, attachments?: AIMessageAttachments[]);
|
|
48
|
-
copy: () => ChatMessage;
|
|
49
|
-
Component: () => react.JSX.Element;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
142
|
type TMessageType = 'user' | 'system' | 'warning' | 'error' | 'information' | 'response' | 'multipleChoice' | 'customMessage';
|
|
53
143
|
type ChatControllerState = {
|
|
54
144
|
current: ChatMessage;
|
|
@@ -95,7 +185,7 @@ declare class ChatController {
|
|
|
95
185
|
dropAll: () => undefined;
|
|
96
186
|
drop: (el: AIMessageAttachments) => void;
|
|
97
187
|
getComponents: () => react.JSX.Element[];
|
|
98
|
-
get: () =>
|
|
188
|
+
get: () => IAttachment[];
|
|
99
189
|
size: () => number;
|
|
100
190
|
};
|
|
101
191
|
}
|
|
@@ -111,6 +201,87 @@ declare class MultipleChoiceMessage<OptionProps> extends ChatMessage {
|
|
|
111
201
|
}) => ReactElement);
|
|
112
202
|
}
|
|
113
203
|
|
|
204
|
+
type TSearchResultState = {
|
|
205
|
+
title: string;
|
|
206
|
+
body: string;
|
|
207
|
+
link: string;
|
|
208
|
+
};
|
|
209
|
+
declare class SemanticSearchReference {
|
|
210
|
+
state: TSearchResultState;
|
|
211
|
+
constructor(props: TSearchResultState);
|
|
212
|
+
Component: () => react.JSX.Element;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* @class SearchController:
|
|
217
|
+
* - mobx Controller for the semantic search logic
|
|
218
|
+
* - search for a term and get the results. This controller must be used
|
|
219
|
+
* to maintain the state of the search string and of the results given a search string
|
|
220
|
+
*/
|
|
221
|
+
declare class SearchController {
|
|
222
|
+
static instance: SearchController;
|
|
223
|
+
state: {
|
|
224
|
+
queryString: string;
|
|
225
|
+
results: SemanticSearchReference[];
|
|
226
|
+
isLoading: boolean;
|
|
227
|
+
disabled: boolean;
|
|
228
|
+
};
|
|
229
|
+
protected constructor();
|
|
230
|
+
search(selectedId: string): Promise<void>;
|
|
231
|
+
protected setReferences(results: SemanticSearchReference[]): void;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
type TReference = {
|
|
235
|
+
title: string;
|
|
236
|
+
body: string;
|
|
237
|
+
link: string;
|
|
238
|
+
isExternal: boolean;
|
|
239
|
+
};
|
|
240
|
+
interface ProcessingUnit {
|
|
241
|
+
visualizationType: TSearchMode;
|
|
242
|
+
content: string;
|
|
243
|
+
references: TReference[];
|
|
244
|
+
isExternal: boolean;
|
|
245
|
+
}
|
|
246
|
+
interface ListingProcessingUnit extends ProcessingUnit {
|
|
247
|
+
visualizationType: 'list';
|
|
248
|
+
title: string;
|
|
249
|
+
link: string;
|
|
250
|
+
}
|
|
251
|
+
interface ChatProcessingUnit extends ProcessingUnit {
|
|
252
|
+
visualizationType: 'chat';
|
|
253
|
+
}
|
|
254
|
+
declare const ViewRendererContext: react.Context<ISemanticSearchViewController>;
|
|
255
|
+
type TSearchMode = 'list' | 'chat' | 'none';
|
|
256
|
+
interface ISemanticSearchViewController {
|
|
257
|
+
state: {
|
|
258
|
+
filters: Record<string, FilterDTO>;
|
|
259
|
+
filtersOpen: boolean;
|
|
260
|
+
isLoading: boolean;
|
|
261
|
+
mode: TSearchMode;
|
|
262
|
+
searchString: string;
|
|
263
|
+
};
|
|
264
|
+
ResultsRenderer: FC;
|
|
265
|
+
clearHistory(): Promise<void>;
|
|
266
|
+
search(str?: string): void;
|
|
267
|
+
toggleFiltersOpen(): void;
|
|
268
|
+
}
|
|
269
|
+
type TResponseData = {
|
|
270
|
+
result: string;
|
|
271
|
+
success: string;
|
|
272
|
+
failed?: boolean;
|
|
273
|
+
};
|
|
274
|
+
interface ISearchResultsController<P extends ProcessingUnit> {
|
|
275
|
+
state: {
|
|
276
|
+
results: P[];
|
|
277
|
+
};
|
|
278
|
+
beforeSearch(props?: object): void;
|
|
279
|
+
afterSearch(props?: object): void;
|
|
280
|
+
clear(): void;
|
|
281
|
+
processResults(qryString: string, results: ProcessingUnit[], responseData?: TResponseData): void;
|
|
282
|
+
Component: FC;
|
|
283
|
+
}
|
|
284
|
+
|
|
114
285
|
declare class ResponseStream extends EventEmitter<{
|
|
115
286
|
part: string;
|
|
116
287
|
}> {
|
|
@@ -122,7 +293,6 @@ declare class ResponseStream extends EventEmitter<{
|
|
|
122
293
|
private partSize;
|
|
123
294
|
private timing;
|
|
124
295
|
private waiting;
|
|
125
|
-
close(): void;
|
|
126
296
|
private calculatePartSize;
|
|
127
297
|
emit<K extends 'part'>(_: K, data: {
|
|
128
298
|
part: string;
|
|
@@ -134,6 +304,16 @@ type RoutinesGenerationState = {
|
|
|
134
304
|
isLoading: boolean;
|
|
135
305
|
progress: number;
|
|
136
306
|
};
|
|
307
|
+
type TPollProgress = {
|
|
308
|
+
message: string;
|
|
309
|
+
progress: number;
|
|
310
|
+
debug: string;
|
|
311
|
+
streamPart?: string;
|
|
312
|
+
};
|
|
313
|
+
type TPollRoutineResult = {
|
|
314
|
+
status: string;
|
|
315
|
+
payload: unknown | TPollProgress;
|
|
316
|
+
};
|
|
137
317
|
type TGenerateFromImage$1 = {
|
|
138
318
|
base64: string;
|
|
139
319
|
description: string;
|
|
@@ -141,7 +321,7 @@ type TGenerateFromImage$1 = {
|
|
|
141
321
|
type TRoutineCompletion = Partial<{
|
|
142
322
|
images: TGenerateFromImage$1[];
|
|
143
323
|
parameters: Record<string, string>;
|
|
144
|
-
stream: ResponseStream
|
|
324
|
+
stream: ResponseStream;
|
|
145
325
|
}> & {
|
|
146
326
|
routineName: string;
|
|
147
327
|
};
|
|
@@ -151,9 +331,16 @@ declare class RoutinesGeneration {
|
|
|
151
331
|
state: RoutinesGenerationState;
|
|
152
332
|
constructor();
|
|
153
333
|
private checkCanGenerate;
|
|
154
|
-
|
|
334
|
+
pollRoutine<T>(routineId: string, stream?: ResponseStream): Promise<T | null>;
|
|
335
|
+
private internalPollRoutine;
|
|
336
|
+
protected callAudioTranscription(audio: Blob): ReturnType<RoutinesGeneration['callRoutineStart']>;
|
|
337
|
+
protected callRoutinePoll(routineId: string): Promise<TPollRoutineResult>;
|
|
338
|
+
protected callRoutineStart(routineName: string, parameters: Record<string, string>, images: TGenerateFromImage$1[]): Promise<{
|
|
339
|
+
orchestrator: {
|
|
340
|
+
routineId: string;
|
|
341
|
+
};
|
|
342
|
+
} | null>;
|
|
155
343
|
private executeRoutine;
|
|
156
|
-
private poll;
|
|
157
344
|
private resetLoading;
|
|
158
345
|
completion<T>(params: TRoutineCompletion): Promise<T | null>;
|
|
159
346
|
stop(): void;
|
|
@@ -162,6 +349,23 @@ declare class RoutinesGeneration {
|
|
|
162
349
|
} | null>;
|
|
163
350
|
}
|
|
164
351
|
|
|
352
|
+
declare class DashboardsRoutinesGeneration extends RoutinesGeneration {
|
|
353
|
+
protected dispatcher: TActionDispatcher;
|
|
354
|
+
constructor(dispatcher: TActionDispatcher);
|
|
355
|
+
private blobToBase64;
|
|
356
|
+
protected callAudioTranscription(audio: Blob): Promise<{
|
|
357
|
+
orchestrator: {
|
|
358
|
+
routineId: string;
|
|
359
|
+
};
|
|
360
|
+
} | null>;
|
|
361
|
+
protected callRoutinePoll(routineId: string): Promise<TPollRoutineResult>;
|
|
362
|
+
protected callRoutineStart(routineName: string, parameters: Record<string, string>, images: TGenerateFromImage$1[]): Promise<{
|
|
363
|
+
orchestrator: {
|
|
364
|
+
routineId: string;
|
|
365
|
+
};
|
|
366
|
+
} | null>;
|
|
367
|
+
}
|
|
368
|
+
|
|
165
369
|
type RetrievedImage = {
|
|
166
370
|
base64: string;
|
|
167
371
|
path: string;
|
|
@@ -182,5 +386,49 @@ declare function getImagesWithDescription({ multiple, }: {
|
|
|
182
386
|
multiple?: boolean;
|
|
183
387
|
}): Promise<TGenerateFromImage[]>;
|
|
184
388
|
|
|
185
|
-
|
|
389
|
+
type TFileContentProps = {
|
|
390
|
+
value: string;
|
|
391
|
+
name: string;
|
|
392
|
+
f?: File;
|
|
393
|
+
error?: Partial<Record<TAttachmentErrorCallback, () => void>>;
|
|
394
|
+
needsControlExtension?: boolean;
|
|
395
|
+
onClose?: () => unknown;
|
|
396
|
+
};
|
|
397
|
+
declare class AIFileContent extends AIContent implements Reactive, IAttachment {
|
|
398
|
+
type: FileType;
|
|
399
|
+
value: string;
|
|
400
|
+
name: string;
|
|
401
|
+
extension: AIFileContentAllowedExtension;
|
|
402
|
+
private __file;
|
|
403
|
+
private __error?;
|
|
404
|
+
private onClose?;
|
|
405
|
+
private overrideSize;
|
|
406
|
+
id: string;
|
|
407
|
+
constructor(props: TFileContentProps);
|
|
408
|
+
setOnClose(callback: () => unknown): this;
|
|
409
|
+
setOverrideSize(overrideSize: {
|
|
410
|
+
width: number;
|
|
411
|
+
height: number;
|
|
412
|
+
}): this;
|
|
413
|
+
get file(): File;
|
|
414
|
+
inferContent: () => string;
|
|
415
|
+
inferExtension: (extension: AIFileContentAllowedExtension) => FileType | undefined;
|
|
416
|
+
static isValidExtension: (extension: string) => extension is "svg" | "jpg" | "jpeg" | "png" | "pdf" | "txt" | "doc" | "docx" | "csv" | "xlsx" | "xls" | "mp3" | "wav";
|
|
417
|
+
static blobToBase64: (blob: Blob) => Promise<string>;
|
|
418
|
+
static fromFile: (props: Omit<TFileContentProps, 'fileName' | 'fileUrl' | 'f'> & {
|
|
419
|
+
f: File;
|
|
420
|
+
}) => Promise<AIFileContent>;
|
|
421
|
+
static getExtensionFromFileName(fileName: string): "svg" | "jpg" | "jpeg" | "png" | "pdf" | "txt" | "doc" | "docx" | "csv" | "xlsx" | "xls" | "mp3" | "wav";
|
|
422
|
+
private static __getExtensionErrorMessage;
|
|
423
|
+
private __throwError;
|
|
424
|
+
getId(): string;
|
|
425
|
+
Component: () => react.JSX.Element;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
declare const WindowDragger: react.ForwardRefExoticComponent<{
|
|
429
|
+
children: ReactNode;
|
|
430
|
+
style?: ThemeUIStyleObject | undefined;
|
|
431
|
+
} & react.RefAttributes<HTMLElement>>;
|
|
432
|
+
|
|
433
|
+
export { AIFileContent, AIMessageAttachments, AutoscrollContainer, ChatController, ChatController2, ChatMessage, type ChatProcessingUnit, DashboardsRoutinesGeneration, type ISearchResultsController, type ISemanticSearchViewController, type ListingProcessingUnit, MultipleChoiceMessage, type ProcessingUnit, ResponseStream, RoutinesGeneration, SearchController, SemanticSearchReference as SemanticSearchResult, type TGenerateFromImage$1 as TGenerateFromImage, type TMessageType, type TMultipleChoiceMessageOption, type TPollRoutineResult, type TReference, type TResponseData, type TRoutineCompletion, type TSearchMode, type ISemanticSearchViewController as ViewController, ViewRendererContext, WindowDragger, getImageFromDisk, getImagesFromDisk, getImagesWithDescription };
|
|
186
434
|
//# sourceMappingURL=index.d.ts.map
|