@apia/ai 4.0.16 → 4.0.18
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 +14 -259
- package/dist/index.js +46 -1798
- package/dist/index.js.map +1 -1
- package/package.json +10 -8
- package/index.ts/index.d.ts +0 -343
- package/index.ts/index.d.ts.map +0 -1
- package/index.ts/index.js +0 -1898
- package/index.ts/index.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,213 +1,8 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import { EventEmitter, AudioRecorder } from '@apia/util';
|
|
5
|
-
import { CollectorField } from '@apia/validations';
|
|
6
|
-
import { FilterDTO } from '@apia/components';
|
|
2
|
+
import { FC, ReactElement } from 'react';
|
|
3
|
+
import { FilterDTO, ChatMessage } from '@apia/components';
|
|
7
4
|
import { TActionDispatcher } from '@apia/dashboard-controller';
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
declare const AutoscrollContainer: ({ children }: {
|
|
11
|
-
children: ReactNode;
|
|
12
|
-
}) => react.JSX.Element;
|
|
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
|
-
}
|
|
37
|
-
declare enum AIMessageRole {
|
|
38
|
-
USER = "USER",
|
|
39
|
-
SYSTEM = "SYSTEM"
|
|
40
|
-
}
|
|
41
|
-
interface Reactive {
|
|
42
|
-
Component: FC<any>;
|
|
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
|
-
canShowSystemMessage: boolean;
|
|
61
|
-
canShowUserMessage: boolean;
|
|
62
|
-
hideDeleteButton: boolean;
|
|
63
|
-
maxAttachmentsSize: number;
|
|
64
|
-
messages: ChatMessage[];
|
|
65
|
-
currentMessage: ChatMessage;
|
|
66
|
-
};
|
|
67
|
-
interface BaseMessageCallbackProps {
|
|
68
|
-
message: ChatMessage;
|
|
69
|
-
}
|
|
70
|
-
interface BaseMessageCallbackResponse {
|
|
71
|
-
responseMessage?: ChatMessage;
|
|
72
|
-
}
|
|
73
|
-
type MessageSubmitCallback<T extends BaseMessageCallbackProps> = (props: T) => Promise<BaseMessageCallbackResponse>;
|
|
74
|
-
type MessageResponseCallback<T extends BaseMessageCallbackResponse> = (props: T) => Promise<BaseMessageCallbackResponse>;
|
|
75
|
-
declare class ChatController2 {
|
|
76
|
-
private onMessageSubmit;
|
|
77
|
-
id: string;
|
|
78
|
-
private onMessageResponse?;
|
|
79
|
-
currentIndex: number;
|
|
80
|
-
state: TChatControllerState;
|
|
81
|
-
private internalAudioRecorder;
|
|
82
|
-
private internalCameraRecorder;
|
|
83
|
-
private maxId;
|
|
84
|
-
audioRecorder: {
|
|
85
|
-
start: () => void;
|
|
86
|
-
stop: () => Promise<void>;
|
|
87
|
-
record: number;
|
|
88
|
-
state: _apia_util.AudioRecorderState;
|
|
89
|
-
};
|
|
90
|
-
constructor(props: Partial<TChatControllerState>, onMessageSubmit: MessageSubmitCallback<BaseMessageCallbackProps>, id: string, onMessageResponse?: MessageResponseCallback<BaseMessageCallbackResponse> | undefined);
|
|
91
|
-
removeMessage(idx: number): void;
|
|
92
|
-
addMessage(message: ChatMessage): void;
|
|
93
|
-
clearHistory(): void;
|
|
94
|
-
clearMessage(): void;
|
|
95
|
-
removeAttachment(attachment: IAttachment): void;
|
|
96
|
-
private isValidToShow;
|
|
97
|
-
nextMessage(): void;
|
|
98
|
-
prevMessage(): void;
|
|
99
|
-
History: (() => react.JSX.Element) & {
|
|
100
|
-
displayName: string;
|
|
101
|
-
};
|
|
102
|
-
Attachments: (() => react.JSX.Element) & {
|
|
103
|
-
displayName: string;
|
|
104
|
-
};
|
|
105
|
-
TextArea: (() => react.JSX.Element) & {
|
|
106
|
-
displayName: string;
|
|
107
|
-
};
|
|
108
|
-
Renderer: () => react.JSX.Element;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
declare class ChatMessage implements Reactive, Cloneable {
|
|
112
|
-
message: ReactNode;
|
|
113
|
-
messageType: TMessageType;
|
|
114
|
-
attachments: IAttachment[];
|
|
115
|
-
reference: ReactNode;
|
|
116
|
-
id: number;
|
|
117
|
-
parseMessage(message: string): string;
|
|
118
|
-
constructor(message?: ReactNode, messageType?: TMessageType, attachments?: IAttachment[], reference?: ReactNode);
|
|
119
|
-
clone: () => ChatMessage;
|
|
120
|
-
removeAttachment(idx: number): void;
|
|
121
|
-
Component: (({ className }: {
|
|
122
|
-
className?: string | undefined;
|
|
123
|
-
}) => react.JSX.Element) & {
|
|
124
|
-
displayName: string;
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
declare class AIContent extends CollectorField implements Reactive {
|
|
129
|
-
type: string;
|
|
130
|
-
content: ReactNode;
|
|
131
|
-
constructor(content?: ReactNode);
|
|
132
|
-
Component: () => react.JSX.Element;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
declare class AIMessageAttachments implements Reactive {
|
|
136
|
-
private close?;
|
|
137
|
-
role: AIMessageRole;
|
|
138
|
-
content: AIContent;
|
|
139
|
-
id: string;
|
|
140
|
-
customDescription: boolean;
|
|
141
|
-
constructor(role: AIMessageRole, content: AIContent, close?: (() => void) | undefined);
|
|
142
|
-
addDescription: () => Promise<void>;
|
|
143
|
-
getId(): string;
|
|
144
|
-
Component: (props: {
|
|
145
|
-
closeButton?: boolean;
|
|
146
|
-
canAddDescription?: boolean;
|
|
147
|
-
}) => react.JSX.Element;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
type TMessageType = 'user' | 'system' | 'warning' | 'error' | 'information' | 'response' | 'multipleChoice' | 'customMessage';
|
|
151
|
-
type ChatControllerState = {
|
|
152
|
-
current: ChatMessage;
|
|
153
|
-
messages: ChatMessage[];
|
|
154
|
-
};
|
|
155
|
-
declare class ChatController {
|
|
156
|
-
#private;
|
|
157
|
-
id: string;
|
|
158
|
-
state: ChatControllerState;
|
|
159
|
-
constructor(id: string, welcomeMessage?: string);
|
|
160
|
-
components: {
|
|
161
|
-
MessageHistory: (() => react.JSX.Element) & {
|
|
162
|
-
displayName: string;
|
|
163
|
-
};
|
|
164
|
-
Textarea: (({ hideDeleteButton, isLoading: outIsLoading, onSubmit, preventAppendUserMessages, }: {
|
|
165
|
-
hideDeleteButton?: boolean | undefined;
|
|
166
|
-
isLoading?: boolean | undefined;
|
|
167
|
-
onSubmit: (chatMessage: ChatMessage) => Promise<void>;
|
|
168
|
-
preventAppendUserMessages?: boolean | undefined;
|
|
169
|
-
}) => react.JSX.Element) & {
|
|
170
|
-
displayName: string;
|
|
171
|
-
};
|
|
172
|
-
};
|
|
173
|
-
currentHistoryIndex: number;
|
|
174
|
-
audioRecorder: {
|
|
175
|
-
start: () => Promise<void>;
|
|
176
|
-
stop: () => Promise<void>;
|
|
177
|
-
record: number;
|
|
178
|
-
state: _apia_util.AudioRecorderState;
|
|
179
|
-
};
|
|
180
|
-
history: {
|
|
181
|
-
add: (message: ChatMessage) => void;
|
|
182
|
-
next: () => void;
|
|
183
|
-
previous: () => void;
|
|
184
|
-
updateState: (message?: ChatMessage) => void;
|
|
185
|
-
size: () => number;
|
|
186
|
-
};
|
|
187
|
-
messages: {
|
|
188
|
-
add: (message: ChatMessage, idx?: number) => void;
|
|
189
|
-
clear: () => void;
|
|
190
|
-
};
|
|
191
|
-
attachments: {
|
|
192
|
-
add: (...aiMessage: AIMessageAttachments[]) => void;
|
|
193
|
-
dropAll: () => undefined;
|
|
194
|
-
drop: (el: AIMessageAttachments) => void;
|
|
195
|
-
getComponents: () => react.JSX.Element[];
|
|
196
|
-
get: () => IAttachment[];
|
|
197
|
-
size: () => number;
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
type TMultipleChoiceMessageOption<OptionProps> = {
|
|
202
|
-
label: string;
|
|
203
|
-
url: string;
|
|
204
|
-
additionalProps?: OptionProps;
|
|
205
|
-
};
|
|
206
|
-
declare class MultipleChoiceMessage<OptionProps> extends ChatMessage {
|
|
207
|
-
constructor(question: string, options: TMultipleChoiceMessageOption<OptionProps>[], Renderer?: (props: {
|
|
208
|
-
item: TMultipleChoiceMessageOption<OptionProps>;
|
|
209
|
-
}) => ReactElement);
|
|
210
|
-
}
|
|
5
|
+
import { EventEmitter, AudioRecorder } from '@apia/util';
|
|
211
6
|
|
|
212
7
|
type TSearchResultState = {
|
|
213
8
|
title: string;
|
|
@@ -239,14 +34,6 @@ declare class SearchController {
|
|
|
239
34
|
protected setReferences(results: SemanticSearchReference[]): void;
|
|
240
35
|
}
|
|
241
36
|
|
|
242
|
-
declare class FloatingChatController extends ChatController2 {
|
|
243
|
-
constructor(props: Partial<TChatControllerState>, onMessageSubmit: MessageSubmitCallback<BaseMessageCallbackProps>, id: string, onMessageResponse?: MessageResponseCallback<BaseMessageCallbackResponse>);
|
|
244
|
-
open(): void;
|
|
245
|
-
Window: (() => react.JSX.Element) & {
|
|
246
|
-
displayName: string;
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
|
-
|
|
250
37
|
type TReference = {
|
|
251
38
|
title: string;
|
|
252
39
|
body: string;
|
|
@@ -285,6 +72,7 @@ interface ISemanticSearchViewController {
|
|
|
285
72
|
type TResponseData = {
|
|
286
73
|
result: string;
|
|
287
74
|
success: string;
|
|
75
|
+
streaming: boolean;
|
|
288
76
|
failed?: boolean;
|
|
289
77
|
};
|
|
290
78
|
interface ISearchResultsController<P extends ProcessingUnit> {
|
|
@@ -304,7 +92,7 @@ declare class ResponseStream extends EventEmitter<{
|
|
|
304
92
|
private buffer;
|
|
305
93
|
private isRunning;
|
|
306
94
|
private locked;
|
|
307
|
-
|
|
95
|
+
maxCompletionTime: number;
|
|
308
96
|
private minPartSize;
|
|
309
97
|
private partSize;
|
|
310
98
|
private timing;
|
|
@@ -402,49 +190,16 @@ declare function getImagesWithDescription({ multiple, }: {
|
|
|
402
190
|
multiple?: boolean;
|
|
403
191
|
}): Promise<TGenerateFromImage[]>;
|
|
404
192
|
|
|
405
|
-
type
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
error?: Partial<Record<TAttachmentErrorCallback, () => void>>;
|
|
410
|
-
needsControlExtension?: boolean;
|
|
411
|
-
onClose?: () => unknown;
|
|
193
|
+
type TMultipleChoiceMessageOption<OptionProps> = {
|
|
194
|
+
label: string;
|
|
195
|
+
url: string;
|
|
196
|
+
additionalProps?: OptionProps;
|
|
412
197
|
};
|
|
413
|
-
declare class
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
extension: AIFileContentAllowedExtension;
|
|
418
|
-
private __file;
|
|
419
|
-
private __error?;
|
|
420
|
-
private onClose?;
|
|
421
|
-
private overrideSize;
|
|
422
|
-
id: string;
|
|
423
|
-
constructor(props: TFileContentProps);
|
|
424
|
-
setOnClose(callback: () => unknown): this;
|
|
425
|
-
setOverrideSize(overrideSize: {
|
|
426
|
-
width: number;
|
|
427
|
-
height: number;
|
|
428
|
-
}): this;
|
|
429
|
-
get file(): File;
|
|
430
|
-
inferContent: () => string;
|
|
431
|
-
inferExtension: (extension: AIFileContentAllowedExtension) => FileType | undefined;
|
|
432
|
-
static isValidExtension: (extension: string) => extension is "svg" | "jpg" | "jpeg" | "png" | "pdf" | "txt" | "doc" | "docx" | "csv" | "xlsx" | "xls" | "mp3" | "wav";
|
|
433
|
-
static blobToBase64: (blob: Blob) => Promise<string>;
|
|
434
|
-
static fromFile: (props: Omit<TFileContentProps, 'fileName' | 'fileUrl' | 'f'> & {
|
|
435
|
-
f: File;
|
|
436
|
-
}) => Promise<AIFileContent>;
|
|
437
|
-
static getExtensionFromFileName(fileName: string): "svg" | "jpg" | "jpeg" | "png" | "pdf" | "txt" | "doc" | "docx" | "csv" | "xlsx" | "xls" | "mp3" | "wav";
|
|
438
|
-
private static __getExtensionErrorMessage;
|
|
439
|
-
private __throwError;
|
|
440
|
-
getId(): string;
|
|
441
|
-
Component: () => react.JSX.Element;
|
|
198
|
+
declare class MultipleChoiceMessage<OptionProps> extends ChatMessage {
|
|
199
|
+
constructor(question: string, options: TMultipleChoiceMessageOption<OptionProps>[], Renderer?: (props: {
|
|
200
|
+
item: TMultipleChoiceMessageOption<OptionProps>;
|
|
201
|
+
}) => ReactElement);
|
|
442
202
|
}
|
|
443
203
|
|
|
444
|
-
|
|
445
|
-
children: ReactNode;
|
|
446
|
-
style?: ThemeUIStyleObject | undefined;
|
|
447
|
-
} & react.RefAttributes<HTMLElement>>;
|
|
448
|
-
|
|
449
|
-
export { AIFileContent, AIMessageAttachments, AutoscrollContainer, ChatController, ChatController2, ChatMessage, type ChatProcessingUnit, DashboardsRoutinesGeneration, FloatingChatController, 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 };
|
|
204
|
+
export { type ChatProcessingUnit, DashboardsRoutinesGeneration, type ISearchResultsController, type ISemanticSearchViewController, type ListingProcessingUnit, MultipleChoiceMessage, type ProcessingUnit, ResponseStream, RoutinesGeneration, SearchController, SemanticSearchReference as SemanticSearchResult, type TGenerateFromImage$1 as TGenerateFromImage, type TMultipleChoiceMessageOption, type TPollRoutineResult, type TReference, type TResponseData, type TRoutineCompletion, type TSearchMode, type ISemanticSearchViewController as ViewController, ViewRendererContext, getImageFromDisk, getImagesFromDisk, getImagesWithDescription };
|
|
450
205
|
//# sourceMappingURL=index.d.ts.map
|