@epam/ai-dial-chat-hooks 1.2.0-rc.0 → 1.2.0-rc.2
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/catalog/useCatalogEditNavigation/useCatalogEditNavigation.js +136 -119
- package/catalog.d.ts +3 -0
- package/conversation/create-chat-stream-api.js +14 -10
- package/conversation/useConversationStream/useConversationStream.js +98 -77
- package/conversation.d.ts +14 -1
- package/file-manager.d.ts +17 -4
- package/file-manager.js +25 -25
- package/files/dial-file-manager.model.js +7 -3
- package/files/dial-file-manager.types.js +1 -1
- package/files/useDialFileListing/useDialFileListing.js +24 -14
- package/files/useDialFileManager/useDialFileManager.js +148 -140
- package/files/useDialFileSharing/useDialFileSharing.js +45 -39
- package/index.d.ts +34 -5
- package/index.js +43 -43
- package/package.json +16 -16
|
@@ -5,126 +5,143 @@ import { getRunnerSchemas as r, isQuickAppSchema as i } from "../../shared/appli
|
|
|
5
5
|
import { CatalogEntityType as a } from "@epam/ai-dial-chat-shared";
|
|
6
6
|
import { useCallback as o, useMemo as s, useState as c } from "react";
|
|
7
7
|
//#region src/catalog/useCatalogEditNavigation/useCatalogEditNavigation.ts
|
|
8
|
-
var l = ({ deployments:
|
|
9
|
-
let
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
onClick: k
|
|
96
|
-
}], i = t(D.createSkill) ? r : r.filter((e) => t(String(e.label)));
|
|
97
|
-
return i.length > 0 && n.push({
|
|
98
|
-
key: "skill",
|
|
99
|
-
label: D.createSkill,
|
|
100
|
-
children: i
|
|
101
|
-
}), m && t(D.createPrompt) && n.push({
|
|
8
|
+
var l = (e) => [...e].sort((e, t) => String(e.label ?? "").localeCompare(String(t.label ?? ""), void 0, { sensitivity: "base" })), u = ({ deployments: u, isCustomAppsEnabled: d, isSchemaAppsEnabled: f, isHideCustomAppCreationEnabled: p, isToolsetsEnabled: m, isPromptsEnabled: h, schemas: g, urls: _, onNavigate: v, deletePrompt: y, deleteToolset: b, deleteSkill: x, deleteApplication: S, refetchPrompts: C, refetchToolsets: w, refetchSkills: T, refetchDeployments: E, onDeleteSuccess: D, labels: O, onNotify: k, onSkillUploadClick: A }) => {
|
|
9
|
+
let j = s(() => r(g), [g]), [M, N] = c(""), P = f && !p, F = o((e) => {
|
|
10
|
+
if (e.type === a.Prompt) {
|
|
11
|
+
v(_.buildPromptEditUrl(e.id));
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if (e.type === a.Skill) {
|
|
15
|
+
v(_.buildSkillEditUrl(e.id));
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (e.type === a.Toolset) {
|
|
19
|
+
v(_.buildToolsetEditUrl(e.id));
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
let n = t(u, e.id);
|
|
23
|
+
if (d && n != null && !n.applicationTypeSchemaId) {
|
|
24
|
+
v(_.buildCustomAppEditUrl(e.id));
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
let r = j.find((e) => e.id === n?.applicationTypeSchemaId)?.id ?? j.find((e) => i(e))?.id;
|
|
28
|
+
r && v(_.buildQuickAppEditUrl(r, e.id));
|
|
29
|
+
}, [
|
|
30
|
+
u,
|
|
31
|
+
d,
|
|
32
|
+
j,
|
|
33
|
+
v,
|
|
34
|
+
_
|
|
35
|
+
]), I = o(async (t) => {
|
|
36
|
+
try {
|
|
37
|
+
if (t.type === a.Prompt) await y(t.id), await C();
|
|
38
|
+
else if (t.type === a.Toolset) await b(t.id), await w();
|
|
39
|
+
else if (t.type === a.Skill) {
|
|
40
|
+
let e = n(t.id);
|
|
41
|
+
if (e == null) throw Error(`Invalid skill resource url: ${t.id}`);
|
|
42
|
+
await x(e.bucket, e.path), await T();
|
|
43
|
+
} else await S(t.id), await E();
|
|
44
|
+
D(t);
|
|
45
|
+
} catch (t) {
|
|
46
|
+
let { traceId: n } = await e(t);
|
|
47
|
+
throw k({
|
|
48
|
+
message: O.deleteError,
|
|
49
|
+
requestId: n
|
|
50
|
+
}), t;
|
|
51
|
+
}
|
|
52
|
+
}, [
|
|
53
|
+
y,
|
|
54
|
+
b,
|
|
55
|
+
x,
|
|
56
|
+
S,
|
|
57
|
+
w,
|
|
58
|
+
E,
|
|
59
|
+
C,
|
|
60
|
+
T,
|
|
61
|
+
D,
|
|
62
|
+
O,
|
|
63
|
+
k
|
|
64
|
+
]), L = s(() => {
|
|
65
|
+
let e = M.trim().toLocaleLowerCase(), t = (t) => !e || t.toLocaleLowerCase().includes(e), n = P ? j.map((e) => ({
|
|
66
|
+
id: e.id,
|
|
67
|
+
label: e.displayName || e.id
|
|
68
|
+
})).filter((e) => t(e.label)).map((e) => ({
|
|
69
|
+
key: `runner:${e.id}`,
|
|
70
|
+
label: e.label,
|
|
71
|
+
onClick: () => v(_.buildQuickAppCreateUrl(e.id))
|
|
72
|
+
})) : [], r = m && t(O.createToolset) ? {
|
|
73
|
+
key: "toolset",
|
|
74
|
+
label: O.createToolset,
|
|
75
|
+
onClick: () => v(_.buildToolsetCreateUrl())
|
|
76
|
+
} : void 0, i = d && !p && t(O.createCustomApp) ? {
|
|
77
|
+
key: "custom-app",
|
|
78
|
+
label: O.createCustomApp,
|
|
79
|
+
onClick: () => v(_.buildCustomAppCreateUrl())
|
|
80
|
+
} : void 0, a = [{
|
|
81
|
+
key: "skill-write-instructions",
|
|
82
|
+
label: O.createSkillWriteInstructions,
|
|
83
|
+
onClick: () => v(_.buildSkillCreateUrl())
|
|
84
|
+
}, {
|
|
85
|
+
key: "skill-upload",
|
|
86
|
+
label: O.createSkillUpload,
|
|
87
|
+
onClick: A
|
|
88
|
+
}];
|
|
89
|
+
return {
|
|
90
|
+
runnerOptions: n,
|
|
91
|
+
toolsetOption: r,
|
|
92
|
+
customAppOption: i,
|
|
93
|
+
visibleSkillChildren: t(O.createSkill) ? a : a.filter((e) => t(String(e.label))),
|
|
94
|
+
promptOption: h && t(O.createPrompt) ? {
|
|
102
95
|
key: "prompt",
|
|
103
|
-
label:
|
|
104
|
-
onClick: () => _
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
96
|
+
label: O.createPrompt,
|
|
97
|
+
onClick: () => v(_.buildPromptCreateUrl())
|
|
98
|
+
} : void 0
|
|
99
|
+
};
|
|
100
|
+
}, [
|
|
101
|
+
M,
|
|
102
|
+
P,
|
|
103
|
+
j,
|
|
104
|
+
v,
|
|
105
|
+
_,
|
|
106
|
+
h,
|
|
107
|
+
O,
|
|
108
|
+
p,
|
|
109
|
+
m,
|
|
110
|
+
d,
|
|
111
|
+
A
|
|
112
|
+
]), R = s(() => {
|
|
113
|
+
let { runnerOptions: e, toolsetOption: t, customAppOption: n, visibleSkillChildren: r, promptOption: i } = L, a = [...e];
|
|
114
|
+
return t && a.push(t), n && a.push(n), r.length > 0 && a.push({
|
|
115
|
+
key: "skill",
|
|
116
|
+
label: O.createSkill,
|
|
117
|
+
children: r
|
|
118
|
+
}), i && a.push(i), l(a);
|
|
119
|
+
}, [L, O.createSkill]), z = s(() => P && j.length > 0 ? {
|
|
120
|
+
value: M,
|
|
121
|
+
onChange: N
|
|
122
|
+
} : void 0, [
|
|
123
|
+
P,
|
|
124
|
+
j.length,
|
|
125
|
+
M
|
|
126
|
+
]);
|
|
127
|
+
return {
|
|
128
|
+
handleEdit: F,
|
|
129
|
+
handleDelete: I,
|
|
130
|
+
createOptions: R,
|
|
131
|
+
createSearch: z,
|
|
132
|
+
createMenuByType: s(() => {
|
|
133
|
+
let { runnerOptions: e, toolsetOption: t, customAppOption: n, visibleSkillChildren: r, promptOption: i } = L;
|
|
134
|
+
return {
|
|
135
|
+
[a.Agent]: {
|
|
136
|
+
options: l(n ? [...e, n] : e),
|
|
137
|
+
search: z
|
|
138
|
+
},
|
|
139
|
+
[a.Toolset]: { options: t ? [t] : [] },
|
|
140
|
+
[a.Skill]: { options: r },
|
|
141
|
+
[a.Prompt]: { options: i ? [i] : [] }
|
|
142
|
+
};
|
|
143
|
+
}, [L, z])
|
|
127
144
|
};
|
|
128
145
|
};
|
|
129
146
|
//#endregion
|
|
130
|
-
export {
|
|
147
|
+
export { u as useCatalogEditNavigation };
|
package/catalog.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { CatalogItemDetailsFetchResult } from '@epam/ai-dial-catalog';
|
|
|
10
10
|
import { CatalogItemLimits } from '@epam/ai-dial-catalog';
|
|
11
11
|
import { CatalogItemOverview } from '@epam/ai-dial-catalog';
|
|
12
12
|
import { CatalogItemTabData } from '@epam/ai-dial-catalog';
|
|
13
|
+
import { CatalogTabCreateMenu } from '@epam/ai-dial-catalog';
|
|
13
14
|
import { CredentialsLevel } from '@epam/ai-dial-catalog';
|
|
14
15
|
import { DeploymentDetailsDto } from '@epam/ai-dial-chat-api-client';
|
|
15
16
|
import { DeploymentItemDto } from '@epam/ai-dial-chat-api-client';
|
|
@@ -1114,6 +1115,8 @@ export declare interface UseCatalogEditNavigationResult {
|
|
|
1114
1115
|
createOptions: DropdownItem[];
|
|
1115
1116
|
/** The Create menu's search field state, or `undefined` when no runner option is offered. */
|
|
1116
1117
|
createSearch: CatalogCreateSearch | undefined;
|
|
1118
|
+
/** The Create menu narrowed to each entity type; models have no entry since they cannot be created. */
|
|
1119
|
+
createMenuByType: Partial<Record<CatalogEntityType, CatalogTabCreateMenu>>;
|
|
1117
1120
|
}
|
|
1118
1121
|
|
|
1119
1122
|
/**
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
//#region src/conversation/create-chat-stream-api.ts
|
|
2
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
3
|
static type = "conversation_save_failed";
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
status;
|
|
5
|
+
constructor(e) {
|
|
6
|
+
super(n), this.name = "GenerationPersistenceError", this.status = e;
|
|
6
7
|
}
|
|
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 {
|
|
8
9
|
constructor(e = i) {
|
|
@@ -36,22 +37,25 @@ var e = { "Content-Type": "application/json" }, t = 409, n = "The response could
|
|
|
36
37
|
i || (i = !0, clearTimeout(r), s && (document.removeEventListener("visibilitychange", o), window.removeEventListener("online", a), window.removeEventListener("pageshow", a)));
|
|
37
38
|
}
|
|
38
39
|
};
|
|
39
|
-
}, u = (e) => typeof e == "object" && !!e && e.name === "AbortError", d = (e
|
|
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) => {
|
|
40
44
|
let i = e.trim();
|
|
41
45
|
if (!i || i.startsWith(":") || !i.startsWith("data: ")) return;
|
|
42
46
|
let a = i.slice(6);
|
|
43
47
|
if (a !== "[DONE]") try {
|
|
44
48
|
let e = JSON.parse(a);
|
|
45
49
|
if (e.error) {
|
|
46
|
-
n(e.error.type === r.type ? new r() : new o(e.error.message));
|
|
50
|
+
n(e.error.type === r.type ? new r(d(e.error)) : new o(e.error.message));
|
|
47
51
|
return;
|
|
48
52
|
}
|
|
49
53
|
t(e);
|
|
50
54
|
} catch {}
|
|
51
|
-
},
|
|
55
|
+
}, p = (n) => {
|
|
52
56
|
let { completionsBasePath: r } = n, i = (...e) => (n.fetchImpl ?? fetch)(...e);
|
|
53
57
|
return {
|
|
54
|
-
streamCompletion: (o, c,
|
|
58
|
+
streamCompletion: (o, c, d, p, m, h, g, _, v) => {
|
|
55
59
|
let { onChunk: y, onComplete: b, onError: x, signal: S } = p;
|
|
56
60
|
(async () => {
|
|
57
61
|
let p;
|
|
@@ -69,7 +73,7 @@ var e = { "Content-Type": "application/json" }, t = 409, n = "The response could
|
|
|
69
73
|
body: JSON.stringify({
|
|
70
74
|
path: o,
|
|
71
75
|
message: c ?? "",
|
|
72
|
-
model:
|
|
76
|
+
model: d,
|
|
73
77
|
custom_content: m || {},
|
|
74
78
|
...h != null && { generationId: h },
|
|
75
79
|
...g != null && { mode: g },
|
|
@@ -105,13 +109,13 @@ var e = { "Content-Type": "application/json" }, t = 409, n = "The response could
|
|
|
105
109
|
let { done: e, value: t } = await w.read();
|
|
106
110
|
if (O) break;
|
|
107
111
|
if (e) {
|
|
108
|
-
E.trim() &&
|
|
112
|
+
E.trim() && f(E, y, k);
|
|
109
113
|
break;
|
|
110
114
|
}
|
|
111
115
|
A.touch(), E += T.decode(t, { stream: !0 });
|
|
112
116
|
let n = E.split("\n");
|
|
113
117
|
E = n.pop() ?? "";
|
|
114
|
-
for (let e of n)
|
|
118
|
+
for (let e of n) f(e, y, k);
|
|
115
119
|
}
|
|
116
120
|
D || (D = !0, b());
|
|
117
121
|
} catch (e) {
|
|
@@ -137,4 +141,4 @@ var e = { "Content-Type": "application/json" }, t = 409, n = "The response could
|
|
|
137
141
|
};
|
|
138
142
|
};
|
|
139
143
|
//#endregion
|
|
140
|
-
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,
|
|
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 };
|