@epam/ai-dial-chat-hooks 1.3.0-dev.149 → 1.3.0-dev.157
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/map-deployment-limits-to-input.d.ts +4 -3
- package/catalog/map-deployment-limits-to-input.d.ts.map +1 -1
- package/catalog/map-deployment-limits-to-input.js +3 -4
- package/conversation/useConversationStream/generation-resume.d.ts +14 -1
- package/conversation/useConversationStream/generation-resume.d.ts.map +1 -1
- package/conversation/useConversationStream/generation-resume.js +60 -51
- package/conversation/useConversationStream/useConversationStream.d.ts.map +1 -1
- package/conversation/useConversationStream/useConversationStream.js +207 -199
- package/package.json +16 -16
- package/usage/usage-banner-source.d.ts +6 -5
- package/usage/usage-banner-source.d.ts.map +1 -1
- package/usage/usage-banner-source.js +36 -12
- package/usage/useDeploymentUsageLimits/useDeploymentUsageLimits.d.ts +42 -18
- package/usage/useDeploymentUsageLimits/useDeploymentUsageLimits.d.ts.map +1 -1
- package/usage/useDeploymentUsageLimits/useDeploymentUsageLimits.js +23 -28
- package/usage/useUsageLimitBanner/useUsageLimitBanner.d.ts +10 -8
- package/usage/useUsageLimitBanner/useUsageLimitBanner.d.ts.map +1 -1
- package/usage/useUsageLimitBanner/useUsageLimitBanner.js +28 -25
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CatalogItemLimits, UsageLimitProgressRow } from '@epam/ai-dial-catalog';
|
|
2
|
-
import {
|
|
2
|
+
import { LimitStatsDto } from '@epam/ai-dial-chat-api-client';
|
|
3
3
|
import { FormatResetTime } from '../usage/map-usage-data-to-dashboard';
|
|
4
|
+
import { UsageLimitsSources } from '../usage/useDeploymentUsageLimits/useDeploymentUsageLimits';
|
|
4
5
|
/** Labels and formatter callbacks for the conversation-input limits mapping utility. */
|
|
5
6
|
export interface ConversationInputLimitsLabels {
|
|
6
7
|
/** Heading of the group listing the selected deployment's token limits. */
|
|
@@ -23,6 +24,6 @@ export interface ConversationInputLimitsLabels {
|
|
|
23
24
|
}) => string;
|
|
24
25
|
}
|
|
25
26
|
export declare const buildResetFields: (stats: LimitStatsDto, formatResetTime: FormatResetTime | undefined) => Pick<UsageLimitProgressRow, "resetLabel" | "resetIsoValue" | "resetAriaLabel">;
|
|
26
|
-
/** Maps
|
|
27
|
-
export declare const mapDeploymentLimitsToInput: (
|
|
27
|
+
/** Maps the deployment's day, week, and month token limits (from `sources.deployment`) and the account cost budget (from `sources.account`) to display-ready rows, or `undefined` when none qualify. */
|
|
28
|
+
export declare const mapDeploymentLimitsToInput: (sources: UsageLimitsSources, labels: ConversationInputLimitsLabels, formatResetTime?: FormatResetTime) => CatalogItemLimits | undefined;
|
|
28
29
|
//# sourceMappingURL=map-deployment-limits-to-input.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map-deployment-limits-to-input.d.ts","sourceRoot":"","sources":["../../src/catalog/map-deployment-limits-to-input.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,iBAAiB,EAEtB,KAAK,qBAAqB,EAC3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"map-deployment-limits-to-input.d.ts","sourceRoot":"","sources":["../../src/catalog/map-deployment-limits-to-input.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,iBAAiB,EAEtB,KAAK,qBAAqB,EAC3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAEV,aAAa,EACd,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4DAA4D,CAAC;AAErG,wFAAwF;AACxF,MAAM,WAAW,6BAA6B;IAC5C,2EAA2E;IAC3E,UAAU,EAAE,MAAM,CAAC;IACnB,kFAAkF;IAClF,SAAS,EAAE,MAAM,CAAC;IAClB,8DAA8D;IAC9D,SAAS,EAAE,MAAM,CAAC;IAClB,+DAA+D;IAC/D,UAAU,EAAE,MAAM,CAAC;IACnB,gEAAgE;IAChE,WAAW,EAAE,MAAM,CAAC;IACpB,sEAAsE;IACtE,gBAAgB,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAC1D,wDAAwD;IACxD,uBAAuB,EAAE,CAAC,MAAM,EAAE;QAChC,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;KACf,KAAK,MAAM,CAAC;CACd;AAgGD,eAAO,MAAM,gBAAgB,GAC3B,OAAO,aAAa,EACpB,iBAAiB,eAAe,GAAG,SAAS,KAC3C,IAAI,CACL,qBAAqB,EACrB,YAAY,GAAG,eAAe,GAAG,gBAAgB,CAYlD,CAAC;AA4GF,wMAAwM;AACxM,eAAO,MAAM,0BAA0B,GACrC,SAAS,kBAAkB,EAC3B,QAAQ,6BAA6B,EACrC,kBAAkB,eAAe,KAChC,iBAAiB,GAAG,SAqCtB,CAAC"}
|
|
@@ -61,7 +61,7 @@ var n = [
|
|
|
61
61
|
return r >= 1 ? t.LimitReached : r >= a && e !== t.LimitReached ? t.RunningLow : e;
|
|
62
62
|
}, void 0), _ = (e, t, n, r, i, a, o) => {
|
|
63
63
|
let s = t.flatMap((t) => {
|
|
64
|
-
let n = e[t.key];
|
|
64
|
+
let n = e?.[t.key];
|
|
65
65
|
return !u(n) || !h(n) ? [] : (o.push(n), [p(n, r[t.labelField], r, i, a)]);
|
|
66
66
|
});
|
|
67
67
|
return s.length > 0 ? {
|
|
@@ -69,11 +69,10 @@ var n = [
|
|
|
69
69
|
rows: s
|
|
70
70
|
} : void 0;
|
|
71
71
|
}, v = (t, i, a) => {
|
|
72
|
-
|
|
73
|
-
let o = [], u = [_(t, n, i.tokenGroup, i, {
|
|
72
|
+
let o = [], u = [_(t.deployment, n, i.tokenGroup, i, {
|
|
74
73
|
format: (e) => s.format(l(e)),
|
|
75
74
|
formatFull: (e) => c.format(e)
|
|
76
|
-
}, a, o), _(t, r, i.costGroup, i, {
|
|
75
|
+
}, a, o), _(t.account, r, i.costGroup, i, {
|
|
77
76
|
format: e,
|
|
78
77
|
formatFull: e
|
|
79
78
|
}, a, o)].filter((e) => e != null);
|
|
@@ -42,6 +42,12 @@ export interface ResumeGenerationOptions {
|
|
|
42
42
|
onSettled?: () => void;
|
|
43
43
|
/** Resumes even though the path is already in `resumingPathsRef`, for a caller that reserved it itself. */
|
|
44
44
|
skipDedupe?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Takes the `generationId` the attach `snapshot` carries so Stop can reach a resumed
|
|
47
|
+
* non-background generation. Set only by the public entry point: stream recovery
|
|
48
|
+
* already knows its local id, and the conflict handover keeps Stop unavailable.
|
|
49
|
+
*/
|
|
50
|
+
trackAttachGenerationId?: boolean;
|
|
45
51
|
}
|
|
46
52
|
/** Host-owned state {@link createResumeIfAwaitingGeneration} reads/writes through. */
|
|
47
53
|
export interface ResumeIfAwaitingGenerationDeps {
|
|
@@ -66,6 +72,13 @@ export interface ResumeIfAwaitingGenerationDeps {
|
|
|
66
72
|
* its id is removed when the resume settles.
|
|
67
73
|
*/
|
|
68
74
|
stoppedGenerationIdsRef?: MutableRefObject<Set<string>>;
|
|
75
|
+
/** Records the id an attach `snapshot` supplied for `path`, so the host can offer Stop for it. */
|
|
76
|
+
rememberResumedGenerationId?: (path: string, generationId: string) => void;
|
|
77
|
+
/**
|
|
78
|
+
* Drops that id again once the resume no longer owns an attached generation. Compare-and-clear:
|
|
79
|
+
* the host removes the entry only while it still holds `generationId`.
|
|
80
|
+
*/
|
|
81
|
+
forgetResumedGenerationId?: (path: string, generationId: string) => void;
|
|
69
82
|
}
|
|
70
83
|
/**
|
|
71
84
|
* Builds `resumeIfAwaitingGeneration`: a hard refresh mid-generation loads a
|
|
@@ -81,5 +94,5 @@ export interface ResumeIfAwaitingGenerationDeps {
|
|
|
81
94
|
* backend's finalize save resolves the placeholder whenever attach is
|
|
82
95
|
* unavailable or ends without a terminal event.
|
|
83
96
|
*/
|
|
84
|
-
export declare const createResumeIfAwaitingGeneration: ({ transport, setConversation, conversationRef, resumingPathsRef, bufferedGenerationsRef, addStreamingPath, removeStreamingPath, isPathDisplayed, generationPersistenceErrorMessage, frameScheduler, stoppedGenerationIdsRef, onReloadError, onReloadSuccess, }: ResumeIfAwaitingGenerationDeps) => (currentConversationId: string, conversation: Conversation, options?: ResumeGenerationOptions) => void;
|
|
97
|
+
export declare const createResumeIfAwaitingGeneration: ({ transport, setConversation, conversationRef, resumingPathsRef, bufferedGenerationsRef, addStreamingPath, removeStreamingPath, isPathDisplayed, generationPersistenceErrorMessage, frameScheduler, stoppedGenerationIdsRef, rememberResumedGenerationId, forgetResumedGenerationId, onReloadError, onReloadSuccess, }: ResumeIfAwaitingGenerationDeps) => (currentConversationId: string, conversation: Conversation, options?: ResumeGenerationOptions) => void;
|
|
85
98
|
//# sourceMappingURL=generation-resume.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generation-resume.d.ts","sourceRoot":"","sources":["../../../src/conversation/useConversationStream/generation-resume.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,YAAY,EAEjB,KAAK,OAAO,EAEb,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAOxE,OAAO,EACL,KAAK,kBAAkB,EAExB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AAE3E;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAAI,SAAS,OAAO,KAAG,OAWtD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,GAC5C,cAAc,YAAY,KACzB,MAKA,CAAC;AAEJ;;;;;;;GAOG;AACH,eAAO,MAAM,0BAA0B,GACrC,cAAc,YAAY,KACzB,OAUF,CAAC;AA6BF,eAAO,MAAM,0BAA0B,UAAkC,CAAC;AAe1E;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,GACvC,MAAM,MAAM,OAAO,CAAC,YAAY,CAAC,EACjC,YAAY,MAAM,OAAO,EACzB,YAAY,CAAC,YAAY,EAAE,YAAY,KAAK,OAAO,KAClD,OAAO,CAAC,YAAY,GAAG,IAAI,CAiB7B,CAAC;AAgEF,sGAAsG;AACtG,MAAM,WAAW,uBAAuB;IACtC,qIAAqI;IACrI,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,oGAAoG;IACpG,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,2GAA2G;IAC3G,UAAU,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"generation-resume.d.ts","sourceRoot":"","sources":["../../../src/conversation/useConversationStream/generation-resume.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,YAAY,EAEjB,KAAK,OAAO,EAEb,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAOxE,OAAO,EACL,KAAK,kBAAkB,EAExB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AAE3E;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAAI,SAAS,OAAO,KAAG,OAWtD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,GAC5C,cAAc,YAAY,KACzB,MAKA,CAAC;AAEJ;;;;;;;GAOG;AACH,eAAO,MAAM,0BAA0B,GACrC,cAAc,YAAY,KACzB,OAUF,CAAC;AA6BF,eAAO,MAA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O,KACrB,IAAI,CAAC;IACV,2DAA2D;IAC3D,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,iFAAiF;IACjF,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC;;;;OAIG;IACH,uBAAuB,CAAC,EAAE,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;IACxD,kGAAkG;IAClG,2BAA2B,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3E;;;OAGG;IACH,yBAAyB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1E;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,gCAAgC,GAAI,wTAgB9C,8BAA8B,MAE7B,uBAAuB,MAAM,EAC7B,cAAc,YAAY,EAC1B,UAAS,uBAA4B,KACpC,IA6SJ,CAAC"}
|
|
@@ -63,67 +63,76 @@ var c = (e) => {
|
|
|
63
63
|
} catch {} finally {
|
|
64
64
|
n.releaseLock();
|
|
65
65
|
}
|
|
66
|
-
}, _ = ({ transport: o, setConversation: s, conversationRef: p, resumingPathsRef: m, bufferedGenerationsRef: h, addStreamingPath: _, removeStreamingPath: v, isPathDisplayed: y, generationPersistenceErrorMessage: b = t, frameScheduler: x, stoppedGenerationIdsRef: S,
|
|
67
|
-
if (!u(
|
|
68
|
-
|
|
66
|
+
}, _ = ({ transport: o, setConversation: s, conversationRef: p, resumingPathsRef: m, bufferedGenerationsRef: h, addStreamingPath: _, removeStreamingPath: v, isPathDisplayed: y, generationPersistenceErrorMessage: b = t, frameScheduler: x, stoppedGenerationIdsRef: S, rememberResumedGenerationId: C, forgetResumedGenerationId: w, onReloadError: T, onReloadSuccess: E }) => (t, D, O = {}) => {
|
|
67
|
+
if (!u(D)) {
|
|
68
|
+
O.onSettled?.();
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
|
-
let
|
|
72
|
-
if (!
|
|
73
|
-
m.current.add(
|
|
74
|
-
let
|
|
71
|
+
let k = r(t);
|
|
72
|
+
if (!O.skipDedupe && m.current.has(k)) return;
|
|
73
|
+
m.current.add(k), _(k);
|
|
74
|
+
let A = l(D), j = A !== -1, M = j ? A : D.messages.length - 1, N = {
|
|
75
75
|
generationId: f,
|
|
76
|
-
messageIndex:
|
|
77
|
-
message:
|
|
76
|
+
messageIndex: M,
|
|
77
|
+
message: O.seedMessage ?? D.messages[M]
|
|
78
78
|
};
|
|
79
|
-
h.current.set(
|
|
80
|
-
let
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
79
|
+
h.current.set(k, N);
|
|
80
|
+
let P = () => h.current.get(k) === N, F = j ? D.messages[M].backgroundGeneration?.generationId : void 0, I, L = () => {
|
|
81
|
+
let e = F ?? I;
|
|
82
|
+
return e != null && (S?.current.has(e) ?? !1);
|
|
83
|
+
}, R = (e) => {
|
|
84
|
+
O.trackAttachGenerationId && !j && e != null && P() && (I = e, C?.(k, e));
|
|
85
|
+
}, z = () => {
|
|
86
|
+
if (I == null) return;
|
|
87
|
+
let e = I;
|
|
88
|
+
I = void 0, S?.current.delete(e), w?.(k, e);
|
|
89
|
+
}, B = (e, t = !1) => {
|
|
90
|
+
if (x?.flush(k), F != null && S?.current.delete(F), z(), !P()) return;
|
|
91
|
+
m.current.delete(k), v(k);
|
|
92
|
+
let n = !j && e && e.messages.length - 1 === M && u(e) && c(N.message);
|
|
93
|
+
t || n ? (N.message = {
|
|
94
|
+
...N.message,
|
|
86
95
|
streamErrorMessage: b
|
|
87
|
-
}, y(
|
|
88
|
-
if (!e || !
|
|
89
|
-
let t = a(e,
|
|
96
|
+
}, y(k) && s((e) => {
|
|
97
|
+
if (!e || !P() || !y(k)) return e;
|
|
98
|
+
let t = a(e, N);
|
|
90
99
|
return p.current = t, t;
|
|
91
|
-
})) : (h.current.delete(
|
|
92
|
-
},
|
|
93
|
-
if (
|
|
100
|
+
})) : (h.current.delete(k), e && y(k) && (s(e), p.current = e));
|
|
101
|
+
}, V = async () => {
|
|
102
|
+
if (P()) try {
|
|
94
103
|
let n = await o.getConversation(e(t));
|
|
95
|
-
if (!
|
|
96
|
-
|
|
104
|
+
if (!P()) return;
|
|
105
|
+
E?.(k), B(n);
|
|
97
106
|
} catch {
|
|
98
|
-
if (!
|
|
99
|
-
x?.flush(
|
|
107
|
+
if (!P()) return;
|
|
108
|
+
x?.flush(k), m.current.delete(k), v(k), F != null && S?.current.delete(F), z(), T?.(k, V, P);
|
|
100
109
|
}
|
|
101
|
-
},
|
|
102
|
-
x?.cancel(
|
|
103
|
-
if (!e || !
|
|
104
|
-
let t = a(e,
|
|
110
|
+
}, H = (e) => {
|
|
111
|
+
x?.cancel(k), P() && (N.message = e, y(k) && s((e) => {
|
|
112
|
+
if (!e || !P() || !y(k)) return e;
|
|
113
|
+
let t = a(e, N);
|
|
105
114
|
return p.current = t, t;
|
|
106
115
|
}));
|
|
107
|
-
},
|
|
108
|
-
if (!e || !
|
|
109
|
-
let t = a(e,
|
|
116
|
+
}, U = () => s((e) => {
|
|
117
|
+
if (!e || !P() || !y(k)) return e;
|
|
118
|
+
let t = a(e, N);
|
|
110
119
|
return p.current = t, t;
|
|
111
|
-
}),
|
|
112
|
-
if (!
|
|
113
|
-
let t = i([
|
|
114
|
-
t && (
|
|
115
|
-
},
|
|
120
|
+
}), W = (e) => {
|
|
121
|
+
if (!P() || L()) return;
|
|
122
|
+
let t = i([N.message], 0, e);
|
|
123
|
+
t && (N.message = t[0]), y(k) && (x ? x.schedule(k, U) : U());
|
|
124
|
+
}, G = async () => {
|
|
116
125
|
let n = new AbortController(), r;
|
|
117
126
|
try {
|
|
118
|
-
r = await o.watchConversation(
|
|
127
|
+
r = await o.watchConversation(k, n.signal);
|
|
119
128
|
} catch {
|
|
120
|
-
await
|
|
129
|
+
await V();
|
|
121
130
|
return;
|
|
122
131
|
}
|
|
123
132
|
try {
|
|
124
133
|
let i = await o.getConversation(e(t));
|
|
125
134
|
if (!u(i)) {
|
|
126
|
-
n.abort(), r.cancel().catch(() => void 0),
|
|
135
|
+
n.abort(), r.cancel().catch(() => void 0), B(i);
|
|
127
136
|
return;
|
|
128
137
|
}
|
|
129
138
|
} catch {}
|
|
@@ -135,38 +144,38 @@ var c = (e) => {
|
|
|
135
144
|
if (n?.action !== "UPDATE") return !1;
|
|
136
145
|
try {
|
|
137
146
|
let n = await o.getConversation(e(t));
|
|
138
|
-
if (!u(n)) return
|
|
147
|
+
if (!u(n)) return B(n), i = !0, !0;
|
|
139
148
|
} catch {}
|
|
140
149
|
return !1;
|
|
141
150
|
});
|
|
142
151
|
} finally {
|
|
143
152
|
clearTimeout(a);
|
|
144
153
|
}
|
|
145
|
-
i || await
|
|
146
|
-
},
|
|
154
|
+
i || await V();
|
|
155
|
+
}, K = async () => {
|
|
147
156
|
let e = new AbortController(), t;
|
|
148
157
|
try {
|
|
149
|
-
t = await o.attachToGeneration(
|
|
158
|
+
t = await o.attachToGeneration(k, e.signal);
|
|
150
159
|
} catch {
|
|
151
160
|
return !1;
|
|
152
161
|
}
|
|
153
162
|
let r = !1, i = !1;
|
|
154
163
|
return await g(t, (e) => {
|
|
155
|
-
if (!
|
|
164
|
+
if (!P()) return !0;
|
|
156
165
|
switch (e.type) {
|
|
157
|
-
case "snapshot": return
|
|
158
|
-
case "chunk": return
|
|
166
|
+
case "snapshot": return R(e.generationId), H(e.message), !1;
|
|
167
|
+
case "chunk": return W(e.chunk), !1;
|
|
159
168
|
case "done":
|
|
160
169
|
case "error":
|
|
161
170
|
case "stopped": return i = e.type === "error" && e.errorType === n.type, r = !0, !0;
|
|
162
171
|
}
|
|
163
|
-
}), r ? (i ?
|
|
172
|
+
}), r ? (i ? B(void 0, !0) : await V(), !0) : (z(), !P());
|
|
164
173
|
};
|
|
165
174
|
(async () => {
|
|
166
175
|
try {
|
|
167
|
-
await
|
|
176
|
+
await K() || await G();
|
|
168
177
|
} finally {
|
|
169
|
-
|
|
178
|
+
O.onSettled?.();
|
|
170
179
|
}
|
|
171
180
|
})();
|
|
172
181
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useConversationStream.d.ts","sourceRoot":"","sources":["../../../src/conversation/useConversationStream/useConversationStream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EACL,KAAK,YAAY,EAEjB,KAAK,oBAAoB,EAEzB,KAAK,WAAW,EACjB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACrB,KAAK,cAAc,EAMpB,MAAM,OAAO,CAAC;AA6Cf,gFAAgF;AAChF,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IACtC,UAAU,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAChC,MAAM,EAAE,WAAW,CAAC;CACrB;AAED;;;;GAIG;AACH,MAAM,WAAW,2BAA2B;IAC1C,6GAA6G;IAC7G,gBAAgB,CACd,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,uBAAuB,EAChC,aAAa,CAAC,EAAE,oBAAoB,EACpC,YAAY,CAAC,EAAE,MAAM,EACrB,IAAI,CAAC,EAAE,yBAAyB,EAChC,YAAY,CAAC,EAAE,MAAM,EACrB,eAAe,CAAC,EAAE,MAAM,GACvB,IAAI,CAAC;IACR;;;OAGG;IACH,cAAc,CAAC,MAAM,EAAE;QACrB,YAAY,EAAE,MAAM,CAAC;QACrB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,CAAC,EAAE,MAAM,CAAC;KACl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M,IAAI,CAAC;IACvB,0BAA0B,EAAE,CAC1B,qBAAqB,EAAE,MAAM,EAC7B,YAAY,EAAE,YAAY,KACvB,IAAI,CAAC;IACV,+GAA+G;IAC/G,yBAAyB,EAAE,CACzB,qBAAqB,EAAE,MAAM,EAC7B,YAAY,EAAE,YAAY,KACvB,YAAY,CAAC;IAClB,WAAW,EAAE,OAAO,CAAC;IACrB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,iEAAiE;IACjE,0BAA0B,EAAE,OAAO,CAAC;IACpC,iDAAiD;IACjD,uBAAuB,EAAE,OAAO,CAAC;IACjC,yEAAyE;IACzE,uBAAuB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9C;AAkBD;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,GAAI,mQAYnC,2BAA2B,KAAG,
|
|
1
|
+
{"version":3,"file":"useConversationStream.d.ts","sourceRoot":"","sources":["../../../src/conversation/useConversationStream/useConversationStream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EACL,KAAK,YAAY,EAEjB,KAAK,oBAAoB,EAEzB,KAAK,WAAW,EACjB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACrB,KAAK,cAAc,EAMpB,MAAM,OAAO,CAAC;AA6Cf,gFAAgF;AAChF,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IACtC,UAAU,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAChC,MAAM,EAAE,WAAW,CAAC;CACrB;AAED;;;;GAIG;AACH,MAAM,WAAW,2BAA2B;IAC1C,6GAA6G;IAC7G,gBAAgB,CACd,IAAI,EAAE,MAAM,EACZ,O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AW,kBAAkB;IACjC;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,qDAAqD;AACrD,MAAM,WAAW,2BAA2B;IAC1C,WAAW,EAAE,CACX,cAAc,EAAE,MAAM,EACtB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,MAAM,EACb,aAAa,CAAC,EAAE,oBAAoB,EACpC,YAAY,CAAC,EAAE,MAAM,EACrB,IAAI,CAAC,EAAE,yBAAyB,EAChC,OAAO,CAAC,EAAE,kBAAkB,KACzB,IAAI,CAAC;IACV,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,0BAA0B,EAAE,CAC1B,qBAAqB,EAAE,MAAM,EAC7B,YAAY,EAAE,YAAY,KACvB,IAAI,CAAC;IACV,+GAA+G;IAC/G,yBAAyB,EAAE,CACzB,qBAAqB,EAAE,MAAM,EAC7B,YAAY,EAAE,YAAY,KACvB,YAAY,CAAC;IAClB,WAAW,EAAE,OAAO,CAAC;IACrB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,iEAAiE;IACjE,0BAA0B,EAAE,OAAO,CAAC;IACpC,iDAAiD;IACjD,uBAAuB,EAAE,OAAO,CAAC;IACjC,yEAAyE;IACzE,uBAAuB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9C;AAkBD;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,GAAI,mQAYnC,2BAA2B,KAAG,2BA88BhC,CAAC"}
|
|
@@ -5,166 +5,174 @@ import { applyChunkToMessages as l } from "./apply-chunk.js";
|
|
|
5
5
|
import { restoreBufferedMessage as u } from "./buffered-generation.js";
|
|
6
6
|
import { createResumeIfAwaitingGeneration as ee, fetchConversationForRecovery as te, findPendingBackgroundMessageIndex as d, hasGeneratedPayload as ne, isAwaitingGenerationResume as f } from "./generation-resume.js";
|
|
7
7
|
import { createFrameScheduler as re } from "./frame-scheduler.js";
|
|
8
|
-
import { MessageRole as
|
|
9
|
-
import { useCallback as
|
|
10
|
-
import { SendCompletionDtoModeEnum as
|
|
8
|
+
import { MessageRole as ie, generateUUID as ae } from "@epam/ai-dial-chat-shared";
|
|
9
|
+
import { useCallback as p, useEffect as m, useMemo as h, useRef as g, useState as _ } from "react";
|
|
10
|
+
import { SendCompletionDtoModeEnum as oe } from "@epam/ai-dial-chat-api-client";
|
|
11
11
|
//#region src/conversation/useConversationStream/useConversationStream.ts
|
|
12
|
-
var
|
|
12
|
+
var se = 2e4, ce = 401, v = 404, y = 2e3, b = 100, le = (e, t, n) => e instanceof i ? n : e instanceof r ? t : e instanceof s ? e.message : "", x = (e) => {
|
|
13
13
|
if (!e) return;
|
|
14
14
|
let t = d(e);
|
|
15
15
|
return t === -1 ? void 0 : e.messages[t].backgroundGeneration?.generationId;
|
|
16
|
-
},
|
|
17
|
-
let
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}, [
|
|
21
|
-
let
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}, [
|
|
25
|
-
let [
|
|
26
|
-
|
|
27
|
-
let [
|
|
28
|
-
|
|
29
|
-
|
|
16
|
+
}, S = ({ conversationId: s, state: { setConversation: S, conversationRef: C }, transport: w, generation: { startGeneration: ue, completeGeneration: de }, channel: T, overlay: E, onStopError: fe, generationConflictMessage: pe = t, generationPersistenceErrorMessage: D = n, onStreamError: O, batchChunksPerFrame: k = !1 }) => {
|
|
17
|
+
let me = g(O);
|
|
18
|
+
m(() => {
|
|
19
|
+
me.current = O;
|
|
20
|
+
}, [O]);
|
|
21
|
+
let he = g(k);
|
|
22
|
+
m(() => {
|
|
23
|
+
he.current = k;
|
|
24
|
+
}, [k]);
|
|
25
|
+
let [A] = _(re), [j, M] = _(() => /* @__PURE__ */ new Set()), N = g(j);
|
|
26
|
+
N.current = j;
|
|
27
|
+
let [P, ge] = _(() => /* @__PURE__ */ new Set()), F = g(/* @__PURE__ */ new Map()), I = g(/* @__PURE__ */ new Map()), L = g(/* @__PURE__ */ new Set()), R = g(/* @__PURE__ */ new Map()), z = g(/* @__PURE__ */ new Set()), B = g(/* @__PURE__ */ new Set()), _e = g(/* @__PURE__ */ new Map()), V = g(!0), H = g(/* @__PURE__ */ new Map()), [U, ve] = _(H.current), W = g(/* @__PURE__ */ new Set()), [ye, be] = _(W.current);
|
|
28
|
+
m(() => (V.current = !0, () => {
|
|
29
|
+
V.current = !1;
|
|
30
30
|
}), []);
|
|
31
|
-
let
|
|
32
|
-
if (!
|
|
33
|
-
let t = new Map(
|
|
34
|
-
t.delete(e),
|
|
35
|
-
}, []),
|
|
36
|
-
if (!
|
|
37
|
-
let r = new Map(
|
|
31
|
+
let G = p((e) => {
|
|
32
|
+
if (!H.current.has(e)) return;
|
|
33
|
+
let t = new Map(H.current);
|
|
34
|
+
t.delete(e), H.current = t, V.current && ve(t);
|
|
35
|
+
}, []), K = p((e, t, n) => {
|
|
36
|
+
if (!V.current || !n()) return;
|
|
37
|
+
let r = new Map(H.current);
|
|
38
38
|
r.set(e, {
|
|
39
39
|
retry: t,
|
|
40
40
|
isCurrent: n
|
|
41
|
-
}),
|
|
42
|
-
}, []),
|
|
41
|
+
}), H.current = r, ve(r);
|
|
42
|
+
}, []), xe = p(async () => {
|
|
43
43
|
if (!s) return;
|
|
44
|
-
let e =
|
|
45
|
-
if (e && e.isCurrent() && !
|
|
46
|
-
|
|
44
|
+
let e = H.current.get(c(s));
|
|
45
|
+
if (e && e.isCurrent() && !W.current.has(e)) {
|
|
46
|
+
W.current.add(e), be(new Set(W.current));
|
|
47
47
|
try {
|
|
48
48
|
await e.retry();
|
|
49
49
|
} finally {
|
|
50
|
-
|
|
50
|
+
W.current.delete(e), V.current && be(new Set(W.current));
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
}, [s]),
|
|
54
|
-
|
|
55
|
-
let
|
|
56
|
-
|
|
53
|
+
}, [s]), Se = g(s);
|
|
54
|
+
m(() => (Se.current = s, () => A.cancelAll()), [s, A]);
|
|
55
|
+
let q = p((e) => V.current && c(Se.current ?? "") === e, []), J = p((e) => {
|
|
56
|
+
G(e), M((t) => {
|
|
57
57
|
if (t.has(e)) return t;
|
|
58
58
|
let n = new Set(t);
|
|
59
59
|
return n.add(e), n;
|
|
60
60
|
});
|
|
61
|
-
}, [
|
|
62
|
-
|
|
61
|
+
}, [G]), Y = p((e) => {
|
|
62
|
+
M((t) => {
|
|
63
63
|
if (!t.has(e)) return t;
|
|
64
64
|
let n = new Set(t);
|
|
65
65
|
return n.delete(e), n;
|
|
66
66
|
});
|
|
67
|
-
}, []),
|
|
68
|
-
|
|
67
|
+
}, []), X = p((e, t) => {
|
|
68
|
+
ge((n) => {
|
|
69
69
|
if (n.has(e) === t) return n;
|
|
70
70
|
let r = new Set(n);
|
|
71
71
|
return t ? r.add(e) : r.delete(e), r;
|
|
72
72
|
});
|
|
73
|
-
}, []),
|
|
74
|
-
|
|
75
|
-
}, [
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
73
|
+
}, []), Ce = p((e, t) => {
|
|
74
|
+
F.current.get(e) === t && (F.current.delete(e), X(e, !1));
|
|
75
|
+
}, [X]), we = p((e, t) => {
|
|
76
|
+
F.current.has(e) || (I.current.set(e, t), X(e, !0));
|
|
77
|
+
}, [X]), Te = p((e, t) => {
|
|
78
|
+
I.current.get(e) === t && (I.current.delete(e), F.current.has(e) || X(e, !1));
|
|
79
|
+
}, [X]), Z = h(() => ee({
|
|
80
|
+
transport: w,
|
|
81
|
+
setConversation: S,
|
|
82
|
+
conversationRef: C,
|
|
83
|
+
resumingPathsRef: L,
|
|
84
|
+
bufferedGenerationsRef: R,
|
|
85
|
+
addStreamingPath: J,
|
|
86
|
+
removeStreamingPath: Y,
|
|
87
|
+
isPathDisplayed: q,
|
|
88
|
+
generationPersistenceErrorMessage: D,
|
|
89
|
+
frameScheduler: k ? A : void 0,
|
|
90
|
+
stoppedGenerationIdsRef: z,
|
|
91
|
+
rememberResumedGenerationId: we,
|
|
92
|
+
forgetResumedGenerationId: Te,
|
|
93
|
+
onReloadError: K,
|
|
94
|
+
onReloadSuccess: G
|
|
89
95
|
}), [
|
|
90
|
-
Y,
|
|
91
|
-
X,
|
|
92
96
|
J,
|
|
93
|
-
|
|
94
|
-
k,
|
|
95
|
-
j,
|
|
96
|
-
M,
|
|
97
|
+
Y,
|
|
97
98
|
q,
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
99
|
+
w,
|
|
100
|
+
D,
|
|
101
|
+
k,
|
|
102
|
+
A,
|
|
103
|
+
we,
|
|
104
|
+
Te,
|
|
105
|
+
K,
|
|
106
|
+
G
|
|
107
|
+
]), Ee = p((t, n, a, s, ee, re, p = oe.Append, m = {}) => {
|
|
108
|
+
let h = re ?? ae(), g = c(t);
|
|
109
|
+
A.flush(g), L.current.delete(g), F.current.set(g, h), _e.current.set(g, h), X(g, !0);
|
|
110
|
+
let _;
|
|
111
|
+
p === oe.Regenerate ? _ = a : p === oe.Edit && (_ = a - 1);
|
|
112
|
+
let v = () => _e.current.get(g) !== h, y = ue(g, h), b = C.current?.messages[a];
|
|
113
|
+
b ? R.current.set(g, {
|
|
114
|
+
generationId: h,
|
|
107
115
|
messageIndex: a,
|
|
108
|
-
message:
|
|
109
|
-
}) :
|
|
110
|
-
let
|
|
111
|
-
|
|
112
|
-
},
|
|
113
|
-
if (
|
|
114
|
-
let e =
|
|
115
|
-
e && e.generationId ===
|
|
116
|
+
message: b
|
|
117
|
+
}) : R.current.delete(g), J(g), E?.notifyGenerationStart?.(), T?.ensureConnected();
|
|
118
|
+
let x = () => {
|
|
119
|
+
v() || Y(g), Ce(g, h), de(g, h), T?.notifyGenerationSettled?.();
|
|
120
|
+
}, fe = () => {
|
|
121
|
+
if (v()) return;
|
|
122
|
+
let e = R.current.get(g);
|
|
123
|
+
e && e.generationId === h && (e.message = {
|
|
116
124
|
...e.message,
|
|
117
|
-
streamErrorMessage:
|
|
118
|
-
},
|
|
119
|
-
if (!t ||
|
|
125
|
+
streamErrorMessage: D
|
|
126
|
+
}, me.current?.(new i()), q(g) && S((t) => {
|
|
127
|
+
if (!t || v() || !q(g)) return t;
|
|
120
128
|
let n = u(t, e);
|
|
121
|
-
return
|
|
129
|
+
return C.current = n, n;
|
|
122
130
|
}));
|
|
123
|
-
},
|
|
124
|
-
if (
|
|
125
|
-
if (!
|
|
131
|
+
}, O = R.current.get(g), k = () => V.current && !v() && R.current.get(g) === O, j = async () => {
|
|
132
|
+
if (k()) {
|
|
133
|
+
if (!q(g)) O && R.current.delete(g);
|
|
126
134
|
else try {
|
|
127
|
-
let n = await
|
|
128
|
-
if (!
|
|
129
|
-
if (
|
|
130
|
-
|
|
135
|
+
let n = await w.getConversation(e(t));
|
|
136
|
+
if (!k()) return;
|
|
137
|
+
if (G(g), !q(g)) {
|
|
138
|
+
O && R.current.delete(g);
|
|
131
139
|
return;
|
|
132
140
|
}
|
|
133
141
|
if (d(n) !== -1) {
|
|
134
|
-
|
|
142
|
+
Z(t, n, { seedMessage: O?.message });
|
|
135
143
|
return;
|
|
136
144
|
}
|
|
137
|
-
if (
|
|
138
|
-
|
|
145
|
+
if (O && O.messageIndex === n.messages.length - 1 && f(n) && ne(O.message)) {
|
|
146
|
+
fe();
|
|
139
147
|
return;
|
|
140
148
|
}
|
|
141
|
-
|
|
149
|
+
O && R.current.delete(g), S(n), C.current = n;
|
|
142
150
|
} catch {
|
|
143
|
-
|
|
151
|
+
k() && K(g, j, k);
|
|
144
152
|
}
|
|
145
153
|
}
|
|
146
|
-
},
|
|
147
|
-
signal:
|
|
154
|
+
}, M = {
|
|
155
|
+
signal: y.signal,
|
|
148
156
|
onChunk: (e) => {
|
|
149
|
-
if (
|
|
150
|
-
let t =
|
|
151
|
-
if (t?.generationId ===
|
|
157
|
+
if (v()) return;
|
|
158
|
+
let t = R.current.get(g);
|
|
159
|
+
if (t?.generationId === h) {
|
|
152
160
|
let n = l([t.message], 0, e);
|
|
153
161
|
n && (t.message = n[0]);
|
|
154
162
|
}
|
|
155
|
-
|
|
156
|
-
let e =
|
|
157
|
-
if (
|
|
163
|
+
q(g) && (he.current && t?.generationId === h ? A.schedule(g, () => {
|
|
164
|
+
let e = R.current.get(g);
|
|
165
|
+
if (v() || !q(g) || e?.generationId !== h) return;
|
|
158
166
|
let t = { ...e };
|
|
159
|
-
|
|
167
|
+
S((e) => {
|
|
160
168
|
if (!e) return e;
|
|
161
169
|
let n = u(e, t);
|
|
162
|
-
return
|
|
170
|
+
return C.current = n, n;
|
|
163
171
|
});
|
|
164
|
-
}) :
|
|
172
|
+
}) : S((t) => {
|
|
165
173
|
if (!t) return t;
|
|
166
|
-
let n =
|
|
167
|
-
if (n?.generationId ===
|
|
174
|
+
let n = R.current.get(g), r;
|
|
175
|
+
if (n?.generationId === h) r = u(t, n);
|
|
168
176
|
else {
|
|
169
177
|
let n = l(t.messages, a, e);
|
|
170
178
|
if (!n) return t;
|
|
@@ -173,157 +181,157 @@ var ae = 2e4, oe = 401, b = 404, x = 2e3, S = 100, se = (e, t, n) => e instanceo
|
|
|
173
181
|
messages: n
|
|
174
182
|
};
|
|
175
183
|
}
|
|
176
|
-
return
|
|
184
|
+
return C.current = r, r;
|
|
177
185
|
}));
|
|
178
186
|
},
|
|
179
187
|
onComplete: async () => {
|
|
180
|
-
|
|
188
|
+
A.flush(g), x(), z.current.has(h) ? z.current.delete(h) : v() || E?.notifyGenerationEnd?.(), await j();
|
|
181
189
|
},
|
|
182
190
|
onError: (e) => {
|
|
183
|
-
|
|
191
|
+
A.flush(g), me.current?.(e), e instanceof o && !v() ? B(e) : e instanceof r && m.resumeOnConflict && !v() ? H(e) : N(e);
|
|
184
192
|
}
|
|
185
|
-
},
|
|
186
|
-
let t =
|
|
187
|
-
n && !(e instanceof i) &&
|
|
188
|
-
},
|
|
193
|
+
}, N = (e) => {
|
|
194
|
+
let t = R.current.get(g), n = t?.generationId === h ? t : void 0;
|
|
195
|
+
n && !(e instanceof i) && R.current.delete(g), x(), n && w.saveConversation && e instanceof i && e.status === ce ? ge(e, n, w.saveConversation.bind(w)) : P(e, n);
|
|
196
|
+
}, P = (e, t) => {
|
|
189
197
|
if (t && e instanceof i && (t.message = {
|
|
190
198
|
...t.message,
|
|
191
|
-
streamErrorMessage:
|
|
192
|
-
}),
|
|
193
|
-
let n =
|
|
194
|
-
|
|
195
|
-
if (!e ||
|
|
196
|
-
let r = t?.generationId ===
|
|
199
|
+
streamErrorMessage: D
|
|
200
|
+
}), v() || !q(g)) return;
|
|
201
|
+
let n = le(e, pe, D);
|
|
202
|
+
S((e) => {
|
|
203
|
+
if (!e || v() || !q(g)) return e;
|
|
204
|
+
let r = t?.generationId === h ? u(e, t) : e, i = {
|
|
197
205
|
...r,
|
|
198
206
|
messages: r.messages.map((e, t) => t === a ? {
|
|
199
207
|
...e,
|
|
200
208
|
streamErrorMessage: n
|
|
201
209
|
} : e)
|
|
202
210
|
};
|
|
203
|
-
return
|
|
211
|
+
return C.current = i, i;
|
|
204
212
|
});
|
|
205
|
-
},
|
|
206
|
-
let a = () =>
|
|
213
|
+
}, ge = async (n, r, i) => {
|
|
214
|
+
let a = () => V.current && !v() && R.current.get(g) === r;
|
|
207
215
|
try {
|
|
208
|
-
let o = await
|
|
216
|
+
let o = await w.getConversation(e(t));
|
|
209
217
|
if (!a()) return;
|
|
210
218
|
if (r.messageIndex !== o.messages.length - 1 || !f(o)) {
|
|
211
|
-
|
|
219
|
+
P(n, r);
|
|
212
220
|
return;
|
|
213
221
|
}
|
|
214
|
-
let s = await i(
|
|
215
|
-
if (!a() || (
|
|
216
|
-
|
|
222
|
+
let s = await i(g, u(o, r));
|
|
223
|
+
if (!a() || (R.current.delete(g), !q(g))) return;
|
|
224
|
+
S(s), C.current = s;
|
|
217
225
|
} catch {
|
|
218
|
-
a() &&
|
|
226
|
+
a() && P(n, r);
|
|
219
227
|
}
|
|
220
|
-
},
|
|
221
|
-
|
|
222
|
-
},
|
|
223
|
-
|
|
224
|
-
let r = await te(() =>
|
|
225
|
-
|
|
226
|
-
},
|
|
227
|
-
|
|
228
|
-
let r = await te(() =>
|
|
229
|
-
|
|
230
|
-
},
|
|
231
|
-
if (
|
|
232
|
-
|
|
228
|
+
}, I = () => {
|
|
229
|
+
x(), z.current.has(h) ? z.current.delete(h) : v() || E?.notifyGenerationEnd?.();
|
|
230
|
+
}, B = async (n) => {
|
|
231
|
+
L.current.add(g);
|
|
232
|
+
let r = await te(() => w.getConversation(e(t)), v);
|
|
233
|
+
U(r, n, !1);
|
|
234
|
+
}, H = async (n) => {
|
|
235
|
+
F.current.get(g) === h && X(g, !1), L.current.add(g);
|
|
236
|
+
let r = await te(() => w.getConversation(e(t)), v, (e) => e.messages.length === a && e.messages.at(-1)?.role === ie.User);
|
|
237
|
+
U(r, n, !0);
|
|
238
|
+
}, U = (e, n, r) => {
|
|
239
|
+
if (v()) {
|
|
240
|
+
x();
|
|
233
241
|
return;
|
|
234
242
|
}
|
|
235
|
-
let i = e?.messages[e.messages.length - 1], o = e != null && e.messages.length - 1 === a && i?.role ===
|
|
243
|
+
let i = e?.messages[e.messages.length - 1], o = e != null && e.messages.length - 1 === a && i?.role === ie.Assistant, s = r && e != null && d(e) !== -1;
|
|
236
244
|
if (!e || !o && !s) {
|
|
237
|
-
|
|
245
|
+
L.current.delete(g), N(n);
|
|
238
246
|
return;
|
|
239
247
|
}
|
|
240
|
-
let c =
|
|
241
|
-
f(e) ?
|
|
248
|
+
let c = R.current.get(g), l = c?.generationId === h ? c : void 0;
|
|
249
|
+
f(e) ? Z(t, e, {
|
|
242
250
|
seedMessage: o ? l?.message : void 0,
|
|
243
251
|
skipDedupe: !0,
|
|
244
|
-
onSettled:
|
|
245
|
-
}) : (
|
|
252
|
+
onSettled: I
|
|
253
|
+
}) : (L.current.delete(g), l && R.current.delete(g), q(g) && (S(e), C.current = e), I());
|
|
246
254
|
};
|
|
247
255
|
(async () => {
|
|
248
256
|
try {
|
|
249
|
-
let e =
|
|
250
|
-
if (
|
|
251
|
-
|
|
257
|
+
let e = T?.channelId ?? await T?.waitForChannel(se) ?? void 0, t = z.current.has(h);
|
|
258
|
+
if (y.signal.aborted || v() || t) {
|
|
259
|
+
R.current.get(g)?.generationId === h && R.current.delete(g), v() || Y(g), Ce(g, h), de(g, h), T?.notifyGenerationSettled?.(), t ? z.current.delete(h) : v() || E?.notifyGenerationEnd?.();
|
|
252
260
|
return;
|
|
253
261
|
}
|
|
254
|
-
|
|
262
|
+
w.streamCompletion(g, n, s, M, ee, h, p, _, e);
|
|
255
263
|
} catch (e) {
|
|
256
|
-
|
|
264
|
+
M.onError(e instanceof Error ? e : Error(String(e)));
|
|
257
265
|
}
|
|
258
266
|
})();
|
|
259
267
|
}, [
|
|
260
|
-
|
|
261
|
-
|
|
268
|
+
ue,
|
|
269
|
+
de,
|
|
270
|
+
J,
|
|
262
271
|
Y,
|
|
263
272
|
X,
|
|
264
|
-
|
|
265
|
-
xe,
|
|
266
|
-
J,
|
|
267
|
-
D?.channelId,
|
|
268
|
-
D?.ensureConnected,
|
|
269
|
-
D?.waitForChannel,
|
|
270
|
-
D?.notifyGenerationSettled,
|
|
271
|
-
O,
|
|
272
|
-
E,
|
|
273
|
-
Q,
|
|
274
|
-
de,
|
|
275
|
-
k,
|
|
276
|
-
M,
|
|
273
|
+
Ce,
|
|
277
274
|
q,
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
275
|
+
T?.channelId,
|
|
276
|
+
T?.ensureConnected,
|
|
277
|
+
T?.waitForChannel,
|
|
278
|
+
T?.notifyGenerationSettled,
|
|
279
|
+
E,
|
|
280
|
+
w,
|
|
281
|
+
Z,
|
|
282
|
+
pe,
|
|
283
|
+
D,
|
|
284
|
+
A,
|
|
285
|
+
K,
|
|
286
|
+
G
|
|
287
|
+
]), De = p((e, t) => {
|
|
288
|
+
let n = c(e), r = R.current.get(n);
|
|
289
|
+
return H.current.get(n)?.isCurrent() && r && t.messages.length - 1 >= r.messageIndex && t.messages[r.messageIndex].role === ie.Assistant && !f(t) ? (G(n), R.current.delete(n), t) : r ? u(t, r) : t;
|
|
290
|
+
}, [G]), Oe = p(() => {
|
|
283
291
|
if (!s) return;
|
|
284
|
-
let e = c(s), t =
|
|
285
|
-
if (!n ||
|
|
286
|
-
|
|
287
|
-
let r =
|
|
288
|
-
let e =
|
|
292
|
+
let e = c(s), t = F.current.get(e), n = t ?? x(C.current) ?? I.current.get(e);
|
|
293
|
+
if (!n || B.current.has(n)) return;
|
|
294
|
+
B.current.add(n), z.current.add(n), A.flush(e), E?.notifyStopGenerating?.();
|
|
295
|
+
let r = R.current.get(e)?.message.content, i = () => F.current.get(e) === n || t == null && N.current.has(e), o = async () => {
|
|
296
|
+
let e = y / b;
|
|
289
297
|
for (let t = 0; t < e; t++) {
|
|
290
|
-
if (!i() || !
|
|
291
|
-
await new Promise((e) => setTimeout(e,
|
|
298
|
+
if (!i() || !V.current) return !0;
|
|
299
|
+
await new Promise((e) => setTimeout(e, b));
|
|
292
300
|
}
|
|
293
301
|
return !i();
|
|
294
302
|
};
|
|
295
303
|
(async () => {
|
|
296
304
|
try {
|
|
297
|
-
await
|
|
305
|
+
await w.stopCompletion({
|
|
298
306
|
generationId: n,
|
|
299
307
|
path: e,
|
|
300
308
|
content: r
|
|
301
309
|
});
|
|
302
310
|
} catch (e) {
|
|
303
311
|
let t = e instanceof Error ? e : Error(String(e));
|
|
304
|
-
if (t instanceof a && t.status ===
|
|
305
|
-
|
|
312
|
+
if (t instanceof a && t.status === v && await o()) return;
|
|
313
|
+
B.current.delete(n), fe?.(t);
|
|
306
314
|
}
|
|
307
315
|
})();
|
|
308
316
|
}, [
|
|
309
317
|
s,
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
]),
|
|
318
|
+
C,
|
|
319
|
+
A,
|
|
320
|
+
fe,
|
|
321
|
+
E,
|
|
322
|
+
w
|
|
323
|
+
]), ke = p((e, t) => Z(e, t, { trackAttachGenerationId: !0 }), [Z]), Ae = s != null && j.has(c(s)), Q = s == null ? null : c(s), je = Q != null && (P.has(Q) || Ae && x(C.current) != null), $ = Q ? U.get(Q) : void 0, Me = $?.isCurrent() ?? !1;
|
|
316
324
|
return {
|
|
317
|
-
hasConversationReloadError:
|
|
318
|
-
isReloadingConversation:
|
|
319
|
-
retryConversationReload:
|
|
320
|
-
startStream:
|
|
321
|
-
handleStop:
|
|
322
|
-
resumeIfAwaitingGeneration:
|
|
323
|
-
restoreBufferedGeneration:
|
|
324
|
-
isStreaming:
|
|
325
|
-
canStopStreaming:
|
|
325
|
+
hasConversationReloadError: Me,
|
|
326
|
+
isReloadingConversation: !!$ && Me && ye.has($),
|
|
327
|
+
retryConversationReload: xe,
|
|
328
|
+
startStream: Ee,
|
|
329
|
+
handleStop: Oe,
|
|
330
|
+
resumeIfAwaitingGeneration: ke,
|
|
331
|
+
restoreBufferedGeneration: De,
|
|
332
|
+
isStreaming: Ae,
|
|
333
|
+
canStopStreaming: je
|
|
326
334
|
};
|
|
327
335
|
};
|
|
328
336
|
//#endregion
|
|
329
|
-
export {
|
|
337
|
+
export { S as useConversationStream };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@epam/ai-dial-chat-hooks",
|
|
3
3
|
"description": "Framework-level React hooks extracted from AI DIAL Chat for building custom chat interfaces",
|
|
4
|
-
"version": "1.3.0-dev.
|
|
4
|
+
"version": "1.3.0-dev.157",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./index.js",
|
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
}
|
|
122
122
|
},
|
|
123
123
|
"dependencies": {
|
|
124
|
-
"@epam/ai-dial-chat-api-client": "1.3.0-dev.
|
|
124
|
+
"@epam/ai-dial-chat-api-client": "1.3.0-dev.157",
|
|
125
125
|
"dompurify": "3.4.16",
|
|
126
126
|
"fflate": "^0.8.3",
|
|
127
127
|
"lru-cache": "^10.4.3",
|
|
@@ -130,22 +130,22 @@
|
|
|
130
130
|
},
|
|
131
131
|
"peerDependencies": {
|
|
132
132
|
"react": "^19.2.8",
|
|
133
|
-
"@epam/ai-dial-attachment-canvas": "1.3.0-dev.
|
|
134
|
-
"@epam/ai-dial-attachment-input": "1.3.0-dev.
|
|
135
|
-
"@epam/ai-dial-catalog": "1.3.0-dev.
|
|
136
|
-
"@epam/ai-dial-chat-overlay": "1.3.0-dev.
|
|
137
|
-
"@epam/ai-dial-chat-shared": "1.3.0-dev.
|
|
138
|
-
"@epam/ai-dial-conversation-input": "1.3.0-dev.
|
|
139
|
-
"@epam/ai-dial-mcp-apps": "1.3.0-dev.
|
|
140
|
-
"@epam/ai-dial-publish-panel": "1.3.0-dev.
|
|
141
|
-
"@epam/ai-dial-quotations": "1.3.0-dev.
|
|
133
|
+
"@epam/ai-dial-attachment-canvas": "1.3.0-dev.157",
|
|
134
|
+
"@epam/ai-dial-attachment-input": "1.3.0-dev.157",
|
|
135
|
+
"@epam/ai-dial-catalog": "1.3.0-dev.157",
|
|
136
|
+
"@epam/ai-dial-chat-overlay": "1.3.0-dev.157",
|
|
137
|
+
"@epam/ai-dial-chat-shared": "1.3.0-dev.157",
|
|
138
|
+
"@epam/ai-dial-conversation-input": "1.3.0-dev.157",
|
|
139
|
+
"@epam/ai-dial-mcp-apps": "1.3.0-dev.157",
|
|
140
|
+
"@epam/ai-dial-publish-panel": "1.3.0-dev.157",
|
|
141
|
+
"@epam/ai-dial-quotations": "1.3.0-dev.157",
|
|
142
142
|
"@epam/ai-dial-react-file-manager": "^0.4.0-dev.11",
|
|
143
|
-
"@epam/ai-dial-scheduled-tasks": "1.3.0-dev.
|
|
144
|
-
"@epam/ai-dial-share": "1.3.0-dev.
|
|
145
|
-
"@epam/ai-dial-skill-editor": "1.3.0-dev.
|
|
146
|
-
"@epam/ai-dial-source-panel": "1.3.0-dev.
|
|
143
|
+
"@epam/ai-dial-scheduled-tasks": "1.3.0-dev.157",
|
|
144
|
+
"@epam/ai-dial-share": "1.3.0-dev.157",
|
|
145
|
+
"@epam/ai-dial-skill-editor": "1.3.0-dev.157",
|
|
146
|
+
"@epam/ai-dial-source-panel": "1.3.0-dev.157",
|
|
147
147
|
"@epam/ai-dial-ui-kit": "^0.16.0-dev.22",
|
|
148
|
-
"@epam/ai-dial-usage-dashboard": "1.3.0-dev.
|
|
148
|
+
"@epam/ai-dial-usage-dashboard": "1.3.0-dev.157",
|
|
149
149
|
"@modelcontextprotocol/sdk": "^1.32.1",
|
|
150
150
|
"@epam/pdf-highlighter-kit": "^0.0.19",
|
|
151
151
|
"@mcp-ui/client": "^7.1.1"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DeploymentLimitsResponseDto } from '@epam/ai-dial-chat-api-client';
|
|
2
1
|
import { UsageLimitBannerSeverity } from '@epam/ai-dial-conversation-input';
|
|
3
2
|
import { UsagePeriod } from './usage-period';
|
|
3
|
+
import { UsageLimitsSources } from './useDeploymentUsageLimits/useDeploymentUsageLimits';
|
|
4
4
|
/** The day/week/month usage stat the composer banner reports on, and how close it is to its limit. */
|
|
5
5
|
export interface UsageBannerSource {
|
|
6
6
|
/** Calendar period of the stat. */
|
|
@@ -15,9 +15,10 @@ export interface UsageBannerSource {
|
|
|
15
15
|
/** `true` when `total` is a real cap: finite, positive, and below DIAL Core's unlimited sentinel. */
|
|
16
16
|
export declare const isCappedStat: (total: number) => boolean;
|
|
17
17
|
/**
|
|
18
|
-
* Returns the capped day/week/month token
|
|
19
|
-
* used/total ratio, classified
|
|
20
|
-
* no stat is capped or the
|
|
18
|
+
* Returns the capped day/week/month token stat of `sources.deployment` or cost
|
|
19
|
+
* stat of `sources.account` with the highest used/total ratio, classified
|
|
20
|
+
* against `thresholdPercent`, or `undefined` when no stat is capped or the
|
|
21
|
+
* worst one is below the threshold.
|
|
21
22
|
*/
|
|
22
|
-
export declare const selectUsageBannerSource: (
|
|
23
|
+
export declare const selectUsageBannerSource: (sources: UsageLimitsSources, thresholdPercent: number) => UsageBannerSource | undefined;
|
|
23
24
|
//# sourceMappingURL=usage-banner-source.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usage-banner-source.d.ts","sourceRoot":"","sources":["../../src/usage/usage-banner-source.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"usage-banner-source.d.ts","sourceRoot":"","sources":["../../src/usage/usage-banner-source.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qDAAqD,CAAC;AAE9F,sGAAsG;AACtG,MAAM,WAAW,iBAAiB;IAChC,mCAAmC;IACnC,MAAM,EAAE,WAAW,CAAC;IACpB,uDAAuD;IACvD,QAAQ,EAAE,wBAAwB,CAAC;IACnC,wEAAwE;IACxE,WAAW,EAAE,MAAM,CAAC;IACpB,6DAA6D;IAC7D,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CAC9B;AAQD,qGAAqG;AACrG,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,KAAG,OAC4B,CAAC;AAsC1E;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,GAClC,SAAS,kBAAkB,EAC3B,kBAAkB,MAAM,KACvB,iBAAiB,GAAG,SAsCtB,CAAC"}
|
|
@@ -2,22 +2,46 @@ import { UsagePeriod as e } from "./usage-period.js";
|
|
|
2
2
|
import { UsageLimitBannerSeverity as t } from "@epam/ai-dial-conversation-input";
|
|
3
3
|
//#region src/usage/usage-banner-source.ts
|
|
4
4
|
var n = 2 ** 53 - 1, r = (e) => Number.isFinite(e) && e > 0 && e < n, i = [
|
|
5
|
-
[
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
[
|
|
5
|
+
[
|
|
6
|
+
"deployment",
|
|
7
|
+
"monthTokenStats",
|
|
8
|
+
e.Month
|
|
9
|
+
],
|
|
10
|
+
[
|
|
11
|
+
"account",
|
|
12
|
+
"monthCostStats",
|
|
13
|
+
e.Month
|
|
14
|
+
],
|
|
15
|
+
[
|
|
16
|
+
"deployment",
|
|
17
|
+
"weekTokenStats",
|
|
18
|
+
e.Week
|
|
19
|
+
],
|
|
20
|
+
[
|
|
21
|
+
"account",
|
|
22
|
+
"weekCostStats",
|
|
23
|
+
e.Week
|
|
24
|
+
],
|
|
25
|
+
[
|
|
26
|
+
"deployment",
|
|
27
|
+
"dayTokenStats",
|
|
28
|
+
e.Day
|
|
29
|
+
],
|
|
30
|
+
[
|
|
31
|
+
"account",
|
|
32
|
+
"dayCostStats",
|
|
33
|
+
e.Day
|
|
34
|
+
]
|
|
11
35
|
], a = (e, n) => {
|
|
12
36
|
let a;
|
|
13
|
-
for (let [t, n] of i) {
|
|
14
|
-
let i = e
|
|
37
|
+
for (let [t, n, o] of i) {
|
|
38
|
+
let i = e[t]?.[n];
|
|
15
39
|
if (i == null || !r(i.total)) continue;
|
|
16
|
-
let
|
|
17
|
-
(a == null ||
|
|
40
|
+
let s = Math.max(i.used, 0) / i.total;
|
|
41
|
+
(a == null || s > a.ratio) && (a = {
|
|
18
42
|
stat: i,
|
|
19
|
-
period:
|
|
20
|
-
ratio:
|
|
43
|
+
period: o,
|
|
44
|
+
ratio: s
|
|
21
45
|
});
|
|
22
46
|
}
|
|
23
47
|
if (a == null) return;
|
|
@@ -1,32 +1,56 @@
|
|
|
1
|
-
import { DeploymentLimitsResponseDto } from '@epam/ai-dial-chat-api-client';
|
|
2
|
-
/**
|
|
3
|
-
export type
|
|
1
|
+
import { DeploymentLimitsResponseDto, UserLimitStatsResponseDto } from '@epam/ai-dial-chat-api-client';
|
|
2
|
+
/** The caller's account-wide cost budget and spend: the top level of a user-usage response. */
|
|
3
|
+
export type AccountUsage = Pick<UserLimitStatsResponseDto, 'dayCostStats' | 'weekCostStats' | 'monthCostStats'>;
|
|
4
|
+
/**
|
|
5
|
+
* What the usage dial and the usage banner are mapped from. Each field has a
|
|
6
|
+
* single scope, so a deployment's figures are never read as the account's or
|
|
7
|
+
* the other way round.
|
|
8
|
+
*/
|
|
9
|
+
export interface UsageLimitsSources {
|
|
10
|
+
/** The selected deployment's own stats (its deployment-usage response). Only its token stats are read. */
|
|
11
|
+
deployment: DeploymentLimitsResponseDto | undefined;
|
|
12
|
+
/** The caller's account budget and spend. Only its cost stats are read. */
|
|
13
|
+
account: AccountUsage | undefined;
|
|
14
|
+
}
|
|
15
|
+
/** Host-configured calls that fetch the two usage sources. */
|
|
16
|
+
export interface UsageLimitsApi {
|
|
17
|
+
/** Fetches one deployment's own usage, every stat scoped to that deployment. */
|
|
18
|
+
getDeploymentUsage: (deploymentId: string) => Promise<DeploymentLimitsResponseDto>;
|
|
19
|
+
/** Fetches the caller's account usage; only its top-level cost stats are read. */
|
|
20
|
+
getAccountUsage: () => Promise<AccountUsage>;
|
|
21
|
+
}
|
|
4
22
|
/** Return shape of {@link useDeploymentUsageLimits}. */
|
|
5
23
|
export interface UseDeploymentUsageLimitsResult {
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
/** `true`
|
|
24
|
+
/** The last successfully fetched value of each source. */
|
|
25
|
+
sources: UsageLimitsSources;
|
|
26
|
+
/** `true` until both calls of the current fetch have settled. */
|
|
9
27
|
isLoading: boolean;
|
|
10
|
-
/** `true` after the most recent fetch rejected. */
|
|
28
|
+
/** `true` after either call of the most recent fetch rejected. */
|
|
11
29
|
hasError: boolean;
|
|
12
|
-
/** Re-fetches
|
|
30
|
+
/** Re-fetches both sources when no request is in flight. */
|
|
13
31
|
refresh: () => void;
|
|
14
32
|
}
|
|
15
33
|
/**
|
|
16
|
-
* Fetches the selected deployment's usage
|
|
17
|
-
* `
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
34
|
+
* Fetches the selected deployment's own usage and the caller's account usage
|
|
35
|
+
* through the provided `api`. The hook accepts the calls as a parameter so the
|
|
36
|
+
* caller supplies an already-configured API client; the hook never constructs
|
|
37
|
+
* or imports one itself. The identity of `api` is not a re-fetch trigger; only
|
|
38
|
+
* `deploymentId` and `refresh()` are.
|
|
39
|
+
*
|
|
40
|
+
* Two sources rather than one deployment-limits response: there, the cost
|
|
41
|
+
* stats add an application's aggregated callee cost to the account spend that
|
|
42
|
+
* already contains it, so an agent's spend would be counted twice.
|
|
21
43
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
44
|
+
* Both calls share one monotonic request ID, so a slower response for a
|
|
45
|
+
* previous deployment never replaces the current value. Each source keeps its
|
|
46
|
+
* last known value when its own call fails, so the open popover can surface a
|
|
47
|
+
* non-blocking error while the other source still renders. The account source
|
|
48
|
+
* survives a deployment change, since it does not depend on the selection.
|
|
25
49
|
*
|
|
26
|
-
* The raw
|
|
50
|
+
* The raw responses are returned rather than a mapped display model: mapping
|
|
27
51
|
* needs the caller's translated labels and locale-bound reset formatter, and
|
|
28
52
|
* holding the mapped value in state here would leave it stale after a language
|
|
29
53
|
* change until the next fetch.
|
|
30
54
|
*/
|
|
31
|
-
export declare const useDeploymentUsageLimits: (deploymentId: string | undefined,
|
|
55
|
+
export declare const useDeploymentUsageLimits: (deploymentId: string | undefined, api: UsageLimitsApi) => UseDeploymentUsageLimitsResult;
|
|
32
56
|
//# sourceMappingURL=useDeploymentUsageLimits.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDeploymentUsageLimits.d.ts","sourceRoot":"","sources":["../../../src/usage/useDeploymentUsageLimits/useDeploymentUsageLimits.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"useDeploymentUsageLimits.d.ts","sourceRoot":"","sources":["../../../src/usage/useDeploymentUsageLimits/useDeploymentUsageLimits.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,2BAA2B,EAC3B,yBAAyB,EAC1B,MAAM,+BAA+B,CAAC;AAGvC,+FAA+F;AAC/F,MAAM,MAAM,YAAY,GAAG,IAAI,CAC7B,yBAAyB,EACzB,cAAc,GAAG,eAAe,GAAG,gBAAgB,CACpD,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,0GAA0G;IAC1G,UAAU,EAAE,2BAA2B,GAAG,SAAS,CAAC;IACpD,2EAA2E;IAC3E,OAAO,EAAE,YAAY,GAAG,SAAS,CAAC;CACnC;AAED,8DAA8D;AAC9D,MAAM,WAAW,cAAc;IAC7B,gFAAgF;IAChF,kBAAkB,EAAE,CAClB,YAAY,EAAE,MAAM,KACjB,OAAO,CAAC,2BAA2B,CAAC,CAAC;IAC1C,kFAAkF;IAClF,eAAe,EAAE,MAAM,OAAO,CAAC,YAAY,CAAC,CAAC;CAC9C;AAED,wDAAwD;AACxD,MAAM,WAAW,8BAA8B;IAC7C,0DAA0D;IAC1D,OAAO,EAAE,kBAAkB,CAAC;IAC5B,iEAAiE;IACjE,SAAS,EAAE,OAAO,CAAC;IACnB,kEAAkE;IAClE,QAAQ,EAAE,OAAO,CAAC;IAClB,4DAA4D;IAC5D,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,wBAAwB,GACnC,cAAc,MAAM,GAAG,SAAS,EAChC,KAAK,cAAc,KAClB,8BA6EF,CAAC"}
|
|
@@ -1,39 +1,34 @@
|
|
|
1
|
-
import { useCallback as e, useEffect as t,
|
|
1
|
+
import { useCallback as e, useEffect as t, useMemo as n, useRef as r, useState as i } from "react";
|
|
2
2
|
//#region src/usage/useDeploymentUsageLimits/useDeploymentUsageLimits.ts
|
|
3
|
-
var
|
|
4
|
-
let [
|
|
5
|
-
|
|
6
|
-
let
|
|
7
|
-
|
|
3
|
+
var a = (a, o) => {
|
|
4
|
+
let [s, c] = i(), [l, u] = i(), [d, f] = i(!1), [p, m] = i(!1), [h, g] = i(0), _ = r(0), v = r(!1), y = r(void 0), b = r(o);
|
|
5
|
+
b.current = o;
|
|
6
|
+
let x = e(() => {
|
|
7
|
+
v.current || g((e) => e + 1);
|
|
8
8
|
}, []);
|
|
9
9
|
return t(() => {
|
|
10
|
-
let e =
|
|
11
|
-
if (
|
|
12
|
-
|
|
10
|
+
let e = y.current !== a;
|
|
11
|
+
if (y.current = a, !a) {
|
|
12
|
+
_.current += 1, c(void 0), f(!1), m(!1), v.current = !1;
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
|
-
e &&
|
|
16
|
-
let t = ++
|
|
17
|
-
return
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (n || t !== m.current) return;
|
|
21
|
-
s(e);
|
|
22
|
-
} catch {
|
|
23
|
-
if (n || t !== m.current) return;
|
|
24
|
-
d(!0);
|
|
25
|
-
} finally {
|
|
26
|
-
!n && t === m.current && (l(!1), h.current = !1);
|
|
27
|
-
}
|
|
15
|
+
e && c(void 0);
|
|
16
|
+
let t = ++_.current, n = !1, r = () => !n && t === _.current;
|
|
17
|
+
return f(!0), m(!1), v.current = !0, (async () => {
|
|
18
|
+
let [e, t] = await Promise.allSettled([b.current.getDeploymentUsage(a), b.current.getAccountUsage()]);
|
|
19
|
+
r() && (e.status === "fulfilled" && c(e.value), t.status === "fulfilled" && u(t.value), m(e.status === "rejected" || t.status === "rejected"), f(!1), v.current = !1);
|
|
28
20
|
})(), () => {
|
|
29
21
|
n = !0;
|
|
30
22
|
};
|
|
31
|
-
}, [
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
23
|
+
}, [a, h]), {
|
|
24
|
+
sources: n(() => ({
|
|
25
|
+
deployment: s,
|
|
26
|
+
account: l
|
|
27
|
+
}), [s, l]),
|
|
28
|
+
isLoading: d,
|
|
29
|
+
hasError: p,
|
|
30
|
+
refresh: x
|
|
36
31
|
};
|
|
37
32
|
};
|
|
38
33
|
//#endregion
|
|
39
|
-
export {
|
|
34
|
+
export { a as useDeploymentUsageLimits };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UsageLimitBannerViewProps } from '@epam/ai-dial-conversation-input';
|
|
2
2
|
import { TranslateFn } from '../usage-reset-time';
|
|
3
|
-
import {
|
|
3
|
+
import { UsageLimitsApi } from '../useDeploymentUsageLimits/useDeploymentUsageLimits';
|
|
4
4
|
/**
|
|
5
5
|
* i18n key strings the consuming app's translation bundle must define for
|
|
6
6
|
* `useUsageLimitBanner` to produce translated strings, in addition to
|
|
@@ -29,8 +29,10 @@ export interface UseUsageLimitBannerOptions {
|
|
|
29
29
|
deploymentId: string | undefined;
|
|
30
30
|
/** Whether the selected deployment is currently generating a response. Defaults to `false`. */
|
|
31
31
|
isGenerationInProgress?: boolean;
|
|
32
|
-
/** Host-configured call that fetches one deployment's
|
|
33
|
-
|
|
32
|
+
/** Host-configured call that fetches one deployment's own usage. */
|
|
33
|
+
getDeploymentUsage: UsageLimitsApi['getDeploymentUsage'];
|
|
34
|
+
/** Host-configured call that fetches the caller's account usage. */
|
|
35
|
+
getAccountUsage: UsageLimitsApi['getAccountUsage'];
|
|
34
36
|
/** Used percentage at or above which a not-yet-exhausted limit raises a warning. */
|
|
35
37
|
warningThresholdPercent: number;
|
|
36
38
|
/** Active UI locale, used to format the reset time. */
|
|
@@ -47,10 +49,10 @@ export interface UseUsageLimitBannerResult {
|
|
|
47
49
|
}
|
|
48
50
|
/**
|
|
49
51
|
* Everything the composer usage banner needs except its rendering: fetches the
|
|
50
|
-
* selected deployment's
|
|
51
|
-
* the limit worth reporting, formats its sentences, and
|
|
52
|
-
* dismissal. Spread `banner` onto `UsageLimitBannerView`
|
|
53
|
-
* `@epam/ai-dial-conversation-input`.
|
|
52
|
+
* selected deployment's own usage and the account usage, refreshes both after
|
|
53
|
+
* each generation, picks the limit worth reporting, formats its sentences, and
|
|
54
|
+
* tracks tab-lifetime dismissal. Spread `banner` onto `UsageLimitBannerView`
|
|
55
|
+
* from `@epam/ai-dial-conversation-input`.
|
|
54
56
|
*/
|
|
55
|
-
export declare const useUsageLimitBanner: ({ deploymentId, isGenerationInProgress,
|
|
57
|
+
export declare const useUsageLimitBanner: ({ deploymentId, isGenerationInProgress, getDeploymentUsage, getAccountUsage, warningThresholdPercent, activeLocale, t, }: UseUsageLimitBannerOptions) => UseUsageLimitBannerResult;
|
|
56
58
|
//# sourceMappingURL=useUsageLimitBanner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUsageLimitBanner.d.ts","sourceRoot":"","sources":["../../../src/usage/useUsageLimitBanner/useUsageLimitBanner.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,yBAAyB,EAC/B,MAAM,kCAAkC,CAAC;AAI1C,OAAO,EAAE,KAAK,WAAW,EAAyB,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EACL,KAAK,
|
|
1
|
+
{"version":3,"file":"useUsageLimitBanner.d.ts","sourceRoot":"","sources":["../../../src/usage/useUsageLimitBanner/useUsageLimitBanner.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,yBAAyB,EAC/B,MAAM,kCAAkC,CAAC;AAI1C,OAAO,EAAE,KAAK,WAAW,EAAyB,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EACL,KAAK,cAAc,EAEpB,MAAM,sDAAsD,CAAC;AAI9D;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB;IACjC,0EAA0E;;IAE1E,2EAA2E;;IAE3E,4EAA4E;;IAE5E,0EAA0E;;IAE1E,2EAA2E;;IAE3E,4EAA4E;;IAE5E,2CAA2C;;CAEnC,CAAC;AAkBX,6CAA6C;AAC7C,MAAM,WAAW,0BAA0B;IACzC,+CAA+C;IAC/C,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,+FAA+F;IAC/F,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,oEAAoE;IACpE,kBAAkB,EAAE,cAAc,CAAC,oBAAoB,CAAC,CAAC;IACzD,oEAAoE;IACpE,eAAe,EAAE,cAAc,CAAC,iBAAiB,CAAC,CAAC;IACnD,oFAAoF;IACpF,uBAAuB,EAAE,MAAM,CAAC;IAChC,uDAAuD;IACvD,YAAY,EAAE,MAAM,CAAC;IACrB,gEAAgE;IAChE,CAAC,EAAE,WAAW,CAAC;CAChB;AAED,gEAAgE;AAChE,MAAM,MAAM,qBAAqB,GAAG,IAAI,CACtC,yBAAyB,EACzB,UAAU,GAAG,WAAW,GAAG,OAAO,GAAG,SAAS,GAAG,gBAAgB,CAClE,CAAC;AAEF,mDAAmD;AACnD,MAAM,WAAW,yBAAyB;IACxC,wIAAwI;IACxI,MAAM,EAAE,qBAAqB,GAAG,SAAS,CAAC;CAC3C;AAED;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAAI,0HAQjC,0BAA0B,KAAG,yBAqE/B,CAAC"}
|
|
@@ -26,41 +26,44 @@ var l = {
|
|
|
26
26
|
[e.Week]: l.reachedWeek,
|
|
27
27
|
[e.Month]: l.reachedMonth
|
|
28
28
|
}
|
|
29
|
-
}, d = ({ deploymentId: e, isGenerationInProgress: c = !1,
|
|
30
|
-
let
|
|
29
|
+
}, d = ({ deploymentId: e, isGenerationInProgress: c = !1, getDeploymentUsage: d, getAccountUsage: f, warningThresholdPercent: p, activeLocale: m, t: h }) => {
|
|
30
|
+
let g = s(() => ({
|
|
31
|
+
getDeploymentUsage: d,
|
|
32
|
+
getAccountUsage: f
|
|
33
|
+
}), [d, f]), { sources: _, isLoading: v, refresh: y } = r(e, g), { isDismissed: b, dismiss: x } = a();
|
|
31
34
|
i({
|
|
32
35
|
isGenerationInProgress: c,
|
|
33
|
-
isLoading:
|
|
34
|
-
refresh:
|
|
36
|
+
isLoading: v,
|
|
37
|
+
refresh: y
|
|
35
38
|
});
|
|
36
|
-
let
|
|
37
|
-
if (
|
|
38
|
-
dismissalKey: `${e}:${
|
|
39
|
-
limitText:
|
|
40
|
-
reset: n(
|
|
39
|
+
let S = s(() => t(_, p), [_, p]), C = s(() => {
|
|
40
|
+
if (S != null && e) return {
|
|
41
|
+
dismissalKey: `${e}:${S.period}:${S.severity}`,
|
|
42
|
+
limitText: h(u[S.severity][S.period], { percent: S.usedPercent }),
|
|
43
|
+
reset: n(S.resetsAt, S.period, m, h)
|
|
41
44
|
};
|
|
42
45
|
}, [
|
|
43
|
-
|
|
46
|
+
S,
|
|
44
47
|
e,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
]),
|
|
48
|
-
|
|
49
|
-
}, [
|
|
48
|
+
m,
|
|
49
|
+
h
|
|
50
|
+
]), w = C?.dismissalKey, T = o(() => {
|
|
51
|
+
w != null && x(w);
|
|
52
|
+
}, [x, w]), E = h(l.closeLabel);
|
|
50
53
|
return { banner: s(() => {
|
|
51
|
-
if (!(
|
|
52
|
-
severity:
|
|
53
|
-
limitText:
|
|
54
|
-
reset:
|
|
55
|
-
onClose:
|
|
56
|
-
closeAriaLabel:
|
|
54
|
+
if (!(S == null || C == null || b(C.dismissalKey))) return {
|
|
55
|
+
severity: S.severity,
|
|
56
|
+
limitText: C.limitText,
|
|
57
|
+
reset: C.reset,
|
|
58
|
+
onClose: T,
|
|
59
|
+
closeAriaLabel: E
|
|
57
60
|
};
|
|
58
61
|
}, [
|
|
59
|
-
|
|
60
|
-
x,
|
|
61
|
-
v,
|
|
62
|
+
S,
|
|
62
63
|
C,
|
|
63
|
-
|
|
64
|
+
b,
|
|
65
|
+
T,
|
|
66
|
+
E
|
|
64
67
|
]) };
|
|
65
68
|
};
|
|
66
69
|
//#endregion
|