@epam/ai-dial-chat-hooks 1.2.0-dev.99 → 1.3.0-dev.5
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/api-error/api-error.js +7 -4
- package/catalog/catalog-derivations.js +1 -1
- package/catalog/deployment-id.js +8 -2
- package/catalog/map-deployment-limits-to-catalog.js +16 -24
- package/catalog/map-deployment-limits-to-input.js +81 -9
- package/catalog/map-deployment-to-catalog-item.js +34 -34
- package/catalog/map-entity-details-to-catalog.js +237 -192
- package/catalog/map-skill-to-catalog-item.js +61 -54
- package/catalog/publish.js +4 -4
- package/catalog/useCatalogEditNavigation/useCatalogEditNavigation.js +122 -101
- package/catalog/useCatalogItemDetails.js +9 -8
- package/catalog/usePublishFolders/usePublishFolders.js +1 -1
- package/catalog.d.ts +171 -34
- package/catalog.js +23 -23
- package/conversation/conversation-transfer/export-conversation.js +24 -16
- package/conversation/conversation-transfer/import-conversation.js +80 -31
- package/conversation/create-chat-stream-api.js +89 -49
- package/conversation/get-model-id-from-conversation-id.js +15 -9
- package/conversation/message-utils.js +44 -2
- package/conversation/stage.js +6 -2
- package/conversation/useActiveConversationSync/useActiveConversationSync.js +7 -8
- package/conversation/useConversationExport/useConversationExport.js +9 -9
- package/conversation/useConversationHandlers/message-utils.js +8 -5
- package/conversation/useConversationHandlers/useConversationHandlers.js +181 -167
- package/conversation/useConversationImport/useConversationImport.js +123 -121
- package/conversation/useConversationPanelItems/useConversationPanelItems.js +49 -31
- package/conversation/useConversationStream/frame-scheduler.js +39 -0
- package/conversation/useConversationStream/generation-resume.js +122 -64
- package/conversation/useConversationStream/useConversationStream.js +298 -118
- package/conversation/useMessageSelectionReply/useMessageSelectionReply.js +189 -0
- package/conversation-sources/useConversationSources/useConversationSources.js +31 -24
- package/conversation-sources.d.ts +1 -1
- package/conversation-transfer.d.ts +2 -1
- package/conversation.d.ts +218 -22
- package/conversation.js +32 -31
- package/file-manager-canvas.d.ts +27 -7
- package/file-manager.d.ts +87 -32
- package/file-manager.js +25 -24
- package/files/attachment-canvas.js +67 -44
- package/files/dial-file-manager-copy-move.util.js +9 -8
- package/files/dial-file-manager-mapping.util.js +2 -1
- package/files/dial-file-manager-path.util.js +24 -2
- package/files/dial-file-manager.model.js +23 -19
- package/files/dial-file-manager.types.js +3 -3
- package/files/file-manager-variant.js +1 -1
- package/files/resolve-dial-file-api-path.js +11 -12
- package/files/useDialFileListing/useDialFileListing.js +140 -127
- package/files/useDialFileManager/useDialFileManager.js +139 -135
- package/files/useDialFileManagerSections/useDialFileManagerSections.js +155 -0
- package/files/useDialFileManagerTabConfig/useDialFileManagerTabConfig.js +20 -15
- package/files/useDialFileMutations/useDialFileMutations.js +65 -60
- package/files/useDialFileUploadBatch/useDialFileUploadBatch.js +117 -110
- package/files/useFileAttachmentPicker/useFileAttachmentPicker.js +28 -23
- package/index.d.ts +643 -128
- package/index.js +136 -134
- package/mcp-apps/useMcpAppTools/useMcpAppTools.js +1 -1
- package/oauth/authorize-url.js +3 -3
- package/oauth/toolset-id.js +5 -3
- package/oauth/useToolsetLogin/useToolsetLogin.js +8 -8
- package/oauth.d.ts +34 -2
- package/oauth.js +9 -9
- package/package.json +19 -23
- package/scheduled-task/scheduled-task-description.js +43 -39
- package/scheduled-task/scheduled-task-trigger.js +74 -71
- package/scheduled-task/use-scheduled-task-runs.js +162 -50
- package/scheduled-task/use-scheduled-tasks.js +52 -48
- package/scheduled-tasks.d.ts +27 -6
- package/scheduled-tasks.js +2 -2
- package/shared/application-schema.js +5 -2
- package/shared/cron-day-of-month.js +13 -0
- package/skill/skill-archive.js +19 -0
- package/skill/skill-types.js +8 -7
- package/skill/skill.js +52 -29
- package/skill/useSkillArchiveImport/useSkillArchiveImport.js +38 -34
- package/skill/useSkillEditorLoad.js +65 -59
- package/skill/useSkillEditorSubmit.js +105 -93
- package/skill/useSkillFileActions.js +70 -58
- package/skill-editor.d.ts +62 -13
- package/skill-editor.js +9 -9
- package/usage/map-user-usage-to-model-limits.js +137 -95
- package/usage.d.ts +8 -3
- package/usePageFileDrag/usePageFileDrag.js +3 -3
- package/utils.d.ts +26 -6
- package/utils.js +10 -10
|
@@ -1,57 +1,57 @@
|
|
|
1
1
|
import { collectAttachmentRefs as e, splitFileIdAnchor as t } from "./attachment-refs.js";
|
|
2
2
|
import { resolveDialFileBucketAndPath as n } from "./dial-file-resolve.js";
|
|
3
|
-
import {
|
|
3
|
+
import { PUBLIC_BUCKET as r, generateUUID as i, sanitizeConversationName as a, stripTrailingDots as o, truncateToUtf8Bytes as s } from "@epam/ai-dial-chat-shared";
|
|
4
4
|
//#region src/conversation/conversation-transfer/import-conversation.ts
|
|
5
|
-
var
|
|
5
|
+
var c = class extends Error {
|
|
6
6
|
constructor(e) {
|
|
7
7
|
super(e), this.name = "UnsupportedImportFormatError";
|
|
8
8
|
}
|
|
9
|
-
},
|
|
9
|
+
}, l = (e) => typeof e == "object" && !!e, u = 5, d = (e) => {
|
|
10
10
|
let t;
|
|
11
11
|
try {
|
|
12
12
|
t = JSON.parse(e);
|
|
13
13
|
} catch {
|
|
14
|
-
throw new
|
|
14
|
+
throw new c("Import file is not valid JSON");
|
|
15
15
|
}
|
|
16
|
-
if (!
|
|
16
|
+
if (!l(t) || t.version !== u || !Array.isArray(t.history)) throw new c("Import file is not a supported export format");
|
|
17
17
|
let n = Array.isArray(t.folders) ? t.folders : [];
|
|
18
18
|
return {
|
|
19
|
-
version:
|
|
19
|
+
version: u,
|
|
20
20
|
history: t.history,
|
|
21
21
|
folders: n
|
|
22
22
|
};
|
|
23
|
-
},
|
|
24
|
-
let
|
|
25
|
-
if (
|
|
26
|
-
let a = n &&
|
|
23
|
+
}, f = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, p = "__", m = 255, h = "applications", g = /[-+]/, _ = /^\d+$/, v = (e) => e ? e.split(g)[0].split(".").every((e) => _.test(e)) : !1, y = (e) => o(s(e.replace(/\r\n|\r/g, "\n").split("\n").map((e) => a(e).trim()).filter(Boolean)[0] ?? "", m)).trimEnd(), b = (e, t, n) => {
|
|
24
|
+
let r = e.split(p);
|
|
25
|
+
if (r.length < 2) return [e, i()].join(p);
|
|
26
|
+
let a = n && v(r[1]) ? r.slice(0, 2) : r.slice(0, 1), o = a.length > 1 ? f.test(r[r.length - 1]) : r.length >= 3, s = r.slice(a.length, o ? -1 : void 0).join(p);
|
|
27
27
|
return [
|
|
28
28
|
...a,
|
|
29
29
|
t || s,
|
|
30
|
-
|
|
31
|
-
].join(
|
|
32
|
-
},
|
|
33
|
-
let n =
|
|
30
|
+
i()
|
|
31
|
+
].join(p);
|
|
32
|
+
}, x = "conversations/", S = (e) => e.startsWith(x) ? e.slice(14) : e, C = (e, t) => {
|
|
33
|
+
let n = S(e.id), r = n.split("/"), i = S(e.folderId), a = r[0], o = i.startsWith(`${a}/`) ? i.slice(a.length + 1).split("/").filter(Boolean) : [], s = r.slice(1).slice(o.length), c = s.slice(0, -1), l = s.at(-1) ?? r.at(-1) ?? n, u = [...o, ...c], d = y(e.name), f = b(l, d, u[0] === h), p = [...u, f].join("/"), m = o.length ? `${t}/${o.join("/")}` : t;
|
|
34
34
|
return {
|
|
35
35
|
conversation: {
|
|
36
36
|
...e,
|
|
37
37
|
...d ? { name: d } : {},
|
|
38
38
|
id: `${t}/${p}`,
|
|
39
|
-
folderId:
|
|
39
|
+
folderId: m
|
|
40
40
|
},
|
|
41
41
|
subPath: p
|
|
42
42
|
};
|
|
43
|
-
},
|
|
44
|
-
let t =
|
|
43
|
+
}, w = (e) => {
|
|
44
|
+
let t = S(e.folderId).split("/").filter(Boolean).slice(1);
|
|
45
45
|
return t.length ? t.join(" / ") : void 0;
|
|
46
|
-
},
|
|
46
|
+
}, T = (e) => e.map((e) => `"${e}"`).join(", "), E = (e, n) => {
|
|
47
47
|
if (!e) return;
|
|
48
48
|
let { fileId: r, anchor: i } = t(e), a = n.get(r);
|
|
49
49
|
if (a != null) return {
|
|
50
50
|
...a,
|
|
51
51
|
url: `${a.url}${i}`
|
|
52
52
|
};
|
|
53
|
-
},
|
|
54
|
-
let n =
|
|
53
|
+
}, D = (e, t) => {
|
|
54
|
+
let n = E(e.url, t), r = E(e.reference_url, t);
|
|
55
55
|
if (n == null && r == null) return;
|
|
56
56
|
let i = n?.title ?? r?.title;
|
|
57
57
|
return {
|
|
@@ -59,19 +59,19 @@ var s = class extends Error {
|
|
|
59
59
|
...r == null ? {} : { reference_url: r.url },
|
|
60
60
|
...i == null ? {} : { title: i }
|
|
61
61
|
};
|
|
62
|
-
},
|
|
62
|
+
}, O = (e, t) => e.map((e) => e.attachments?.length ? {
|
|
63
63
|
...e,
|
|
64
64
|
attachments: e.attachments.map((e) => {
|
|
65
|
-
let n =
|
|
65
|
+
let n = D(e, t);
|
|
66
66
|
return n ? {
|
|
67
67
|
...e,
|
|
68
68
|
...n
|
|
69
69
|
} : e;
|
|
70
70
|
})
|
|
71
|
-
} : e),
|
|
71
|
+
} : e), k = (e, t) => e.map((e) => {
|
|
72
72
|
let n = e.body?.source;
|
|
73
73
|
if (n?.attachment == null) return e;
|
|
74
|
-
let r =
|
|
74
|
+
let r = D(n.attachment, t);
|
|
75
75
|
return r == null ? e : {
|
|
76
76
|
...e,
|
|
77
77
|
body: {
|
|
@@ -85,7 +85,7 @@ var s = class extends Error {
|
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
};
|
|
88
|
-
}),
|
|
88
|
+
}), A = (e, t) => ({
|
|
89
89
|
...e,
|
|
90
90
|
messages: e.messages.map((e) => {
|
|
91
91
|
let n = e.custom_content;
|
|
@@ -96,23 +96,72 @@ var s = class extends Error {
|
|
|
96
96
|
custom_content: {
|
|
97
97
|
...n,
|
|
98
98
|
...r?.length ? { attachments: r.map((e) => {
|
|
99
|
-
let n =
|
|
99
|
+
let n = D(e, t);
|
|
100
100
|
return n ? {
|
|
101
101
|
...e,
|
|
102
102
|
...n
|
|
103
103
|
} : e;
|
|
104
104
|
}) } : {},
|
|
105
|
-
...i?.length ? { stages:
|
|
106
|
-
...a?.length ? { annotations:
|
|
105
|
+
...i?.length ? { stages: O(i, t) } : {},
|
|
106
|
+
...a?.length ? { annotations: k(a, t) } : {}
|
|
107
107
|
}
|
|
108
108
|
};
|
|
109
109
|
})
|
|
110
|
-
}),
|
|
110
|
+
}), j = (e, i) => {
|
|
111
|
+
if (!e) return;
|
|
112
|
+
let a = n(t(e).fileId);
|
|
113
|
+
if (!(!a || a.bucket === i || a.bucket === r)) return a.path.split("/").pop() || a.path;
|
|
114
|
+
}, M = (e, t, n) => e.flatMap((e) => {
|
|
115
|
+
let r = j(e.url, t);
|
|
116
|
+
if (r != null) return n.push(r), [];
|
|
117
|
+
let i = j(e.reference_url, t);
|
|
118
|
+
if (i == null) return [e];
|
|
119
|
+
n.push(i);
|
|
120
|
+
let { reference_url: a, reference_type: o, ...s } = e;
|
|
121
|
+
return s.url == null && s.data == null ? [] : [s];
|
|
122
|
+
}), N = (e, t, n) => e.map((e) => {
|
|
123
|
+
let r = e.body, i = j(r?.source?.attachment?.url, t);
|
|
124
|
+
if (r == null || i == null) return e;
|
|
125
|
+
n.push(i);
|
|
126
|
+
let { source: a, ...o } = r;
|
|
127
|
+
return {
|
|
128
|
+
...e,
|
|
129
|
+
body: o
|
|
130
|
+
};
|
|
131
|
+
}), P = (e, t) => {
|
|
132
|
+
let n = [], r = e.messages.map((e) => {
|
|
133
|
+
let r = e.custom_content;
|
|
134
|
+
if (!r) return e;
|
|
135
|
+
let { attachments: i, stages: a, annotations: o } = r;
|
|
136
|
+
return !i?.length && !a?.length && !o?.length ? e : {
|
|
137
|
+
...e,
|
|
138
|
+
custom_content: {
|
|
139
|
+
...r,
|
|
140
|
+
...i?.length ? { attachments: M(i, t, n) } : {},
|
|
141
|
+
...a?.length ? { stages: a.map((e) => e.attachments?.length ? {
|
|
142
|
+
...e,
|
|
143
|
+
attachments: M(e.attachments, t, n)
|
|
144
|
+
} : e) } : {},
|
|
145
|
+
...o?.length ? { annotations: N(o, t, n) } : {}
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
});
|
|
149
|
+
return n.length ? {
|
|
150
|
+
conversation: {
|
|
151
|
+
...e,
|
|
152
|
+
messages: r
|
|
153
|
+
},
|
|
154
|
+
droppedNames: n
|
|
155
|
+
} : {
|
|
156
|
+
conversation: e,
|
|
157
|
+
droppedNames: n
|
|
158
|
+
};
|
|
159
|
+
}, F = (e) => e.split("/").pop() || e, I = (t, r, i) => {
|
|
111
160
|
let a = [], o = [];
|
|
112
161
|
for (let s of e(t)) {
|
|
113
162
|
let e = n(s.fileId);
|
|
114
163
|
if (!e) {
|
|
115
|
-
o.push(
|
|
164
|
+
o.push(F(s.fileId));
|
|
116
165
|
continue;
|
|
117
166
|
}
|
|
118
167
|
let t = e.path.split("/").pop() ?? e.path, c = r.get(e.path);
|
|
@@ -133,4 +182,4 @@ var s = class extends Error {
|
|
|
133
182
|
};
|
|
134
183
|
};
|
|
135
184
|
//#endregion
|
|
136
|
-
export {
|
|
185
|
+
export { c as UnsupportedImportFormatError, P as dropForeignAttachmentRefs, T as formatQuotedNameList, w as getFolderBreadcrumb, d as parseImportEnvelope, I as planAttachmentUploads, C as rebaseConversationId, A as rewriteAttachmentUrls };
|
|
@@ -1,93 +1,133 @@
|
|
|
1
1
|
//#region src/conversation/create-chat-stream-api.ts
|
|
2
|
-
var e = { "Content-Type": "application/json" }, t = 409, n = "
|
|
3
|
-
|
|
2
|
+
var e = { "Content-Type": "application/json" }, t = 409, n = "The response could not be saved. It is still shown here, but may be lost if you reload or leave this page. Copy it before continuing.", r = class extends Error {
|
|
3
|
+
static type = "conversation_save_failed";
|
|
4
|
+
status;
|
|
5
|
+
constructor(e) {
|
|
6
|
+
super(n), this.name = "GenerationPersistenceError", this.status = e;
|
|
7
|
+
}
|
|
8
|
+
}, i = "A response is already being generated in this conversation. Wait for it to finish or stop it before sending another message.", a = class extends Error {
|
|
9
|
+
constructor(e = i) {
|
|
4
10
|
super(e), this.name = "GenerationConflictError";
|
|
5
11
|
}
|
|
6
|
-
},
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
}, o = class extends Error {
|
|
13
|
+
constructor(e) {
|
|
14
|
+
super(e), this.name = "StreamUpstreamError";
|
|
15
|
+
}
|
|
16
|
+
}, s = class extends Error {
|
|
17
|
+
constructor(e) {
|
|
18
|
+
super("The completion stream was interrupted", { cause: e }), this.name = "StreamInterruptedError";
|
|
19
|
+
}
|
|
20
|
+
}, c = 45e3, l = (e, t) => {
|
|
21
|
+
let n = Date.now(), r, i = !1, a = () => {
|
|
22
|
+
if (i) return;
|
|
23
|
+
let o = Date.now() - n;
|
|
24
|
+
if (o >= e) {
|
|
25
|
+
t();
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
clearTimeout(r), r = setTimeout(a, e - o);
|
|
29
|
+
}, o = () => {
|
|
30
|
+
document.visibilityState === "visible" && a();
|
|
31
|
+
}, s = typeof window < "u" && typeof document < "u";
|
|
32
|
+
return s && (document.addEventListener("visibilitychange", o), window.addEventListener("online", a), window.addEventListener("pageshow", a)), r = setTimeout(a, e), {
|
|
33
|
+
touch: () => {
|
|
34
|
+
n = Date.now();
|
|
35
|
+
},
|
|
36
|
+
stop: () => {
|
|
37
|
+
i || (i = !0, clearTimeout(r), s && (document.removeEventListener("visibilitychange", o), window.removeEventListener("online", a), window.removeEventListener("pageshow", a)));
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}, u = (e) => typeof e == "object" && !!e && e.name === "AbortError", d = (e) => {
|
|
41
|
+
let { status: t } = e;
|
|
42
|
+
return typeof t == "number" ? t : void 0;
|
|
43
|
+
}, f = (e, t, n) => {
|
|
44
|
+
let i = e.trim();
|
|
45
|
+
if (!i || i.startsWith(":") || !i.startsWith("data: ")) return;
|
|
46
|
+
let a = i.slice(6);
|
|
47
|
+
if (a !== "[DONE]") try {
|
|
48
|
+
let e = JSON.parse(a);
|
|
12
49
|
if (e.error) {
|
|
13
|
-
n(
|
|
50
|
+
n(e.error.type === r.type ? new r(d(e.error)) : new o(e.error.message));
|
|
14
51
|
return;
|
|
15
52
|
}
|
|
16
53
|
t(e);
|
|
17
54
|
} catch {}
|
|
18
|
-
},
|
|
19
|
-
let { completionsBasePath:
|
|
55
|
+
}, p = (n) => {
|
|
56
|
+
let { completionsBasePath: r } = n, i = (...e) => (n.fetchImpl ?? fetch)(...e);
|
|
20
57
|
return {
|
|
21
|
-
streamCompletion: (
|
|
22
|
-
let { onChunk:
|
|
58
|
+
streamCompletion: (o, c, d, p, m, h, g, _, v) => {
|
|
59
|
+
let { onChunk: y, onComplete: b, onError: x, signal: S } = p;
|
|
23
60
|
(async () => {
|
|
24
|
-
let
|
|
61
|
+
let p;
|
|
25
62
|
try {
|
|
26
63
|
let t = n.getTimezone?.();
|
|
27
|
-
|
|
64
|
+
p = await i(`${r}/completions`, {
|
|
28
65
|
method: "POST",
|
|
29
66
|
credentials: "include",
|
|
30
|
-
signal:
|
|
67
|
+
signal: S,
|
|
31
68
|
headers: {
|
|
32
69
|
...e,
|
|
33
70
|
...n.getCsrfToken() == null ? {} : { "X-CSRF-Token": n.getCsrfToken() },
|
|
34
71
|
...t ? { "X-Timezone": t } : {}
|
|
35
72
|
},
|
|
36
73
|
body: JSON.stringify({
|
|
37
|
-
path:
|
|
74
|
+
path: o,
|
|
38
75
|
message: c ?? "",
|
|
39
|
-
model:
|
|
40
|
-
custom_content:
|
|
41
|
-
...
|
|
42
|
-
...
|
|
43
|
-
...
|
|
44
|
-
...
|
|
76
|
+
model: d,
|
|
77
|
+
custom_content: m || {},
|
|
78
|
+
...h != null && { generationId: h },
|
|
79
|
+
...g != null && { mode: g },
|
|
80
|
+
..._ != null && { messageIndex: _ },
|
|
81
|
+
...v != null && { clientChannelId: v }
|
|
45
82
|
})
|
|
46
83
|
});
|
|
47
84
|
} catch (e) {
|
|
48
|
-
if (e
|
|
49
|
-
|
|
85
|
+
if (u(e)) return;
|
|
86
|
+
x(new s(e));
|
|
50
87
|
return;
|
|
51
88
|
}
|
|
52
|
-
let
|
|
53
|
-
if (
|
|
54
|
-
if (
|
|
55
|
-
|
|
89
|
+
let C = p.headers.get("x-csrf-token");
|
|
90
|
+
if (C && n.setCsrfToken(C), !p.ok) {
|
|
91
|
+
if (p.status === t) {
|
|
92
|
+
x(new a());
|
|
56
93
|
return;
|
|
57
94
|
}
|
|
58
|
-
|
|
95
|
+
x(/* @__PURE__ */ Error(`Stream request failed with status ${p.status}`));
|
|
59
96
|
return;
|
|
60
97
|
}
|
|
61
|
-
if (!
|
|
62
|
-
|
|
98
|
+
if (!p.body) {
|
|
99
|
+
x(/* @__PURE__ */ Error("No response body"));
|
|
63
100
|
return;
|
|
64
101
|
}
|
|
65
|
-
let
|
|
66
|
-
|
|
67
|
-
}
|
|
102
|
+
let w = p.body.getReader(), T = new TextDecoder(), E = "", D = !1, O = !1, k = (e) => {
|
|
103
|
+
D || (D = !0, A.stop(), x(e));
|
|
104
|
+
}, A = l(n.idleTimeoutMs ?? 45e3, () => {
|
|
105
|
+
O = !0, k(new s()), w.cancel().catch(() => void 0);
|
|
106
|
+
});
|
|
68
107
|
try {
|
|
69
108
|
for (;;) {
|
|
70
|
-
let { done: e, value: t } = await
|
|
109
|
+
let { done: e, value: t } = await w.read();
|
|
110
|
+
if (O) break;
|
|
71
111
|
if (e) {
|
|
72
|
-
|
|
112
|
+
E.trim() && f(E, y, k);
|
|
73
113
|
break;
|
|
74
114
|
}
|
|
75
|
-
|
|
76
|
-
let n =
|
|
77
|
-
|
|
78
|
-
for (let e of n)
|
|
115
|
+
A.touch(), E += T.decode(t, { stream: !0 });
|
|
116
|
+
let n = E.split("\n");
|
|
117
|
+
E = n.pop() ?? "";
|
|
118
|
+
for (let e of n) f(e, y, k);
|
|
79
119
|
}
|
|
80
|
-
|
|
120
|
+
D || (D = !0, b());
|
|
81
121
|
} catch (e) {
|
|
82
|
-
if (e
|
|
83
|
-
|
|
122
|
+
if (u(e)) return;
|
|
123
|
+
k(new s(e));
|
|
84
124
|
} finally {
|
|
85
|
-
|
|
125
|
+
A.stop(), w.releaseLock();
|
|
86
126
|
}
|
|
87
127
|
})();
|
|
88
128
|
},
|
|
89
129
|
stopCompletion: async (t) => {
|
|
90
|
-
let
|
|
130
|
+
let a = await i(`${r}/completions/stop`, {
|
|
91
131
|
method: "POST",
|
|
92
132
|
credentials: "include",
|
|
93
133
|
headers: {
|
|
@@ -95,10 +135,10 @@ var e = { "Content-Type": "application/json" }, t = 409, n = "A response is alre
|
|
|
95
135
|
...n.getCsrfToken() == null ? {} : { "X-CSRF-Token": n.getCsrfToken() }
|
|
96
136
|
},
|
|
97
137
|
body: JSON.stringify(t)
|
|
98
|
-
}),
|
|
99
|
-
if (
|
|
138
|
+
}), o = a.headers.get("x-csrf-token");
|
|
139
|
+
if (o && n.setCsrfToken(o), !a.ok) throw Error(`stopCompletion failed: ${a.status}`);
|
|
100
140
|
}
|
|
101
141
|
};
|
|
102
142
|
};
|
|
103
143
|
//#endregion
|
|
104
|
-
export {
|
|
144
|
+
export { i as DEFAULT_GENERATION_CONFLICT_MESSAGE, n as DEFAULT_GENERATION_PERSISTENCE_ERROR_MESSAGE, c as DEFAULT_STREAM_IDLE_TIMEOUT_MS, a as GenerationConflictError, r as GenerationPersistenceError, s as StreamInterruptedError, o as StreamUpstreamError, p as createChatStreamApi };
|
|
@@ -1,14 +1,20 @@
|
|
|
1
|
+
import { findDeploymentByIdOrReference as e } from "../catalog/deployment-id.js";
|
|
1
2
|
//#region src/conversation/get-model-id-from-conversation-id.ts
|
|
2
|
-
var
|
|
3
|
-
let [r, i] =
|
|
4
|
-
return n &&
|
|
5
|
-
},
|
|
6
|
-
let n =
|
|
3
|
+
var t = "__", n = /[-+]/, r = /^\d+$/, i = ".scheduler", a = "applications", o = (e) => e ? e.split(n)[0].split(".").every((e) => r.test(e)) : !1, s = (e, n) => {
|
|
4
|
+
let [r, i] = e.split(t);
|
|
5
|
+
return n && o(i) ? [r, i].join(t) : r;
|
|
6
|
+
}, c = (e) => {
|
|
7
|
+
let n = e.split("/");
|
|
7
8
|
if (n.length < 3) return;
|
|
8
|
-
let
|
|
9
|
+
let r = n.slice(2), o = r[0] === i ? r.slice(2) : r, c = o.findIndex((e) => e.includes(t));
|
|
9
10
|
if (c === -1) return;
|
|
10
|
-
let l =
|
|
11
|
+
let l = o[c], u = o.slice(0, c).filter(Boolean), d = s(l, u.at(-2) === a), f = [...u, d].filter(Boolean);
|
|
11
12
|
return f.length > 0 ? f.join("/") : void 0;
|
|
12
|
-
}
|
|
13
|
+
}, l = (e) => {
|
|
14
|
+
let t = c(e);
|
|
15
|
+
if (!t) return [];
|
|
16
|
+
let n = t.split("/");
|
|
17
|
+
return n.map((e, t) => n.slice(t).join("/"));
|
|
18
|
+
}, u = (t, n) => l(n).map((n) => e(t, n)).find(Boolean);
|
|
13
19
|
//#endregion
|
|
14
|
-
export {
|
|
20
|
+
export { u as findDeploymentForConversationId, l as getModelIdCandidatesFromConversationId, c as getModelIdFromConversationId };
|
|
@@ -9,6 +9,48 @@ var i = (t, n, r, i) => i && n === r - 1 && t.role === e.Assistant, a = (e) => {
|
|
|
9
9
|
return null;
|
|
10
10
|
}, o = (t) => t.role === e.Assistant && (t.custom_content?.stages?.length ?? 0) > 0, s = (t) => {
|
|
11
11
|
for (let n = t.length - 1; n >= 0; n--) if (t[n].role === e.User) return t[n].custom_content?.configuration_value;
|
|
12
|
-
}, c = (e) =>
|
|
12
|
+
}, c = (e) => {
|
|
13
|
+
if (typeof e.default == "boolean") return e.default;
|
|
14
|
+
let t = e.oneOf;
|
|
15
|
+
if (Array.isArray(t) && t.length === 1) {
|
|
16
|
+
let e = t[0];
|
|
17
|
+
if (typeof e == "object" && e && "const" in e && typeof e.const == "boolean") return e.const;
|
|
18
|
+
}
|
|
19
|
+
}, l = (e) => {
|
|
20
|
+
let t = e?.properties;
|
|
21
|
+
if (t == null) return;
|
|
22
|
+
let n = Object.entries(t).flatMap(([e, t]) => {
|
|
23
|
+
let n = c(t);
|
|
24
|
+
return n === void 0 ? [] : [[e, n]];
|
|
25
|
+
});
|
|
26
|
+
return n.length > 0 ? Object.fromEntries(n) : void 0;
|
|
27
|
+
}, u = (t) => {
|
|
28
|
+
let n = -1;
|
|
29
|
+
for (let r = t.length - 1; r >= 0; r--) if (t[r].role === e.User) {
|
|
30
|
+
n = r;
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
let r = t[n]?.custom_content?.configuration_value;
|
|
34
|
+
for (let i = n + 1; i < t.length; i++) {
|
|
35
|
+
let n = t[i];
|
|
36
|
+
if (n.role !== e.Assistant) continue;
|
|
37
|
+
let a = l(n.custom_content?.form_schema);
|
|
38
|
+
a && (r = {
|
|
39
|
+
...r,
|
|
40
|
+
...a
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return r;
|
|
44
|
+
}, d = (t, n, r) => {
|
|
45
|
+
let i = n.length - 1, a = n[i];
|
|
46
|
+
if (a?.role !== e.Assistant) return;
|
|
47
|
+
let o = l(a.custom_content?.form_schema);
|
|
48
|
+
if (!o) return;
|
|
49
|
+
let s = Object.fromEntries(r.filter((e) => e in o).sort().map((e) => [e, o[e]]));
|
|
50
|
+
if (Object.keys(s).length !== 0) return {
|
|
51
|
+
key: `${t}|${i}|${JSON.stringify(s)}`,
|
|
52
|
+
values: s
|
|
53
|
+
};
|
|
54
|
+
}, f = (e) => (e ?? "").toLowerCase().replace(/[^a-z]/g, "") === "plaintext" ? t.PlainText : t.Markdown;
|
|
13
55
|
//#endregion
|
|
14
|
-
export { a as getLastDeploymentId, s as getLastUserMessageToolConfiguration, i as isMessageStreaming, o as messageHasStages,
|
|
56
|
+
export { d as getFormSchemaToolSyncKey, a as getLastDeploymentId, s as getLastUserMessageToolConfiguration, u as getLatestToolConfiguration, l as getToolConfigurationFromFormSchema, i as isMessageStreaming, o as messageHasStages, f as normalizeResponseFormat };
|
package/conversation/stage.js
CHANGED
|
@@ -14,10 +14,14 @@ var t = (t) => t === e.Completed ? e.Completed : t === e.Failed ? e.Failed : nul
|
|
|
14
14
|
status: t(e.status),
|
|
15
15
|
...e.content != null && { content: e.content },
|
|
16
16
|
...e.tag != null && { tag: e.tag },
|
|
17
|
-
...e.attachments?.length && { attachments: e.attachments.map(n) }
|
|
17
|
+
...e.attachments?.length && { attachments: e.attachments.map(n) },
|
|
18
|
+
...e.parent_stage_index != null && { parent_stage_index: e.parent_stage_index }
|
|
18
19
|
}), i = (e) => {
|
|
19
20
|
let t = Array.isArray(e) ? e : e?.custom_content?.stages ?? e?.customContent?.stages;
|
|
20
|
-
if (t?.length) return t.map(r
|
|
21
|
+
if (t?.length) return t.map((e, t) => r(e.index == null ? {
|
|
22
|
+
...e,
|
|
23
|
+
index: t
|
|
24
|
+
} : e));
|
|
21
25
|
};
|
|
22
26
|
//#endregion
|
|
23
27
|
export { i as mapStages, r as toStage };
|
|
@@ -2,17 +2,16 @@ import { useEffect as e, useMemo as t } from "react";
|
|
|
2
2
|
//#region src/conversation/useActiveConversationSync/useActiveConversationSync.ts
|
|
3
3
|
var n = ({ activeConversationId: n, items: r, refreshConversations: i, markConversationViewed: a, conversationIdsMatch: o, toPanelConversationId: s }) => {
|
|
4
4
|
let c = t(() => n ? s(n) : void 0, [n, s]);
|
|
5
|
-
|
|
5
|
+
e(() => {
|
|
6
6
|
c && (r.some((e) => o(e.id, c)) || i());
|
|
7
|
-
}, [c, o])
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
}, [c, o]);
|
|
8
|
+
let l = c ? r.find((e) => o(e.id, c))?.id : void 0;
|
|
9
|
+
return e(() => {
|
|
10
|
+
c && l && a(l);
|
|
11
11
|
}, [
|
|
12
12
|
c,
|
|
13
|
-
|
|
14
|
-
a
|
|
15
|
-
o
|
|
13
|
+
l,
|
|
14
|
+
a
|
|
16
15
|
]), c;
|
|
17
16
|
};
|
|
18
17
|
//#endregion
|
|
@@ -171,12 +171,12 @@ var S = 5, C = 512 * 1024 * 1024, w = 429, T = 5, E = 2e3, D = (e) => e instance
|
|
|
171
171
|
}, s);
|
|
172
172
|
return I.startJob(c, (e) => R(c, t, i, o, s, e));
|
|
173
173
|
}, [I, R]), B = b(async (e, t, n) => {
|
|
174
|
-
let r = d.ExportAll, a = [],
|
|
174
|
+
let r = d.ExportAll, a = [], c;
|
|
175
175
|
do {
|
|
176
176
|
if (n.aborted) return;
|
|
177
177
|
let t;
|
|
178
178
|
try {
|
|
179
|
-
t = await x.listConversations({ nextToken:
|
|
179
|
+
t = await x.listConversations({ nextToken: c }, { signal: n });
|
|
180
180
|
} catch (t) {
|
|
181
181
|
if (n.aborted) return;
|
|
182
182
|
if (E(t).isUnauthorized) F?.({
|
|
@@ -197,18 +197,18 @@ var S = 5, C = 512 * 1024 * 1024, w = 429, T = 5, E = 2e3, D = (e) => e instance
|
|
|
197
197
|
a.push(...t.items.filter(j).map((e) => ({
|
|
198
198
|
id: e.id,
|
|
199
199
|
title: e.title
|
|
200
|
-
}))),
|
|
201
|
-
} while (
|
|
200
|
+
}))), c = t.nextToken;
|
|
201
|
+
} while (c);
|
|
202
202
|
I.setJobProgress(e, p({
|
|
203
203
|
kind: r,
|
|
204
204
|
phase: f.Prepare
|
|
205
205
|
}));
|
|
206
|
-
let
|
|
206
|
+
let l = [];
|
|
207
207
|
for (let t of a) {
|
|
208
208
|
if (n.aborted) return;
|
|
209
209
|
try {
|
|
210
210
|
let e = await A(x, T(t.id), n);
|
|
211
|
-
|
|
211
|
+
l.push(e);
|
|
212
212
|
} catch (r) {
|
|
213
213
|
if (n.aborted) return;
|
|
214
214
|
let i = E(r);
|
|
@@ -240,17 +240,17 @@ var S = 5, C = 512 * 1024 * 1024, w = 429, T = 5, E = 2e3, D = (e) => e instance
|
|
|
240
240
|
I.setJobProgress(e, p({
|
|
241
241
|
kind: r,
|
|
242
242
|
phase: f.Transfer,
|
|
243
|
-
completed:
|
|
243
|
+
completed: l.length,
|
|
244
244
|
total: a.length
|
|
245
245
|
}, {
|
|
246
|
-
completed:
|
|
246
|
+
completed: l.length,
|
|
247
247
|
total: a.length,
|
|
248
248
|
kind: v.Conversation
|
|
249
249
|
}));
|
|
250
250
|
}
|
|
251
251
|
}
|
|
252
252
|
if (!n.aborted) try {
|
|
253
|
-
y(o(i(
|
|
253
|
+
y(o(i(l.map(s), [])), t), k?.({ jobId: e }), I.succeedJob(e);
|
|
254
254
|
} catch (t) {
|
|
255
255
|
let n = M(t) ? g.FileTooLarge : g.Unknown, r = await D(t);
|
|
256
256
|
F?.({
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { MessageRole as e } from "@epam/ai-dial-chat-shared";
|
|
2
2
|
//#region src/conversation/useConversationHandlers/message-utils.ts
|
|
3
|
-
var t = (e) => e != null && Object.keys(e).length > 0, n = (e,
|
|
3
|
+
var t = (e) => e != null && Object.keys(e).length > 0, n = (e, n) => t(n) ? {
|
|
4
|
+
...e,
|
|
5
|
+
configuration_value: n
|
|
6
|
+
} : e, r = (e, t) => (e?.length ?? 0) === (t?.length ?? 0) ? (e ?? []).some((e, n) => e.url !== t?.[n]?.url) : !0, i = (e, t, n, i, a) => {
|
|
4
7
|
if (t !== e.content || i.length > 0) return !0;
|
|
5
8
|
let o = e.custom_content?.attachments?.length ?? 0;
|
|
6
|
-
return
|
|
7
|
-
},
|
|
9
|
+
return n.length === o ? a != null && r(e.custom_content?.skills, a) : !0;
|
|
10
|
+
}, a = (t) => t == null || t.role !== e.Assistant || !!t.wasStoppedByUser || t.streamErrorMessage != null, o = (e, t, n, r, o, s) => {
|
|
8
11
|
let c = e[t];
|
|
9
|
-
return c ?
|
|
12
|
+
return c ? i(c, n, r, o, s) || a(e[t + 1]) : !1;
|
|
10
13
|
};
|
|
11
14
|
//#endregion
|
|
12
|
-
export { t as hasActiveToolConfig,
|
|
15
|
+
export { t as hasActiveToolConfig, a as isAnswerIncomplete, i as isMessageChanged, o as shouldRerunGenerationOnEdit, n as withToolConfiguration };
|