@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,256 +1,270 @@
|
|
|
1
1
|
import { useAttachmentUpload as e } from "../useAttachmentUpload/useAttachmentUpload.js";
|
|
2
2
|
import { attachmentsToDtos as t } from "./attachment-to-dto.js";
|
|
3
3
|
import { createMessagePair as n } from "./message-factory.js";
|
|
4
|
-
import { hasActiveToolConfig as r, shouldRerunGenerationOnEdit as i } from "./message-utils.js";
|
|
5
|
-
import { getStarterDisplayText as
|
|
6
|
-
import { getConversationPath as
|
|
7
|
-
import { MessageRole as
|
|
8
|
-
import { useCallback as
|
|
9
|
-
import { SendCompletionDtoModeEnum as
|
|
4
|
+
import { hasActiveToolConfig as r, shouldRerunGenerationOnEdit as i, withToolConfiguration as a } from "./message-utils.js";
|
|
5
|
+
import { getStarterDisplayText as o, getStarterSubmitText as s } from "./starter-option.js";
|
|
6
|
+
import { getConversationPath as c } from "../useConversationStream/conversation-path.js";
|
|
7
|
+
import { MessageRole as l, generateUUID as u } from "@epam/ai-dial-chat-shared";
|
|
8
|
+
import { useCallback as d, useState as f } from "react";
|
|
9
|
+
import { SendCompletionDtoModeEnum as p } from "@epam/ai-dial-chat-api-client";
|
|
10
10
|
//#region src/conversation/useConversationHandlers/useConversationHandlers.ts
|
|
11
|
-
var
|
|
12
|
-
let [
|
|
13
|
-
filesApi:
|
|
14
|
-
bucket:
|
|
15
|
-
onNetworkError:
|
|
16
|
-
}),
|
|
17
|
-
if (!
|
|
18
|
-
let o = t(i), s = r(
|
|
11
|
+
var m = ({ conversation: m, conversationId: h, bucket: g, isStreaming: _, startStream: v, state: { setConversation: y, conversationRef: b }, filesApi: x, conversationsApi: S, rateApi: C, resolveModelId: w, onConversationDeleted: T, showNetworkError: E, toolConfigurationValue: D }) => {
|
|
12
|
+
let [O, k] = f(null), [A, j] = f(/* @__PURE__ */ new Set()), [M, N] = f(null), { handleUploadAttachment: P } = e({
|
|
13
|
+
filesApi: x,
|
|
14
|
+
bucket: g,
|
|
15
|
+
onNetworkError: E
|
|
16
|
+
}), F = d(async (e, i, a) => {
|
|
17
|
+
if (!h || !m) return;
|
|
18
|
+
let o = t(i), s = r(D), c = o?.length || s || a?.length ? {
|
|
19
19
|
...o?.length ? { attachments: o } : {},
|
|
20
|
-
...s ? { configuration_value:
|
|
20
|
+
...s ? { configuration_value: D } : {},
|
|
21
21
|
...a?.length ? { skills: a } : {}
|
|
22
|
-
} : void 0,
|
|
23
|
-
|
|
22
|
+
} : void 0, l = w(), { userMessage: d, assistantMessage: f } = n(e, c, l);
|
|
23
|
+
y((e) => {
|
|
24
24
|
if (!e) return e;
|
|
25
25
|
let t = {
|
|
26
26
|
...e,
|
|
27
27
|
messages: [
|
|
28
28
|
...e.messages,
|
|
29
29
|
d,
|
|
30
|
-
|
|
30
|
+
f
|
|
31
31
|
]
|
|
32
32
|
};
|
|
33
|
-
return
|
|
34
|
-
}),
|
|
33
|
+
return b.current = t, t;
|
|
34
|
+
}), v(h, e, m.messages.length + 1, l, c, u(), p.Append);
|
|
35
35
|
}, [
|
|
36
|
-
p,
|
|
37
36
|
m,
|
|
37
|
+
h,
|
|
38
|
+
b,
|
|
39
|
+
w,
|
|
38
40
|
y,
|
|
39
|
-
C,
|
|
40
41
|
v,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (
|
|
45
|
-
let
|
|
46
|
-
if (!
|
|
47
|
-
let
|
|
48
|
-
...
|
|
42
|
+
D
|
|
43
|
+
]), I = d((e) => {
|
|
44
|
+
let t = b.current;
|
|
45
|
+
if (_ || !h || !t || e === -1 || t.messages[e]?.role !== l.Assistant) return;
|
|
46
|
+
let n = t.messages[e - 1];
|
|
47
|
+
if (!n || n.role !== l.User) return;
|
|
48
|
+
let r = w(), i = a(n.custom_content, D), o = {
|
|
49
|
+
...t.messages[e],
|
|
49
50
|
content: "",
|
|
50
51
|
custom_content: void 0,
|
|
51
52
|
wasStoppedByUser: void 0,
|
|
52
53
|
stoppedWithoutContent: void 0,
|
|
53
54
|
streamErrorMessage: void 0,
|
|
54
|
-
deploymentId:
|
|
55
|
-
},
|
|
56
|
-
...
|
|
57
|
-
messages: [
|
|
55
|
+
deploymentId: r
|
|
56
|
+
}, s = {
|
|
57
|
+
...t,
|
|
58
|
+
messages: [
|
|
59
|
+
...t.messages.slice(0, e - 1),
|
|
60
|
+
{
|
|
61
|
+
...n,
|
|
62
|
+
custom_content: i
|
|
63
|
+
},
|
|
64
|
+
o
|
|
65
|
+
]
|
|
58
66
|
};
|
|
59
|
-
|
|
67
|
+
b.current = s, y(s), j((t) => new Set([...t].filter((t) => t < e))), v(h, n.content, e, r, i, u(), p.Regenerate);
|
|
60
68
|
}, [
|
|
61
|
-
|
|
62
|
-
|
|
69
|
+
h,
|
|
70
|
+
b,
|
|
71
|
+
_,
|
|
72
|
+
w,
|
|
63
73
|
y,
|
|
64
|
-
g,
|
|
65
|
-
C,
|
|
66
74
|
v,
|
|
67
|
-
|
|
68
|
-
]),
|
|
69
|
-
|
|
70
|
-
}, [
|
|
71
|
-
if (!
|
|
72
|
-
let e =
|
|
73
|
-
|
|
74
|
-
let t =
|
|
75
|
+
D
|
|
76
|
+
]), L = d((e) => {
|
|
77
|
+
_ || k(e);
|
|
78
|
+
}, [_]), R = d(() => {
|
|
79
|
+
if (!h || O == null) return;
|
|
80
|
+
let e = O;
|
|
81
|
+
k(null);
|
|
82
|
+
let t = b.current;
|
|
75
83
|
if (!t || e === -1) return;
|
|
76
|
-
let n =
|
|
77
|
-
if (r.length === 0 || r.length === 1 && r[0].role ===
|
|
78
|
-
|
|
84
|
+
let n = c(h), r = t.messages[e + 1]?.role === l.Assistant ? t.messages.filter((t, n) => n !== e && n !== e + 1) : t.messages.filter((t, n) => n !== e);
|
|
85
|
+
if (r.length === 0 || r.length === 1 && r[0].role === l.Status) {
|
|
86
|
+
S.deleteConversation({ path: n }), T?.();
|
|
79
87
|
return;
|
|
80
88
|
}
|
|
81
89
|
let i = {
|
|
82
90
|
...t,
|
|
83
91
|
messages: r
|
|
84
92
|
};
|
|
85
|
-
|
|
93
|
+
b.current = i, y(i), S.saveConversation({
|
|
86
94
|
path: n,
|
|
87
95
|
saveConversationBodyDto: { conversation: i }
|
|
88
96
|
});
|
|
89
97
|
}, [
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
]),
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
98
|
+
h,
|
|
99
|
+
b,
|
|
100
|
+
S,
|
|
101
|
+
T,
|
|
102
|
+
O,
|
|
103
|
+
y
|
|
104
|
+
]), z = d(async (e, t, n) => {
|
|
105
|
+
let r = b.current;
|
|
106
|
+
if (!h || !r) return !1;
|
|
107
|
+
let i = r.messages[e];
|
|
108
|
+
if (!i) return !1;
|
|
109
|
+
let a = i.rating, o = {
|
|
110
|
+
...r,
|
|
111
|
+
messages: r.messages.map((n, r) => r === e ? {
|
|
103
112
|
...n,
|
|
104
113
|
rating: t ?? void 0
|
|
105
114
|
} : n)
|
|
106
115
|
};
|
|
107
|
-
|
|
108
|
-
let
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
116
|
+
y(() => (b.current = o, o));
|
|
117
|
+
let s = c(h), l = () => {
|
|
118
|
+
y((t) => {
|
|
119
|
+
if (!t) return t;
|
|
120
|
+
let n = {
|
|
112
121
|
...t,
|
|
113
|
-
|
|
114
|
-
|
|
122
|
+
messages: t.messages.map((t, n) => n === e ? {
|
|
123
|
+
...t,
|
|
124
|
+
rating: a
|
|
125
|
+
} : t)
|
|
126
|
+
};
|
|
127
|
+
return b.current = n, n;
|
|
115
128
|
});
|
|
116
|
-
},
|
|
117
|
-
path:
|
|
118
|
-
saveConversationBodyDto: { conversation:
|
|
119
|
-
}),
|
|
120
|
-
if (!
|
|
129
|
+
}, u = () => S.saveConversation({
|
|
130
|
+
path: s,
|
|
131
|
+
saveConversationBodyDto: { conversation: o }
|
|
132
|
+
}), d = i.responseId;
|
|
133
|
+
if (!d) return l(), !1;
|
|
121
134
|
try {
|
|
122
|
-
return await
|
|
123
|
-
conversationId:
|
|
124
|
-
responseId:
|
|
125
|
-
modelId:
|
|
135
|
+
return await C.rateMessage({ rateMessageDto: {
|
|
136
|
+
conversationId: r.id,
|
|
137
|
+
responseId: d,
|
|
138
|
+
modelId: r.model.id,
|
|
126
139
|
rate: t,
|
|
127
140
|
...n ? { comment: n } : {}
|
|
128
|
-
} }), await
|
|
141
|
+
} }), await u(), !0;
|
|
129
142
|
} catch {
|
|
130
|
-
return
|
|
143
|
+
return l(), !1;
|
|
131
144
|
}
|
|
132
145
|
}, [
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
y,
|
|
136
|
-
x,
|
|
146
|
+
h,
|
|
147
|
+
b,
|
|
137
148
|
S,
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
let
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
149
|
+
C,
|
|
150
|
+
y
|
|
151
|
+
]), B = d((e, t, i) => {
|
|
152
|
+
let a = b.current;
|
|
153
|
+
if (!h || !a) return;
|
|
154
|
+
let c = o(e, i), l = s(e, i), d = t ? { [t]: e.const } : void 0, f = r(D), m = d || f ? {
|
|
155
|
+
...d ? { form_value: d } : {},
|
|
156
|
+
...f ? { configuration_value: D } : {}
|
|
157
|
+
} : void 0, g = w(), { userMessage: _, assistantMessage: x } = n(c, m, g);
|
|
158
|
+
y((e) => {
|
|
146
159
|
if (!e) return e;
|
|
147
160
|
let t = {
|
|
148
161
|
...e,
|
|
149
162
|
messages: [
|
|
150
163
|
...e.messages,
|
|
151
|
-
|
|
164
|
+
_,
|
|
152
165
|
x
|
|
153
166
|
]
|
|
154
167
|
};
|
|
155
|
-
return
|
|
156
|
-
}),
|
|
168
|
+
return b.current = t, t;
|
|
169
|
+
}), v(h, l, a.messages.length + 1, g, m, u(), p.Append);
|
|
157
170
|
}, [
|
|
158
|
-
|
|
159
|
-
|
|
171
|
+
h,
|
|
172
|
+
b,
|
|
173
|
+
w,
|
|
160
174
|
y,
|
|
161
|
-
C,
|
|
162
175
|
v,
|
|
163
|
-
|
|
164
|
-
E
|
|
176
|
+
D
|
|
165
177
|
]);
|
|
166
178
|
return {
|
|
167
|
-
handleSend:
|
|
168
|
-
handleUploadAttachment:
|
|
169
|
-
handleRegenerateMessage:
|
|
170
|
-
handleDeleteMessage:
|
|
171
|
-
handleConfirmDelete:
|
|
172
|
-
handleRateMessage:
|
|
173
|
-
handleButtonSelect:
|
|
174
|
-
|
|
179
|
+
handleSend: F,
|
|
180
|
+
handleUploadAttachment: P,
|
|
181
|
+
handleRegenerateMessage: I,
|
|
182
|
+
handleDeleteMessage: L,
|
|
183
|
+
handleConfirmDelete: R,
|
|
184
|
+
handleRateMessage: z,
|
|
185
|
+
handleButtonSelect: d((e, t, n) => {
|
|
186
|
+
let r = b.current;
|
|
187
|
+
!h || !r || _ || (e["dial:widgetOptions"].confirmationMessage ? N({
|
|
175
188
|
starter: e,
|
|
176
189
|
propertyKey: t,
|
|
177
190
|
description: n
|
|
178
|
-
}) :
|
|
191
|
+
}) : B(e, t, n));
|
|
179
192
|
}, [
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
193
|
+
h,
|
|
194
|
+
b,
|
|
195
|
+
_,
|
|
196
|
+
B
|
|
184
197
|
]),
|
|
185
|
-
handleConfirmStarter:
|
|
186
|
-
if (!
|
|
187
|
-
let { starter: e, propertyKey: t, description: n } =
|
|
188
|
-
|
|
189
|
-
}, [
|
|
190
|
-
handleStartEdit:
|
|
191
|
-
|
|
198
|
+
handleConfirmStarter: d(() => {
|
|
199
|
+
if (!M) return;
|
|
200
|
+
let { starter: e, propertyKey: t, description: n } = M;
|
|
201
|
+
N(null), B(e, t, n);
|
|
202
|
+
}, [M, B]),
|
|
203
|
+
handleStartEdit: d((e) => {
|
|
204
|
+
j((t) => new Set([...t, e]));
|
|
192
205
|
}, []),
|
|
193
|
-
handleCancelEdit:
|
|
194
|
-
|
|
206
|
+
handleCancelEdit: d((e) => {
|
|
207
|
+
j((t) => {
|
|
195
208
|
let n = new Set(t);
|
|
196
209
|
return n.delete(e), n;
|
|
197
210
|
});
|
|
198
211
|
}, []),
|
|
199
|
-
handleEditMessage:
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
212
|
+
handleEditMessage: d(async (e, n, r, o, s) => {
|
|
213
|
+
let c = b.current;
|
|
214
|
+
if (_ || !h || !c) return;
|
|
215
|
+
let d = e;
|
|
216
|
+
if (d === -1 || c.messages[d].role !== l.User) return;
|
|
217
|
+
let f = c.messages[d];
|
|
218
|
+
if (!i(c.messages, d, n, r, o, s)) {
|
|
219
|
+
j((e) => {
|
|
206
220
|
let t = new Set(e);
|
|
207
|
-
return t.delete(
|
|
221
|
+
return t.delete(d), t;
|
|
208
222
|
});
|
|
209
223
|
return;
|
|
210
224
|
}
|
|
211
|
-
let
|
|
225
|
+
let m = t(o), g = new Set(r.map((e) => e.id)), x = [...(f.custom_content?.attachments ?? []).filter((e) => {
|
|
212
226
|
let t = e.url ?? e.data ?? e.title;
|
|
213
|
-
return
|
|
214
|
-
}), ...
|
|
215
|
-
|
|
216
|
-
...
|
|
217
|
-
...
|
|
218
|
-
...
|
|
219
|
-
} : Object.keys(
|
|
220
|
-
let
|
|
221
|
-
...
|
|
227
|
+
return g.has(t);
|
|
228
|
+
}), ...m ?? []], { attachments: S, skills: C, ...T } = f.custom_content ?? {}, E = s ?? C, O;
|
|
229
|
+
O = x.length > 0 || E?.length ? {
|
|
230
|
+
...T,
|
|
231
|
+
...x.length > 0 ? { attachments: x } : {},
|
|
232
|
+
...E?.length ? { skills: E } : {}
|
|
233
|
+
} : Object.keys(T).length > 0 ? T : void 0, O = a(O, D);
|
|
234
|
+
let k = {
|
|
235
|
+
...f,
|
|
222
236
|
content: n,
|
|
223
|
-
custom_content:
|
|
224
|
-
},
|
|
225
|
-
role:
|
|
237
|
+
custom_content: O
|
|
238
|
+
}, A = Date.now(), M = {
|
|
239
|
+
role: l.Assistant,
|
|
226
240
|
content: "",
|
|
227
|
-
timestamp: new Date(
|
|
228
|
-
},
|
|
229
|
-
...
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
],
|
|
233
|
-
...
|
|
234
|
-
messages:
|
|
241
|
+
timestamp: new Date(A).toISOString()
|
|
242
|
+
}, N = [
|
|
243
|
+
...c.messages.slice(0, d),
|
|
244
|
+
k,
|
|
245
|
+
M
|
|
246
|
+
], P = {
|
|
247
|
+
...c,
|
|
248
|
+
messages: N
|
|
235
249
|
};
|
|
236
|
-
|
|
237
|
-
let
|
|
238
|
-
|
|
250
|
+
b.current = P, y(P);
|
|
251
|
+
let F = w();
|
|
252
|
+
v(h, n, N.length - 1, F, O, u(), p.Edit), j(/* @__PURE__ */ new Set());
|
|
239
253
|
}, [
|
|
240
|
-
|
|
241
|
-
|
|
254
|
+
h,
|
|
255
|
+
b,
|
|
256
|
+
_,
|
|
257
|
+
w,
|
|
242
258
|
y,
|
|
243
|
-
g,
|
|
244
|
-
C,
|
|
245
259
|
v,
|
|
246
|
-
|
|
260
|
+
D
|
|
247
261
|
]),
|
|
248
|
-
editingMessageIndexes:
|
|
249
|
-
pendingDeleteIndex:
|
|
250
|
-
setPendingDeleteIndex:
|
|
251
|
-
pendingStarterContext:
|
|
252
|
-
setPendingStarterContext:
|
|
262
|
+
editingMessageIndexes: A,
|
|
263
|
+
pendingDeleteIndex: O,
|
|
264
|
+
setPendingDeleteIndex: k,
|
|
265
|
+
pendingStarterContext: M,
|
|
266
|
+
setPendingStarterContext: N
|
|
253
267
|
};
|
|
254
268
|
};
|
|
255
269
|
//#endregion
|
|
256
|
-
export {
|
|
270
|
+
export { m as useConversationHandlers };
|