@epam/ai-dial-chat-hooks 1.2.0-dev.15 → 1.2.0-dev.152
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 +5 -4
- package/attachment/useAttachmentValidation/useAttachmentValidation.js +26 -19
- package/attachments.d.ts +10 -4
- package/catalog/map-deployment-limits-to-input.js +81 -9
- package/catalog/map-deployment-to-catalog-item.js +2 -2
- package/catalog/map-skill-to-catalog-item.js +30 -27
- package/catalog/publish.js +2 -1
- package/catalog/useApplicationCredentials/useApplicationCredentials.js +39 -0
- package/catalog/useSkillDetailsPanelData/useSkillDetailsPanelData.js +39 -39
- package/catalog/useSkillItemDetails.js +17 -13
- package/catalog.d.ts +86 -19
- package/catalog.js +6 -5
- package/conversation/conversation-transfer/queue.js +8 -5
- package/conversation/create-chat-stream-api.js +30 -21
- package/conversation/stage.js +23 -0
- package/conversation/useAttachmentUpload/useAttachmentUpload.js +12 -5
- package/conversation/useConversationImport/useConversationImport.js +1 -1
- package/conversation/useConversationPanelItems/useConversationPanelItems.js +2 -3
- package/conversation/useConversationScroll/useConversationScroll.js +68 -64
- package/conversation/useConversationStream/apply-chunk.js +1 -1
- package/conversation/useConversationStream/generation-resume.js +75 -63
- package/conversation/useConversationStream/useConversationStream.js +145 -102
- package/conversation-overlay.d.ts +7 -0
- package/conversation-overlay.js +2 -0
- package/conversation-sources/useConversationSources/useConversationSources.js +31 -24
- package/conversation-sources.d.ts +1 -1
- package/conversation.d.ts +147 -15
- package/conversation.js +31 -30
- package/file-manager-canvas.d.ts +398 -0
- package/file-manager-canvas.js +2 -0
- package/file-manager.d.ts +71 -330
- package/file-manager.js +15 -15
- package/files/attachment-canvas.js +51 -13
- package/files/attachment-types.js +14 -13
- package/files/useDialFileManagerTabConfig/useDialFileManagerTabConfig.js +1 -5
- package/files/useFileAttachmentPicker/useFileAttachmentPicker.js +43 -0
- package/index.d.ts +784 -57
- package/index.js +123 -111
- package/mcp-apps/useMcpAppHostAdapter/useMcpAppHostAdapter.js +7 -5
- package/mcp-apps/useMcpAppHostContext/useMcpAppHostContext.js +1 -1
- package/mcp-apps/useMcpAppTools/useMcpAppTools.js +1 -1
- package/mcp-apps/useOpenMcpAppCanvas/useOpenMcpAppCanvas.js +25 -23
- package/mcp-apps.d.ts +8 -6
- package/package.json +37 -18
- package/scheduled-task/scheduled-task-description.js +77 -0
- package/scheduled-task/scheduled-task-preparation.js +24 -0
- package/scheduled-task/scheduled-task-trigger.js +7 -2
- package/scheduled-task/scheduled-tasks-api-client.js +19 -0
- package/scheduled-task/use-scheduled-task-runs.js +82 -0
- package/scheduled-task/use-scheduled-tasks.js +93 -0
- package/scheduled-tasks.d.ts +180 -3
- package/scheduled-tasks.js +7 -2
- package/skill/skill.js +10 -7
- package/skill/useSkillArchiveImport/useSkillArchiveImport.js +75 -0
- package/skill/useSkillEditorLoad.js +29 -28
- package/skill/useSkillEditorSubmit.js +93 -75
- package/skill-editor.d.ts +110 -1
- package/skill-editor.js +9 -8
- package/usage/map-usage-data-to-dashboard.js +66 -0
- package/usage/map-user-usage-to-model-limits.js +160 -0
- package/usage.d.ts +120 -0
- package/usage.js +3 -0
- package/utils.d.ts +3 -1
package/catalog.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ApplicationExternalServiceDto } from '@epam/ai-dial-chat-api-client';
|
|
1
2
|
import { CatalogContentTreeNode } from '@epam/ai-dial-catalog';
|
|
2
3
|
import { CatalogEntityType } from '@epam/ai-dial-chat-shared';
|
|
3
4
|
import { CatalogItem } from '@epam/ai-dial-catalog';
|
|
@@ -14,8 +15,10 @@ import { DeploymentLimitsResponseDto } from '@epam/ai-dial-chat-api-client';
|
|
|
14
15
|
import { DialToolsetAuthSettingsDto } from '@epam/ai-dial-chat-api-client';
|
|
15
16
|
import { DialToolsetDto } from '@epam/ai-dial-chat-api-client';
|
|
16
17
|
import { DropdownItem } from '@epam/ai-dial-ui-kit';
|
|
18
|
+
import { ExternalServicesApi } from '@epam/ai-dial-chat-api-client';
|
|
17
19
|
import { ListFilesResponseDto } from '@epam/ai-dial-chat-api-client';
|
|
18
20
|
import { NotificationVariant } from '@epam/ai-dial-ui-kit';
|
|
21
|
+
import { OfflineCredentialsApi } from '@epam/ai-dial-chat-api-client';
|
|
19
22
|
import { PromptResponseDto } from '@epam/ai-dial-chat-api-client';
|
|
20
23
|
import { PublicationRule } from '@epam/ai-dial-publish-panel';
|
|
21
24
|
import { PublishApi } from '@epam/ai-dial-chat-api-client';
|
|
@@ -132,6 +135,13 @@ export declare const buildSkillContentTree: (files: SkillMetadataItemDto[], skil
|
|
|
132
135
|
* authored it, when it last changed, and its file inventory. Grouping folders
|
|
133
136
|
* in the file listing are excluded from both the count and the rows. Sizes are
|
|
134
137
|
* not shown — the skill metadata carries no content-length field.
|
|
138
|
+
*
|
|
139
|
+
* `skill` is the authoritative `getSkillMetadata` response when that request
|
|
140
|
+
* fulfilled; the caller falls back to the catalog listing entry only when it
|
|
141
|
+
* rejected (`useSkillItemDetails`'s `onFetchSkillDetails`). Either way, this
|
|
142
|
+
* function never fills a gap in one source from the other — an absent
|
|
143
|
+
* `author` omits the row and an absent `updatedAt` leaves the updated row's
|
|
144
|
+
* value empty, exactly as `skill` carries it.
|
|
135
145
|
*/
|
|
136
146
|
export declare const buildSkillOverview: (skill: SkillMetadataItemDto | undefined, files: SkillMetadataItemDto[], about: SkillAboutDetails | undefined, labels: SkillOverviewLabels) => CatalogItemOverview;
|
|
137
147
|
|
|
@@ -237,6 +247,28 @@ export declare enum CatalogPrimaryActionType {
|
|
|
237
247
|
*/
|
|
238
248
|
export declare type CatalogPublishEntityType = 'model' | 'toolset' | 'application' | 'prompt' | 'skill';
|
|
239
249
|
|
|
250
|
+
/** Labels and formatter callbacks for the conversation-input limits mapping utility. */
|
|
251
|
+
export declare interface ConversationInputLimitsLabels {
|
|
252
|
+
/** Heading of the group listing the selected deployment's token limits. */
|
|
253
|
+
tokenGroup: string;
|
|
254
|
+
/** Heading of the group listing the caller's cost budget, which spans every deployment. */
|
|
255
|
+
costGroup: string;
|
|
256
|
+
/** Label for the current-UTC-day row, used by both groups. */
|
|
257
|
+
periodDay: string;
|
|
258
|
+
/** Label for the current-UTC-week row, used by both groups. */
|
|
259
|
+
periodWeek: string;
|
|
260
|
+
/** Label for the current-UTC-month row, used by both groups. */
|
|
261
|
+
periodMonth: string;
|
|
262
|
+
/** Formats the combined used/total display value for a capped row. */
|
|
263
|
+
formatValueLabel: (used: string, total: string) => string;
|
|
264
|
+
/** Formats the ARIA label for a capped progress row. */
|
|
265
|
+
formatProgressAriaLabel: (params: {
|
|
266
|
+
label: string;
|
|
267
|
+
used: string;
|
|
268
|
+
total: string;
|
|
269
|
+
}) => string;
|
|
270
|
+
}
|
|
271
|
+
|
|
240
272
|
/**
|
|
241
273
|
* Wraps the generated `PublishApi` in the positional-argument surface the
|
|
242
274
|
* catalog and conversation publish flows call, so each host app re-exports one
|
|
@@ -359,6 +391,9 @@ export declare const filterHiddenOwnedItems: (items: readonly CatalogItem[], hid
|
|
|
359
391
|
*/
|
|
360
392
|
export declare const findDeploymentByIdOrReference: (deployments: DeploymentItemDto[], idOrReference: string | null | undefined) => DeploymentItemDto | undefined;
|
|
361
393
|
|
|
394
|
+
/** Formats a raw `resetsAt` into display strings, or returns `undefined` when it cannot be formatted. */
|
|
395
|
+
declare type FormatResetTime = (resetsAt: string | undefined) => ResetTimeDisplay | undefined;
|
|
396
|
+
|
|
362
397
|
/**
|
|
363
398
|
* The publish folder a public catalog entity id sits in: the segments between
|
|
364
399
|
* the `public` bucket and the entity name, decoded to the plain text the
|
|
@@ -396,8 +431,8 @@ export declare const mapDeploymentDetailsDtoToEntityDetails: (dto: DeploymentDet
|
|
|
396
431
|
/** Maps a deployment limits DTO to display-ready catalog limits, or `undefined` when no qualifying stats exist. */
|
|
397
432
|
export declare const mapDeploymentLimitsDtoToCatalogLimits: (dto: DeploymentLimitsResponseDto | undefined, labels: DeploymentLimitsLabels) => CatalogItemLimits | undefined;
|
|
398
433
|
|
|
399
|
-
/** Maps
|
|
400
|
-
export declare const mapDeploymentLimitsToInput: (dto: DeploymentLimitsResponseDto | undefined) =>
|
|
434
|
+
/** 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. */
|
|
435
|
+
export declare const mapDeploymentLimitsToInput: (dto: DeploymentLimitsResponseDto | undefined, labels: ConversationInputLimitsLabels, formatResetTime?: FormatResetTime) => CatalogItemLimits | undefined;
|
|
401
436
|
|
|
402
437
|
/** Maps a deployment listing row into the catalog UI's `CatalogItem` shape. */
|
|
403
438
|
export declare const mapDeploymentToCatalogItem: (deployment: DeploymentItemDto, { favoriteIds, entityDetails, folderLabels, editableSchemaIds, isCustomAppsEditable, activeLocale, primaryLocale, resolveIconUrl, }: MapDeploymentToCatalogItemOptions) => CatalogItem;
|
|
@@ -579,18 +614,6 @@ export declare interface ModelSpecification {
|
|
|
579
614
|
createdAt?: number;
|
|
580
615
|
}
|
|
581
616
|
|
|
582
|
-
/** Normalized monthly token usage consumed by the conversation input control. */
|
|
583
|
-
export declare interface MonthlyUsageLimit {
|
|
584
|
-
/** Normalized used-token count. */
|
|
585
|
-
used: number;
|
|
586
|
-
/** Configured monthly token limit. */
|
|
587
|
-
total: number;
|
|
588
|
-
/** Remaining monthly tokens, clamped to zero. */
|
|
589
|
-
remaining: number;
|
|
590
|
-
/** Monthly utilization percentage, clamped to 0–100. */
|
|
591
|
-
usedPercent: number;
|
|
592
|
-
}
|
|
593
|
-
|
|
594
617
|
/** A skill resource URL split into the bucket and the path within it. */
|
|
595
618
|
export declare interface ParsedSkillResourceUrl {
|
|
596
619
|
/** DIAL Core bucket name. */
|
|
@@ -683,6 +706,23 @@ export declare const readSkillManifest: (response: Response) => Promise<string |
|
|
|
683
706
|
*/
|
|
684
707
|
export declare const reconcileFilterTopics: (persistedTopics: ReadonlySet<string>, items: readonly CatalogItem[]) => Set<string>;
|
|
685
708
|
|
|
709
|
+
/**
|
|
710
|
+
* One reset time, already parsed and formatted by the host. Declared
|
|
711
|
+
* structurally here so this library never imports an application type; the
|
|
712
|
+
* host passes a value that satisfies this shape (e.g. `apps/chat`'s own
|
|
713
|
+
* `ResetTimeDisplay`).
|
|
714
|
+
*/
|
|
715
|
+
declare interface ResetTimeDisplay {
|
|
716
|
+
/** Exclusive end of the period as an epoch ms value, for the host's boundary scheduling. */
|
|
717
|
+
resetsAtMs: number;
|
|
718
|
+
/** Machine-readable instant for a `<time dateTime>` attribute. */
|
|
719
|
+
isoValue: string;
|
|
720
|
+
/** Visible reset line. */
|
|
721
|
+
label: string;
|
|
722
|
+
/** Accessible expansion of the reset line. */
|
|
723
|
+
ariaLabel: string;
|
|
724
|
+
}
|
|
725
|
+
|
|
686
726
|
/**
|
|
687
727
|
* Resolves the primary action for a catalog item.
|
|
688
728
|
*
|
|
@@ -699,7 +739,8 @@ export declare const reconcileFilterTopics: (persistedTopics: ReadonlySet<string
|
|
|
699
739
|
*/
|
|
700
740
|
export declare const resolveCatalogPrimaryAction: (item: CatalogItem, fetchPrompt: (item: CatalogItem) => Promise<PromptResponseDto>) => Promise<CatalogPrimaryActionResult>;
|
|
701
741
|
|
|
702
|
-
|
|
742
|
+
/** Resolves a deployment's display folder, including organization applications without a folder path. */
|
|
743
|
+
export declare const resolveDeploymentFolder: (deployment: Pick<DeploymentItemDto, "isMy" | "sharedWithMe" | "applicationFolder"> & Partial<Pick<DeploymentItemDto, "type">>, labels: DeploymentFolderLabels) => string[];
|
|
703
744
|
|
|
704
745
|
/** Returns the MCP resource kind a catalog item's Connect endpoint belongs to, or `null` when the item exposes no MCP endpoint. */
|
|
705
746
|
export declare const resolveMcpResourceKind: (type: CatalogEntityType, supportsMcp?: boolean) => McpResourceKind | null;
|
|
@@ -756,6 +797,12 @@ export declare interface SkillDetailsApi {
|
|
|
756
797
|
limit?: number;
|
|
757
798
|
recursive?: boolean;
|
|
758
799
|
}, signal?: AbortSignal): Promise<SkillFileListResponseDto>;
|
|
800
|
+
/**
|
|
801
|
+
* Fetches a single skill's own authoritative metadata (`author`,
|
|
802
|
+
* `updatedAt`, and the rest of `SkillMetadataItemDto`) — not the catalog
|
|
803
|
+
* listing entry, which may be sparse for a shared skill.
|
|
804
|
+
*/
|
|
805
|
+
getSkillMetadata(bucket: string, path: string, signal?: AbortSignal): Promise<SkillMetadataItemDto>;
|
|
759
806
|
}
|
|
760
807
|
|
|
761
808
|
/** A skill's parsed manifest details. */
|
|
@@ -898,6 +945,25 @@ export declare const toPublishEntityType: (type: CatalogEntityType) => CatalogPu
|
|
|
898
945
|
*/
|
|
899
946
|
export declare const toPublishRuleDto: (rule: PublicationRule) => PublishRuleDto;
|
|
900
947
|
|
|
948
|
+
/** Loads fresh service statuses without coupling proactive credentials to a live completion. */
|
|
949
|
+
export declare const useApplicationCredentials: ({ appId, externalServicesClient, offlineCredentialsClient, }: UseApplicationCredentialsParams) => {
|
|
950
|
+
services: ApplicationExternalServiceDto[];
|
|
951
|
+
isOfflineConnected: boolean;
|
|
952
|
+
isLoading: boolean;
|
|
953
|
+
hasError: boolean;
|
|
954
|
+
refresh: () => Promise<void>;
|
|
955
|
+
};
|
|
956
|
+
|
|
957
|
+
/** Configured operations for loading application credential metadata. */
|
|
958
|
+
export declare interface UseApplicationCredentialsParams {
|
|
959
|
+
/** Application identifier passed through to the configured client. */
|
|
960
|
+
appId: string;
|
|
961
|
+
/** Host-configured external-services API. */
|
|
962
|
+
externalServicesClient: Pick<ExternalServicesApi, 'listExternalServices'>;
|
|
963
|
+
/** Host-configured offline-credentials API. */
|
|
964
|
+
offlineCredentialsClient: Pick<OfflineCredentialsApi, 'getOfflineCredentials'>;
|
|
965
|
+
}
|
|
966
|
+
|
|
901
967
|
/**
|
|
902
968
|
* Owns the catalog's edit/delete/create-menu navigation: routing the details
|
|
903
969
|
* panel's Edit action to the right editor URL for each item type, deleting an
|
|
@@ -1217,10 +1283,11 @@ export declare interface UseSkillFilePreviewResult {
|
|
|
1217
1283
|
|
|
1218
1284
|
/**
|
|
1219
1285
|
* Headless hook that encapsulates skill detail fetching: manifest download and
|
|
1220
|
-
* parse, package file listing,
|
|
1221
|
-
* loads. `useCatalogItemDetails` delegates
|
|
1222
|
-
* only surface skill details consume this
|
|
1223
|
-
* deployment and prompt ports the full catalog
|
|
1286
|
+
* parse, package file listing, authoritative metadata fetching, overview
|
|
1287
|
+
* construction, and in-package file loads. `useCatalogItemDetails` delegates
|
|
1288
|
+
* its skill branch here; hosts that only surface skill details consume this
|
|
1289
|
+
* hook directly, without the deployment and prompt ports the full catalog
|
|
1290
|
+
* pipeline requires.
|
|
1224
1291
|
*/
|
|
1225
1292
|
export declare const useSkillItemDetails: ({ api, skills, skillOverviewLabels, }: UseSkillItemDetailsOptions) => UseSkillItemDetailsResult;
|
|
1226
1293
|
|
package/catalog.js
CHANGED
|
@@ -17,8 +17,9 @@ import { useCatalogEditNavigation as Z } from "./catalog/useCatalogEditNavigatio
|
|
|
17
17
|
import { useSkillItemDetails as Q } from "./catalog/useSkillItemDetails.js";
|
|
18
18
|
import { useCatalogItemDetails as $ } from "./catalog/useCatalogItemDetails.js";
|
|
19
19
|
import { useCatalogToolsetCredentials as ee } from "./catalog/useCatalogToolsetCredentials/useCatalogToolsetCredentials.js";
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
|
|
20
|
+
import { useApplicationCredentials as te } from "./catalog/useApplicationCredentials/useApplicationCredentials.js";
|
|
21
|
+
import { useSkillDetailsPanelData as ne } from "./catalog/useSkillDetailsPanelData/useSkillDetailsPanelData.js";
|
|
22
|
+
import { FavoriteEntityType as re, useFavoriteEntitiesState as ie } from "./catalog/useFavoriteEntitiesState/useFavoriteEntitiesState.js";
|
|
23
|
+
import { usePublishFolders as ae } from "./catalog/usePublishFolders/usePublishFolders.js";
|
|
24
|
+
import { SkillPreviewErrorKind as oe, useSkillFilePreview as se } from "./skill/useSkillFilePreview.js";
|
|
25
|
+
export { s as AuthenticationType, Y as CatalogPrimaryActionType, re as FavoriteEntityType, P as McpResourceKind, b as PUBLIC_SKILL_BUCKET, x as SKILL_LISTING_MAX_PAGES, S as SKILL_LISTING_PAGE_SIZE, C as SKILL_MANIFEST_MAX_BYTES, oe as SkillPreviewErrorKind, w as SkillSource, F as buildApplicationMcpUrl, n as buildChatCompletionsUrl, I as buildConnectApi, r as buildDeploymentConnectApi, _ as buildPromptOverview, i as buildResponsesUrl, E as buildSkillContentTree, D as buildSkillOverview, L as buildToolsetMcpUrl, e as createPublishApiClient, W as deriveAvailableTabIds, G as deriveFavoriteItems, a as encodeDeploymentId, K as filterCatalogItemsBySelector, q as filterHiddenOwnedItems, o as findDeploymentByIdOrReference, z as getPublicCatalogEntityFolderPath, v as isOrganisationPromptItem, B as isPublicCatalogEntityId, u as mapDeploymentDetailsDtoToEntityDetails, c as mapDeploymentLimitsDtoToCatalogLimits, l as mapDeploymentLimitsToInput, p as mapDeploymentToCatalogItem, m as mapDeploymentToolsetCredentials, d as mapEntityDetailsToCatalogDetails, y as mapPromptToCatalogItem, V as mapPublishConversationResultDto, H as mapPublishHistoryEntryDto, O as mapSkillToCatalogItem, f as mapToolsetCredentials, h as mapToolsetToCatalogItem, T as parseSkillResourceUrl, k as readSkillFileBytes, A as readSkillFilePreviewBytes, j as readSkillManifest, J as reconcileFilterTopics, X as resolveCatalogPrimaryAction, g as resolveDeploymentFolder, R as resolveMcpResourceKind, M as resolveSkillFileDownloadPath, N as resolveSkillManifestFileId, U as toPublishEntityType, t as toPublishRuleDto, te as useApplicationCredentials, Z as useCatalogEditNavigation, $ as useCatalogItemDetails, ee as useCatalogToolsetCredentials, ie as useFavoriteEntitiesState, ae as usePublishFolders, ne as useSkillDetailsPanelData, se as useSkillFilePreview, Q as useSkillItemDetails };
|
|
@@ -27,13 +27,14 @@ var o = () => {
|
|
|
27
27
|
progress: { percent: 100 },
|
|
28
28
|
errorCode: void 0
|
|
29
29
|
});
|
|
30
|
-
}, [u]), m = n((t, n) => {
|
|
31
|
-
s((
|
|
32
|
-
...
|
|
30
|
+
}, [u]), m = n((t, n, r) => {
|
|
31
|
+
s((i) => i.map((i) => i.id !== t || i.status !== e.InProgress ? i : {
|
|
32
|
+
...i,
|
|
33
33
|
status: e.Warning,
|
|
34
34
|
progress: { percent: 100 },
|
|
35
35
|
errorCode: void 0,
|
|
36
|
-
warningCode: n
|
|
36
|
+
warningCode: n,
|
|
37
|
+
warningNames: r
|
|
37
38
|
}));
|
|
38
39
|
}, []), h = n((t, n) => {
|
|
39
40
|
u(t, {
|
|
@@ -57,7 +58,9 @@ var o = () => {
|
|
|
57
58
|
return l.current.set(t, () => (u(t, {
|
|
58
59
|
status: e.InProgress,
|
|
59
60
|
progress: { percent: 0 },
|
|
60
|
-
errorCode: void 0
|
|
61
|
+
errorCode: void 0,
|
|
62
|
+
warningCode: void 0,
|
|
63
|
+
warningNames: void 0
|
|
61
64
|
}), r())), r();
|
|
62
65
|
}, [u]);
|
|
63
66
|
return r(() => {
|
|
@@ -1,30 +1,39 @@
|
|
|
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 = (e, t, n) => {
|
|
16
|
+
let i = e.trim();
|
|
17
|
+
if (!i || i.startsWith(":") || !i.startsWith("data: ")) return;
|
|
18
|
+
let a = i.slice(6);
|
|
19
|
+
if (a !== "[DONE]") try {
|
|
20
|
+
let e = JSON.parse(a);
|
|
12
21
|
if (e.error) {
|
|
13
|
-
n(
|
|
22
|
+
n(e.error.type === r.type ? new r() : new o(e.error.message));
|
|
14
23
|
return;
|
|
15
24
|
}
|
|
16
25
|
t(e);
|
|
17
26
|
} catch {}
|
|
18
|
-
},
|
|
19
|
-
let { completionsBasePath:
|
|
27
|
+
}, c = (n) => {
|
|
28
|
+
let { completionsBasePath: r } = n, i = (...e) => (n.fetchImpl ?? fetch)(...e);
|
|
20
29
|
return {
|
|
21
|
-
streamCompletion: (
|
|
30
|
+
streamCompletion: (o, c, l, u, d, f, p, m, h) => {
|
|
22
31
|
let { onChunk: g, onComplete: _, onError: v, signal: y } = u;
|
|
23
32
|
(async () => {
|
|
24
33
|
let u;
|
|
25
34
|
try {
|
|
26
35
|
let t = n.getTimezone?.();
|
|
27
|
-
u = await
|
|
36
|
+
u = await i(`${r}/completions`, {
|
|
28
37
|
method: "POST",
|
|
29
38
|
credentials: "include",
|
|
30
39
|
signal: y,
|
|
@@ -34,7 +43,7 @@ var e = { "Content-Type": "application/json" }, t = 409, n = "A response is alre
|
|
|
34
43
|
...t ? { "X-Timezone": t } : {}
|
|
35
44
|
},
|
|
36
45
|
body: JSON.stringify({
|
|
37
|
-
path:
|
|
46
|
+
path: o,
|
|
38
47
|
message: c ?? "",
|
|
39
48
|
model: l,
|
|
40
49
|
custom_content: d || {},
|
|
@@ -52,7 +61,7 @@ var e = { "Content-Type": "application/json" }, t = 409, n = "A response is alre
|
|
|
52
61
|
let b = u.headers.get("x-csrf-token");
|
|
53
62
|
if (b && n.setCsrfToken(b), !u.ok) {
|
|
54
63
|
if (u.status === t) {
|
|
55
|
-
v(new
|
|
64
|
+
v(new a());
|
|
56
65
|
return;
|
|
57
66
|
}
|
|
58
67
|
v(/* @__PURE__ */ Error(`Stream request failed with status ${u.status}`));
|
|
@@ -69,13 +78,13 @@ var e = { "Content-Type": "application/json" }, t = 409, n = "A response is alre
|
|
|
69
78
|
for (;;) {
|
|
70
79
|
let { done: e, value: t } = await x.read();
|
|
71
80
|
if (e) {
|
|
72
|
-
C.trim() &&
|
|
81
|
+
C.trim() && s(C, g, T);
|
|
73
82
|
break;
|
|
74
83
|
}
|
|
75
84
|
C += S.decode(t, { stream: !0 });
|
|
76
85
|
let n = C.split("\n");
|
|
77
86
|
C = n.pop() ?? "";
|
|
78
|
-
for (let e of n)
|
|
87
|
+
for (let e of n) s(e, g, T);
|
|
79
88
|
}
|
|
80
89
|
w || _();
|
|
81
90
|
} catch (e) {
|
|
@@ -87,7 +96,7 @@ var e = { "Content-Type": "application/json" }, t = 409, n = "A response is alre
|
|
|
87
96
|
})();
|
|
88
97
|
},
|
|
89
98
|
stopCompletion: async (t) => {
|
|
90
|
-
let
|
|
99
|
+
let a = await i(`${r}/completions/stop`, {
|
|
91
100
|
method: "POST",
|
|
92
101
|
credentials: "include",
|
|
93
102
|
headers: {
|
|
@@ -95,10 +104,10 @@ var e = { "Content-Type": "application/json" }, t = 409, n = "A response is alre
|
|
|
95
104
|
...n.getCsrfToken() == null ? {} : { "X-CSRF-Token": n.getCsrfToken() }
|
|
96
105
|
},
|
|
97
106
|
body: JSON.stringify(t)
|
|
98
|
-
}),
|
|
99
|
-
if (
|
|
107
|
+
}), o = a.headers.get("x-csrf-token");
|
|
108
|
+
if (o && n.setCsrfToken(o), !a.ok) throw Error(`stopCompletion failed: ${a.status}`);
|
|
100
109
|
}
|
|
101
110
|
};
|
|
102
111
|
};
|
|
103
112
|
//#endregion
|
|
104
|
-
export {
|
|
113
|
+
export { i as DEFAULT_GENERATION_CONFLICT_MESSAGE, n as DEFAULT_GENERATION_PERSISTENCE_ERROR_MESSAGE, a as GenerationConflictError, r as GenerationPersistenceError, o as StreamUpstreamError, c as createChatStreamApi };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { StageStatus as e } from "@epam/ai-dial-chat-shared";
|
|
2
|
+
//#region src/conversation/stage.ts
|
|
3
|
+
var t = (t) => t === e.Completed ? e.Completed : t === e.Failed ? e.Failed : null, n = (e) => ({
|
|
4
|
+
title: e.title ?? "",
|
|
5
|
+
...e.index != null && { index: e.index },
|
|
6
|
+
...e.type != null && { type: e.type },
|
|
7
|
+
...e.data != null && { data: e.data },
|
|
8
|
+
...e.url != null && { url: e.url },
|
|
9
|
+
...e.reference_type != null && { reference_type: e.reference_type },
|
|
10
|
+
...e.reference_url != null && { reference_url: e.reference_url }
|
|
11
|
+
}), r = (e) => ({
|
|
12
|
+
index: e.index ?? 0,
|
|
13
|
+
name: e.name ?? "",
|
|
14
|
+
status: t(e.status),
|
|
15
|
+
...e.content != null && { content: e.content },
|
|
16
|
+
...e.tag != null && { tag: e.tag },
|
|
17
|
+
...e.attachments?.length && { attachments: e.attachments.map(n) }
|
|
18
|
+
}), i = (e) => {
|
|
19
|
+
let t = Array.isArray(e) ? e : e?.custom_content?.stages ?? e?.customContent?.stages;
|
|
20
|
+
if (t?.length) return t.map(r);
|
|
21
|
+
};
|
|
22
|
+
//#endregion
|
|
23
|
+
export { i as mapStages, r as toStage };
|
|
@@ -26,9 +26,16 @@ var o = 700, s = 5, c = (e) => t(e.split("/").filter(Boolean).pop() ?? "file").r
|
|
|
26
26
|
})).url,
|
|
27
27
|
name: a.fileName
|
|
28
28
|
};
|
|
29
|
-
} catch (
|
|
30
|
-
if (l(
|
|
29
|
+
} catch (c) {
|
|
30
|
+
if (l(c)) {
|
|
31
31
|
if (i.markTaken(a.fileName), o < s) {
|
|
32
|
+
if (t.listFiles) try {
|
|
33
|
+
let e = await t.listFiles({
|
|
34
|
+
bucket: u,
|
|
35
|
+
path: a.path.slice(0, a.path.lastIndexOf("/"))
|
|
36
|
+
});
|
|
37
|
+
for (let t of e.items) i.markTaken(t.name);
|
|
38
|
+
} catch {}
|
|
32
39
|
a = i.allocate(n);
|
|
33
40
|
continue;
|
|
34
41
|
}
|
|
@@ -38,10 +45,10 @@ var o = 700, s = 5, c = (e) => t(e.split("/").filter(Boolean).pop() ?? "file").r
|
|
|
38
45
|
let e = p.current.splice(0);
|
|
39
46
|
d?.(e), m.current = null;
|
|
40
47
|
}, f);
|
|
41
|
-
let
|
|
42
|
-
throw
|
|
48
|
+
let t = c instanceof Error ? c : /* @__PURE__ */ Error("Network upload failed");
|
|
49
|
+
throw t.errorReason = r.Network, t;
|
|
43
50
|
}
|
|
44
|
-
throw
|
|
51
|
+
throw c;
|
|
45
52
|
}
|
|
46
53
|
}, [
|
|
47
54
|
u,
|
|
@@ -191,7 +191,7 @@ var b = 5, x = 5, S = (e) => /\.(dial|zip)$/i.test(e.name), C = (e) => new Promi
|
|
|
191
191
|
jobId: n,
|
|
192
192
|
code: t.AttachmentSkipped,
|
|
193
193
|
names: [...j]
|
|
194
|
-
}), A.length > 0 ? D.failJob(n, h.Unknown) : j.size > 0 ? D.warnJob(n, t.AttachmentSkipped) : D.succeedJob(n);
|
|
194
|
+
}), A.length > 0 ? D.failJob(n, h.Unknown) : j.size > 0 ? D.warnJob(n, t.AttachmentSkipped, [...j]) : D.succeedJob(n);
|
|
195
195
|
}
|
|
196
196
|
}, [
|
|
197
197
|
l,
|
|
@@ -4,7 +4,7 @@ import { getModelIdFromConversationId as n } from "../get-model-id-from-conversa
|
|
|
4
4
|
import { FilterTab as r } from "@epam/ai-dial-chat-shared";
|
|
5
5
|
import { useMemo as i } from "react";
|
|
6
6
|
//#region src/conversation/useConversationPanelItems/useConversationPanelItems.ts
|
|
7
|
-
var a = (e) => e.sharedWithMe ? r.Shared : e.publishedWithMe ? r.Organization : r.MyChats, o = ({ items: r, deployments: o, isDeploymentsLoading: s, toPanelConversationId: c, resolveIconUrl: l, resolveIconTooltip: u, resolveHref: d,
|
|
7
|
+
var a = (e) => e.sharedWithMe ? r.Shared : e.publishedWithMe ? r.Organization : r.MyChats, o = ({ items: r, deployments: o, isDeploymentsLoading: s, toPanelConversationId: c, resolveIconUrl: l, resolveIconTooltip: u, resolveHref: d, resolveTaskPresentation: f }) => i(() => r.map((r) => {
|
|
8
8
|
let i = c(r.id), p = n(r.id), m = p ? t(o, p) : void 0, h = p ? e(p.split("/").pop() ?? p) : "", g = f?.(r);
|
|
9
9
|
return {
|
|
10
10
|
id: i,
|
|
@@ -16,8 +16,7 @@ var a = (e) => e.sharedWithMe ? r.Shared : e.publishedWithMe ? r.Organization :
|
|
|
16
16
|
source: a(r),
|
|
17
17
|
href: d(i),
|
|
18
18
|
...g == null ? {} : {
|
|
19
|
-
|
|
20
|
-
taskBadgeLabel: g.label,
|
|
19
|
+
leadingIcon: g.leadingIcon,
|
|
21
20
|
isUnread: g.isUnread
|
|
22
21
|
}
|
|
23
22
|
};
|
|
@@ -1,121 +1,125 @@
|
|
|
1
1
|
import { useCallback as e, useEffect as t, useLayoutEffect as n, useRef as r, useState as i } from "react";
|
|
2
2
|
//#region src/conversation/useConversationScroll/useConversationScroll.ts
|
|
3
3
|
var a = 80, o = 1, s = ({ messages: s, isAssistantTyping: c, conversationId: l }) => {
|
|
4
|
-
let [u, d] = i(!1), f = r(null), p = r(null), m = r(null), h = r(!1), g = r(!1), _ = r(null), v = r(/* @__PURE__ */ new Map()),
|
|
5
|
-
t ?
|
|
6
|
-
}, []),
|
|
7
|
-
|
|
8
|
-
}, []),
|
|
4
|
+
let [u, d] = i(!1), f = r(null), p = r(null), m = r(null), h = r(!1), g = r(!1), _ = r(null), v = r(!0), y = r(/* @__PURE__ */ new Map()), b = e((e, t) => {
|
|
5
|
+
t ? y.current.set(e, t) : y.current.delete(e);
|
|
6
|
+
}, []), x = r(null), S = e((e) => {
|
|
7
|
+
x.current = e;
|
|
8
|
+
}, []), C = e((e, t) => {
|
|
9
9
|
let n = f.current;
|
|
10
10
|
n && n.scrollTo({
|
|
11
11
|
top: e,
|
|
12
12
|
behavior: t ? "instant" : "smooth"
|
|
13
13
|
});
|
|
14
|
-
}, []), C = e(() => {
|
|
15
|
-
m.current && (m.current.style.height = "0px"), h.current = !1, g.current = !1, _.current = null;
|
|
16
14
|
}, []), w = e(() => {
|
|
15
|
+
m.current && (m.current.style.height = "0px"), h.current = !1, g.current = !1, _.current = null;
|
|
16
|
+
}, []), T = e(() => {
|
|
17
17
|
let e = f.current, t = p.current;
|
|
18
18
|
if (!e || !t) return null;
|
|
19
19
|
let n = e.getBoundingClientRect(), r = t.getBoundingClientRect();
|
|
20
20
|
return e.scrollTop + (r.bottom - n.top) - e.clientHeight;
|
|
21
|
-
}, []),
|
|
22
|
-
let t =
|
|
23
|
-
t != null &&
|
|
24
|
-
}, [
|
|
21
|
+
}, []), E = e((e = !1) => {
|
|
22
|
+
let t = T();
|
|
23
|
+
t != null && C(Math.max(t, 0), e);
|
|
24
|
+
}, [C, T]), D = e(() => {
|
|
25
25
|
let e = f.current, t = p.current;
|
|
26
26
|
if (!e || !t) return null;
|
|
27
27
|
let n = e.getBoundingClientRect();
|
|
28
28
|
return t.getBoundingClientRect().bottom - n.top - e.clientHeight;
|
|
29
|
-
}, []),
|
|
29
|
+
}, []), O = e(() => {
|
|
30
30
|
if (!g.current) return;
|
|
31
|
-
let e =
|
|
32
|
-
e == null || e < -1 ||
|
|
33
|
-
}, [
|
|
34
|
-
let t = f.current, n =
|
|
31
|
+
let e = D();
|
|
32
|
+
e == null || e < -1 || w();
|
|
33
|
+
}, [w, D]), k = e((e) => {
|
|
34
|
+
let t = f.current, n = y.current.get(e);
|
|
35
35
|
if (!t || !n) return null;
|
|
36
36
|
let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a = t.scrollTop + (i.top - r.top);
|
|
37
37
|
return Math.max(a, 0);
|
|
38
|
-
}, []),
|
|
39
|
-
let n =
|
|
40
|
-
n != null &&
|
|
41
|
-
}, [
|
|
42
|
-
let e =
|
|
38
|
+
}, []), A = e((e, t = !1) => {
|
|
39
|
+
let n = k(e);
|
|
40
|
+
n != null && C(n, t);
|
|
41
|
+
}, [k, C]), j = e(() => {
|
|
42
|
+
let e = T();
|
|
43
43
|
return e == null ? null : Math.max(e, 0);
|
|
44
|
-
}, [
|
|
44
|
+
}, [T]), M = e(() => {
|
|
45
45
|
if (!h.current) return null;
|
|
46
|
-
let e = _.current, t =
|
|
46
|
+
let e = _.current, t = j();
|
|
47
47
|
return e == null || t == null ? null : Math.max(e, t);
|
|
48
|
-
}, [
|
|
49
|
-
let e = f.current, t =
|
|
48
|
+
}, [j]), N = e(() => {
|
|
49
|
+
let e = f.current, t = M();
|
|
50
50
|
!e || t == null || e.scrollTop > t + o && (e.scrollTop = t);
|
|
51
|
-
}, [
|
|
52
|
-
let t = m.current, n =
|
|
51
|
+
}, [M]), P = e((e) => {
|
|
52
|
+
let t = m.current, n = j();
|
|
53
53
|
if (!t || n == null) return;
|
|
54
54
|
let r = Math.max(e - n, 0);
|
|
55
55
|
t.style.height = `${r}px`, h.current = r > 0, g.current = !1, _.current = r > 0 ? e : null;
|
|
56
|
-
}, [
|
|
57
|
-
let t =
|
|
58
|
-
t != null && (
|
|
56
|
+
}, [j]), F = e((e) => {
|
|
57
|
+
let t = k(e);
|
|
58
|
+
t != null && (P(t), A(e, !1));
|
|
59
59
|
}, [
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
]),
|
|
64
|
-
let e =
|
|
65
|
-
|
|
66
|
-
|
|
60
|
+
P,
|
|
61
|
+
k,
|
|
62
|
+
A
|
|
63
|
+
]), I = e(() => {
|
|
64
|
+
let e = D();
|
|
65
|
+
if (e == null) return;
|
|
66
|
+
let t = e < a;
|
|
67
|
+
v.current = t, d(!t);
|
|
68
|
+
}, [D]), L = r(s.length), R = r(null);
|
|
67
69
|
n(() => {
|
|
68
|
-
let e = s.length !==
|
|
69
|
-
|
|
70
|
+
let e = s.length !== L.current, t = l !== R.current, n = () => {
|
|
71
|
+
L.current = s.length, R.current = l;
|
|
70
72
|
};
|
|
71
|
-
t &&
|
|
72
|
-
let r =
|
|
73
|
-
if (r != null &&
|
|
74
|
-
|
|
73
|
+
t && w();
|
|
74
|
+
let r = x.current;
|
|
75
|
+
if (r != null && y.current.has(r)) {
|
|
76
|
+
x.current = null, F(r), n();
|
|
75
77
|
return;
|
|
76
78
|
}
|
|
77
|
-
c || ((e || t) &&
|
|
79
|
+
c || ((e || t) && E(!1), n());
|
|
78
80
|
}, [
|
|
79
81
|
s,
|
|
80
82
|
c,
|
|
81
83
|
l,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
84
|
+
E,
|
|
85
|
+
F,
|
|
86
|
+
w
|
|
85
87
|
]), n(() => {
|
|
86
|
-
!c && h.current && (g.current = !0,
|
|
87
|
-
}, [c,
|
|
88
|
-
let
|
|
89
|
-
|
|
88
|
+
!c && h.current && (g.current = !0, O());
|
|
89
|
+
}, [c, O]);
|
|
90
|
+
let z = e(() => {
|
|
91
|
+
N(), O(), I();
|
|
90
92
|
}, [
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
93
|
+
N,
|
|
94
|
+
O,
|
|
95
|
+
I
|
|
94
96
|
]);
|
|
95
97
|
return t(() => {
|
|
96
98
|
let e = f.current;
|
|
97
|
-
if (e) return e.addEventListener("scroll",
|
|
98
|
-
}, [
|
|
99
|
+
if (e) return e.addEventListener("scroll", z, { passive: !0 }), () => e.removeEventListener("scroll", z);
|
|
100
|
+
}, [z]), t(() => {
|
|
99
101
|
let e = p.current;
|
|
100
102
|
if (!e) return;
|
|
101
103
|
let t = new ResizeObserver(() => {
|
|
102
|
-
|
|
104
|
+
let e = v.current && !h.current;
|
|
105
|
+
N(), e && E(!0), O(), I();
|
|
103
106
|
});
|
|
104
107
|
return t.observe(e), () => t.disconnect();
|
|
105
108
|
}, [
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
+
N,
|
|
110
|
+
O,
|
|
111
|
+
I,
|
|
112
|
+
E
|
|
109
113
|
]), {
|
|
110
114
|
containerRef: f,
|
|
111
115
|
contentRef: p,
|
|
112
116
|
spacerRef: m,
|
|
113
|
-
setMessageRef:
|
|
117
|
+
setMessageRef: b,
|
|
114
118
|
isScrollButtonVisible: u,
|
|
115
119
|
scrollToBottom: e(() => {
|
|
116
|
-
|
|
117
|
-
}, [
|
|
118
|
-
armAnchor:
|
|
120
|
+
E(!1);
|
|
121
|
+
}, [E]),
|
|
122
|
+
armAnchor: S
|
|
119
123
|
};
|
|
120
124
|
};
|
|
121
125
|
//#endregion
|