@apia/ai 4.0.9 → 4.0.13
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 +1191 -280
- 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
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode, FC, ReactElement } from 'react';
|
|
3
|
+
import * as _apia_util from '@apia/util';
|
|
4
|
+
import { EventEmitter, AudioRecorder } from '@apia/util';
|
|
5
|
+
import { CollectorField } from '@apia/validations';
|
|
6
|
+
import { FilterDTO } from '@apia/components';
|
|
7
|
+
import { TActionDispatcher } from '@apia/dashboard-controller';
|
|
8
|
+
|
|
9
|
+
declare const AutoscrollContainer: ({ children }: {
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
}) => react.JSX.Element;
|
|
12
|
+
|
|
13
|
+
declare class ChatMessage {
|
|
14
|
+
message: ReactNode;
|
|
15
|
+
messageType: TMessageType;
|
|
16
|
+
attachments: IAttachment[];
|
|
17
|
+
reference: ReactNode;
|
|
18
|
+
id: number;
|
|
19
|
+
parseMessage(message: string): string;
|
|
20
|
+
constructor(message?: ReactNode, messageType?: TMessageType, attachments?: IAttachment[], reference?: ReactNode);
|
|
21
|
+
copy: () => ChatMessage;
|
|
22
|
+
Component: (() => react.JSX.Element) & {
|
|
23
|
+
displayName: string;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface IAttachment {
|
|
28
|
+
Component: (props?: any) => ReactNode;
|
|
29
|
+
getId: () => string;
|
|
30
|
+
}
|
|
31
|
+
type TChatControllerState = {
|
|
32
|
+
isLoading: boolean;
|
|
33
|
+
isRecording: boolean;
|
|
34
|
+
canRecord: boolean;
|
|
35
|
+
canAttach: boolean;
|
|
36
|
+
canAddSystemMessage: boolean;
|
|
37
|
+
canAddUserMessage: boolean;
|
|
38
|
+
hideDeleteButton: boolean;
|
|
39
|
+
maxAttachmentsSize: number;
|
|
40
|
+
messages: ChatMessage[];
|
|
41
|
+
attachments: IAttachment[];
|
|
42
|
+
currentMessage: string;
|
|
43
|
+
};
|
|
44
|
+
type MessageCallback = (props: {
|
|
45
|
+
message: ChatMessage;
|
|
46
|
+
attachments: IAttachment[];
|
|
47
|
+
}) => Promise<any>;
|
|
48
|
+
declare class ChatController2 {
|
|
49
|
+
private onMessageSubmit;
|
|
50
|
+
id: string;
|
|
51
|
+
state: TChatControllerState;
|
|
52
|
+
constructor(props: Partial<TChatControllerState>, onMessageSubmit: MessageCallback, id: string);
|
|
53
|
+
addMessage(message: ChatMessage): void;
|
|
54
|
+
protected Header: () => react.JSX.Element;
|
|
55
|
+
protected History: () => react.JSX.Element;
|
|
56
|
+
protected Attachments: () => react.JSX.Element;
|
|
57
|
+
protected TextArea: (() => react.JSX.Element) & {
|
|
58
|
+
displayName: string;
|
|
59
|
+
};
|
|
60
|
+
Renderer: (() => react.JSX.Element) & {
|
|
61
|
+
displayName: string;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
declare enum AIMessageRole {
|
|
66
|
+
USER = "USER",
|
|
67
|
+
SYSTEM = "SYSTEM"
|
|
68
|
+
}
|
|
69
|
+
interface Reactive {
|
|
70
|
+
Component: FC<any>;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
declare class AIContent extends CollectorField implements Reactive {
|
|
74
|
+
type: string;
|
|
75
|
+
content: ReactNode;
|
|
76
|
+
constructor(content?: ReactNode);
|
|
77
|
+
Component: () => react.JSX.Element;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
declare class AIMessageAttachments implements Reactive, IAttachment {
|
|
81
|
+
private close?;
|
|
82
|
+
role: AIMessageRole;
|
|
83
|
+
content: AIContent;
|
|
84
|
+
id: string;
|
|
85
|
+
customDescription: boolean;
|
|
86
|
+
constructor(role: AIMessageRole, content: AIContent, close?: (() => void) | undefined);
|
|
87
|
+
addDescription: () => Promise<void>;
|
|
88
|
+
getId(): string;
|
|
89
|
+
Component: (props: {
|
|
90
|
+
closeButton?: boolean;
|
|
91
|
+
canAddDescription?: boolean;
|
|
92
|
+
}) => react.JSX.Element;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
type TMessageType = 'user' | 'system' | 'warning' | 'error' | 'information' | 'response' | 'multipleChoice' | 'customMessage';
|
|
96
|
+
type ChatControllerState = {
|
|
97
|
+
current: ChatMessage;
|
|
98
|
+
messages: ChatMessage[];
|
|
99
|
+
};
|
|
100
|
+
declare class ChatController {
|
|
101
|
+
#private;
|
|
102
|
+
id: string;
|
|
103
|
+
state: ChatControllerState;
|
|
104
|
+
constructor(id: string, welcomeMessage?: string);
|
|
105
|
+
components: {
|
|
106
|
+
MessageHistory: (() => react.JSX.Element) & {
|
|
107
|
+
displayName: string;
|
|
108
|
+
};
|
|
109
|
+
Textarea: (({ hideDeleteButton, isLoading: outIsLoading, onSubmit, preventAppendUserMessages, }: {
|
|
110
|
+
hideDeleteButton?: boolean | undefined;
|
|
111
|
+
isLoading?: boolean | undefined;
|
|
112
|
+
onSubmit: (chatMessage: ChatMessage) => Promise<void>;
|
|
113
|
+
preventAppendUserMessages?: boolean | undefined;
|
|
114
|
+
}) => react.JSX.Element) & {
|
|
115
|
+
displayName: string;
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
currentHistoryIndex: number;
|
|
119
|
+
audioRecorder: {
|
|
120
|
+
start: () => Promise<void>;
|
|
121
|
+
stop: () => Promise<void>;
|
|
122
|
+
record: number;
|
|
123
|
+
state: _apia_util.AudioRecorderState;
|
|
124
|
+
};
|
|
125
|
+
history: {
|
|
126
|
+
add: (message: ChatMessage) => void;
|
|
127
|
+
next: () => void;
|
|
128
|
+
previous: () => void;
|
|
129
|
+
updateState: (message?: ChatMessage) => void;
|
|
130
|
+
size: () => number;
|
|
131
|
+
};
|
|
132
|
+
messages: {
|
|
133
|
+
add: (message: ChatMessage, idx?: number) => void;
|
|
134
|
+
clear: () => void;
|
|
135
|
+
};
|
|
136
|
+
attachments: {
|
|
137
|
+
add: (...aiMessage: AIMessageAttachments[]) => void;
|
|
138
|
+
dropAll: () => undefined;
|
|
139
|
+
drop: (el: AIMessageAttachments) => void;
|
|
140
|
+
getComponents: () => react.JSX.Element[];
|
|
141
|
+
get: () => IAttachment[];
|
|
142
|
+
size: () => number;
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
type TMultipleChoiceMessageOption<OptionProps> = {
|
|
147
|
+
label: string;
|
|
148
|
+
url: string;
|
|
149
|
+
additionalProps?: OptionProps;
|
|
150
|
+
};
|
|
151
|
+
declare class MultipleChoiceMessage<OptionProps> extends ChatMessage {
|
|
152
|
+
constructor(question: string, options: TMultipleChoiceMessageOption<OptionProps>[], Renderer?: (props: {
|
|
153
|
+
item: TMultipleChoiceMessageOption<OptionProps>;
|
|
154
|
+
}) => ReactElement);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
type TSearchResultState = {
|
|
158
|
+
title: string;
|
|
159
|
+
body: string;
|
|
160
|
+
link: string;
|
|
161
|
+
};
|
|
162
|
+
declare class SemanticSearchReference {
|
|
163
|
+
state: TSearchResultState;
|
|
164
|
+
constructor(props: TSearchResultState);
|
|
165
|
+
Component: () => react.JSX.Element;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* @class SearchController:
|
|
170
|
+
* - mobx Controller for the semantic search logic
|
|
171
|
+
* - search for a term and get the results. This controller must be used
|
|
172
|
+
* to maintain the state of the search string and of the results given a search string
|
|
173
|
+
*/
|
|
174
|
+
declare class SearchController {
|
|
175
|
+
static instance: SearchController;
|
|
176
|
+
state: {
|
|
177
|
+
queryString: string;
|
|
178
|
+
results: SemanticSearchReference[];
|
|
179
|
+
isLoading: boolean;
|
|
180
|
+
disabled: boolean;
|
|
181
|
+
};
|
|
182
|
+
protected constructor();
|
|
183
|
+
search(selectedId: string): Promise<void>;
|
|
184
|
+
protected setReferences(results: SemanticSearchReference[]): void;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
type TReference = {
|
|
188
|
+
title: string;
|
|
189
|
+
body: string;
|
|
190
|
+
link: string;
|
|
191
|
+
isExternal: boolean;
|
|
192
|
+
};
|
|
193
|
+
interface ProcessingUnit {
|
|
194
|
+
visualizationType: TSearchMode;
|
|
195
|
+
content: string;
|
|
196
|
+
references: TReference[];
|
|
197
|
+
isExternal: boolean;
|
|
198
|
+
}
|
|
199
|
+
interface ListingProcessingUnit extends ProcessingUnit {
|
|
200
|
+
visualizationType: 'list';
|
|
201
|
+
title: string;
|
|
202
|
+
link: string;
|
|
203
|
+
}
|
|
204
|
+
interface ChatProcessingUnit extends ProcessingUnit {
|
|
205
|
+
visualizationType: 'chat';
|
|
206
|
+
}
|
|
207
|
+
declare const ViewRendererContext: react.Context<ISemanticSearchViewController>;
|
|
208
|
+
type TSearchMode = 'list' | 'chat' | 'none';
|
|
209
|
+
interface ISemanticSearchViewController {
|
|
210
|
+
state: {
|
|
211
|
+
filters: Record<string, FilterDTO>;
|
|
212
|
+
filtersOpen: boolean;
|
|
213
|
+
isLoading: boolean;
|
|
214
|
+
mode: TSearchMode;
|
|
215
|
+
searchString: string;
|
|
216
|
+
};
|
|
217
|
+
ResultsRenderer: FC;
|
|
218
|
+
clearHistory(): Promise<void>;
|
|
219
|
+
search(str?: string): void;
|
|
220
|
+
toggleFiltersOpen(): void;
|
|
221
|
+
}
|
|
222
|
+
type TResponseData = {
|
|
223
|
+
result: string;
|
|
224
|
+
success: string;
|
|
225
|
+
failed?: boolean;
|
|
226
|
+
};
|
|
227
|
+
interface ISearchResultsController<P extends ProcessingUnit> {
|
|
228
|
+
state: {
|
|
229
|
+
results: P[];
|
|
230
|
+
};
|
|
231
|
+
beforeSearch(props?: object): void;
|
|
232
|
+
afterSearch(props?: object): void;
|
|
233
|
+
clear(): void;
|
|
234
|
+
processResults(qryString: string, results: ProcessingUnit[], responseData?: TResponseData): void;
|
|
235
|
+
Component: FC;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
declare class ResponseStream extends EventEmitter<{
|
|
239
|
+
part: string;
|
|
240
|
+
}> {
|
|
241
|
+
private buffer;
|
|
242
|
+
private isRunning;
|
|
243
|
+
private locked;
|
|
244
|
+
private maxCompletionTime;
|
|
245
|
+
private minPartSize;
|
|
246
|
+
private partSize;
|
|
247
|
+
private timing;
|
|
248
|
+
private waiting;
|
|
249
|
+
private calculatePartSize;
|
|
250
|
+
emit<K extends 'part'>(_: K, data: {
|
|
251
|
+
part: string;
|
|
252
|
+
}[K]): void;
|
|
253
|
+
run(): void;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
type RoutinesGenerationState = {
|
|
257
|
+
isLoading: boolean;
|
|
258
|
+
progress: number;
|
|
259
|
+
};
|
|
260
|
+
type TPollProgress = {
|
|
261
|
+
message: string;
|
|
262
|
+
progress: number;
|
|
263
|
+
debug: string;
|
|
264
|
+
streamPart?: string;
|
|
265
|
+
};
|
|
266
|
+
type TPollRoutineResult = {
|
|
267
|
+
status: string;
|
|
268
|
+
payload: unknown | TPollProgress;
|
|
269
|
+
};
|
|
270
|
+
type TGenerateFromImage$1 = {
|
|
271
|
+
base64: string;
|
|
272
|
+
description: string;
|
|
273
|
+
};
|
|
274
|
+
type TRoutineCompletion = Partial<{
|
|
275
|
+
images: TGenerateFromImage$1[];
|
|
276
|
+
parameters: Record<string, string>;
|
|
277
|
+
stream: ResponseStream;
|
|
278
|
+
}> & {
|
|
279
|
+
routineName: string;
|
|
280
|
+
};
|
|
281
|
+
declare class RoutinesGeneration {
|
|
282
|
+
audioRecorder: AudioRecorder;
|
|
283
|
+
private routineId;
|
|
284
|
+
state: RoutinesGenerationState;
|
|
285
|
+
constructor();
|
|
286
|
+
private checkCanGenerate;
|
|
287
|
+
pollRoutine<T>(routineId: string, stream?: ResponseStream): Promise<T | null>;
|
|
288
|
+
private internalPollRoutine;
|
|
289
|
+
protected callAudioTranscription(audio: Blob): ReturnType<RoutinesGeneration['callRoutineStart']>;
|
|
290
|
+
protected callRoutinePoll(routineId: string): Promise<TPollRoutineResult>;
|
|
291
|
+
protected callRoutineStart(routineName: string, parameters: Record<string, string>, images: TGenerateFromImage$1[]): Promise<{
|
|
292
|
+
orchestrator: {
|
|
293
|
+
routineId: string;
|
|
294
|
+
};
|
|
295
|
+
} | null>;
|
|
296
|
+
private executeRoutine;
|
|
297
|
+
private resetLoading;
|
|
298
|
+
completion<T>(params: TRoutineCompletion): Promise<T | null>;
|
|
299
|
+
stop(): void;
|
|
300
|
+
transcribeAudio(audio: Blob): Promise<{
|
|
301
|
+
transcription: string;
|
|
302
|
+
} | null>;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
declare class DashboardsRoutinesGeneration extends RoutinesGeneration {
|
|
306
|
+
protected dispatcher: TActionDispatcher;
|
|
307
|
+
constructor(dispatcher: TActionDispatcher);
|
|
308
|
+
private blobToBase64;
|
|
309
|
+
protected callAudioTranscription(audio: Blob): Promise<{
|
|
310
|
+
orchestrator: {
|
|
311
|
+
routineId: string;
|
|
312
|
+
};
|
|
313
|
+
} | null>;
|
|
314
|
+
protected callRoutinePoll(routineId: string): Promise<TPollRoutineResult>;
|
|
315
|
+
protected callRoutineStart(routineName: string, parameters: Record<string, string>, images: TGenerateFromImage$1[]): Promise<{
|
|
316
|
+
orchestrator: {
|
|
317
|
+
routineId: string;
|
|
318
|
+
};
|
|
319
|
+
} | null>;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
type RetrievedImage = {
|
|
323
|
+
base64: string;
|
|
324
|
+
path: string;
|
|
325
|
+
};
|
|
326
|
+
declare function getImageFromDisk(inputProps?: Partial<{
|
|
327
|
+
accept: string;
|
|
328
|
+
}>): Promise<RetrievedImage | null>;
|
|
329
|
+
declare function getImagesFromDisk(inputProps?: Partial<{
|
|
330
|
+
accept: string;
|
|
331
|
+
multiple: string;
|
|
332
|
+
}>): Promise<RetrievedImage[]>;
|
|
333
|
+
|
|
334
|
+
type TGenerateFromImage = {
|
|
335
|
+
base64: string;
|
|
336
|
+
description: string;
|
|
337
|
+
};
|
|
338
|
+
declare function getImagesWithDescription({ multiple, }: {
|
|
339
|
+
multiple?: boolean;
|
|
340
|
+
}): Promise<TGenerateFromImage[]>;
|
|
341
|
+
|
|
342
|
+
export { 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, getImageFromDisk, getImagesFromDisk, getImagesWithDescription };
|
|
343
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|