@apia/ai 3.0.12 → 4.0.0
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 +111 -29
- package/dist/index.js +783 -338
- package/dist/index.js.map +1 -1
- package/package.json +8 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,46 +1,100 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { ReactNode, ReactElement } from 'react';
|
|
3
|
-
import
|
|
2
|
+
import { ReactNode, FC, ReactElement } from 'react';
|
|
3
|
+
import * as _apia_util from '@apia/util';
|
|
4
|
+
import { EventEmitter, AudioRecorder } from '@apia/util';
|
|
5
|
+
import { ResponseStream as ResponseStream$1 } from '@apia/ai';
|
|
6
|
+
|
|
7
|
+
declare const AutoscrollContainer: ({ children }: {
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
}) => react.JSX.Element;
|
|
10
|
+
|
|
11
|
+
declare enum AIMessageRole {
|
|
12
|
+
USER = "USER",
|
|
13
|
+
SYSTEM = "SYSTEM"
|
|
14
|
+
}
|
|
15
|
+
interface Reactive {
|
|
16
|
+
Component: FC<any>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare class AIContent implements Reactive {
|
|
20
|
+
content: ReactNode;
|
|
21
|
+
constructor(content?: ReactNode);
|
|
22
|
+
Component: () => react.JSX.Element;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
declare class AIMessageAttachments implements Reactive {
|
|
26
|
+
private close?;
|
|
27
|
+
role: AIMessageRole;
|
|
28
|
+
content: AIContent;
|
|
29
|
+
id: string;
|
|
30
|
+
constructor(role: AIMessageRole, content: AIContent, close?: (() => void) | undefined);
|
|
31
|
+
addDescription: () => Promise<void>;
|
|
32
|
+
Component: (props: {
|
|
33
|
+
closeButton?: boolean;
|
|
34
|
+
canAddDescription?: boolean;
|
|
35
|
+
}) => react.JSX.Element;
|
|
36
|
+
}
|
|
4
37
|
|
|
5
38
|
declare class ChatMessage {
|
|
6
|
-
|
|
39
|
+
message: ReactNode;
|
|
7
40
|
messageType: TMessageType;
|
|
41
|
+
attachments: AIMessageAttachments[];
|
|
8
42
|
id: number;
|
|
9
43
|
parseMessage(message: string): string;
|
|
10
|
-
constructor(message
|
|
11
|
-
|
|
44
|
+
constructor(message?: ReactNode, messageType?: TMessageType, attachments?: AIMessageAttachments[]);
|
|
45
|
+
copy: () => ChatMessage;
|
|
46
|
+
Component: () => react.JSX.Element;
|
|
12
47
|
}
|
|
13
48
|
|
|
14
|
-
type TMessageType = 'user' | 'system' | 'warning' | 'error' | 'information' | 'response' | 'multipleChoice';
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
49
|
+
type TMessageType = 'user' | 'system' | 'warning' | 'error' | 'information' | 'response' | 'multipleChoice' | 'customMessage';
|
|
50
|
+
type ChatControllerState = {
|
|
51
|
+
current: ChatMessage;
|
|
52
|
+
messages: ChatMessage[];
|
|
53
|
+
};
|
|
54
|
+
declare class ChatController {
|
|
19
55
|
#private;
|
|
20
56
|
id: string;
|
|
57
|
+
state: ChatControllerState;
|
|
21
58
|
constructor(id: string, welcomeMessage?: string);
|
|
22
59
|
components: {
|
|
23
|
-
MessageHistory: () => react.JSX.Element
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
60
|
+
MessageHistory: (() => react.JSX.Element) & {
|
|
61
|
+
displayName: string;
|
|
62
|
+
};
|
|
63
|
+
Textarea: (({ hideDeleteButton, isLoading: outIsLoading, onSubmit, preventAppendUserMessages, }: {
|
|
64
|
+
hideDeleteButton?: boolean | undefined;
|
|
65
|
+
isLoading?: boolean | undefined;
|
|
66
|
+
onSubmit: (chatMessage: ChatMessage) => Promise<void>;
|
|
67
|
+
preventAppendUserMessages?: boolean | undefined;
|
|
68
|
+
}) => react.JSX.Element) & {
|
|
31
69
|
displayName: string;
|
|
32
70
|
};
|
|
33
71
|
};
|
|
72
|
+
currentHistoryIndex: number;
|
|
73
|
+
audioRecorder: {
|
|
74
|
+
start: () => Promise<void>;
|
|
75
|
+
stop: () => Promise<void>;
|
|
76
|
+
record: number;
|
|
77
|
+
state: _apia_util.AudioRecorderState;
|
|
78
|
+
};
|
|
34
79
|
history: {
|
|
35
|
-
add: (
|
|
36
|
-
next: () =>
|
|
37
|
-
previous: () =>
|
|
38
|
-
|
|
80
|
+
add: (message: ChatMessage) => void;
|
|
81
|
+
next: () => void;
|
|
82
|
+
previous: () => void;
|
|
83
|
+
updateState: (message?: ChatMessage) => void;
|
|
84
|
+
size: () => number;
|
|
39
85
|
};
|
|
40
86
|
messages: {
|
|
41
87
|
add: (message: ChatMessage, idx?: number) => void;
|
|
42
88
|
clear: () => void;
|
|
43
89
|
};
|
|
90
|
+
attachments: {
|
|
91
|
+
add: (...aiMessage: AIMessageAttachments[]) => void;
|
|
92
|
+
dropAll: () => undefined;
|
|
93
|
+
drop: (el: AIMessageAttachments) => void;
|
|
94
|
+
getComponents: () => react.JSX.Element[];
|
|
95
|
+
get: () => AIMessageAttachments[];
|
|
96
|
+
size: () => number;
|
|
97
|
+
};
|
|
44
98
|
}
|
|
45
99
|
|
|
46
100
|
type TMultipleChoiceMessageOption<OptionProps> = {
|
|
@@ -49,13 +103,9 @@ type TMultipleChoiceMessageOption<OptionProps> = {
|
|
|
49
103
|
additionalProps?: OptionProps;
|
|
50
104
|
};
|
|
51
105
|
declare class MultipleChoiceMessage<OptionProps> extends ChatMessage {
|
|
52
|
-
|
|
53
|
-
private options;
|
|
54
|
-
private Renderer?;
|
|
55
|
-
constructor(question: string, options: TMultipleChoiceMessageOption<OptionProps>[], Renderer?: ((props: {
|
|
106
|
+
constructor(question: string, options: TMultipleChoiceMessageOption<OptionProps>[], Renderer?: (props: {
|
|
56
107
|
item: TMultipleChoiceMessageOption<OptionProps>;
|
|
57
|
-
}) => ReactElement)
|
|
58
|
-
get message(): react.JSX.Element;
|
|
108
|
+
}) => ReactElement);
|
|
59
109
|
}
|
|
60
110
|
|
|
61
111
|
declare class ResponseStream extends EventEmitter<{
|
|
@@ -74,5 +124,37 @@ declare class ResponseStream extends EventEmitter<{
|
|
|
74
124
|
run(): void;
|
|
75
125
|
}
|
|
76
126
|
|
|
77
|
-
|
|
127
|
+
type RoutinesGenerationState = {
|
|
128
|
+
isLoading: boolean;
|
|
129
|
+
progress: number;
|
|
130
|
+
};
|
|
131
|
+
type TGenerateFromImage = {
|
|
132
|
+
base64: string;
|
|
133
|
+
description: string;
|
|
134
|
+
};
|
|
135
|
+
type TRoutineCompletion = Partial<{
|
|
136
|
+
images: TGenerateFromImage[];
|
|
137
|
+
parameters: Record<string, string>;
|
|
138
|
+
stream: ResponseStream$1;
|
|
139
|
+
}> & {
|
|
140
|
+
routineName: string;
|
|
141
|
+
};
|
|
142
|
+
declare class RoutinesGeneration {
|
|
143
|
+
audioRecorder: AudioRecorder;
|
|
144
|
+
private routineId;
|
|
145
|
+
state: RoutinesGenerationState;
|
|
146
|
+
constructor();
|
|
147
|
+
private checkCanGenerate;
|
|
148
|
+
private pollRoutine;
|
|
149
|
+
private executeRoutine;
|
|
150
|
+
private poll;
|
|
151
|
+
private resetLoading;
|
|
152
|
+
completion<T>(params: TRoutineCompletion): Promise<T | null>;
|
|
153
|
+
stop(): void;
|
|
154
|
+
transcribeAudio(audio: Blob): Promise<{
|
|
155
|
+
transcription: string;
|
|
156
|
+
} | null>;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export { AIMessageAttachments, AutoscrollContainer, ChatController, ChatMessage, MultipleChoiceMessage, ResponseStream, RoutinesGeneration, type TGenerateFromImage, type TMessageType, type TMultipleChoiceMessageOption, type TRoutineCompletion };
|
|
78
160
|
//# sourceMappingURL=index.d.ts.map
|