@apia/ai 5.0.0 → 5.0.1
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/chat/AutoscrollContainer.d.ts +12 -0
- package/dist/chat/AutoscrollContainer.d.ts.map +1 -0
- package/dist/chat/AutoscrollContainer.js +150 -0
- package/dist/chat/AutoscrollContainer.js.map +1 -0
- package/dist/chat/ChatController/CameraController.d.ts +18 -0
- package/dist/chat/ChatController/CameraController.d.ts.map +1 -0
- package/dist/chat/ChatController/CameraController.js +99 -0
- package/dist/chat/ChatController/CameraController.js.map +1 -0
- package/dist/chat/ChatController/ChatController.d.ts +58 -0
- package/dist/chat/ChatController/ChatController.d.ts.map +1 -0
- package/dist/chat/ChatController/ChatController.js +320 -0
- package/dist/chat/ChatController/ChatController.js.map +1 -0
- package/dist/chat/ChatController/StreamMessage.d.ts +39 -0
- package/dist/chat/ChatController/StreamMessage.d.ts.map +1 -0
- package/dist/chat/ChatController/StreamMessage.js +84 -0
- package/dist/chat/ChatController/StreamMessage.js.map +1 -0
- package/dist/chat/ChatController/components/Attachments.d.ts +14 -0
- package/dist/chat/ChatController/components/Attachments.d.ts.map +1 -0
- package/dist/chat/ChatController/components/Attachments.js +35 -0
- package/dist/chat/ChatController/components/Attachments.js.map +1 -0
- package/dist/chat/ChatController/components/ChatMessage.d.ts +28 -0
- package/dist/chat/ChatController/components/ChatMessage.d.ts.map +1 -0
- package/dist/chat/ChatController/components/ChatMessage.js +74 -0
- package/dist/chat/ChatController/components/ChatMessage.js.map +1 -0
- package/dist/chat/ChatController/components/Ellipsis.d.ts +6 -0
- package/dist/chat/ChatController/components/Ellipsis.d.ts.map +1 -0
- package/dist/chat/ChatController/components/Ellipsis.js +23 -0
- package/dist/chat/ChatController/components/Ellipsis.js.map +1 -0
- package/dist/chat/ChatController/components/FileAttachment.js +76 -0
- package/dist/chat/ChatController/components/FileAttachment.js.map +1 -0
- package/dist/chat/ChatController/components/Header.d.ts +11 -0
- package/dist/chat/ChatController/components/Header.d.ts.map +1 -0
- package/dist/chat/ChatController/components/Header.js +12 -0
- package/dist/chat/ChatController/components/Header.js.map +1 -0
- package/dist/chat/ChatController/components/History.d.ts +12 -0
- package/dist/chat/ChatController/components/History.d.ts.map +1 -0
- package/dist/chat/ChatController/components/History.js +47 -0
- package/dist/chat/ChatController/components/History.js.map +1 -0
- package/dist/chat/ChatController/components/Message.d.ts +17 -0
- package/dist/chat/ChatController/components/Message.d.ts.map +1 -0
- package/dist/chat/ChatController/components/Message.js +38 -0
- package/dist/chat/ChatController/components/Message.js.map +1 -0
- package/dist/chat/ChatController/components/MessageBlock.d.ts +9 -0
- package/dist/chat/ChatController/components/MessageBlock.d.ts.map +1 -0
- package/dist/chat/ChatController/components/MessageBlock.js +16 -0
- package/dist/chat/ChatController/components/MessageBlock.js.map +1 -0
- package/dist/chat/ChatController/components/MessageBlocks.d.ts +26 -0
- package/dist/chat/ChatController/components/MessageBlocks.d.ts.map +1 -0
- package/dist/chat/ChatController/components/MessageBlocks.js +87 -0
- package/dist/chat/ChatController/components/MessageBlocks.js.map +1 -0
- package/dist/chat/ChatController/components/MessageBody.d.ts +12 -0
- package/dist/chat/ChatController/components/MessageBody.d.ts.map +1 -0
- package/dist/chat/ChatController/components/MessageBody.js +78 -0
- package/dist/chat/ChatController/components/MessageBody.js.map +1 -0
- package/dist/chat/ChatController/components/QuestionAnswerMessage.d.ts +12 -0
- package/dist/chat/ChatController/components/QuestionAnswerMessage.d.ts.map +1 -0
- package/dist/chat/ChatController/components/QuestionAnswerMessage.js +21 -0
- package/dist/chat/ChatController/components/QuestionAnswerMessage.js.map +1 -0
- package/dist/chat/ChatController/components/QuestionBlocks.d.ts +11 -0
- package/dist/chat/ChatController/components/QuestionBlocks.d.ts.map +1 -0
- package/dist/chat/ChatController/components/QuestionBlocks.js +24 -0
- package/dist/chat/ChatController/components/QuestionBlocks.js.map +1 -0
- package/dist/chat/ChatController/components/TextArea.d.ts +39 -0
- package/dist/chat/ChatController/components/TextArea.d.ts.map +1 -0
- package/dist/chat/ChatController/components/TextArea.js +377 -0
- package/dist/chat/ChatController/components/TextArea.js.map +1 -0
- package/dist/chat/ChatController/components/ThinkingBlocks.d.ts +17 -0
- package/dist/chat/ChatController/components/ThinkingBlocks.d.ts.map +1 -0
- package/dist/chat/ChatController/components/ThinkingBlocks.js +259 -0
- package/dist/chat/ChatController/components/ThinkingBlocks.js.map +1 -0
- package/dist/chat/ChatController/components/rate.d.ts +4 -0
- package/dist/chat/ChatController/components/rate.d.ts.map +1 -0
- package/dist/chat/ChatController/components/rate.js +68 -0
- package/dist/chat/ChatController/components/rate.js.map +1 -0
- package/dist/chat/ChatController/types.d.ts +39 -0
- package/dist/chat/ChatController/types.d.ts.map +1 -0
- package/dist/chat/ChatController/util.js +22 -0
- package/dist/chat/ChatController/util.js.map +1 -0
- package/dist/chat/FloatingChatController.d.ts +35 -0
- package/dist/chat/FloatingChatController.d.ts.map +1 -0
- package/dist/chat/FloatingChatController.js +81 -0
- package/dist/chat/FloatingChatController.js.map +1 -0
- package/dist/components/chat/messages/MultipleChoiceMessage.d.ts +17 -0
- package/dist/components/chat/messages/MultipleChoiceMessage.d.ts.map +1 -0
- package/dist/components/chat/messages/MultipleChoiceMessage.js +31 -0
- package/dist/components/chat/messages/MultipleChoiceMessage.js.map +1 -0
- package/dist/components/documents/ImageBinaryField/getImage.d.ts +14 -0
- package/dist/components/documents/ImageBinaryField/getImage.d.ts.map +1 -0
- package/dist/components/documents/ImageBinaryField/getImage.js +47 -0
- package/dist/components/documents/ImageBinaryField/getImage.js.map +1 -0
- package/dist/components/documents/ImageBinaryField/getImageSrcString.js +6 -0
- package/dist/components/documents/ImageBinaryField/getImageSrcString.js.map +1 -0
- package/dist/components/documents/UploadModal/ImageIcon.js +18 -0
- package/dist/components/documents/UploadModal/ImageIcon.js.map +1 -0
- package/dist/components/documents/UploadModal/getImagesWithDescription.d.ts +10 -0
- package/dist/components/documents/UploadModal/getImagesWithDescription.d.ts.map +1 -0
- package/dist/components/documents/UploadModal/getImagesWithDescription.js +148 -0
- package/dist/components/documents/UploadModal/getImagesWithDescription.js.map +1 -0
- package/dist/index.d.ts +30 -483
- package/dist/index.js +29 -1824
- package/dist/index.js.map +1 -1
- package/dist/routines/DashboardRoutinesGeneration.d.ts +22 -0
- package/dist/routines/DashboardRoutinesGeneration.d.ts.map +1 -0
- package/dist/routines/DashboardRoutinesGeneration.js +54 -0
- package/dist/routines/DashboardRoutinesGeneration.js.map +1 -0
- package/dist/routines/RoutinesGeneration.d.ts +54 -0
- package/dist/routines/RoutinesGeneration.d.ts.map +1 -0
- package/dist/routines/RoutinesGeneration.js +174 -0
- package/dist/routines/RoutinesGeneration.js.map +1 -0
- package/dist/semanticSearch/SearchController/index.d.ts +23 -0
- package/dist/semanticSearch/SearchController/index.d.ts.map +1 -0
- package/dist/semanticSearch/SearchController/index.js +56 -0
- package/dist/semanticSearch/SearchController/index.js.map +1 -0
- package/dist/semanticSearch/SearchController/objects/SemanticSearchReference/Component.js +15 -0
- package/dist/semanticSearch/SearchController/objects/SemanticSearchReference/Component.js.map +1 -0
- package/dist/semanticSearch/SearchController/objects/SemanticSearchReference/index.d.ts +15 -0
- package/dist/semanticSearch/SearchController/objects/SemanticSearchReference/index.d.ts.map +1 -0
- package/dist/semanticSearch/SearchController/objects/SemanticSearchReference/index.js +25 -0
- package/dist/semanticSearch/SearchController/objects/SemanticSearchReference/index.js.map +1 -0
- package/dist/semanticSearch/ViewController/types.d.ts +62 -0
- package/dist/semanticSearch/ViewController/types.d.ts.map +1 -0
- package/dist/semanticSearch/ViewController/types.js +8 -0
- package/dist/semanticSearch/ViewController/types.js.map +1 -0
- package/dist/stream/ResponseStream.d.ts +55 -0
- package/dist/stream/ResponseStream.d.ts.map +1 -0
- package/dist/stream/ResponseStream.js +214 -0
- package/dist/stream/ResponseStream.js.map +1 -0
- package/dist/stream/StreamServicePoller.d.ts +16 -0
- package/dist/stream/StreamServicePoller.d.ts.map +1 -0
- package/dist/stream/StreamServicePoller.js +52 -0
- package/dist/stream/StreamServicePoller.js.map +1 -0
- package/package.json +10 -9
package/dist/index.js
CHANGED
|
@@ -1,1825 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
__publicField$a(this, "state", { title: "", body: "", link: "" });
|
|
31
|
-
__publicField$a(this, "Component", () => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
32
|
-
"(",
|
|
33
|
-
/* @__PURE__ */ jsx(Component, { instance: this }),
|
|
34
|
-
")"
|
|
35
|
-
] }));
|
|
36
|
-
this.state = props;
|
|
37
|
-
makeObservable(this, { state: observable });
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
var __defProp$9 = Object.defineProperty;
|
|
42
|
-
var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
43
|
-
var __publicField$9 = (obj, key, value) => {
|
|
44
|
-
__defNormalProp$9(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
45
|
-
return value;
|
|
46
|
-
};
|
|
47
|
-
const _SearchController = class _SearchController {
|
|
48
|
-
constructor() {
|
|
49
|
-
__publicField$9(this, "state", { queryString: "", results: [], isLoading: false, disabled: false });
|
|
50
|
-
makeObservable(this, { state: observable });
|
|
51
|
-
}
|
|
52
|
-
async search(selectedId) {
|
|
53
|
-
const filters = await FiltersStore.getFiltersById(
|
|
54
|
-
Number.parseInt(selectedId)
|
|
55
|
-
);
|
|
56
|
-
FiltersStore.setFilters(filters, "U");
|
|
57
|
-
_SearchController.instance.state.isLoading = true;
|
|
58
|
-
const response = await ApiaApi.post(
|
|
59
|
-
makeApiaUrl({
|
|
60
|
-
action: "search",
|
|
61
|
-
semSearchId: selectedId
|
|
62
|
-
}),
|
|
63
|
-
{
|
|
64
|
-
postData: {
|
|
65
|
-
q: _SearchController.instance.state.queryString,
|
|
66
|
-
filters: JSON.stringify(FiltersStore.getFiltersAsFilterValue("U"))
|
|
67
|
-
},
|
|
68
|
-
postDataTreatement: "stringify",
|
|
69
|
-
stringifyOptions: { arrayFormat: "repeat" }
|
|
70
|
-
}
|
|
71
|
-
);
|
|
72
|
-
if (response?.data?.results) {
|
|
73
|
-
this.setReferences(response.data.results);
|
|
74
|
-
}
|
|
75
|
-
this.state.isLoading = false;
|
|
76
|
-
}
|
|
77
|
-
setReferences(results) {
|
|
78
|
-
if (typeof results === "string" && results) {
|
|
79
|
-
results = JSON.parse(results);
|
|
80
|
-
}
|
|
81
|
-
_SearchController.instance.state.results = results.map(
|
|
82
|
-
(x) => x instanceof SemanticSearchReference ? x : new SemanticSearchReference(x)
|
|
83
|
-
);
|
|
84
|
-
_SearchController.instance.state.disabled = false;
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
__publicField$9(_SearchController, "instance", new _SearchController());
|
|
88
|
-
let SearchController = _SearchController;
|
|
89
|
-
|
|
90
|
-
const AutoscrollContainer = ({ children, threshold = 150, className }) => {
|
|
91
|
-
const wrapperRef = useRef(null);
|
|
92
|
-
const autoScrollEnabled = useRef(true);
|
|
93
|
-
useEffect(() => {
|
|
94
|
-
const wrapper = wrapperRef.current;
|
|
95
|
-
if (!wrapper)
|
|
96
|
-
return;
|
|
97
|
-
const scrollEl = findScrollContainer(wrapper);
|
|
98
|
-
const isNearBottom = () => scrollEl.scrollHeight - (scrollEl.scrollTop + scrollEl.clientHeight) <= threshold;
|
|
99
|
-
const onWheel = (e) => {
|
|
100
|
-
if (e.deltaY < 0) {
|
|
101
|
-
autoScrollEnabled.current = false;
|
|
102
|
-
} else if (e.deltaY > 0 && isNearBottom()) {
|
|
103
|
-
autoScrollEnabled.current = true;
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
const onScroll = () => {
|
|
107
|
-
if (isNearBottom()) {
|
|
108
|
-
autoScrollEnabled.current = true;
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
function enable() {
|
|
112
|
-
autoScrollEnabled.current = true;
|
|
113
|
-
}
|
|
114
|
-
scrollEl.addEventListener("wheel", onWheel, { passive: true });
|
|
115
|
-
scrollEl.addEventListener("scroll", onScroll, { passive: true });
|
|
116
|
-
document.addEventListener("enableAutoScroll", enable);
|
|
117
|
-
scrollEl.scrollTo({ top: scrollEl.scrollHeight, behavior: "smooth" });
|
|
118
|
-
const mo = new MutationObserver(() => {
|
|
119
|
-
if (autoScrollEnabled.current) {
|
|
120
|
-
scrollEl.scrollTo({ top: scrollEl.scrollHeight, behavior: "smooth" });
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
mo.observe(wrapper, { childList: true, subtree: true });
|
|
124
|
-
return () => {
|
|
125
|
-
scrollEl.removeEventListener("wheel", onWheel);
|
|
126
|
-
scrollEl.removeEventListener("enableAutoScroll", enable);
|
|
127
|
-
scrollEl.removeEventListener("scroll", onScroll);
|
|
128
|
-
mo.disconnect();
|
|
129
|
-
};
|
|
130
|
-
}, [threshold]);
|
|
131
|
-
return /* @__PURE__ */ jsx("div", { ref: wrapperRef, className: `${className || ""} autoscrollContainer`, children });
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
var __defProp$8 = Object.defineProperty;
|
|
135
|
-
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
136
|
-
var __publicField$8 = (obj, key, value) => {
|
|
137
|
-
__defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
138
|
-
return value;
|
|
139
|
-
};
|
|
140
|
-
let maxId = 0;
|
|
141
|
-
class ChatMessage {
|
|
142
|
-
constructor(message = "", messageType = "user", attachments = [], reference = null) {
|
|
143
|
-
__publicField$8(this, "id");
|
|
144
|
-
__publicField$8(this, "state");
|
|
145
|
-
__publicField$8(this, "clone", () => new ChatMessage(
|
|
146
|
-
this.message,
|
|
147
|
-
this.messageType,
|
|
148
|
-
this.attachments.map((x) => {
|
|
149
|
-
return { ...x };
|
|
150
|
-
}),
|
|
151
|
-
this.reference
|
|
152
|
-
));
|
|
153
|
-
this.state = { message, messageType, attachments, reference };
|
|
154
|
-
this.id = maxId++;
|
|
155
|
-
if (messageType === "response")
|
|
156
|
-
this.messageType = "system";
|
|
157
|
-
if (typeof message === "string")
|
|
158
|
-
this.message = message;
|
|
159
|
-
makeObservable(this, {
|
|
160
|
-
state: observable
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
get message() {
|
|
164
|
-
return this.state.message;
|
|
165
|
-
}
|
|
166
|
-
get messageType() {
|
|
167
|
-
return this.state.messageType;
|
|
168
|
-
}
|
|
169
|
-
get attachments() {
|
|
170
|
-
return this.state.attachments;
|
|
171
|
-
}
|
|
172
|
-
get reference() {
|
|
173
|
-
return this.state.reference;
|
|
174
|
-
}
|
|
175
|
-
set message(value) {
|
|
176
|
-
this.state.message = value;
|
|
177
|
-
}
|
|
178
|
-
set messageType(value) {
|
|
179
|
-
this.state.messageType = value;
|
|
180
|
-
}
|
|
181
|
-
set attachments(value) {
|
|
182
|
-
this.state.attachments = value;
|
|
183
|
-
}
|
|
184
|
-
set reference(value) {
|
|
185
|
-
this.state.reference = value;
|
|
186
|
-
}
|
|
187
|
-
removeAttachment(attachment) {
|
|
188
|
-
this.attachments = this.attachments.filter(
|
|
189
|
-
(current) => current !== attachment
|
|
190
|
-
);
|
|
191
|
-
}
|
|
192
|
-
addAttachmentDescription(attachment, description) {
|
|
193
|
-
const a = this.attachments.find((current) => current === attachment);
|
|
194
|
-
if (a) {
|
|
195
|
-
a.description = description;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
setMessageType(type) {
|
|
199
|
-
this.messageType = type;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
const FileAttachment = observer(
|
|
204
|
-
({
|
|
205
|
-
attachment,
|
|
206
|
-
onAddDescription,
|
|
207
|
-
onRemove
|
|
208
|
-
}) => {
|
|
209
|
-
const { ref } = ApiaUtil.instance.tooltips.useHover({
|
|
210
|
-
preferredOrientationX: "left",
|
|
211
|
-
preferredOrientationY: "top",
|
|
212
|
-
minSize: {
|
|
213
|
-
width: 200,
|
|
214
|
-
height: 400
|
|
215
|
-
},
|
|
216
|
-
attachToMousePosition: true,
|
|
217
|
-
closeOnMouseLeaveAttachedElement: true,
|
|
218
|
-
children: /* @__PURE__ */ jsxs(
|
|
219
|
-
Box,
|
|
220
|
-
{
|
|
221
|
-
sx: {
|
|
222
|
-
display: "flex",
|
|
223
|
-
alignItems: "center",
|
|
224
|
-
flexDirection: "column"
|
|
225
|
-
},
|
|
226
|
-
children: [
|
|
227
|
-
/* @__PURE__ */ jsx("h1", { children: attachment.name }),
|
|
228
|
-
/* @__PURE__ */ jsx("img", { src: attachment.base64 }),
|
|
229
|
-
attachment.description && /* @__PURE__ */ jsx(Label, { children: attachment.description })
|
|
230
|
-
]
|
|
231
|
-
}
|
|
232
|
-
)
|
|
233
|
-
});
|
|
234
|
-
return /* @__PURE__ */ jsx(
|
|
235
|
-
FileCard,
|
|
236
|
-
{
|
|
237
|
-
ref,
|
|
238
|
-
name: attachment.name,
|
|
239
|
-
handleClose: onRemove,
|
|
240
|
-
additionalButtons: onAddDescription ? [
|
|
241
|
-
{
|
|
242
|
-
icon: "Pencil",
|
|
243
|
-
onClick: () => {
|
|
244
|
-
const collector = new Collector();
|
|
245
|
-
collector.add(
|
|
246
|
-
new collector.fields.textarea(
|
|
247
|
-
"desc",
|
|
248
|
-
getLabel("lblDes").text,
|
|
249
|
-
{ initialValue: attachment.description }
|
|
250
|
-
)
|
|
251
|
-
);
|
|
252
|
-
collector.show({
|
|
253
|
-
onConfirm: (ev) => {
|
|
254
|
-
if (ev) {
|
|
255
|
-
onAddDescription(attachment, ev.desc);
|
|
256
|
-
}
|
|
257
|
-
return true;
|
|
258
|
-
},
|
|
259
|
-
title: getLabel("btnAddComment").text
|
|
260
|
-
});
|
|
261
|
-
},
|
|
262
|
-
variant: "icon-only"
|
|
263
|
-
}
|
|
264
|
-
] : []
|
|
265
|
-
}
|
|
266
|
-
);
|
|
267
|
-
}
|
|
268
|
-
);
|
|
269
|
-
|
|
270
|
-
const Attachments = observer(
|
|
271
|
-
({
|
|
272
|
-
attachments,
|
|
273
|
-
onRemove,
|
|
274
|
-
onAddDescription,
|
|
275
|
-
className
|
|
276
|
-
}) => {
|
|
277
|
-
if (!attachments.length)
|
|
278
|
-
return null;
|
|
279
|
-
return /* @__PURE__ */ jsx(
|
|
280
|
-
Box,
|
|
281
|
-
{
|
|
282
|
-
className: `attachments ${className}`,
|
|
283
|
-
...getVariant("layout.common.chat.attachments"),
|
|
284
|
-
children: attachments.map((x) => /* @__PURE__ */ jsx(
|
|
285
|
-
FileAttachment,
|
|
286
|
-
{
|
|
287
|
-
attachment: x,
|
|
288
|
-
onRemove: onRemove ? () => onRemove(x) : void 0,
|
|
289
|
-
onAddDescription
|
|
290
|
-
},
|
|
291
|
-
x.id
|
|
292
|
-
))
|
|
293
|
-
}
|
|
294
|
-
);
|
|
295
|
-
}
|
|
296
|
-
);
|
|
297
|
-
|
|
298
|
-
const MessageBlock = memo(
|
|
299
|
-
({ componentData }) => {
|
|
300
|
-
if (typeof componentData.args === "string") {
|
|
301
|
-
componentData.args = JSON.parse(componentData.args);
|
|
302
|
-
}
|
|
303
|
-
const Component = importComponent(componentData.path);
|
|
304
|
-
return /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(Component, { ...componentData.args }) });
|
|
305
|
-
}
|
|
306
|
-
);
|
|
307
|
-
|
|
308
|
-
const MessageBlocks = observer(
|
|
309
|
-
({ streamParts }) => {
|
|
310
|
-
const parts = streamParts.map((p, i) => {
|
|
311
|
-
if (p.blockType === "describer") {
|
|
312
|
-
return /* @__PURE__ */ jsx(
|
|
313
|
-
Box,
|
|
314
|
-
{
|
|
315
|
-
variant: "layout.common.ai.semanticSearch.execution.streamBlocks",
|
|
316
|
-
className: "sem_search__stream_blocks",
|
|
317
|
-
as: "ul",
|
|
318
|
-
children: /* @__PURE__ */ jsx(
|
|
319
|
-
Box,
|
|
320
|
-
{
|
|
321
|
-
variant: "layout.common.ai.semanticSearch.execution.streamBlocks",
|
|
322
|
-
as: "li",
|
|
323
|
-
className: `sem_search__stream_block ${p.describer.type}`,
|
|
324
|
-
children: p.describer.content
|
|
325
|
-
},
|
|
326
|
-
i
|
|
327
|
-
)
|
|
328
|
-
}
|
|
329
|
-
);
|
|
330
|
-
} else if (p.blockType === "text") {
|
|
331
|
-
return p.str.split(/(!!\[[^]+])/g).map((c) => {
|
|
332
|
-
if (c.match(/^!!\[[^]+]$/)) {
|
|
333
|
-
const definition = JSON.parse(
|
|
334
|
-
decodeBase64ToUtf8(
|
|
335
|
-
(c.match(/^!!\[([^]+)]$/) ?? [void 0, void 0])[1] ?? ""
|
|
336
|
-
)
|
|
337
|
-
);
|
|
338
|
-
return /* @__PURE__ */ jsx(MessageBlock, { componentData: definition }, i);
|
|
339
|
-
} else {
|
|
340
|
-
return /* @__PURE__ */ jsx(MDRenderer, { str: c }, i);
|
|
341
|
-
}
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
});
|
|
345
|
-
return parts;
|
|
346
|
-
}
|
|
347
|
-
);
|
|
348
|
-
|
|
349
|
-
const Message = observer(
|
|
350
|
-
({
|
|
351
|
-
className,
|
|
352
|
-
type,
|
|
353
|
-
id,
|
|
354
|
-
message,
|
|
355
|
-
attachments,
|
|
356
|
-
reference
|
|
357
|
-
}) => {
|
|
358
|
-
return /* @__PURE__ */ jsxs(
|
|
359
|
-
Box,
|
|
360
|
-
{
|
|
361
|
-
as: "pre",
|
|
362
|
-
className: `history_message ${className || ""} ${type}`,
|
|
363
|
-
children: [
|
|
364
|
-
/* @__PURE__ */ jsx(
|
|
365
|
-
Box,
|
|
366
|
-
{
|
|
367
|
-
className: "history_message__content",
|
|
368
|
-
...typeof message === "string" ? {
|
|
369
|
-
children: /* @__PURE__ */ jsx(
|
|
370
|
-
MessageBlocks,
|
|
371
|
-
{
|
|
372
|
-
streamParts: [{ blockType: "text", str: message }]
|
|
373
|
-
}
|
|
374
|
-
)
|
|
375
|
-
} : { children: message }
|
|
376
|
-
}
|
|
377
|
-
),
|
|
378
|
-
attachments.length > 0 && /* @__PURE__ */ jsx(Attachments, { attachments }),
|
|
379
|
-
reference && /* @__PURE__ */ jsx(Box, { className: "history_message__references", children: reference })
|
|
380
|
-
]
|
|
381
|
-
},
|
|
382
|
-
id
|
|
383
|
-
);
|
|
384
|
-
}
|
|
385
|
-
);
|
|
386
|
-
|
|
387
|
-
const History = observer(
|
|
388
|
-
({
|
|
389
|
-
messages,
|
|
390
|
-
className
|
|
391
|
-
}) => {
|
|
392
|
-
let currentType = "";
|
|
393
|
-
return /* @__PURE__ */ jsx(AutoscrollContainer, { className, children: /* @__PURE__ */ jsx(
|
|
394
|
-
Box,
|
|
395
|
-
{
|
|
396
|
-
...getVariant("layout.common.chat.history"),
|
|
397
|
-
className: "chat_history",
|
|
398
|
-
children: messages.map((current, i) => {
|
|
399
|
-
let first = false;
|
|
400
|
-
let last = false;
|
|
401
|
-
if (currentType !== current.messageType) {
|
|
402
|
-
currentType = current.messageType;
|
|
403
|
-
first = true;
|
|
404
|
-
}
|
|
405
|
-
if (i === messages.length - 1 || messages[i + 1].messageType !== current.messageType) {
|
|
406
|
-
last = true;
|
|
407
|
-
}
|
|
408
|
-
return /* @__PURE__ */ jsx(
|
|
409
|
-
Message,
|
|
410
|
-
{
|
|
411
|
-
className: first ? "first" : last ? "last" : void 0,
|
|
412
|
-
type: current.messageType,
|
|
413
|
-
id: String(current.id),
|
|
414
|
-
attachments: current.attachments,
|
|
415
|
-
reference: current.reference,
|
|
416
|
-
message: current.message
|
|
417
|
-
}
|
|
418
|
-
);
|
|
419
|
-
})
|
|
420
|
-
}
|
|
421
|
-
) });
|
|
422
|
-
}
|
|
423
|
-
);
|
|
424
|
-
|
|
425
|
-
function getBase64FromFile(f) {
|
|
426
|
-
return ((f2) => new Promise((resolve, reject) => {
|
|
427
|
-
const reader = new FileReader();
|
|
428
|
-
reader.readAsDataURL(f2);
|
|
429
|
-
reader.onload = () => resolve(reader.result);
|
|
430
|
-
reader.onerror = () => reject();
|
|
431
|
-
}))(f);
|
|
432
|
-
}
|
|
433
|
-
function getBase64FromBlob(b) {
|
|
434
|
-
return ((blob) => new Promise((resolve, reject) => {
|
|
435
|
-
const reader = new FileReader();
|
|
436
|
-
reader.onloadend = () => {
|
|
437
|
-
const base64String = reader.result;
|
|
438
|
-
resolve(base64String);
|
|
439
|
-
};
|
|
440
|
-
reader.onerror = reject;
|
|
441
|
-
reader.readAsDataURL(blob);
|
|
442
|
-
}))(b);
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
const TextArea = observer(
|
|
446
|
-
({
|
|
447
|
-
additionalOptions = [],
|
|
448
|
-
isLoading,
|
|
449
|
-
isRecording,
|
|
450
|
-
disablePrevButton,
|
|
451
|
-
disableNextButton,
|
|
452
|
-
onSubmit,
|
|
453
|
-
onChange,
|
|
454
|
-
onClearHistory,
|
|
455
|
-
onAttach,
|
|
456
|
-
onRecord,
|
|
457
|
-
onRecordCancel,
|
|
458
|
-
onVideoRecord,
|
|
459
|
-
onPrev,
|
|
460
|
-
onNext,
|
|
461
|
-
value,
|
|
462
|
-
attachments,
|
|
463
|
-
className
|
|
464
|
-
}) => {
|
|
465
|
-
const fileInputRef = useRef(null);
|
|
466
|
-
const searchControlsRef = useRef(null);
|
|
467
|
-
const [dragging, setDragging] = useState(false);
|
|
468
|
-
const handleAttachments = async (ev) => {
|
|
469
|
-
if (ev.target.files) {
|
|
470
|
-
for await (const f of ev.target.files) {
|
|
471
|
-
const base64 = await getBase64FromFile(f);
|
|
472
|
-
onAttach({
|
|
473
|
-
base64,
|
|
474
|
-
name: f.name,
|
|
475
|
-
id: f.name
|
|
476
|
-
});
|
|
477
|
-
}
|
|
478
|
-
ev.target.value = "";
|
|
479
|
-
}
|
|
480
|
-
};
|
|
481
|
-
const menuItemsList = [
|
|
482
|
-
...additionalOptions.length > 0 ? [...additionalOptions, "separator"] : [],
|
|
483
|
-
{
|
|
484
|
-
children: getLabel("btnUpload").text,
|
|
485
|
-
title: getLabel("btnUpload").text,
|
|
486
|
-
icon: "File",
|
|
487
|
-
onClick: () => fileInputRef.current?.click(),
|
|
488
|
-
key: "2"
|
|
489
|
-
},
|
|
490
|
-
{
|
|
491
|
-
title: getLabel("lblOpenCamera").text,
|
|
492
|
-
children: getLabel("lblOpenCamera").text,
|
|
493
|
-
icon: "Camera",
|
|
494
|
-
onClick: onVideoRecord,
|
|
495
|
-
key: "3"
|
|
496
|
-
},
|
|
497
|
-
"separator",
|
|
498
|
-
{
|
|
499
|
-
icon: "ArrowLeft",
|
|
500
|
-
children: getLabel("btnAiPrevious").text,
|
|
501
|
-
title: getLabel("btnAiPrevious").text,
|
|
502
|
-
onClick: onPrev,
|
|
503
|
-
disabled: disablePrevButton,
|
|
504
|
-
key: "0"
|
|
505
|
-
},
|
|
506
|
-
{
|
|
507
|
-
icon: "ArrowRight",
|
|
508
|
-
children: getLabel("btnAiNext").text,
|
|
509
|
-
title: getLabel("btnAiNext").text,
|
|
510
|
-
onClick: onNext,
|
|
511
|
-
disabled: disableNextButton,
|
|
512
|
-
key: "1"
|
|
513
|
-
},
|
|
514
|
-
"separator",
|
|
515
|
-
{
|
|
516
|
-
icon: "Trash",
|
|
517
|
-
onClick: onClearHistory,
|
|
518
|
-
key: "5",
|
|
519
|
-
children: getLabel("btnAiDeleteMessages").text,
|
|
520
|
-
title: getLabel("btnAiDeleteMessages").text
|
|
521
|
-
}
|
|
522
|
-
];
|
|
523
|
-
const handleDragLeave = (ev) => {
|
|
524
|
-
ev.preventDefault();
|
|
525
|
-
setDragging(false);
|
|
526
|
-
};
|
|
527
|
-
const handleDrop = (ev) => {
|
|
528
|
-
ev.preventDefault();
|
|
529
|
-
setDragging(false);
|
|
530
|
-
const fileElement = document.getElementById(
|
|
531
|
-
`invisible__attach__file`
|
|
532
|
-
);
|
|
533
|
-
(fileInputRef.current ?? fileElement).files = ev.dataTransfer.files;
|
|
534
|
-
const event = new Event("change", { bubbles: true });
|
|
535
|
-
fileElement.dispatchEvent(event);
|
|
536
|
-
};
|
|
537
|
-
const handleDragOver = (ev) => {
|
|
538
|
-
ev.preventDefault();
|
|
539
|
-
};
|
|
540
|
-
const handleDragEnter = (ev) => {
|
|
541
|
-
ev.preventDefault();
|
|
542
|
-
setDragging(true);
|
|
543
|
-
};
|
|
544
|
-
return /* @__PURE__ */ jsxs(
|
|
545
|
-
Form,
|
|
546
|
-
{
|
|
547
|
-
onDrop: handleDrop,
|
|
548
|
-
onDragOver: handleDragOver,
|
|
549
|
-
onDragEnter: handleDragEnter,
|
|
550
|
-
onDragLeave: handleDragLeave,
|
|
551
|
-
onSubmit: (ev) => {
|
|
552
|
-
ev.preventDefault();
|
|
553
|
-
onSubmit();
|
|
554
|
-
},
|
|
555
|
-
className: `search_controls ${className}`,
|
|
556
|
-
...getVariant("layout.common.chat.form"),
|
|
557
|
-
children: [
|
|
558
|
-
dragging ? /* @__PURE__ */ jsx(
|
|
559
|
-
Box,
|
|
560
|
-
{
|
|
561
|
-
sx: {
|
|
562
|
-
height: "150px",
|
|
563
|
-
border: "3px dashed #aaa",
|
|
564
|
-
width: "100%",
|
|
565
|
-
display: "flex",
|
|
566
|
-
alignItems: "center",
|
|
567
|
-
justifyContent: "center"
|
|
568
|
-
},
|
|
569
|
-
children: getLabel("msgAiDragAndDrop").text
|
|
570
|
-
}
|
|
571
|
-
) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
572
|
-
/* @__PURE__ */ jsx(
|
|
573
|
-
AutogrowTextarea,
|
|
574
|
-
{
|
|
575
|
-
ref: searchControlsRef,
|
|
576
|
-
"aria-label": (
|
|
577
|
-
/** TODO: Crear etiqueta para búsqueda */
|
|
578
|
-
"Frase de b\xFAsqueda"
|
|
579
|
-
),
|
|
580
|
-
value,
|
|
581
|
-
className: "searchTextArea",
|
|
582
|
-
onChange: (ev) => onChange(ev.target.value),
|
|
583
|
-
onKeyDown: (ev) => {
|
|
584
|
-
if ((ev.code === "Enter" || ev.code === "NumpadEnter") && !ev.shiftKey) {
|
|
585
|
-
ev.preventDefault();
|
|
586
|
-
ev.target.closest("form").querySelector('[type="submit"]').click();
|
|
587
|
-
}
|
|
588
|
-
},
|
|
589
|
-
sx: {
|
|
590
|
-
resize: "none",
|
|
591
|
-
px: spacing(4),
|
|
592
|
-
background: "transparent",
|
|
593
|
-
border: "none",
|
|
594
|
-
alignContent: "center"
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
),
|
|
598
|
-
/* @__PURE__ */ jsxs(Box, { className: "chatButtons", children: [
|
|
599
|
-
/* @__PURE__ */ jsx(
|
|
600
|
-
IconButton,
|
|
601
|
-
{
|
|
602
|
-
className: "ChatBarButton",
|
|
603
|
-
icon: isRecording ? "Trash" : "Ellipsis",
|
|
604
|
-
variant: "icon-only",
|
|
605
|
-
iconSize: "Sm",
|
|
606
|
-
onClick: isRecording ? onRecordCancel : (ev) => {
|
|
607
|
-
ApiaUtil.instance.menu.open({
|
|
608
|
-
menuProps: {
|
|
609
|
-
anchorPoint: { x: ev.clientX, y: ev.clientY }
|
|
610
|
-
},
|
|
611
|
-
items: menuItemsList
|
|
612
|
-
});
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
),
|
|
616
|
-
value === "" && attachments.length === 0 || isRecording ? /* @__PURE__ */ jsx(
|
|
617
|
-
IconButton,
|
|
618
|
-
{
|
|
619
|
-
className: `ChatBarButton ${isRecording ? "isRecording" : ""}`,
|
|
620
|
-
icon: isRecording ? "Stop" : "Microphone",
|
|
621
|
-
variant: "icon-only",
|
|
622
|
-
iconSize: "Sm",
|
|
623
|
-
title: getLabel("lblAiRecordAudio").text,
|
|
624
|
-
onClick: onRecord,
|
|
625
|
-
isLoading,
|
|
626
|
-
disabled: isLoading && !isRecording,
|
|
627
|
-
sx: {
|
|
628
|
-
color: isRecording ? "red" : void 0
|
|
629
|
-
},
|
|
630
|
-
id: "transcribeAudio"
|
|
631
|
-
}
|
|
632
|
-
) : /* @__PURE__ */ jsx(
|
|
633
|
-
IconButton,
|
|
634
|
-
{
|
|
635
|
-
className: "ChatBarButton",
|
|
636
|
-
isLoading,
|
|
637
|
-
icon: "ArrowRight",
|
|
638
|
-
variant: "icon-only",
|
|
639
|
-
iconSize: "Sm",
|
|
640
|
-
title: getLabel("btnBus").title,
|
|
641
|
-
type: "submit"
|
|
642
|
-
}
|
|
643
|
-
)
|
|
644
|
-
] })
|
|
645
|
-
] }),
|
|
646
|
-
/* @__PURE__ */ jsx(
|
|
647
|
-
"input",
|
|
648
|
-
{
|
|
649
|
-
ref: fileInputRef,
|
|
650
|
-
id: "invisible__attach__file",
|
|
651
|
-
type: "file",
|
|
652
|
-
multiple: true,
|
|
653
|
-
onChange: handleAttachments,
|
|
654
|
-
sx: { display: "none" }
|
|
655
|
-
}
|
|
656
|
-
)
|
|
657
|
-
]
|
|
658
|
-
}
|
|
659
|
-
);
|
|
660
|
-
}
|
|
661
|
-
);
|
|
662
|
-
|
|
663
|
-
var __defProp$7 = Object.defineProperty;
|
|
664
|
-
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
665
|
-
var __publicField$7 = (obj, key, value) => {
|
|
666
|
-
__defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
667
|
-
return value;
|
|
668
|
-
};
|
|
669
|
-
class CameraController {
|
|
670
|
-
constructor() {
|
|
671
|
-
__publicField$7(this, "state", {
|
|
672
|
-
videoStream: null,
|
|
673
|
-
isOpen: false
|
|
674
|
-
});
|
|
675
|
-
__publicField$7(this, "currentCapture", null);
|
|
676
|
-
__publicField$7(this, "videoElement");
|
|
677
|
-
__publicField$7(this, "Component", () => {
|
|
678
|
-
return /* @__PURE__ */ jsx(
|
|
679
|
-
"video",
|
|
680
|
-
{
|
|
681
|
-
ref: (el) => {
|
|
682
|
-
if (el) {
|
|
683
|
-
el.srcObject = this.videoElement.srcObject;
|
|
684
|
-
el.autoplay = true;
|
|
685
|
-
el.playsInline = true;
|
|
686
|
-
}
|
|
687
|
-
},
|
|
688
|
-
style: { width: "100%", height: "auto" }
|
|
689
|
-
}
|
|
690
|
-
);
|
|
691
|
-
});
|
|
692
|
-
makeObservable(this, {
|
|
693
|
-
state: observable,
|
|
694
|
-
openCamera: action,
|
|
695
|
-
closeCamera: action
|
|
696
|
-
});
|
|
697
|
-
this.videoElement = document.createElement("video");
|
|
698
|
-
this.videoElement.autoplay = true;
|
|
699
|
-
this.videoElement.playsInline = true;
|
|
700
|
-
}
|
|
701
|
-
async openCamera() {
|
|
702
|
-
try {
|
|
703
|
-
const stream = await navigator.mediaDevices.getUserMedia({ video: true });
|
|
704
|
-
this.state.videoStream = stream;
|
|
705
|
-
this.videoElement.srcObject = stream;
|
|
706
|
-
this.state.isOpen = true;
|
|
707
|
-
ApiaUtil.instance.modals.open({
|
|
708
|
-
children: /* @__PURE__ */ jsx(this.Component, {}),
|
|
709
|
-
onConfirm: () => {
|
|
710
|
-
this.closeCamera();
|
|
711
|
-
},
|
|
712
|
-
onClose: () => {
|
|
713
|
-
this.closeCamera();
|
|
714
|
-
}
|
|
715
|
-
});
|
|
716
|
-
} catch (error) {
|
|
717
|
-
console.error("Error while accessing the camera:", error);
|
|
718
|
-
this.state.isOpen = false;
|
|
719
|
-
this.closeCamera();
|
|
720
|
-
}
|
|
721
|
-
}
|
|
722
|
-
async closeCamera() {
|
|
723
|
-
if (!this.videoElement.srcObject)
|
|
724
|
-
return;
|
|
725
|
-
const canvas = document.createElement("canvas");
|
|
726
|
-
canvas.width = this.videoElement.videoWidth;
|
|
727
|
-
canvas.height = this.videoElement.videoHeight;
|
|
728
|
-
const ctx = canvas.getContext("2d");
|
|
729
|
-
if (ctx)
|
|
730
|
-
ctx.drawImage(this.videoElement, 0, 0, canvas.width, canvas.height);
|
|
731
|
-
this.currentCapture = await new Promise((resolve) => {
|
|
732
|
-
canvas.toBlob((blob) => {
|
|
733
|
-
if (blob) {
|
|
734
|
-
const file = new File([blob], "captured_image.jpg", {
|
|
735
|
-
type: "image/jpeg"
|
|
736
|
-
});
|
|
737
|
-
resolve(file);
|
|
738
|
-
} else {
|
|
739
|
-
this.closeCamera();
|
|
740
|
-
}
|
|
741
|
-
}, "image/jpeg");
|
|
742
|
-
}).finally(() => {
|
|
743
|
-
this.state.videoStream?.getTracks().forEach((track) => track.stop());
|
|
744
|
-
this.state.videoStream = null;
|
|
745
|
-
this.videoElement.srcObject = null;
|
|
746
|
-
this.state.isOpen = false;
|
|
747
|
-
});
|
|
748
|
-
}
|
|
749
|
-
pop() {
|
|
750
|
-
const returnFile = this.currentCapture;
|
|
751
|
-
this.currentCapture = null;
|
|
752
|
-
return returnFile;
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
var __defProp$6 = Object.defineProperty;
|
|
757
|
-
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
758
|
-
var __publicField$6 = (obj, key, value) => {
|
|
759
|
-
__defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
760
|
-
return value;
|
|
761
|
-
};
|
|
762
|
-
class ChatController {
|
|
763
|
-
constructor(props, onMessageSubmit, onClearHistory, additionalOptions, classNames) {
|
|
764
|
-
this.onMessageSubmit = onMessageSubmit;
|
|
765
|
-
this.onClearHistory = onClearHistory;
|
|
766
|
-
this.additionalOptions = additionalOptions;
|
|
767
|
-
this.classNames = classNames;
|
|
768
|
-
__publicField$6(this, "currentIndex", 0);
|
|
769
|
-
__publicField$6(this, "state", {
|
|
770
|
-
isLoading: false,
|
|
771
|
-
canRecord: true,
|
|
772
|
-
canAttach: true,
|
|
773
|
-
maxAttachmentsSize: 100,
|
|
774
|
-
messages: [],
|
|
775
|
-
currentMessage: new ChatMessage("", "user")
|
|
776
|
-
});
|
|
777
|
-
__publicField$6(this, "internalAudioRecorder", new AudioRecorder());
|
|
778
|
-
__publicField$6(this, "internalCameraRecorder", new CameraController());
|
|
779
|
-
__publicField$6(this, "maxId", 0);
|
|
780
|
-
__publicField$6(this, "audioRecorder", {
|
|
781
|
-
cancelOnStop: false,
|
|
782
|
-
start: () => {
|
|
783
|
-
this.state.isLoading = true;
|
|
784
|
-
this.internalAudioRecorder.start().then(async (blob) => {
|
|
785
|
-
if (this.audioRecorder.cancelOnStop) {
|
|
786
|
-
this.audioRecorder.cancelOnStop = false;
|
|
787
|
-
return;
|
|
788
|
-
}
|
|
789
|
-
this.state.currentMessage.attachments.push({
|
|
790
|
-
id: String(this.maxId++),
|
|
791
|
-
name: `userRecord_${this.audioRecorder.record++}.wav`,
|
|
792
|
-
base64: await getBase64FromBlob(blob)
|
|
793
|
-
});
|
|
794
|
-
const currentMessage = new ChatMessage(
|
|
795
|
-
this.state.currentMessage.message,
|
|
796
|
-
"user"
|
|
797
|
-
);
|
|
798
|
-
this.state.currentMessage.message = "";
|
|
799
|
-
const submitMessage = this.state.currentMessage;
|
|
800
|
-
this.state.currentMessage = currentMessage;
|
|
801
|
-
await this.handleSubmit({
|
|
802
|
-
message: submitMessage,
|
|
803
|
-
eraseCurrentMessage: false
|
|
804
|
-
});
|
|
805
|
-
}).finally(() => {
|
|
806
|
-
this.state.isLoading = false;
|
|
807
|
-
});
|
|
808
|
-
},
|
|
809
|
-
stop: async () => {
|
|
810
|
-
this.internalAudioRecorder.stop();
|
|
811
|
-
},
|
|
812
|
-
record: 0,
|
|
813
|
-
state: this.internalAudioRecorder.state
|
|
814
|
-
});
|
|
815
|
-
__publicField$6(this, "handleSubmit", async (props) => {
|
|
816
|
-
if (!this.audioRecorder.state.recording) {
|
|
817
|
-
const currentMessage = props?.message || this.state.currentMessage;
|
|
818
|
-
if (currentMessage.message || currentMessage.attachments.length > 0) {
|
|
819
|
-
this.state.isLoading = true;
|
|
820
|
-
if (props?.eraseCurrentMessage !== false) {
|
|
821
|
-
this.state.currentMessage = new ChatMessage("", "user");
|
|
822
|
-
}
|
|
823
|
-
await this.onMessageSubmit({
|
|
824
|
-
message: currentMessage,
|
|
825
|
-
...this.getAdditionalProps()
|
|
826
|
-
});
|
|
827
|
-
this.state.isLoading = false;
|
|
828
|
-
}
|
|
829
|
-
}
|
|
830
|
-
});
|
|
831
|
-
__publicField$6(this, "History", observer(() => /* @__PURE__ */ jsx(
|
|
832
|
-
History,
|
|
833
|
-
{
|
|
834
|
-
messages: this.state.messages,
|
|
835
|
-
className: this.classNames?.history
|
|
836
|
-
}
|
|
837
|
-
)));
|
|
838
|
-
__publicField$6(this, "Attachments", observer(() => /* @__PURE__ */ jsx(
|
|
839
|
-
Attachments,
|
|
840
|
-
{
|
|
841
|
-
attachments: this.state.currentMessage.attachments,
|
|
842
|
-
onRemove: (a) => {
|
|
843
|
-
this.removeAttachment(a);
|
|
844
|
-
},
|
|
845
|
-
className: this.classNames?.attachments,
|
|
846
|
-
onAddDescription: (a, ev) => this.state.currentMessage.addAttachmentDescription(a, ev)
|
|
847
|
-
}
|
|
848
|
-
)));
|
|
849
|
-
__publicField$6(this, "TextArea", observer(() => /* @__PURE__ */ jsx(
|
|
850
|
-
TextArea,
|
|
851
|
-
{
|
|
852
|
-
additionalOptions: this.additionalOptions,
|
|
853
|
-
className: this.classNames?.textarea,
|
|
854
|
-
value: this.state.currentMessage.message,
|
|
855
|
-
isLoading: this.state.isLoading,
|
|
856
|
-
isRecording: this.internalAudioRecorder.state.recording,
|
|
857
|
-
disablePrevButton: !this.canGoPrev(),
|
|
858
|
-
disableNextButton: !this.canGoNext(),
|
|
859
|
-
onChange: (ev) => {
|
|
860
|
-
this.state.currentMessage.message = ev;
|
|
861
|
-
},
|
|
862
|
-
onSubmit: () => this.handleSubmit(),
|
|
863
|
-
onClearHistory: () => {
|
|
864
|
-
this.clearHistory();
|
|
865
|
-
},
|
|
866
|
-
onAttach: async (ev) => {
|
|
867
|
-
this.state.currentMessage.attachments.push({
|
|
868
|
-
...ev,
|
|
869
|
-
id: String(this.maxId++)
|
|
870
|
-
});
|
|
871
|
-
},
|
|
872
|
-
onRecord: () => {
|
|
873
|
-
!this.internalAudioRecorder.state.recording ? this.audioRecorder.start() : this.audioRecorder.stop();
|
|
874
|
-
},
|
|
875
|
-
onRecordCancel: async () => {
|
|
876
|
-
if (this.internalAudioRecorder.state.recording) {
|
|
877
|
-
this.audioRecorder.cancelOnStop = true;
|
|
878
|
-
await this.audioRecorder.stop();
|
|
879
|
-
}
|
|
880
|
-
},
|
|
881
|
-
onVideoRecord: async () => {
|
|
882
|
-
!this.internalCameraRecorder.state.isOpen && await this.internalCameraRecorder.openCamera();
|
|
883
|
-
await new Promise((resolve, _) => {
|
|
884
|
-
const checkCapture = async () => {
|
|
885
|
-
if (!this.internalCameraRecorder.state.isOpen) {
|
|
886
|
-
const capture = this.internalCameraRecorder.pop();
|
|
887
|
-
if (capture) {
|
|
888
|
-
this.state.currentMessage.attachments.push({
|
|
889
|
-
id: String(this.maxId++),
|
|
890
|
-
name: capture.name,
|
|
891
|
-
base64: await getBase64FromFile(capture)
|
|
892
|
-
});
|
|
893
|
-
return resolve();
|
|
894
|
-
}
|
|
895
|
-
} else {
|
|
896
|
-
requestAnimationFrame(checkCapture);
|
|
897
|
-
}
|
|
898
|
-
};
|
|
899
|
-
checkCapture();
|
|
900
|
-
});
|
|
901
|
-
},
|
|
902
|
-
onPrev: () => {
|
|
903
|
-
this.prevMessage();
|
|
904
|
-
},
|
|
905
|
-
onNext: () => {
|
|
906
|
-
this.nextMessage();
|
|
907
|
-
},
|
|
908
|
-
attachments: this.state.currentMessage.attachments
|
|
909
|
-
}
|
|
910
|
-
)));
|
|
911
|
-
__publicField$6(this, "Renderer", () => /* @__PURE__ */ jsxs(
|
|
912
|
-
Box,
|
|
913
|
-
{
|
|
914
|
-
...getVariant("layout.common.chat.controller"),
|
|
915
|
-
className: "chat_controller",
|
|
916
|
-
children: [
|
|
917
|
-
/* @__PURE__ */ jsx(this.History, {}),
|
|
918
|
-
/* @__PURE__ */ jsx(this.Attachments, {}),
|
|
919
|
-
/* @__PURE__ */ jsx(this.TextArea, {})
|
|
920
|
-
]
|
|
921
|
-
}
|
|
922
|
-
));
|
|
923
|
-
this.state = Object.assign({}, this.state, props);
|
|
924
|
-
makeObservable(this, { state: observable });
|
|
925
|
-
}
|
|
926
|
-
removeMessage(idx) {
|
|
927
|
-
this.state.messages = this.state.messages.filter((_, i) => i !== idx);
|
|
928
|
-
}
|
|
929
|
-
addMessage(message) {
|
|
930
|
-
this.state.messages.push(message);
|
|
931
|
-
this.currentIndex = this.state.messages.length;
|
|
932
|
-
}
|
|
933
|
-
clearHistory() {
|
|
934
|
-
this.state.messages = [];
|
|
935
|
-
this.onClearHistory && this.onClearHistory();
|
|
936
|
-
}
|
|
937
|
-
clearMessage() {
|
|
938
|
-
this.state.currentMessage = new ChatMessage("", "user");
|
|
939
|
-
}
|
|
940
|
-
removeAttachment(attachment) {
|
|
941
|
-
this.state.currentMessage.removeAttachment(attachment);
|
|
942
|
-
}
|
|
943
|
-
isForHistory(message) {
|
|
944
|
-
return message && message.messageType === "user";
|
|
945
|
-
}
|
|
946
|
-
canGoNext() {
|
|
947
|
-
let condition = false;
|
|
948
|
-
const slice = this.state.messages.slice(
|
|
949
|
-
this.currentIndex,
|
|
950
|
-
this.state.messages.length
|
|
951
|
-
);
|
|
952
|
-
const n = slice.length;
|
|
953
|
-
if (this.currentIndex + 1 > n) {
|
|
954
|
-
return condition;
|
|
955
|
-
}
|
|
956
|
-
for (let i = 0; i < n && !condition; i++) {
|
|
957
|
-
const current = slice[i];
|
|
958
|
-
condition = current.messageType === "user";
|
|
959
|
-
}
|
|
960
|
-
return condition;
|
|
961
|
-
}
|
|
962
|
-
canGoPrev() {
|
|
963
|
-
let condition = false;
|
|
964
|
-
if (this.currentIndex - 1 === -1) {
|
|
965
|
-
return condition;
|
|
966
|
-
}
|
|
967
|
-
for (let i = this.state.messages.slice(0, this.currentIndex).length - 1; i >= 0 && !condition; i--) {
|
|
968
|
-
const current = this.state.messages[i];
|
|
969
|
-
condition = current.messageType === "user";
|
|
970
|
-
}
|
|
971
|
-
return condition;
|
|
972
|
-
}
|
|
973
|
-
nextMessage() {
|
|
974
|
-
let newCurrentMessage = void 0;
|
|
975
|
-
let i = this.currentIndex;
|
|
976
|
-
const n = this.state.messages.length;
|
|
977
|
-
if (n === 0 || n - 1 === i) {
|
|
978
|
-
return;
|
|
979
|
-
}
|
|
980
|
-
while (!newCurrentMessage && i < n - 1) {
|
|
981
|
-
newCurrentMessage = this.state.messages[i + 1];
|
|
982
|
-
i++;
|
|
983
|
-
if (this.isForHistory(newCurrentMessage)) {
|
|
984
|
-
this.state.currentMessage = newCurrentMessage.clone();
|
|
985
|
-
break;
|
|
986
|
-
} else {
|
|
987
|
-
newCurrentMessage = void 0;
|
|
988
|
-
}
|
|
989
|
-
if (i === this.currentIndex) {
|
|
990
|
-
break;
|
|
991
|
-
}
|
|
992
|
-
}
|
|
993
|
-
this.currentIndex = i;
|
|
994
|
-
}
|
|
995
|
-
prevMessage() {
|
|
996
|
-
let newCurrentMessage = void 0;
|
|
997
|
-
let i = this.currentIndex;
|
|
998
|
-
const n = this.state.messages.length;
|
|
999
|
-
if (n === 0 || i === 0) {
|
|
1000
|
-
return;
|
|
1001
|
-
}
|
|
1002
|
-
while (!newCurrentMessage && i > 0) {
|
|
1003
|
-
newCurrentMessage = this.state.messages[i - 1];
|
|
1004
|
-
i--;
|
|
1005
|
-
if (this.isForHistory(newCurrentMessage)) {
|
|
1006
|
-
this.state.currentMessage = newCurrentMessage.clone();
|
|
1007
|
-
break;
|
|
1008
|
-
} else {
|
|
1009
|
-
newCurrentMessage = void 0;
|
|
1010
|
-
}
|
|
1011
|
-
if (i === this.currentIndex) {
|
|
1012
|
-
break;
|
|
1013
|
-
}
|
|
1014
|
-
}
|
|
1015
|
-
this.currentIndex = i;
|
|
1016
|
-
}
|
|
1017
|
-
getAdditionalProps() {
|
|
1018
|
-
return {};
|
|
1019
|
-
}
|
|
1020
|
-
}
|
|
1021
|
-
|
|
1022
|
-
var __defProp$5 = Object.defineProperty;
|
|
1023
|
-
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1024
|
-
var __publicField$5 = (obj, key, value) => {
|
|
1025
|
-
__defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1026
|
-
return value;
|
|
1027
|
-
};
|
|
1028
|
-
class FloatingChatController extends ChatController {
|
|
1029
|
-
constructor(props) {
|
|
1030
|
-
super(
|
|
1031
|
-
{ isWindowOpen: false, ...props },
|
|
1032
|
-
props.onMessageSubmit,
|
|
1033
|
-
props.onClearHistory,
|
|
1034
|
-
props.additionalOptions,
|
|
1035
|
-
props.classNames
|
|
1036
|
-
);
|
|
1037
|
-
__publicField$5(this, "modalTitle");
|
|
1038
|
-
__publicField$5(this, "Window", observer(() => {
|
|
1039
|
-
return this.state.isWindowOpen ? null : /* @__PURE__ */ jsx(
|
|
1040
|
-
IconButton,
|
|
1041
|
-
{
|
|
1042
|
-
className: "chat_controller__open",
|
|
1043
|
-
icon: "Magic",
|
|
1044
|
-
size: "Md",
|
|
1045
|
-
variant: "icon-outline",
|
|
1046
|
-
onClick: () => {
|
|
1047
|
-
this.open();
|
|
1048
|
-
}
|
|
1049
|
-
}
|
|
1050
|
-
);
|
|
1051
|
-
}));
|
|
1052
|
-
this.modalTitle = props.modalTitle;
|
|
1053
|
-
makeObservable({ open: action });
|
|
1054
|
-
if (props.props.isWindowOpen) {
|
|
1055
|
-
this.state.isWindowOpen = false;
|
|
1056
|
-
this.open();
|
|
1057
|
-
}
|
|
1058
|
-
}
|
|
1059
|
-
getModalTitle() {
|
|
1060
|
-
return this.modalTitle;
|
|
1061
|
-
}
|
|
1062
|
-
setModalTitle(title) {
|
|
1063
|
-
this.modalTitle = title;
|
|
1064
|
-
}
|
|
1065
|
-
open() {
|
|
1066
|
-
if (!this.state.isWindowOpen) {
|
|
1067
|
-
this.state.isWindowOpen = true;
|
|
1068
|
-
ApiaUtil.instance.modals.open({
|
|
1069
|
-
variant: "layout.common.chat.assistant.floatingAssistant",
|
|
1070
|
-
defaultPosition: {
|
|
1071
|
-
bottom: "10px",
|
|
1072
|
-
right: "10px"
|
|
1073
|
-
},
|
|
1074
|
-
id: "floatingAssistant",
|
|
1075
|
-
draggable: true,
|
|
1076
|
-
dragBounded: true,
|
|
1077
|
-
children: /* @__PURE__ */ jsx(this.Renderer, {}),
|
|
1078
|
-
onClose: () => {
|
|
1079
|
-
this.state.isWindowOpen = false;
|
|
1080
|
-
},
|
|
1081
|
-
title: this.modalTitle
|
|
1082
|
-
});
|
|
1083
|
-
}
|
|
1084
|
-
}
|
|
1085
|
-
}
|
|
1086
|
-
|
|
1087
|
-
var __defProp$4 = Object.defineProperty;
|
|
1088
|
-
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1089
|
-
var __publicField$4 = (obj, key, value) => {
|
|
1090
|
-
__defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1091
|
-
return value;
|
|
1092
|
-
};
|
|
1093
|
-
class StreamMessage {
|
|
1094
|
-
constructor(messageFooter, hasStream) {
|
|
1095
|
-
this.messageFooter = messageFooter;
|
|
1096
|
-
__publicField$4(this, "blocks", []);
|
|
1097
|
-
__publicField$4(this, "references", []);
|
|
1098
|
-
__publicField$4(this, "tables", {});
|
|
1099
|
-
__publicField$4(this, "charts", {});
|
|
1100
|
-
__publicField$4(this, "finished", true);
|
|
1101
|
-
makeObservable(this, {
|
|
1102
|
-
references: observable,
|
|
1103
|
-
blocks: observable,
|
|
1104
|
-
tables: observable,
|
|
1105
|
-
charts: observable,
|
|
1106
|
-
finished: observable
|
|
1107
|
-
});
|
|
1108
|
-
hasStream && (this.finished = false);
|
|
1109
|
-
}
|
|
1110
|
-
addPart(part, afterAddPart) {
|
|
1111
|
-
if (this.blocks.length > 0 && this.blocks[this.blocks.length - 1].blockType === "text" && part.blockType === "text") {
|
|
1112
|
-
const aux = this.blocks[this.blocks.length - 1];
|
|
1113
|
-
if (aux !== part) {
|
|
1114
|
-
aux.str += part.str;
|
|
1115
|
-
}
|
|
1116
|
-
} else {
|
|
1117
|
-
this.blocks.push(part);
|
|
1118
|
-
}
|
|
1119
|
-
afterAddPart && afterAddPart(part);
|
|
1120
|
-
}
|
|
1121
|
-
getLastBlock() {
|
|
1122
|
-
return this.blocks[this.blocks.length - 1];
|
|
1123
|
-
}
|
|
1124
|
-
streamFinished() {
|
|
1125
|
-
this.finished = true;
|
|
1126
|
-
}
|
|
1127
|
-
}
|
|
1128
|
-
|
|
1129
|
-
const Ellipsis = () => {
|
|
1130
|
-
const [e, setE] = useState(0);
|
|
1131
|
-
let dots = ".";
|
|
1132
|
-
for (let i = 0; i < e; i++) {
|
|
1133
|
-
dots += ".";
|
|
1134
|
-
}
|
|
1135
|
-
const interval = useRef(0);
|
|
1136
|
-
useEffect(() => {
|
|
1137
|
-
interval.current = setInterval(() => {
|
|
1138
|
-
setE((e2) => e2 === 2 ? 0 : e2 + 1);
|
|
1139
|
-
}, 500);
|
|
1140
|
-
return () => {
|
|
1141
|
-
clearInterval(interval.current);
|
|
1142
|
-
};
|
|
1143
|
-
});
|
|
1144
|
-
return /* @__PURE__ */ jsx("div", { className: "ellipsis", children: dots });
|
|
1145
|
-
};
|
|
1146
|
-
|
|
1147
|
-
const Header = observer(
|
|
1148
|
-
({ childComponent }) => {
|
|
1149
|
-
return /* @__PURE__ */ jsx(Box, { className: "search_header_container", children: childComponent });
|
|
1150
|
-
}
|
|
1151
|
-
);
|
|
1152
|
-
|
|
1153
|
-
async function rate(el, how, query) {
|
|
1154
|
-
return new Promise((resolve) => {
|
|
1155
|
-
const collector = new Collector();
|
|
1156
|
-
collector.add(
|
|
1157
|
-
new collector.fields.textarea("comment", "Comment", {
|
|
1158
|
-
validationRules: { required: true },
|
|
1159
|
-
properties: { autoFocus: true }
|
|
1160
|
-
})
|
|
1161
|
-
);
|
|
1162
|
-
const tooltip = ApiaUtil.instance.tooltips.open({
|
|
1163
|
-
attachToElement: { current: el },
|
|
1164
|
-
children: /* @__PURE__ */ jsx(
|
|
1165
|
-
collector.Render,
|
|
1166
|
-
{
|
|
1167
|
-
sx: {
|
|
1168
|
-
width: "300px",
|
|
1169
|
-
minWidth: "unset",
|
|
1170
|
-
".collector__buttons button": {
|
|
1171
|
-
fontSize: 14,
|
|
1172
|
-
py: 2,
|
|
1173
|
-
px: 3
|
|
1174
|
-
}
|
|
1175
|
-
},
|
|
1176
|
-
resolve: (w) => {
|
|
1177
|
-
(async () => {
|
|
1178
|
-
const result = await ApiaApi.post(
|
|
1179
|
-
makeApiaUrl({ action: "giveFeedback" }),
|
|
1180
|
-
{
|
|
1181
|
-
postData: {
|
|
1182
|
-
query,
|
|
1183
|
-
feedback: w.comment,
|
|
1184
|
-
positive: how === "up"
|
|
1185
|
-
},
|
|
1186
|
-
postDataTreatement: "stringify"
|
|
1187
|
-
}
|
|
1188
|
-
);
|
|
1189
|
-
tooltip.close();
|
|
1190
|
-
resolve(!result?.hasError && !result?.hasMessages);
|
|
1191
|
-
})();
|
|
1192
|
-
return true;
|
|
1193
|
-
}
|
|
1194
|
-
}
|
|
1195
|
-
),
|
|
1196
|
-
minSize: {
|
|
1197
|
-
width: 300,
|
|
1198
|
-
height: 220
|
|
1199
|
-
},
|
|
1200
|
-
preferredOrientationX: "right",
|
|
1201
|
-
preferredOrientationY: "top",
|
|
1202
|
-
closeOnMouseLeaveAttachedElement: false,
|
|
1203
|
-
closeOnMouseLeaveTooltip: false,
|
|
1204
|
-
closeOnClickOut: true,
|
|
1205
|
-
closeOnClick: false,
|
|
1206
|
-
closeOnEscape: true,
|
|
1207
|
-
closeOnScrollOut: true,
|
|
1208
|
-
closeOthers: true,
|
|
1209
|
-
attachToElementAnchorPoint: "topRight"
|
|
1210
|
-
});
|
|
1211
|
-
});
|
|
1212
|
-
}
|
|
1213
|
-
|
|
1214
|
-
const MessageBody = observer(
|
|
1215
|
-
({
|
|
1216
|
-
onRate,
|
|
1217
|
-
store
|
|
1218
|
-
}) => {
|
|
1219
|
-
const [thumb, setThumb] = useState(void 0);
|
|
1220
|
-
const hasText = (store.blocks.find((x) => x.blockType === "text")?.str ?? "").length > 0;
|
|
1221
|
-
return /* @__PURE__ */ jsxs(Box, { className: "sem_search__system_message", children: [
|
|
1222
|
-
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1223
|
-
/* @__PURE__ */ jsx(Box, { className: "message__body markdown", children: /* @__PURE__ */ jsx(MessageBlocks, { streamParts: store.blocks }) }),
|
|
1224
|
-
onRate && hasText ? /* @__PURE__ */ jsxs(Box, { className: "sem_search__thumbs", children: [
|
|
1225
|
-
/* @__PURE__ */ jsx(
|
|
1226
|
-
IconButton,
|
|
1227
|
-
{
|
|
1228
|
-
variant: "icon-only",
|
|
1229
|
-
icon: "ThumbsUp",
|
|
1230
|
-
className: thumb === "up" ? "selected" : thumb === "down" ? "unselected" : "no_feedback",
|
|
1231
|
-
onClick: (ev) => onRate(ev.target, "up").then((res) => {
|
|
1232
|
-
if (res) {
|
|
1233
|
-
setThumb("up");
|
|
1234
|
-
}
|
|
1235
|
-
})
|
|
1236
|
-
}
|
|
1237
|
-
),
|
|
1238
|
-
/* @__PURE__ */ jsx(
|
|
1239
|
-
IconButton,
|
|
1240
|
-
{
|
|
1241
|
-
variant: "icon-only",
|
|
1242
|
-
icon: "ThumbsDown",
|
|
1243
|
-
className: thumb === "down" ? "selected" : thumb === "up" ? "unselected" : "no_feedback",
|
|
1244
|
-
onClick: (ev) => onRate(ev.target, "down").then((res) => {
|
|
1245
|
-
if (res) {
|
|
1246
|
-
setThumb("down");
|
|
1247
|
-
}
|
|
1248
|
-
})
|
|
1249
|
-
}
|
|
1250
|
-
)
|
|
1251
|
-
] }) : /* @__PURE__ */ jsx(Fragment, {})
|
|
1252
|
-
] }),
|
|
1253
|
-
!hasText && /* @__PURE__ */ jsx(Ellipsis, {}),
|
|
1254
|
-
store.messageFooter && store.finished && /* @__PURE__ */ jsx(Box, { className: "message__body markdown", children: /* @__PURE__ */ jsx(MDRenderer, { str: store.messageFooter }) })
|
|
1255
|
-
] });
|
|
1256
|
-
}
|
|
1257
|
-
);
|
|
1258
|
-
|
|
1259
|
-
class MultipleChoiceMessage extends ChatMessage {
|
|
1260
|
-
constructor(question, options, Renderer) {
|
|
1261
|
-
super(
|
|
1262
|
-
Renderer ? /* @__PURE__ */ jsxs(Box, { className: "multipleChoiceMessage customRenderer", children: [
|
|
1263
|
-
/* @__PURE__ */ jsx(Paragraph, { children: question }),
|
|
1264
|
-
options.map((item) => /* @__PURE__ */ jsx(Renderer, { item }, item.url))
|
|
1265
|
-
] }) : /* @__PURE__ */ jsxs(Box, { className: "multipleChoiceMessage", children: [
|
|
1266
|
-
/* @__PURE__ */ jsx(Paragraph, { children: question }),
|
|
1267
|
-
/* @__PURE__ */ jsx(Box, { as: "ul", children: options.map((current) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(
|
|
1268
|
-
SimpleButton,
|
|
1269
|
-
{
|
|
1270
|
-
className: "multipleChoice__option",
|
|
1271
|
-
onClick: () => {
|
|
1272
|
-
ApiaUtil.instance.tabs.openTab(current.label, current.url);
|
|
1273
|
-
},
|
|
1274
|
-
children: current.label
|
|
1275
|
-
}
|
|
1276
|
-
) }, current.label)) })
|
|
1277
|
-
] }),
|
|
1278
|
-
"multipleChoice"
|
|
1279
|
-
);
|
|
1280
|
-
}
|
|
1281
|
-
}
|
|
1282
|
-
|
|
1283
|
-
var __defProp$3 = Object.defineProperty;
|
|
1284
|
-
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1285
|
-
var __publicField$3 = (obj, key, value) => {
|
|
1286
|
-
__defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1287
|
-
return value;
|
|
1288
|
-
};
|
|
1289
|
-
function isPollProgress(payload) {
|
|
1290
|
-
return payload?.progress !== void 0;
|
|
1291
|
-
}
|
|
1292
|
-
class RoutinesGeneration {
|
|
1293
|
-
constructor() {
|
|
1294
|
-
__publicField$3(this, "audioRecorder", new AudioRecorder());
|
|
1295
|
-
__publicField$3(this, "routineId", "");
|
|
1296
|
-
__publicField$3(this, "state", {
|
|
1297
|
-
isLoading: false,
|
|
1298
|
-
progress: 0
|
|
1299
|
-
});
|
|
1300
|
-
makeObservable(this, {
|
|
1301
|
-
completion: action,
|
|
1302
|
-
state: observable,
|
|
1303
|
-
stop: action,
|
|
1304
|
-
transcribeAudio: action
|
|
1305
|
-
});
|
|
1306
|
-
}
|
|
1307
|
-
checkCanGenerate() {
|
|
1308
|
-
if (this.state.isLoading) {
|
|
1309
|
-
throw new Error("Cannot queue two simultaneous generations");
|
|
1310
|
-
}
|
|
1311
|
-
this.state.isLoading = true;
|
|
1312
|
-
}
|
|
1313
|
-
async pollRoutine(routineId, stream) {
|
|
1314
|
-
this.routineId = routineId;
|
|
1315
|
-
this.state.isLoading = true;
|
|
1316
|
-
return this.internalPollRoutine(stream);
|
|
1317
|
-
}
|
|
1318
|
-
async internalPollRoutine(stream) {
|
|
1319
|
-
while (this.state.isLoading) {
|
|
1320
|
-
const pollResult = await this.callRoutinePoll(this.routineId);
|
|
1321
|
-
if (isPollProgress(pollResult.payload)) {
|
|
1322
|
-
try {
|
|
1323
|
-
const res = JSON.parse(pollResult.payload.debug);
|
|
1324
|
-
if (res.length > 0) {
|
|
1325
|
-
res.forEach((c) => {
|
|
1326
|
-
console.log(JSON.parse(c));
|
|
1327
|
-
});
|
|
1328
|
-
}
|
|
1329
|
-
if (pollResult.payload.streamPart && stream) {
|
|
1330
|
-
stream.emit("part", pollResult.payload.streamPart);
|
|
1331
|
-
}
|
|
1332
|
-
this.state.progress = pollResult.payload.progress;
|
|
1333
|
-
} catch (e) {
|
|
1334
|
-
console.error(e);
|
|
1335
|
-
}
|
|
1336
|
-
} else if (pollResult.status === "FINISHED") {
|
|
1337
|
-
this.resetLoading();
|
|
1338
|
-
return pollResult.payload;
|
|
1339
|
-
} else if (pollResult.status === "ERROR") {
|
|
1340
|
-
this.resetLoading();
|
|
1341
|
-
throw new Error(pollResult.payload);
|
|
1342
|
-
} else {
|
|
1343
|
-
this.resetLoading();
|
|
1344
|
-
throw new Error("Wrong poll response");
|
|
1345
|
-
}
|
|
1346
|
-
}
|
|
1347
|
-
return null;
|
|
1348
|
-
}
|
|
1349
|
-
async callAudioTranscription(audio) {
|
|
1350
|
-
const url = makeApiaUrl({
|
|
1351
|
-
action: "routineStart",
|
|
1352
|
-
routine: "transcription/Transcribe"
|
|
1353
|
-
});
|
|
1354
|
-
const response = await axios.post(url, audio.arrayBuffer(), {
|
|
1355
|
-
headers: {
|
|
1356
|
-
"Content-Type": "application/octet-stream"
|
|
1357
|
-
}
|
|
1358
|
-
});
|
|
1359
|
-
const result = await parseSuccessfulResponse(response, "");
|
|
1360
|
-
if (result?.orchestrator) {
|
|
1361
|
-
return result;
|
|
1362
|
-
}
|
|
1363
|
-
return null;
|
|
1364
|
-
}
|
|
1365
|
-
async callRoutinePoll(routineId) {
|
|
1366
|
-
const result = await ApiaApi.post(
|
|
1367
|
-
makeApiaUrl({
|
|
1368
|
-
action: "routinePoll",
|
|
1369
|
-
routineId
|
|
1370
|
-
})
|
|
1371
|
-
);
|
|
1372
|
-
if (result?.data?.orchestrator) {
|
|
1373
|
-
return JSON.parse(result.data.orchestrator);
|
|
1374
|
-
} else {
|
|
1375
|
-
throw new Error("Poll failed");
|
|
1376
|
-
}
|
|
1377
|
-
}
|
|
1378
|
-
async callRoutineStart(routineName, parameters, images) {
|
|
1379
|
-
const result = await ApiaApi.post(
|
|
1380
|
-
makeApiaUrl({
|
|
1381
|
-
action: "routineStart",
|
|
1382
|
-
routine: routineName
|
|
1383
|
-
}),
|
|
1384
|
-
{
|
|
1385
|
-
postData: {
|
|
1386
|
-
images: JSON.stringify(images),
|
|
1387
|
-
...parameters
|
|
1388
|
-
},
|
|
1389
|
-
stringifyOptions: {
|
|
1390
|
-
arrayFormat: "repeat"
|
|
1391
|
-
},
|
|
1392
|
-
postDataTreatement: "stringify"
|
|
1393
|
-
}
|
|
1394
|
-
);
|
|
1395
|
-
return result?.data || null;
|
|
1396
|
-
}
|
|
1397
|
-
async executeRoutine(routineName, parameters, images, stream) {
|
|
1398
|
-
this.checkCanGenerate();
|
|
1399
|
-
try {
|
|
1400
|
-
const result = await this.callRoutineStart(
|
|
1401
|
-
routineName,
|
|
1402
|
-
parameters,
|
|
1403
|
-
images
|
|
1404
|
-
);
|
|
1405
|
-
if (result?.orchestrator?.routineId !== void 0) {
|
|
1406
|
-
this.routineId = result?.orchestrator.routineId;
|
|
1407
|
-
return this.internalPollRoutine(stream);
|
|
1408
|
-
} else {
|
|
1409
|
-
throw new Error("Cannot get routine id");
|
|
1410
|
-
}
|
|
1411
|
-
} catch (e) {
|
|
1412
|
-
this.resetLoading();
|
|
1413
|
-
throw e;
|
|
1414
|
-
}
|
|
1415
|
-
}
|
|
1416
|
-
resetLoading() {
|
|
1417
|
-
this.state.isLoading = false;
|
|
1418
|
-
this.state.progress = 0;
|
|
1419
|
-
}
|
|
1420
|
-
async completion(params) {
|
|
1421
|
-
return this.executeRoutine(
|
|
1422
|
-
params.routineName,
|
|
1423
|
-
params.parameters ?? {},
|
|
1424
|
-
params.images ?? [],
|
|
1425
|
-
params.stream
|
|
1426
|
-
);
|
|
1427
|
-
}
|
|
1428
|
-
stop() {
|
|
1429
|
-
this.resetLoading();
|
|
1430
|
-
ApiaApi.get(
|
|
1431
|
-
makeApiaUrl({
|
|
1432
|
-
action: "routineStop",
|
|
1433
|
-
routineId: this.routineId
|
|
1434
|
-
})
|
|
1435
|
-
);
|
|
1436
|
-
}
|
|
1437
|
-
async transcribeAudio(audio) {
|
|
1438
|
-
const result = await this.callAudioTranscription(audio);
|
|
1439
|
-
if (result) {
|
|
1440
|
-
this.state.isLoading = true;
|
|
1441
|
-
if (result?.orchestrator?.routineId) {
|
|
1442
|
-
this.routineId = result?.orchestrator?.routineId;
|
|
1443
|
-
return await this.internalPollRoutine();
|
|
1444
|
-
}
|
|
1445
|
-
}
|
|
1446
|
-
throw new Error("Something went wrong while transcribing the audio");
|
|
1447
|
-
}
|
|
1448
|
-
}
|
|
1449
|
-
|
|
1450
|
-
class DashboardsRoutinesGeneration extends RoutinesGeneration {
|
|
1451
|
-
constructor(dispatcher) {
|
|
1452
|
-
super();
|
|
1453
|
-
this.dispatcher = dispatcher;
|
|
1454
|
-
}
|
|
1455
|
-
blobToBase64(audio) {
|
|
1456
|
-
return new Promise((resolve, reject) => {
|
|
1457
|
-
const reader = new FileReader();
|
|
1458
|
-
reader.onloadend = () => {
|
|
1459
|
-
if (reader.result && typeof reader.result === "string") {
|
|
1460
|
-
const base64 = reader.result.split(",")[1];
|
|
1461
|
-
resolve(base64);
|
|
1462
|
-
} else {
|
|
1463
|
-
reject(new Error("Could not convert Blob to base64"));
|
|
1464
|
-
}
|
|
1465
|
-
};
|
|
1466
|
-
reader.onerror = reject;
|
|
1467
|
-
reader.readAsDataURL(audio);
|
|
1468
|
-
});
|
|
1469
|
-
}
|
|
1470
|
-
async callAudioTranscription(audio) {
|
|
1471
|
-
const audioBase64 = await this.blobToBase64(audio);
|
|
1472
|
-
const result = await this.dispatcher({
|
|
1473
|
-
action: "transcription",
|
|
1474
|
-
audioBase64
|
|
1475
|
-
});
|
|
1476
|
-
return result?.data || null;
|
|
1477
|
-
}
|
|
1478
|
-
async callRoutinePoll(routineId) {
|
|
1479
|
-
const result = await this.dispatcher({
|
|
1480
|
-
action: "routinePoll",
|
|
1481
|
-
routineId
|
|
1482
|
-
});
|
|
1483
|
-
if (result?.data?.orchestrator) {
|
|
1484
|
-
const parsed = JSON.parse(result.data.orchestrator);
|
|
1485
|
-
return parsed;
|
|
1486
|
-
}
|
|
1487
|
-
throw new Error("Poll failed");
|
|
1488
|
-
}
|
|
1489
|
-
async callRoutineStart(routineName, parameters, images) {
|
|
1490
|
-
const result = await this.dispatcher({
|
|
1491
|
-
action: "routineStart",
|
|
1492
|
-
routine: routineName,
|
|
1493
|
-
...parameters,
|
|
1494
|
-
images
|
|
1495
|
-
});
|
|
1496
|
-
return result?.data || null;
|
|
1497
|
-
}
|
|
1498
|
-
}
|
|
1499
|
-
|
|
1500
|
-
var __defProp$2 = Object.defineProperty;
|
|
1501
|
-
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1502
|
-
var __publicField$2 = (obj, key, value) => {
|
|
1503
|
-
__defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1504
|
-
return value;
|
|
1505
|
-
};
|
|
1506
|
-
class ResponseStream extends EventEmitter {
|
|
1507
|
-
constructor() {
|
|
1508
|
-
super(...arguments);
|
|
1509
|
-
__publicField$2(this, "buffer", "");
|
|
1510
|
-
__publicField$2(this, "isRunning", false);
|
|
1511
|
-
__publicField$2(this, "locked", false);
|
|
1512
|
-
__publicField$2(this, "maxCompletionTime", 150);
|
|
1513
|
-
// ms
|
|
1514
|
-
__publicField$2(this, "minPartSize", 2);
|
|
1515
|
-
__publicField$2(this, "partSize", 2);
|
|
1516
|
-
__publicField$2(this, "timing", 5);
|
|
1517
|
-
// ms
|
|
1518
|
-
__publicField$2(this, "waiting", []);
|
|
1519
|
-
}
|
|
1520
|
-
calculatePartSize() {
|
|
1521
|
-
const totalSize = this.buffer.length + this.waiting.reduce((a, b) => a + b.length, 0);
|
|
1522
|
-
this.partSize = Math.max(
|
|
1523
|
-
this.minPartSize,
|
|
1524
|
-
totalSize * (this.timing / this.maxCompletionTime)
|
|
1525
|
-
);
|
|
1526
|
-
}
|
|
1527
|
-
emit(ev, data) {
|
|
1528
|
-
if (ev === "part") {
|
|
1529
|
-
let chunk = data;
|
|
1530
|
-
const blockMatches = chunk.matchAll(
|
|
1531
|
-
/<BLOCK-START type="([^"]+)">(.+?)<\/BLOCK-END type="\1">/g
|
|
1532
|
-
);
|
|
1533
|
-
for (const match of blockMatches) {
|
|
1534
|
-
this.emit("block", { description: match[2], type: match[1] });
|
|
1535
|
-
chunk = chunk.replaceAll(match[0], "");
|
|
1536
|
-
}
|
|
1537
|
-
if (this.locked) {
|
|
1538
|
-
this.waiting.push(chunk);
|
|
1539
|
-
} else {
|
|
1540
|
-
this.buffer += chunk;
|
|
1541
|
-
}
|
|
1542
|
-
this.calculatePartSize();
|
|
1543
|
-
this.run();
|
|
1544
|
-
} else {
|
|
1545
|
-
super.emit(ev, data);
|
|
1546
|
-
}
|
|
1547
|
-
}
|
|
1548
|
-
run() {
|
|
1549
|
-
if (!this.isRunning) {
|
|
1550
|
-
this.isRunning = true;
|
|
1551
|
-
const interval = setInterval(() => {
|
|
1552
|
-
this.locked = true;
|
|
1553
|
-
const choosedSize = Math.min(this.buffer.length, this.partSize);
|
|
1554
|
-
const part = this.buffer.slice(0, choosedSize);
|
|
1555
|
-
this.buffer = this.buffer.slice(choosedSize);
|
|
1556
|
-
while (this.waiting.length > 0) {
|
|
1557
|
-
const part2 = this.waiting.shift();
|
|
1558
|
-
if (part2) {
|
|
1559
|
-
this.buffer += part2;
|
|
1560
|
-
}
|
|
1561
|
-
}
|
|
1562
|
-
this.locked = false;
|
|
1563
|
-
if (part) {
|
|
1564
|
-
super.emit("part", part);
|
|
1565
|
-
} else {
|
|
1566
|
-
this.isRunning = false;
|
|
1567
|
-
clearInterval(interval);
|
|
1568
|
-
}
|
|
1569
|
-
}, this.timing);
|
|
1570
|
-
}
|
|
1571
|
-
}
|
|
1572
|
-
}
|
|
1573
|
-
|
|
1574
|
-
async function getImageFromDisk(inputProps) {
|
|
1575
|
-
return (await getImagesFromDisk({ ...inputProps, multiple: "false" }))[0] ?? null;
|
|
1576
|
-
}
|
|
1577
|
-
function getImagesFromDisk(inputProps) {
|
|
1578
|
-
return new Promise((resolve) => {
|
|
1579
|
-
const input = document.createElement("input");
|
|
1580
|
-
input.accept = "image/*";
|
|
1581
|
-
input.type = "file";
|
|
1582
|
-
input.style.display = "none";
|
|
1583
|
-
Object.assign(input, inputProps);
|
|
1584
|
-
document.body.append(input);
|
|
1585
|
-
input.addEventListener("change", (event) => {
|
|
1586
|
-
const target = event?.target;
|
|
1587
|
-
if (!target?.files)
|
|
1588
|
-
return;
|
|
1589
|
-
const retrievedImages = [];
|
|
1590
|
-
const sources = [...target.files ?? []];
|
|
1591
|
-
const checkResolve = () => {
|
|
1592
|
-
if (sources.length === retrievedImages.length) {
|
|
1593
|
-
resolve(retrievedImages.filter((c) => !!c));
|
|
1594
|
-
}
|
|
1595
|
-
};
|
|
1596
|
-
sources.forEach((file) => {
|
|
1597
|
-
if (file) {
|
|
1598
|
-
const reader = new FileReader();
|
|
1599
|
-
reader.onload = function(e) {
|
|
1600
|
-
const binary = e.target?.result?.split(",")[1];
|
|
1601
|
-
input.remove();
|
|
1602
|
-
retrievedImages.push({
|
|
1603
|
-
base64: binary,
|
|
1604
|
-
path: file.name
|
|
1605
|
-
});
|
|
1606
|
-
checkResolve();
|
|
1607
|
-
};
|
|
1608
|
-
reader.readAsDataURL(file);
|
|
1609
|
-
} else {
|
|
1610
|
-
retrievedImages.push(null);
|
|
1611
|
-
}
|
|
1612
|
-
checkResolve();
|
|
1613
|
-
});
|
|
1614
|
-
});
|
|
1615
|
-
input.click();
|
|
1616
|
-
});
|
|
1617
|
-
}
|
|
1618
|
-
|
|
1619
|
-
const ImageIcon = ({
|
|
1620
|
-
deletable,
|
|
1621
|
-
onClick,
|
|
1622
|
-
onRemove,
|
|
1623
|
-
src
|
|
1624
|
-
}) => {
|
|
1625
|
-
return /* @__PURE__ */ jsxs(Box, { className: "image_preview", children: [
|
|
1626
|
-
deletable && /* @__PURE__ */ jsx(IconButton, { icon: "Close", size: "Xs", iconSize: "Xs", onClick: onRemove }),
|
|
1627
|
-
/* @__PURE__ */ jsx("img", { src, onClick })
|
|
1628
|
-
] });
|
|
1629
|
-
};
|
|
1630
|
-
|
|
1631
|
-
function getSrcFromBase64(base64) {
|
|
1632
|
-
return `data:image/jpg;base64,${base64}`;
|
|
1633
|
-
}
|
|
1634
|
-
|
|
1635
|
-
var __defProp$1 = Object.defineProperty;
|
|
1636
|
-
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1637
|
-
var __publicField$1 = (obj, key, value) => {
|
|
1638
|
-
__defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1639
|
-
return value;
|
|
1640
|
-
};
|
|
1641
|
-
class ImagesStore {
|
|
1642
|
-
constructor(images, multiple) {
|
|
1643
|
-
this.multiple = multiple;
|
|
1644
|
-
__publicField$1(this, "images", /* @__PURE__ */ new Map());
|
|
1645
|
-
__publicField$1(this, "selectedId", "");
|
|
1646
|
-
this.images = new Map(
|
|
1647
|
-
images.map((c) => {
|
|
1648
|
-
const id = uniqueId();
|
|
1649
|
-
return [id, { ...c, id }];
|
|
1650
|
-
})
|
|
1651
|
-
);
|
|
1652
|
-
this.selectedId = this.images.values().next().value?.id || "";
|
|
1653
|
-
makeAutoObservable(this);
|
|
1654
|
-
}
|
|
1655
|
-
}
|
|
1656
|
-
const GetImagesDescription = observer(({ store }) => {
|
|
1657
|
-
return /* @__PURE__ */ jsxs(
|
|
1658
|
-
Box,
|
|
1659
|
-
{
|
|
1660
|
-
className: "images_description_generator",
|
|
1661
|
-
...getVariant("layout.design.projectAnalysis.imagesLoader"),
|
|
1662
|
-
children: [
|
|
1663
|
-
/* @__PURE__ */ jsx(Box, { className: "images_sort_wrapper", children: /* @__PURE__ */ jsx(
|
|
1664
|
-
SortableList,
|
|
1665
|
-
{
|
|
1666
|
-
onSortChange: (ev) => {
|
|
1667
|
-
store.images = new Map(
|
|
1668
|
-
ev.map((c) => [
|
|
1669
|
-
c.props.id,
|
|
1670
|
-
c.props.additionalProps
|
|
1671
|
-
])
|
|
1672
|
-
);
|
|
1673
|
-
},
|
|
1674
|
-
children: [...store.images].map(([k, c]) => /* @__PURE__ */ jsx(SortableListItem, { additionalProps: c, id: c.id, children: /* @__PURE__ */ jsx(
|
|
1675
|
-
ImageIcon,
|
|
1676
|
-
{
|
|
1677
|
-
deletable: store.multiple,
|
|
1678
|
-
onClick: () => {
|
|
1679
|
-
store.selectedId = c.id;
|
|
1680
|
-
},
|
|
1681
|
-
onRemove: () => {
|
|
1682
|
-
store.images.delete(k);
|
|
1683
|
-
},
|
|
1684
|
-
src: getSrcFromBase64(c.base64 ?? "")
|
|
1685
|
-
}
|
|
1686
|
-
) }, c.id))
|
|
1687
|
-
}
|
|
1688
|
-
) }),
|
|
1689
|
-
/* @__PURE__ */ jsxs(Box, { className: "image_editor", children: [
|
|
1690
|
-
/* @__PURE__ */ jsx(Box, { className: "image_preview", children: store.images.get(store.selectedId) && /* @__PURE__ */ jsx(
|
|
1691
|
-
"img",
|
|
1692
|
-
{
|
|
1693
|
-
src: getSrcFromBase64(
|
|
1694
|
-
store.images.get(store.selectedId).base64 ?? ""
|
|
1695
|
-
)
|
|
1696
|
-
}
|
|
1697
|
-
) }),
|
|
1698
|
-
/* @__PURE__ */ jsxs(Box, { className: "image_description", children: [
|
|
1699
|
-
/* @__PURE__ */ jsx(
|
|
1700
|
-
Textarea,
|
|
1701
|
-
{
|
|
1702
|
-
autoFocus: true,
|
|
1703
|
-
disabled: !store.images.get(store.selectedId),
|
|
1704
|
-
onChange: (ev) => {
|
|
1705
|
-
const image = store.images.get(store.selectedId);
|
|
1706
|
-
if (image)
|
|
1707
|
-
image.description = ev.target.value;
|
|
1708
|
-
},
|
|
1709
|
-
value: store.images.get(store.selectedId)?.description
|
|
1710
|
-
}
|
|
1711
|
-
),
|
|
1712
|
-
store.multiple && /* @__PURE__ */ jsx(
|
|
1713
|
-
IconButton,
|
|
1714
|
-
{
|
|
1715
|
-
icon: "Attach",
|
|
1716
|
-
onClick: () => {
|
|
1717
|
-
getImagesFromDisk({ multiple: "true" }).then((res) => {
|
|
1718
|
-
res.forEach((c) => {
|
|
1719
|
-
const id = uniqueId();
|
|
1720
|
-
store.images.set(id, {
|
|
1721
|
-
base64: c.base64,
|
|
1722
|
-
description: "",
|
|
1723
|
-
id
|
|
1724
|
-
});
|
|
1725
|
-
});
|
|
1726
|
-
});
|
|
1727
|
-
},
|
|
1728
|
-
size: "Md",
|
|
1729
|
-
iconSize: "Sm",
|
|
1730
|
-
variant: "icon-only"
|
|
1731
|
-
}
|
|
1732
|
-
)
|
|
1733
|
-
] })
|
|
1734
|
-
] })
|
|
1735
|
-
]
|
|
1736
|
-
}
|
|
1737
|
-
);
|
|
1738
|
-
});
|
|
1739
|
-
function getImagesWithDescription({
|
|
1740
|
-
multiple
|
|
1741
|
-
}) {
|
|
1742
|
-
return new Promise((resolve) => {
|
|
1743
|
-
getImagesFromDisk({ multiple: multiple ? "true" : void 0 }).then(
|
|
1744
|
-
(images) => {
|
|
1745
|
-
const store = new ImagesStore(
|
|
1746
|
-
images.map((c) => ({
|
|
1747
|
-
base64: c.base64,
|
|
1748
|
-
description: ""
|
|
1749
|
-
})),
|
|
1750
|
-
multiple || false
|
|
1751
|
-
);
|
|
1752
|
-
ApiaUtil.instance.modals.open({
|
|
1753
|
-
children: /* @__PURE__ */ jsx(GetImagesDescription, { store }),
|
|
1754
|
-
initialFocusGetter(modalInnerRef) {
|
|
1755
|
-
return modalInnerRef.querySelector("textarea");
|
|
1756
|
-
},
|
|
1757
|
-
onConfirm: () => {
|
|
1758
|
-
resolve([...toJS(store.images).values()]);
|
|
1759
|
-
},
|
|
1760
|
-
onCancel() {
|
|
1761
|
-
resolve([]);
|
|
1762
|
-
},
|
|
1763
|
-
size: "xxxl-fixed",
|
|
1764
|
-
noHeader: true
|
|
1765
|
-
});
|
|
1766
|
-
}
|
|
1767
|
-
);
|
|
1768
|
-
});
|
|
1769
|
-
}
|
|
1770
|
-
|
|
1771
|
-
const ViewRendererContext = createContext(
|
|
1772
|
-
{}
|
|
1773
|
-
);
|
|
1774
|
-
|
|
1775
|
-
var __defProp = Object.defineProperty;
|
|
1776
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1777
|
-
var __publicField = (obj, key, value) => {
|
|
1778
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1779
|
-
return value;
|
|
1780
|
-
};
|
|
1781
|
-
class StreamServicePoller {
|
|
1782
|
-
constructor() {
|
|
1783
|
-
__publicField(this, "closed", true);
|
|
1784
|
-
__publicField(this, "stream", new ResponseStream());
|
|
1785
|
-
}
|
|
1786
|
-
on(ev, cb) {
|
|
1787
|
-
return this.stream.on(ev, cb);
|
|
1788
|
-
}
|
|
1789
|
-
async start(token) {
|
|
1790
|
-
try {
|
|
1791
|
-
while (!this.closed) {
|
|
1792
|
-
const res = await ApiaApi.post(
|
|
1793
|
-
makeApiaUrl({
|
|
1794
|
-
ajaxUrl: "apia.streamAction.run",
|
|
1795
|
-
action: "poll",
|
|
1796
|
-
streamToken: token
|
|
1797
|
-
})
|
|
1798
|
-
);
|
|
1799
|
-
if (res?.data?.part) {
|
|
1800
|
-
this.stream.emit("part", res.data.part);
|
|
1801
|
-
}
|
|
1802
|
-
if (res?.data?.closed) {
|
|
1803
|
-
this.closed = true;
|
|
1804
|
-
this.stream.emit("close", null);
|
|
1805
|
-
}
|
|
1806
|
-
}
|
|
1807
|
-
} finally {
|
|
1808
|
-
this.closed = true;
|
|
1809
|
-
}
|
|
1810
|
-
}
|
|
1811
|
-
}
|
|
1812
|
-
const poller = new StreamServicePoller();
|
|
1813
|
-
poller.start("mytokenquerecibidelserver");
|
|
1814
|
-
poller.on("block", (block) => {
|
|
1815
|
-
console.log({ block });
|
|
1816
|
-
});
|
|
1817
|
-
poller.on("part", (part) => {
|
|
1818
|
-
console.log({ part });
|
|
1819
|
-
});
|
|
1820
|
-
poller.on("close", () => {
|
|
1821
|
-
console.log("Termin\xE9 de stemear!");
|
|
1822
|
-
});
|
|
1823
|
-
|
|
1824
|
-
export { Attachments, AutoscrollContainer, CameraController, ChatController, ChatMessage, DashboardsRoutinesGeneration, Ellipsis, FloatingChatController, Header, History, Message, MessageBlock, MessageBlocks, MessageBody, MultipleChoiceMessage, ResponseStream, RoutinesGeneration, SearchController, SemanticSearchReference as SemanticSearchResult, StreamMessage, StreamServicePoller, TextArea, ViewRendererContext, getImageFromDisk, getImagesFromDisk, getImagesWithDescription, rate };
|
|
1
|
+
export { default as SearchController } from './semanticSearch/SearchController/index.js';
|
|
2
|
+
export { SemanticSearchReference as SemanticSearchResult } from './semanticSearch/SearchController/objects/SemanticSearchReference/index.js';
|
|
3
|
+
export { MultipleChoiceMessage } from './components/chat/messages/MultipleChoiceMessage.js';
|
|
4
|
+
export { DashboardsRoutinesGeneration } from './routines/DashboardRoutinesGeneration.js';
|
|
5
|
+
export { ResponseStream } from './stream/ResponseStream.js';
|
|
6
|
+
export { RoutinesGeneration } from './routines/RoutinesGeneration.js';
|
|
7
|
+
export { ViewRendererContext } from './semanticSearch/ViewController/types.js';
|
|
8
|
+
export { StreamServicePoller } from './stream/StreamServicePoller.js';
|
|
9
|
+
export { getImagesWithDescription } from './components/documents/UploadModal/getImagesWithDescription.js';
|
|
10
|
+
export { getImageFromDisk, getImagesFromDisk } from './components/documents/ImageBinaryField/getImage.js';
|
|
11
|
+
export { AutoscrollContainer } from './chat/AutoscrollContainer.js';
|
|
12
|
+
export { FloatingChatController } from './chat/FloatingChatController.js';
|
|
13
|
+
export { ChatController } from './chat/ChatController/ChatController.js';
|
|
14
|
+
export { StreamMessage } from './chat/ChatController/StreamMessage.js';
|
|
15
|
+
export { CameraController } from './chat/ChatController/CameraController.js';
|
|
16
|
+
export { Attachments } from './chat/ChatController/components/Attachments.js';
|
|
17
|
+
export { ChatMessage } from './chat/ChatController/components/ChatMessage.js';
|
|
18
|
+
export { Ellipsis } from './chat/ChatController/components/Ellipsis.js';
|
|
19
|
+
export { Header } from './chat/ChatController/components/Header.js';
|
|
20
|
+
export { History } from './chat/ChatController/components/History.js';
|
|
21
|
+
export { Message } from './chat/ChatController/components/Message.js';
|
|
22
|
+
export { MessageBlock } from './chat/ChatController/components/MessageBlock.js';
|
|
23
|
+
export { ThinkingBlocks } from './chat/ChatController/components/ThinkingBlocks.js';
|
|
24
|
+
export { QuestionBlocks } from './chat/ChatController/components/QuestionBlocks.js';
|
|
25
|
+
export { QuestionAnswerMessage } from './chat/ChatController/components/QuestionAnswerMessage.js';
|
|
26
|
+
export { rate } from './chat/ChatController/components/rate.js';
|
|
27
|
+
export { TextArea } from './chat/ChatController/components/TextArea.js';
|
|
28
|
+
export { MessageBody } from './chat/ChatController/components/MessageBody.js';
|
|
29
|
+
export { MessageBlocks } from './chat/ChatController/components/MessageBlocks.js';
|
|
1825
30
|
//# sourceMappingURL=index.js.map
|