@apia/ai 4.0.43 → 4.0.44
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 +279 -17
- package/dist/index.js +1274 -63
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import react__default, { PropsWithChildren, ReactNode, ReactElement, FC } from 'react';
|
|
3
|
+
import { TMenuItem, FilterDTO } from '@apia/components';
|
|
4
4
|
import { TActionDispatcher } from '@apia/dashboard-controller';
|
|
5
|
+
import * as _apia_util from '@apia/util';
|
|
5
6
|
import { EventEmitter, AudioRecorder } from '@apia/util';
|
|
6
7
|
|
|
7
8
|
type TSearchResultState = {
|
|
@@ -34,6 +35,14 @@ declare class SearchController {
|
|
|
34
35
|
protected setReferences(results: SemanticSearchReference[]): void;
|
|
35
36
|
}
|
|
36
37
|
|
|
38
|
+
interface AutoscrollContainerProps {
|
|
39
|
+
/** How close (in px) to the bottom you have to be *when scrolling down*
|
|
40
|
+
* for auto-scroll to kick back in. */
|
|
41
|
+
threshold?: number;
|
|
42
|
+
className?: string;
|
|
43
|
+
}
|
|
44
|
+
declare const AutoscrollContainer: react__default.FC<PropsWithChildren<AutoscrollContainerProps>>;
|
|
45
|
+
|
|
37
46
|
type TReference = {
|
|
38
47
|
title: string;
|
|
39
48
|
body: string;
|
|
@@ -42,6 +51,254 @@ type TReference = {
|
|
|
42
51
|
score: number;
|
|
43
52
|
startIndex: number;
|
|
44
53
|
};
|
|
54
|
+
type TMessageType = 'user' | 'system' | 'warning' | 'error' | 'information' | 'response' | 'multipleChoice' | 'customMessage';
|
|
55
|
+
interface IAttachment {
|
|
56
|
+
name: string;
|
|
57
|
+
id: string;
|
|
58
|
+
base64: string;
|
|
59
|
+
description?: string;
|
|
60
|
+
}
|
|
61
|
+
type TChatControllerState = {
|
|
62
|
+
isLoading: boolean;
|
|
63
|
+
canRecord: boolean;
|
|
64
|
+
canAttach: boolean;
|
|
65
|
+
canAddUserMessage: boolean;
|
|
66
|
+
canAddSystemMessage: boolean;
|
|
67
|
+
maxAttachmentsSize: number;
|
|
68
|
+
messages: ChatMessage[];
|
|
69
|
+
currentMessage: ChatMessage;
|
|
70
|
+
};
|
|
71
|
+
interface MessageCallbackProps {
|
|
72
|
+
message: ChatMessage;
|
|
73
|
+
}
|
|
74
|
+
type MessageSubmitCallback = (props: MessageCallbackProps) => unknown;
|
|
75
|
+
type ClearHistoryCallback = () => unknown;
|
|
76
|
+
type TComponentRender = {
|
|
77
|
+
path: string;
|
|
78
|
+
args: Record<any, any>;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
declare class ChatMessage {
|
|
82
|
+
id: number;
|
|
83
|
+
state: {
|
|
84
|
+
message: ReactNode;
|
|
85
|
+
messageType: TMessageType;
|
|
86
|
+
attachments: IAttachment[];
|
|
87
|
+
reference: ReactNode;
|
|
88
|
+
};
|
|
89
|
+
get message(): ReactNode;
|
|
90
|
+
get messageType(): TMessageType;
|
|
91
|
+
get attachments(): IAttachment[];
|
|
92
|
+
get reference(): ReactNode;
|
|
93
|
+
set message(value: ReactNode);
|
|
94
|
+
set messageType(value: TMessageType);
|
|
95
|
+
set attachments(value: IAttachment[]);
|
|
96
|
+
set reference(value: ReactNode);
|
|
97
|
+
constructor(message?: ReactNode, messageType?: TMessageType, attachments?: IAttachment[], reference?: ReactNode);
|
|
98
|
+
clone: () => ChatMessage;
|
|
99
|
+
removeAttachment(attachment: IAttachment): void;
|
|
100
|
+
addAttachmentDescription(attachment: IAttachment, description: string): void;
|
|
101
|
+
setMessageType(type: TMessageType): void;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
declare class ChatController<T extends Record<string, unknown> = Record<string, unknown>> {
|
|
105
|
+
private onMessageSubmit;
|
|
106
|
+
private onClearHistory;
|
|
107
|
+
private additionalOptions?;
|
|
108
|
+
private classNames?;
|
|
109
|
+
currentIndex: number;
|
|
110
|
+
state: TChatControllerState & T;
|
|
111
|
+
private internalAudioRecorder;
|
|
112
|
+
private internalCameraRecorder;
|
|
113
|
+
private maxId;
|
|
114
|
+
audioRecorder: {
|
|
115
|
+
cancelOnStop: boolean;
|
|
116
|
+
start: () => void;
|
|
117
|
+
stop: () => Promise<void>;
|
|
118
|
+
record: number;
|
|
119
|
+
state: _apia_util.AudioRecorderState;
|
|
120
|
+
};
|
|
121
|
+
constructor(props: Partial<TChatControllerState & T>, onMessageSubmit: MessageSubmitCallback, onClearHistory: ClearHistoryCallback, additionalOptions?: TMenuItem[] | undefined, classNames?: {
|
|
122
|
+
history?: string;
|
|
123
|
+
textarea?: string;
|
|
124
|
+
attachments?: string;
|
|
125
|
+
} | undefined);
|
|
126
|
+
removeMessage(idx: number): void;
|
|
127
|
+
addMessage(message: ChatMessage): void;
|
|
128
|
+
clearHistory(): void;
|
|
129
|
+
clearMessage(): void;
|
|
130
|
+
removeAttachment(attachment: IAttachment): void;
|
|
131
|
+
private handleSubmit;
|
|
132
|
+
private isForHistory;
|
|
133
|
+
private canGoNext;
|
|
134
|
+
private canGoPrev;
|
|
135
|
+
nextMessage(): void;
|
|
136
|
+
prevMessage(): void;
|
|
137
|
+
protected getAdditionalProps(): Partial<MessageCallbackProps>;
|
|
138
|
+
History: (() => react.JSX.Element) & {
|
|
139
|
+
displayName: string;
|
|
140
|
+
};
|
|
141
|
+
Attachments: (() => react.JSX.Element) & {
|
|
142
|
+
displayName: string;
|
|
143
|
+
};
|
|
144
|
+
TextArea: (() => react.JSX.Element) & {
|
|
145
|
+
displayName: string;
|
|
146
|
+
};
|
|
147
|
+
Renderer: () => react.JSX.Element;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
declare class FloatingChatController extends ChatController<{
|
|
151
|
+
isWindowOpen: boolean;
|
|
152
|
+
}> {
|
|
153
|
+
private modalTitle;
|
|
154
|
+
constructor(props: {
|
|
155
|
+
props: Partial<TChatControllerState & {
|
|
156
|
+
isWindowOpen: boolean;
|
|
157
|
+
}>;
|
|
158
|
+
onMessageSubmit: MessageSubmitCallback;
|
|
159
|
+
onClearHistory: ClearHistoryCallback;
|
|
160
|
+
modalTitle?: string;
|
|
161
|
+
additionalOptions?: TMenuItem[];
|
|
162
|
+
classNames?: {
|
|
163
|
+
history?: string;
|
|
164
|
+
textarea?: string;
|
|
165
|
+
attachments?: string;
|
|
166
|
+
};
|
|
167
|
+
});
|
|
168
|
+
getModalTitle(): string | undefined;
|
|
169
|
+
setModalTitle(title: string): void;
|
|
170
|
+
open(): void;
|
|
171
|
+
Window: (() => react.JSX.Element | null) & {
|
|
172
|
+
displayName: string;
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
declare const Attachments: (({ attachments, onRemove, onAddDescription, className, }: {
|
|
177
|
+
attachments: IAttachment[];
|
|
178
|
+
onRemove?: (a: IAttachment) => unknown;
|
|
179
|
+
onAddDescription?: (a: IAttachment, d: string) => unknown;
|
|
180
|
+
className?: string;
|
|
181
|
+
}) => react.JSX.Element | null) & {
|
|
182
|
+
displayName: string;
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
declare const Ellipsis: () => react.JSX.Element;
|
|
186
|
+
|
|
187
|
+
declare const Header: (({ childComponent }: {
|
|
188
|
+
childComponent: ReactNode;
|
|
189
|
+
}) => react.JSX.Element) & {
|
|
190
|
+
displayName: string;
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
declare const History: (({ messages, className, }: {
|
|
194
|
+
messages: ChatMessage[];
|
|
195
|
+
className?: string;
|
|
196
|
+
}) => react.JSX.Element) & {
|
|
197
|
+
displayName: string;
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
declare const Message: (({ className, type, id, message, attachments, reference, }: {
|
|
201
|
+
className?: string;
|
|
202
|
+
type: TMessageType;
|
|
203
|
+
id: string;
|
|
204
|
+
message: ReactNode;
|
|
205
|
+
attachments: IAttachment[];
|
|
206
|
+
reference: ReactNode;
|
|
207
|
+
}) => react.JSX.Element) & {
|
|
208
|
+
displayName: string;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
declare const MessageBlock: react.MemoExoticComponent<({ componentData }: {
|
|
212
|
+
componentData: TComponentRender;
|
|
213
|
+
}) => react.JSX.Element>;
|
|
214
|
+
|
|
215
|
+
declare function rate(el: HTMLElement, how: 'up' | 'down', query: string): Promise<boolean>;
|
|
216
|
+
|
|
217
|
+
declare const TextArea: (({ additionalOptions, isLoading, isRecording, disablePrevButton, disableNextButton, onSubmit, onChange, onClearHistory, onAttach, onRecord, onRecordCancel, onVideoRecord, onPrev, onNext, value, attachments, className, }: {
|
|
218
|
+
additionalOptions?: TMenuItem[];
|
|
219
|
+
className?: string;
|
|
220
|
+
isLoading: boolean;
|
|
221
|
+
isRecording: boolean;
|
|
222
|
+
disablePrevButton: boolean;
|
|
223
|
+
disableNextButton: boolean;
|
|
224
|
+
onClearHistory: () => unknown;
|
|
225
|
+
onSubmit: () => unknown;
|
|
226
|
+
onChange: (v: string) => unknown;
|
|
227
|
+
onAttach: (ev: IAttachment) => unknown;
|
|
228
|
+
onRecord: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
229
|
+
onRecordCancel: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
230
|
+
onVideoRecord: () => unknown;
|
|
231
|
+
onPrev: () => unknown;
|
|
232
|
+
onNext: () => unknown;
|
|
233
|
+
value: string;
|
|
234
|
+
attachments: IAttachment[];
|
|
235
|
+
}) => react.JSX.Element) & {
|
|
236
|
+
displayName: string;
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
declare const MessageBody: (({ onRate, store, }: {
|
|
240
|
+
onRate?: (target: HTMLElement, how: "up" | "down") => Promise<boolean>;
|
|
241
|
+
store: StreamMessage;
|
|
242
|
+
}) => react.JSX.Element) & {
|
|
243
|
+
displayName: string;
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
type TBlockType = 'text' | 'describer';
|
|
247
|
+
type TBaseStreamBlock<T extends TBlockType = TBlockType> = {
|
|
248
|
+
blockType: T;
|
|
249
|
+
};
|
|
250
|
+
type TTextStreamBlock = TBaseStreamBlock<'text'> & {
|
|
251
|
+
str: string;
|
|
252
|
+
};
|
|
253
|
+
type TDescriberStreamBlock = TBaseStreamBlock<'describer'> & {
|
|
254
|
+
describer: TDescriberBlock;
|
|
255
|
+
};
|
|
256
|
+
type TStreamBlock = TTextStreamBlock | TDescriberStreamBlock;
|
|
257
|
+
declare const MessageBlocks: (({ streamParts }: {
|
|
258
|
+
streamParts: TStreamBlock[];
|
|
259
|
+
}) => (react.JSX.Element | react.JSX.Element[] | undefined)[]) & {
|
|
260
|
+
displayName: string;
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
type TDescriberBlock = {
|
|
264
|
+
type: string;
|
|
265
|
+
content: string;
|
|
266
|
+
};
|
|
267
|
+
declare class StreamMessage {
|
|
268
|
+
blocks: TStreamBlock[];
|
|
269
|
+
references: TReference[];
|
|
270
|
+
tables: Record<string, string>;
|
|
271
|
+
charts: Record<string, string>;
|
|
272
|
+
constructor();
|
|
273
|
+
addPart<T extends TStreamBlock>(part: T, afterAddPart?: (added: T) => void): void;
|
|
274
|
+
getLastBlock(): TStreamBlock;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
declare class CameraController {
|
|
278
|
+
state: {
|
|
279
|
+
videoStream: MediaStream | null;
|
|
280
|
+
isOpen: boolean;
|
|
281
|
+
};
|
|
282
|
+
private currentCapture;
|
|
283
|
+
private videoElement;
|
|
284
|
+
constructor();
|
|
285
|
+
openCamera(): Promise<void>;
|
|
286
|
+
closeCamera(): Promise<void>;
|
|
287
|
+
pop(): File | null;
|
|
288
|
+
Component: () => react.JSX.Element;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
type TMultipleChoiceMessageOption<OptionProps> = {
|
|
292
|
+
label: string;
|
|
293
|
+
url: string;
|
|
294
|
+
additionalProps?: OptionProps;
|
|
295
|
+
};
|
|
296
|
+
declare class MultipleChoiceMessage<OptionProps> extends ChatMessage {
|
|
297
|
+
constructor(question: string, options: TMultipleChoiceMessageOption<OptionProps>[], Renderer?: (props: {
|
|
298
|
+
item: TMultipleChoiceMessageOption<OptionProps>;
|
|
299
|
+
}) => ReactElement);
|
|
300
|
+
}
|
|
301
|
+
|
|
45
302
|
type TSearchListItem = {
|
|
46
303
|
content: string;
|
|
47
304
|
isExternal: boolean;
|
|
@@ -95,14 +352,20 @@ interface ISearchResultsController<P extends ProcessingUnit> {
|
|
|
95
352
|
Component: FC;
|
|
96
353
|
}
|
|
97
354
|
|
|
355
|
+
type StreamBlock = {
|
|
356
|
+
type: string;
|
|
357
|
+
description: string;
|
|
358
|
+
};
|
|
98
359
|
type ResponseStreamEvents = {
|
|
360
|
+
block: StreamBlock;
|
|
99
361
|
part: string;
|
|
100
|
-
block: {
|
|
101
|
-
type: string;
|
|
102
|
-
description: string;
|
|
103
|
-
};
|
|
104
362
|
};
|
|
105
|
-
|
|
363
|
+
type ResponseStreamBlock = {
|
|
364
|
+
type: string;
|
|
365
|
+
content: string;
|
|
366
|
+
id: string;
|
|
367
|
+
};
|
|
368
|
+
declare class ResponseStream<T extends ResponseStreamEvents = ResponseStreamEvents> extends EventEmitter<T> {
|
|
106
369
|
private buffer;
|
|
107
370
|
private isRunning;
|
|
108
371
|
private locked;
|
|
@@ -112,7 +375,7 @@ declare class ResponseStream extends EventEmitter<ResponseStreamEvents> {
|
|
|
112
375
|
private timing;
|
|
113
376
|
private waiting;
|
|
114
377
|
private calculatePartSize;
|
|
115
|
-
emit<K extends keyof
|
|
378
|
+
emit<K extends keyof T>(ev: K, data: T[K]): void;
|
|
116
379
|
run(): void;
|
|
117
380
|
}
|
|
118
381
|
|
|
@@ -202,16 +465,15 @@ declare function getImagesWithDescription({ multiple, }: {
|
|
|
202
465
|
multiple?: boolean;
|
|
203
466
|
}): Promise<TGenerateFromImage[]>;
|
|
204
467
|
|
|
205
|
-
type
|
|
206
|
-
|
|
207
|
-
url: string;
|
|
208
|
-
additionalProps?: OptionProps;
|
|
468
|
+
type PollerEvents = ResponseStreamEvents & {
|
|
469
|
+
close: null;
|
|
209
470
|
};
|
|
210
|
-
declare class
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
471
|
+
declare class StreamServicePoller {
|
|
472
|
+
closed: boolean;
|
|
473
|
+
stream: ResponseStream<PollerEvents>;
|
|
474
|
+
on<K extends keyof PollerEvents>(ev: K, cb: (ev: PollerEvents[K]) => unknown): _apia_util.UnSubscriber;
|
|
475
|
+
start(token: string): Promise<void>;
|
|
214
476
|
}
|
|
215
477
|
|
|
216
|
-
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 TSearchListItem, type TSearchMode, type ISemanticSearchViewController as ViewController, ViewRendererContext, getImageFromDisk, getImagesFromDisk, getImagesWithDescription };
|
|
478
|
+
export { Attachments, AutoscrollContainer, CameraController, ChatController, ChatMessage, type ChatProcessingUnit, type ClearHistoryCallback, DashboardsRoutinesGeneration, Ellipsis, FloatingChatController, Header, History, type IAttachment, type ISearchResultsController, type ISemanticSearchViewController, type ListingProcessingUnit, Message, MessageBlock, MessageBlocks, MessageBody, type MessageCallbackProps, type MessageSubmitCallback, MultipleChoiceMessage, type ProcessingUnit, ResponseStream, type ResponseStreamBlock, type ResponseStreamEvents, RoutinesGeneration, SearchController, SemanticSearchReference as SemanticSearchResult, type StreamBlock, StreamMessage, StreamServicePoller, type TBaseStreamBlock, type TBlockType, type TChatControllerState, type TComponentRender, type TDescriberBlock, type TDescriberStreamBlock, type TGenerateFromImage$1 as TGenerateFromImage, type TMessageType, type TMultipleChoiceMessageOption, type TPollRoutineResult, type TReference, type TResponseData, type TRoutineCompletion, type TSearchListItem, type TSearchMode, type TStreamBlock, type TTextStreamBlock, TextArea, type ISemanticSearchViewController as ViewController, ViewRendererContext, getImageFromDisk, getImagesFromDisk, getImagesWithDescription, rate };
|
|
217
479
|
//# sourceMappingURL=index.d.ts.map
|