@epam/ai-dial-chat-hooks 1.1.6 → 1.1.8
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/catalog-derivations.js +1 -1
- package/catalog/deployment-id.js +8 -2
- package/catalog/map-deployment-limits-to-input.js +81 -9
- package/catalog.d.ts +67 -14
- package/catalog.js +22 -22
- package/conversation/create-chat-stream-api.js +85 -49
- package/conversation/message-utils.js +44 -2
- package/conversation/useConversationStream/generation-resume.js +104 -63
- package/conversation/useConversationStream/useConversationStream.js +181 -110
- package/conversation.d.ts +85 -3
- package/conversation.js +29 -29
- package/index.d.ts +254 -18
- package/index.js +124 -122
- package/package.json +24 -15
- package/usage/map-usage-data-to-dashboard.js +66 -0
- package/usage/map-user-usage-to-model-limits.js +202 -0
- package/usage.d.ts +125 -0
- package/usage.js +3 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region src/catalog/catalog-derivations.ts
|
|
2
|
-
var e = (e, t) => e.filter((e) => t.has(e.type)), t = (e, t) => t ? e.filter((e) => !e.isMyApp) : [...e], n = (e) => e.filter((e) => e.isUserFavorite), r = (e, t) => {
|
|
2
|
+
var e = (e, t) => e.filter((e) => t.has(e.type)), t = (e, t) => t ? e.filter((e) => !e.isMyApp) : [...e], n = (e) => e.filter((e) => e.isUserFavorite && !e.isHidden), r = (e, t) => {
|
|
3
3
|
let n = new Set(e.map((e) => e.type));
|
|
4
4
|
return t.filter((e) => n.has(e));
|
|
5
5
|
}, i = (e, t) => {
|
package/catalog/deployment-id.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
//#region src/catalog/deployment-id.ts
|
|
2
|
-
var e = (e) => e.split("/").map((e) => encodeURIComponent(e)).join("/"), t = (e
|
|
2
|
+
var e = (e) => e.split("/").map((e) => encodeURIComponent(e)).join("/"), t = (e) => e.split("/").map((e) => {
|
|
3
|
+
try {
|
|
4
|
+
return decodeURIComponent(e);
|
|
5
|
+
} catch {
|
|
6
|
+
return e;
|
|
7
|
+
}
|
|
8
|
+
}).join("/"), n = (n) => e(t(n)), r = (e, t) => {
|
|
3
9
|
if (t) return e.find((e) => e.id === t) ?? e.find((e) => e.reference === t);
|
|
4
10
|
};
|
|
5
11
|
//#endregion
|
|
6
|
-
export { e as encodeDeploymentId,
|
|
12
|
+
export { t as decodeDeploymentId, e as encodeDeploymentId, r as findDeploymentByIdOrReference, n as normalizeDeploymentId };
|
|
@@ -1,14 +1,86 @@
|
|
|
1
|
+
import { formatCost as e } from "@epam/ai-dial-chat-shared";
|
|
2
|
+
import { CatalogLimitStatus as t } from "@epam/ai-dial-catalog";
|
|
1
3
|
//#region src/catalog/map-deployment-limits-to-input.ts
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
var n = [
|
|
5
|
+
{
|
|
6
|
+
key: "dayTokenStats",
|
|
7
|
+
labelField: "periodDay"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
key: "weekTokenStats",
|
|
11
|
+
labelField: "periodWeek"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
key: "monthTokenStats",
|
|
15
|
+
labelField: "periodMonth"
|
|
16
|
+
}
|
|
17
|
+
], r = [
|
|
18
|
+
{
|
|
19
|
+
key: "dayCostStats",
|
|
20
|
+
labelField: "periodDay"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
key: "weekCostStats",
|
|
24
|
+
labelField: "periodWeek"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
key: "monthCostStats",
|
|
28
|
+
labelField: "periodMonth"
|
|
29
|
+
}
|
|
30
|
+
], i = 2 ** 53 - 1, a = .75, o = [1e6, 1e3], s = new Intl.NumberFormat(void 0, {
|
|
31
|
+
notation: "compact",
|
|
32
|
+
maximumFractionDigits: 1
|
|
33
|
+
}), c = new Intl.NumberFormat(void 0, { maximumFractionDigits: 2 }), l = (e) => {
|
|
34
|
+
let t = o.find((t) => Math.abs(e) >= t);
|
|
35
|
+
return t == null ? e : Math.trunc(e / t * 10) / 10 * t;
|
|
36
|
+
}, u = (e) => e != null && Number.isFinite(e.total) && Number.isFinite(e.used) && e.total > 0, d = (e) => e >= i, f = (e, t) => {
|
|
37
|
+
let n = t?.(e.resetsAt);
|
|
38
|
+
return n ? {
|
|
39
|
+
resetLabel: n.label,
|
|
40
|
+
resetIsoValue: n.isoValue,
|
|
41
|
+
resetAriaLabel: n.ariaLabel
|
|
42
|
+
} : {};
|
|
43
|
+
}, p = (e, t, n, r, i) => {
|
|
44
|
+
let a = Math.max(0, e.used), o = e.total, s = r.format(a), c = r.format(o);
|
|
6
45
|
return {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
46
|
+
label: t,
|
|
47
|
+
used: a,
|
|
48
|
+
total: o,
|
|
49
|
+
...f(e, i),
|
|
50
|
+
usedLabel: s,
|
|
51
|
+
totalLabel: c,
|
|
52
|
+
valueLabel: n.formatValueLabel(s, c),
|
|
53
|
+
ariaLabel: n.formatProgressAriaLabel({
|
|
54
|
+
label: t,
|
|
55
|
+
used: r.formatFull(a),
|
|
56
|
+
total: r.formatFull(o)
|
|
57
|
+
})
|
|
11
58
|
};
|
|
59
|
+
}, m = (e) => d(e.total) ? 0 : Math.max(e.used, 0) / e.total, h = (e) => m(e) >= a, g = (e) => e.reduce((e, n) => {
|
|
60
|
+
let r = m(n);
|
|
61
|
+
return r >= 1 ? t.LimitReached : r >= a && e !== t.LimitReached ? t.RunningLow : e;
|
|
62
|
+
}, void 0), _ = (e, t, n, r, i, a, o) => {
|
|
63
|
+
let s = t.flatMap((t) => {
|
|
64
|
+
let n = e[t.key];
|
|
65
|
+
return !u(n) || !h(n) ? [] : (o.push(n), [p(n, r[t.labelField], r, i, a)]);
|
|
66
|
+
});
|
|
67
|
+
return s.length > 0 ? {
|
|
68
|
+
label: n,
|
|
69
|
+
rows: s
|
|
70
|
+
} : void 0;
|
|
71
|
+
}, v = (t, i, a) => {
|
|
72
|
+
if (t == null) return;
|
|
73
|
+
let o = [], u = [_(t, n, i.tokenGroup, i, {
|
|
74
|
+
format: (e) => s.format(l(e)),
|
|
75
|
+
formatFull: (e) => c.format(e)
|
|
76
|
+
}, a, o), _(t, r, i.costGroup, i, {
|
|
77
|
+
format: e,
|
|
78
|
+
formatFull: e
|
|
79
|
+
}, a, o)].filter((e) => e != null);
|
|
80
|
+
return u.length > 0 ? {
|
|
81
|
+
groups: u,
|
|
82
|
+
status: g(o)
|
|
83
|
+
} : void 0;
|
|
12
84
|
};
|
|
13
85
|
//#endregion
|
|
14
|
-
export {
|
|
86
|
+
export { v as mapDeploymentLimitsToInput };
|
package/catalog.d.ts
CHANGED
|
@@ -244,6 +244,28 @@ export declare enum CatalogPrimaryActionType {
|
|
|
244
244
|
*/
|
|
245
245
|
export declare type CatalogPublishEntityType = 'model' | 'toolset' | 'application' | 'prompt' | 'skill';
|
|
246
246
|
|
|
247
|
+
/** Labels and formatter callbacks for the conversation-input limits mapping utility. */
|
|
248
|
+
export declare interface ConversationInputLimitsLabels {
|
|
249
|
+
/** Heading of the group listing the selected deployment's token limits. */
|
|
250
|
+
tokenGroup: string;
|
|
251
|
+
/** Heading of the group listing the caller's cost budget and spend against it. */
|
|
252
|
+
costGroup: string;
|
|
253
|
+
/** Label for the current-UTC-day row, used by both groups. */
|
|
254
|
+
periodDay: string;
|
|
255
|
+
/** Label for the current-UTC-week row, used by both groups. */
|
|
256
|
+
periodWeek: string;
|
|
257
|
+
/** Label for the current-UTC-month row, used by both groups. */
|
|
258
|
+
periodMonth: string;
|
|
259
|
+
/** Formats the combined used/total display value for a capped row. */
|
|
260
|
+
formatValueLabel: (used: string, total: string) => string;
|
|
261
|
+
/** Formats the ARIA label for a capped progress row. */
|
|
262
|
+
formatProgressAriaLabel: (params: {
|
|
263
|
+
label: string;
|
|
264
|
+
used: string;
|
|
265
|
+
total: string;
|
|
266
|
+
}) => string;
|
|
267
|
+
}
|
|
268
|
+
|
|
247
269
|
/**
|
|
248
270
|
* Wraps the generated `PublishApi` in the positional-argument surface the
|
|
249
271
|
* catalog and conversation publish flows call, so each host app re-exports one
|
|
@@ -252,6 +274,15 @@ export declare type CatalogPublishEntityType = 'model' | 'toolset' | 'applicatio
|
|
|
252
274
|
*/
|
|
253
275
|
export declare const createPublishApiClient: (publishApi: PublishApi) => PublishApiClient;
|
|
254
276
|
|
|
277
|
+
/**
|
|
278
|
+
* Inverse of `encodeDeploymentId` — decodes each `/`-separated segment back
|
|
279
|
+
* to its raw, human-readable form. A segment that isn't valid
|
|
280
|
+
* percent-encoding is passed through unchanged rather than throwing, since
|
|
281
|
+
* this decodes externally-sourced ids (the settings iframe's postMessage
|
|
282
|
+
* protocol).
|
|
283
|
+
*/
|
|
284
|
+
export declare const decodeDeploymentId: (id: string) => string;
|
|
285
|
+
|
|
255
286
|
/** Translated folder-path labels for the Personal/Shared/Public deployment groupings. */
|
|
256
287
|
export declare interface DeploymentFolderLabels {
|
|
257
288
|
personal: string;
|
|
@@ -301,7 +332,7 @@ export declare interface DeploymentLimitsLabels {
|
|
|
301
332
|
export declare const deriveAvailableTabIds: <T extends CatalogEntityType>(items: readonly CatalogItem[], tabOrder: readonly T[]) => T[];
|
|
302
333
|
|
|
303
334
|
/**
|
|
304
|
-
* Returns items marked as a user favorite, in original order.
|
|
335
|
+
* Returns items marked as a user favorite that are not hidden, in original order.
|
|
305
336
|
*/
|
|
306
337
|
export declare const deriveFavoriteItems: (items: readonly CatalogItem[]) => CatalogItem[];
|
|
307
338
|
|
|
@@ -366,6 +397,9 @@ export declare const filterHiddenOwnedItems: (items: readonly CatalogItem[], hid
|
|
|
366
397
|
*/
|
|
367
398
|
export declare const findDeploymentByIdOrReference: (deployments: DeploymentItemDto[], idOrReference: string | null | undefined) => DeploymentItemDto | undefined;
|
|
368
399
|
|
|
400
|
+
/** Formats a raw `resetsAt` into display strings, or returns `undefined` when it cannot be formatted. */
|
|
401
|
+
declare type FormatResetTime = (resetsAt: string | undefined) => ResetTimeDisplay | undefined;
|
|
402
|
+
|
|
369
403
|
/**
|
|
370
404
|
* The publish folder a public catalog entity id sits in: the segments between
|
|
371
405
|
* the `public` bucket and the entity name, decoded to the plain text the
|
|
@@ -403,8 +437,8 @@ export declare const mapDeploymentDetailsDtoToEntityDetails: (dto: DeploymentDet
|
|
|
403
437
|
/** Maps a deployment limits DTO to display-ready catalog limits, or `undefined` when no qualifying stats exist. */
|
|
404
438
|
export declare const mapDeploymentLimitsDtoToCatalogLimits: (dto: DeploymentLimitsResponseDto | undefined, labels: DeploymentLimitsLabels) => CatalogItemLimits | undefined;
|
|
405
439
|
|
|
406
|
-
/** Maps
|
|
407
|
-
export declare const mapDeploymentLimitsToInput: (dto: DeploymentLimitsResponseDto | undefined) =>
|
|
440
|
+
/** Maps a deployment's day, week, and month token limits and the caller's cost budget to display-ready rows, or `undefined` when none qualify. */
|
|
441
|
+
export declare const mapDeploymentLimitsToInput: (dto: DeploymentLimitsResponseDto | undefined, labels: ConversationInputLimitsLabels, formatResetTime?: FormatResetTime) => CatalogItemLimits | undefined;
|
|
408
442
|
|
|
409
443
|
/** Maps a deployment listing row into the catalog UI's `CatalogItem` shape. */
|
|
410
444
|
export declare const mapDeploymentToCatalogItem: (deployment: DeploymentItemDto, { favoriteIds, entityDetails, folderLabels, editableSchemaIds, isCustomAppsEditable, activeLocale, primaryLocale, resolveIconUrl, }: MapDeploymentToCatalogItemOptions) => CatalogItem;
|
|
@@ -586,17 +620,19 @@ export declare interface ModelSpecification {
|
|
|
586
620
|
createdAt?: number;
|
|
587
621
|
}
|
|
588
622
|
|
|
589
|
-
/**
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
623
|
+
/**
|
|
624
|
+
* Encodes a deployment/application id to its single-encoded form regardless
|
|
625
|
+
* of whether the value it received was already percent-encoded or the raw,
|
|
626
|
+
* human-readable form — decoding first then re-encoding once is idempotent
|
|
627
|
+
* either way, since `decodeDeploymentId` on a raw (unencoded) id is a no-op.
|
|
628
|
+
* Use this instead of `encodeDeploymentId` at a boundary that cannot
|
|
629
|
+
* guarantee which form it receives, such as a `postMessage` payload from the
|
|
630
|
+
* settings iframe: calling `encodeDeploymentId` directly on a value the
|
|
631
|
+
* sender already encoded escapes the existing `%` characters a second time
|
|
632
|
+
* (`%20` becomes `%2520`), which the backend only ever undoes once and so
|
|
633
|
+
* 404s on.
|
|
634
|
+
*/
|
|
635
|
+
export declare const normalizeDeploymentId: (id: string) => string;
|
|
600
636
|
|
|
601
637
|
/** A skill resource URL split into the bucket and the path within it. */
|
|
602
638
|
export declare interface ParsedSkillResourceUrl {
|
|
@@ -690,6 +726,23 @@ export declare const readSkillManifest: (response: Response) => Promise<string |
|
|
|
690
726
|
*/
|
|
691
727
|
export declare const reconcileFilterTopics: (persistedTopics: ReadonlySet<string>, items: readonly CatalogItem[]) => Set<string>;
|
|
692
728
|
|
|
729
|
+
/**
|
|
730
|
+
* One reset time, already parsed and formatted by the host. Declared
|
|
731
|
+
* structurally here so this library never imports an application type; the
|
|
732
|
+
* host passes a value that satisfies this shape (e.g. `apps/chat`'s own
|
|
733
|
+
* `ResetTimeDisplay`).
|
|
734
|
+
*/
|
|
735
|
+
declare interface ResetTimeDisplay {
|
|
736
|
+
/** Exclusive end of the period as an epoch ms value, for the host's boundary scheduling. */
|
|
737
|
+
resetsAtMs: number;
|
|
738
|
+
/** Machine-readable instant for a `<time dateTime>` attribute. */
|
|
739
|
+
isoValue: string;
|
|
740
|
+
/** Visible reset line. */
|
|
741
|
+
label: string;
|
|
742
|
+
/** Accessible expansion of the reset line. */
|
|
743
|
+
ariaLabel: string;
|
|
744
|
+
}
|
|
745
|
+
|
|
693
746
|
/**
|
|
694
747
|
* Resolves the primary action for a catalog item.
|
|
695
748
|
*
|
package/catalog.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { createPublishApiClient as e, toPublishRuleDto as t } from "./catalog/create-publish-api.js";
|
|
2
2
|
import { buildChatCompletionsUrl as n, buildDeploymentConnectApi as r, buildResponsesUrl as i } from "./catalog/deployment-endpoint-url.js";
|
|
3
|
-
import {
|
|
4
|
-
import { AuthenticationType as
|
|
5
|
-
import { mapDeploymentLimitsDtoToCatalogLimits as
|
|
6
|
-
import { mapDeploymentLimitsToInput as
|
|
7
|
-
import { mapDeploymentDetailsDtoToEntityDetails as
|
|
8
|
-
import { mapDeploymentToCatalogItem as
|
|
9
|
-
import { buildPromptOverview as
|
|
10
|
-
import { PUBLIC_SKILL_BUCKET as
|
|
11
|
-
import { buildSkillContentTree as
|
|
12
|
-
import { McpResourceKind as
|
|
13
|
-
import { getPublicCatalogEntityFolderPath as
|
|
14
|
-
import { deriveAvailableTabIds as
|
|
15
|
-
import { CatalogPrimaryActionType as
|
|
16
|
-
import { useCatalogEditNavigation as
|
|
17
|
-
import { useSkillItemDetails as
|
|
18
|
-
import { useCatalogItemDetails as
|
|
19
|
-
import { useCatalogToolsetCredentials as
|
|
20
|
-
import { useSkillDetailsPanelData as
|
|
21
|
-
import { FavoriteEntityType as
|
|
22
|
-
import { usePublishFolders as
|
|
23
|
-
import { SkillPreviewErrorKind as
|
|
24
|
-
export {
|
|
3
|
+
import { decodeDeploymentId as a, encodeDeploymentId as o, findDeploymentByIdOrReference as s, normalizeDeploymentId as c } from "./catalog/deployment-id.js";
|
|
4
|
+
import { AuthenticationType as l } from "./catalog/entity-details.js";
|
|
5
|
+
import { mapDeploymentLimitsDtoToCatalogLimits as u } from "./catalog/map-deployment-limits-to-catalog.js";
|
|
6
|
+
import { mapDeploymentLimitsToInput as d } from "./catalog/map-deployment-limits-to-input.js";
|
|
7
|
+
import { mapDeploymentDetailsDtoToEntityDetails as f, mapEntityDetailsToCatalogDetails as p, mapToolsetCredentials as m } from "./catalog/map-entity-details-to-catalog.js";
|
|
8
|
+
import { mapDeploymentToCatalogItem as h, mapDeploymentToolsetCredentials as g, mapToolsetToCatalogItem as _, resolveDeploymentFolder as v } from "./catalog/map-deployment-to-catalog-item.js";
|
|
9
|
+
import { buildPromptOverview as y, isOrganisationPromptItem as b, mapPromptToCatalogItem as x } from "./catalog/map-prompt-to-catalog-item.js";
|
|
10
|
+
import { PUBLIC_SKILL_BUCKET as S, SKILL_LISTING_MAX_PAGES as C, SKILL_LISTING_PAGE_SIZE as w, SKILL_MANIFEST_MAX_BYTES as T, SkillSource as E, parseSkillResourceUrl as D } from "./skill/skill-types.js";
|
|
11
|
+
import { buildSkillContentTree as O, buildSkillOverview as k, mapSkillToCatalogItem as A, readSkillFileBytes as j, readSkillFilePreviewBytes as M, readSkillManifest as N, resolveSkillFileDownloadPath as P, resolveSkillManifestFileId as F } from "./catalog/map-skill-to-catalog-item.js";
|
|
12
|
+
import { McpResourceKind as I, buildApplicationMcpUrl as L, buildConnectApi as R, buildToolsetMcpUrl as z, resolveMcpResourceKind as B } from "./catalog/mcp-endpoint-url.js";
|
|
13
|
+
import { getPublicCatalogEntityFolderPath as V, isPublicCatalogEntityId as H, mapPublishConversationResultDto as U, mapPublishHistoryEntryDto as W, toPublishEntityType as G } from "./catalog/publish.js";
|
|
14
|
+
import { deriveAvailableTabIds as K, deriveFavoriteItems as q, filterCatalogItemsBySelector as J, filterHiddenOwnedItems as Y, reconcileFilterTopics as X } from "./catalog/catalog-derivations.js";
|
|
15
|
+
import { CatalogPrimaryActionType as Z, resolveCatalogPrimaryAction as Q } from "./catalog/catalog-primary-action.js";
|
|
16
|
+
import { useCatalogEditNavigation as $ } from "./catalog/useCatalogEditNavigation/useCatalogEditNavigation.js";
|
|
17
|
+
import { useSkillItemDetails as ee } from "./catalog/useSkillItemDetails.js";
|
|
18
|
+
import { useCatalogItemDetails as te } from "./catalog/useCatalogItemDetails.js";
|
|
19
|
+
import { useCatalogToolsetCredentials as ne } from "./catalog/useCatalogToolsetCredentials/useCatalogToolsetCredentials.js";
|
|
20
|
+
import { useSkillDetailsPanelData as re } from "./catalog/useSkillDetailsPanelData/useSkillDetailsPanelData.js";
|
|
21
|
+
import { FavoriteEntityType as ie, useFavoriteEntitiesState as ae } from "./catalog/useFavoriteEntitiesState/useFavoriteEntitiesState.js";
|
|
22
|
+
import { usePublishFolders as oe } from "./catalog/usePublishFolders/usePublishFolders.js";
|
|
23
|
+
import { SkillPreviewErrorKind as se, useSkillFilePreview as ce } from "./skill/useSkillFilePreview.js";
|
|
24
|
+
export { l as AuthenticationType, Z as CatalogPrimaryActionType, ie as FavoriteEntityType, I as McpResourceKind, S as PUBLIC_SKILL_BUCKET, C as SKILL_LISTING_MAX_PAGES, w as SKILL_LISTING_PAGE_SIZE, T as SKILL_MANIFEST_MAX_BYTES, se as SkillPreviewErrorKind, E as SkillSource, L as buildApplicationMcpUrl, n as buildChatCompletionsUrl, R as buildConnectApi, r as buildDeploymentConnectApi, y as buildPromptOverview, i as buildResponsesUrl, O as buildSkillContentTree, k as buildSkillOverview, z as buildToolsetMcpUrl, e as createPublishApiClient, a as decodeDeploymentId, K as deriveAvailableTabIds, q as deriveFavoriteItems, o as encodeDeploymentId, J as filterCatalogItemsBySelector, Y as filterHiddenOwnedItems, s as findDeploymentByIdOrReference, V as getPublicCatalogEntityFolderPath, b as isOrganisationPromptItem, H as isPublicCatalogEntityId, f as mapDeploymentDetailsDtoToEntityDetails, u as mapDeploymentLimitsDtoToCatalogLimits, d as mapDeploymentLimitsToInput, h as mapDeploymentToCatalogItem, g as mapDeploymentToolsetCredentials, p as mapEntityDetailsToCatalogDetails, x as mapPromptToCatalogItem, U as mapPublishConversationResultDto, W as mapPublishHistoryEntryDto, A as mapSkillToCatalogItem, m as mapToolsetCredentials, _ as mapToolsetToCatalogItem, c as normalizeDeploymentId, D as parseSkillResourceUrl, j as readSkillFileBytes, M as readSkillFilePreviewBytes, N as readSkillManifest, X as reconcileFilterTopics, Q as resolveCatalogPrimaryAction, v as resolveDeploymentFolder, B as resolveMcpResourceKind, P as resolveSkillFileDownloadPath, F as resolveSkillManifestFileId, G as toPublishEntityType, t as toPublishRuleDto, $ as useCatalogEditNavigation, te as useCatalogItemDetails, ne as useCatalogToolsetCredentials, ae as useFavoriteEntitiesState, oe as usePublishFolders, re as useSkillDetailsPanelData, ce as useSkillFilePreview, ee as useSkillItemDetails };
|
|
@@ -1,93 +1,129 @@
|
|
|
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
|
+
constructor() {
|
|
5
|
+
super(n), this.name = "GenerationPersistenceError";
|
|
6
|
+
}
|
|
7
|
+
}, 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
|
+
constructor(e = i) {
|
|
4
9
|
super(e), this.name = "GenerationConflictError";
|
|
5
10
|
}
|
|
6
|
-
},
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
}, o = class extends Error {
|
|
12
|
+
constructor(e) {
|
|
13
|
+
super(e), this.name = "StreamUpstreamError";
|
|
14
|
+
}
|
|
15
|
+
}, s = class extends Error {
|
|
16
|
+
constructor(e) {
|
|
17
|
+
super("The completion stream was interrupted", { cause: e }), this.name = "StreamInterruptedError";
|
|
18
|
+
}
|
|
19
|
+
}, c = 45e3, l = (e, t) => {
|
|
20
|
+
let n = Date.now(), r, i = !1, a = () => {
|
|
21
|
+
if (i) return;
|
|
22
|
+
let o = Date.now() - n;
|
|
23
|
+
if (o >= e) {
|
|
24
|
+
t();
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
clearTimeout(r), r = setTimeout(a, e - o);
|
|
28
|
+
}, o = () => {
|
|
29
|
+
document.visibilityState === "visible" && a();
|
|
30
|
+
}, s = typeof window < "u" && typeof document < "u";
|
|
31
|
+
return s && (document.addEventListener("visibilitychange", o), window.addEventListener("online", a), window.addEventListener("pageshow", a)), r = setTimeout(a, e), {
|
|
32
|
+
touch: () => {
|
|
33
|
+
n = Date.now();
|
|
34
|
+
},
|
|
35
|
+
stop: () => {
|
|
36
|
+
i || (i = !0, clearTimeout(r), s && (document.removeEventListener("visibilitychange", o), window.removeEventListener("online", a), window.removeEventListener("pageshow", a)));
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}, u = (e) => typeof e == "object" && !!e && e.name === "AbortError", d = (e, t, n) => {
|
|
40
|
+
let i = e.trim();
|
|
41
|
+
if (!i || i.startsWith(":") || !i.startsWith("data: ")) return;
|
|
42
|
+
let a = i.slice(6);
|
|
43
|
+
if (a !== "[DONE]") try {
|
|
44
|
+
let e = JSON.parse(a);
|
|
12
45
|
if (e.error) {
|
|
13
|
-
n(
|
|
46
|
+
n(e.error.type === r.type ? new r() : new o(e.error.message));
|
|
14
47
|
return;
|
|
15
48
|
}
|
|
16
49
|
t(e);
|
|
17
50
|
} catch {}
|
|
18
|
-
},
|
|
19
|
-
let { completionsBasePath:
|
|
51
|
+
}, f = (n) => {
|
|
52
|
+
let { completionsBasePath: r } = n, i = (...e) => (n.fetchImpl ?? fetch)(...e);
|
|
20
53
|
return {
|
|
21
|
-
streamCompletion: (
|
|
22
|
-
let { onChunk:
|
|
54
|
+
streamCompletion: (o, c, f, p, m, h, g, _, v) => {
|
|
55
|
+
let { onChunk: y, onComplete: b, onError: x, signal: S } = p;
|
|
23
56
|
(async () => {
|
|
24
|
-
let
|
|
57
|
+
let p;
|
|
25
58
|
try {
|
|
26
59
|
let t = n.getTimezone?.();
|
|
27
|
-
|
|
60
|
+
p = await i(`${r}/completions`, {
|
|
28
61
|
method: "POST",
|
|
29
62
|
credentials: "include",
|
|
30
|
-
signal:
|
|
63
|
+
signal: S,
|
|
31
64
|
headers: {
|
|
32
65
|
...e,
|
|
33
66
|
...n.getCsrfToken() == null ? {} : { "X-CSRF-Token": n.getCsrfToken() },
|
|
34
67
|
...t ? { "X-Timezone": t } : {}
|
|
35
68
|
},
|
|
36
69
|
body: JSON.stringify({
|
|
37
|
-
path:
|
|
70
|
+
path: o,
|
|
38
71
|
message: c ?? "",
|
|
39
|
-
model:
|
|
40
|
-
custom_content:
|
|
41
|
-
...
|
|
42
|
-
...
|
|
43
|
-
...
|
|
44
|
-
...
|
|
72
|
+
model: f,
|
|
73
|
+
custom_content: m || {},
|
|
74
|
+
...h != null && { generationId: h },
|
|
75
|
+
...g != null && { mode: g },
|
|
76
|
+
..._ != null && { messageIndex: _ },
|
|
77
|
+
...v != null && { clientChannelId: v }
|
|
45
78
|
})
|
|
46
79
|
});
|
|
47
80
|
} catch (e) {
|
|
48
|
-
if (e
|
|
49
|
-
|
|
81
|
+
if (u(e)) return;
|
|
82
|
+
x(new s(e));
|
|
50
83
|
return;
|
|
51
84
|
}
|
|
52
|
-
let
|
|
53
|
-
if (
|
|
54
|
-
if (
|
|
55
|
-
|
|
85
|
+
let C = p.headers.get("x-csrf-token");
|
|
86
|
+
if (C && n.setCsrfToken(C), !p.ok) {
|
|
87
|
+
if (p.status === t) {
|
|
88
|
+
x(new a());
|
|
56
89
|
return;
|
|
57
90
|
}
|
|
58
|
-
|
|
91
|
+
x(/* @__PURE__ */ Error(`Stream request failed with status ${p.status}`));
|
|
59
92
|
return;
|
|
60
93
|
}
|
|
61
|
-
if (!
|
|
62
|
-
|
|
94
|
+
if (!p.body) {
|
|
95
|
+
x(/* @__PURE__ */ Error("No response body"));
|
|
63
96
|
return;
|
|
64
97
|
}
|
|
65
|
-
let
|
|
66
|
-
|
|
67
|
-
}
|
|
98
|
+
let w = p.body.getReader(), T = new TextDecoder(), E = "", D = !1, O = !1, k = (e) => {
|
|
99
|
+
D || (D = !0, A.stop(), x(e));
|
|
100
|
+
}, A = l(n.idleTimeoutMs ?? 45e3, () => {
|
|
101
|
+
O = !0, k(new s()), w.cancel().catch(() => void 0);
|
|
102
|
+
});
|
|
68
103
|
try {
|
|
69
104
|
for (;;) {
|
|
70
|
-
let { done: e, value: t } = await
|
|
105
|
+
let { done: e, value: t } = await w.read();
|
|
106
|
+
if (O) break;
|
|
71
107
|
if (e) {
|
|
72
|
-
|
|
108
|
+
E.trim() && d(E, y, k);
|
|
73
109
|
break;
|
|
74
110
|
}
|
|
75
|
-
|
|
76
|
-
let n =
|
|
77
|
-
|
|
78
|
-
for (let e of n)
|
|
111
|
+
A.touch(), E += T.decode(t, { stream: !0 });
|
|
112
|
+
let n = E.split("\n");
|
|
113
|
+
E = n.pop() ?? "";
|
|
114
|
+
for (let e of n) d(e, y, k);
|
|
79
115
|
}
|
|
80
|
-
|
|
116
|
+
D || (D = !0, b());
|
|
81
117
|
} catch (e) {
|
|
82
|
-
if (e
|
|
83
|
-
|
|
118
|
+
if (u(e)) return;
|
|
119
|
+
k(new s(e));
|
|
84
120
|
} finally {
|
|
85
|
-
|
|
121
|
+
A.stop(), w.releaseLock();
|
|
86
122
|
}
|
|
87
123
|
})();
|
|
88
124
|
},
|
|
89
125
|
stopCompletion: async (t) => {
|
|
90
|
-
let
|
|
126
|
+
let a = await i(`${r}/completions/stop`, {
|
|
91
127
|
method: "POST",
|
|
92
128
|
credentials: "include",
|
|
93
129
|
headers: {
|
|
@@ -95,10 +131,10 @@ var e = { "Content-Type": "application/json" }, t = 409, n = "A response is alre
|
|
|
95
131
|
...n.getCsrfToken() == null ? {} : { "X-CSRF-Token": n.getCsrfToken() }
|
|
96
132
|
},
|
|
97
133
|
body: JSON.stringify(t)
|
|
98
|
-
}),
|
|
99
|
-
if (
|
|
134
|
+
}), o = a.headers.get("x-csrf-token");
|
|
135
|
+
if (o && n.setCsrfToken(o), !a.ok) throw Error(`stopCompletion failed: ${a.status}`);
|
|
100
136
|
}
|
|
101
137
|
};
|
|
102
138
|
};
|
|
103
139
|
//#endregion
|
|
104
|
-
export {
|
|
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, f as createChatStreamApi };
|
|
@@ -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 };
|