@epam/statgpt-conversation-view 0.7.0-dev.34 → 0.7.0-dev.4

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.
@@ -0,0 +1,20 @@
1
+ import { Conversation, ConversationInfo } from '@epam/ai-dial-shared';
2
+ import { ConversationViewActions } from '../../../models/actions';
3
+ export interface UseConversationLifecycleArgs {
4
+ actions: ConversationViewActions;
5
+ conversation: Conversation | null;
6
+ locale: string;
7
+ conversationsRoute?: string;
8
+ openUrl: (url: string) => void;
9
+ setConversations: (conversations: ConversationInfo[]) => void;
10
+ }
11
+ /**
12
+ * Conversation-level actions: duplicating the current (read-only) conversation
13
+ * — copying its attachments when the file actions are available, then creating
14
+ * the copy, refreshing the conversation list and navigating to it — and opening
15
+ * a fresh conversation from the onboarding footer.
16
+ */
17
+ export declare const useConversationLifecycle: ({ actions, conversation, locale, conversationsRoute, openUrl, setConversations, }: UseConversationLifecycleArgs) => {
18
+ handleOpeningOfNewConversation: () => void;
19
+ duplicateConversation: () => Promise<void>;
20
+ };
@@ -0,0 +1,24 @@
1
+ import { Conversation } from '@epam/ai-dial-shared';
2
+ import { Dispatch, SetStateAction } from 'react';
3
+ import { ConversationViewActions } from '../../../models/actions';
4
+ export interface UseConversationLoaderArgs {
5
+ conversationKey: string;
6
+ actions: ConversationViewActions;
7
+ setConversation: Dispatch<SetStateAction<Conversation | null>>;
8
+ setCrossDatasetAttachmentsState: () => void;
9
+ sendMessageToConversation: (content: string, data: Conversation | null, customChoiceId?: string) => void;
10
+ onConversationNotFound?: () => void;
11
+ }
12
+ /**
13
+ * Loads the conversation for the current `conversationKey`, derives its
14
+ * read-only flag, and sends the stored `prompt` to start the first turn when
15
+ * there are no user messages yet (an empty conversation, or one holding only a
16
+ * seed assistant message). Owns the `isLoading` / `isReadonlyConversation` UI
17
+ * state and clears the request cache around each load. On failure it marks the
18
+ * conversation read-only and calls `onConversationNotFound`. Re-fetches only
19
+ * when `conversationKey` changes.
20
+ */
21
+ export declare const useConversationLoader: ({ conversationKey, actions, setConversation, setCrossDatasetAttachmentsState, sendMessageToConversation, onConversationNotFound, }: UseConversationLoaderArgs) => {
22
+ isLoading: boolean;
23
+ isReadonlyConversation: boolean;
24
+ };
@@ -0,0 +1,13 @@
1
+ import { Conversation } from '@epam/ai-dial-shared';
2
+ import { ConversationViewActions } from '../../../models/actions';
3
+ export interface UseConversationSaverArgs {
4
+ actions: ConversationViewActions;
5
+ conversationKey: string;
6
+ }
7
+ /**
8
+ * Persists the conversation back to the DIAL API via `actions.updateConversation`
9
+ * — only `name`, `messages` and `customViewState` are sent. Failures are logged
10
+ * and swallowed (the local state is left untouched). Shared by the streaming and
11
+ * message-feedback flows, which both flush local edits to the server.
12
+ */
13
+ export declare const useConversationSaver: ({ actions, conversationKey, }: UseConversationSaverArgs) => (updatedConversation: Conversation) => Promise<void>;
@@ -0,0 +1,35 @@
1
+ import { Conversation } from '@epam/ai-dial-shared';
2
+ import { Message } from '../../../../../dial-toolkit/src/index';
3
+ import { HttpError } from '../../../../../shared-toolkit/src/index';
4
+ import { Dispatch, SetStateAction } from 'react';
5
+ import { StatusMessages } from '../../../types/texts';
6
+ export interface UseConversationStreamingArgs {
7
+ conversation: Conversation | null;
8
+ setConversation: Dispatch<SetStateAction<Conversation | null>>;
9
+ saveConversation: (conversation: Conversation) => Promise<void>;
10
+ updateAssistantMessage: (assistantMessage: Message, partialMessage: Partial<Message>) => Message | undefined;
11
+ addUserMessageToConversation: (userMessage: Message) => void;
12
+ initializeAssistantMessage: () => Message;
13
+ isStreaming: boolean;
14
+ setIsStreaming: (isStreaming: boolean) => void;
15
+ statusMessages: StatusMessages;
16
+ isCrossDatasetModeOn: boolean;
17
+ token?: string | null;
18
+ handleInvalidStreaming?: (error: HttpError) => void;
19
+ }
20
+ /**
21
+ * The SSE streaming engine: starting/aborting a stream, merging partials,
22
+ * mapping transport errors to user-facing messages, persisting the finalized
23
+ * conversation, and the send / regenerate / edit entry points. Decoupled from
24
+ * the `conversation` prop for its core flow — every entry point receives the
25
+ * conversation as an explicit `data` argument; the prop is only read to derive
26
+ * the "retry last failed message" affordance.
27
+ */
28
+ export declare const useConversationStreaming: ({ conversation, setConversation, saveConversation, updateAssistantMessage, addUserMessageToConversation, initializeAssistantMessage, isStreaming, setIsStreaming, statusMessages, isCrossDatasetModeOn, token, handleInvalidStreaming, }: UseConversationStreamingArgs) => {
29
+ sendMessageToConversation: (content: string, data: Conversation | null, customChoiceId?: string) => Promise<void>;
30
+ regenerateMessage: (message: Message, data: Conversation | null) => Promise<void>;
31
+ editMessage: (message: Message, data: Conversation | null) => Promise<void>;
32
+ onStopStreaming: () => void;
33
+ isLastMessageFailed: boolean;
34
+ regenerateLastMessage: (() => Promise<void>) | undefined;
35
+ };
@@ -0,0 +1,43 @@
1
+ import { CustomViewState } from '../../../../../dial-toolkit/src/index';
2
+ import { ConversationViewProps } from '../types';
3
+ /**
4
+ * Orchestrates the ConversationView feature: reads the shared contexts once and
5
+ * composes the focused sub-hooks — saver → message mutations → streaming →
6
+ * feedback → lifecycle → loader, plus the standalone `useOnboardingSync`
7
+ * effects — then returns a flat view-model object consumed by the presentational
8
+ * layout. Mirrors the `useFilters` orchestration pattern. The only hard ordering
9
+ * constraint is that streaming is wired before the loader, since the loader
10
+ * auto-sends the first message via `sendMessageToConversation`.
11
+ */
12
+ export declare const useConversationView: (props: ConversationViewProps) => {
13
+ isLoading: boolean;
14
+ isReadonlyConversation: boolean;
15
+ isStreaming: boolean;
16
+ isOpenedAdvancedView: boolean;
17
+ isShowOnboarding: boolean | undefined;
18
+ isAgentAvailable: boolean;
19
+ statusMessages: import('../../../types/texts').StatusMessages;
20
+ conversationViewState: CustomViewState | undefined;
21
+ messageServerActions: {
22
+ getFile: import('../../../types/actions').GetAttachmentContent;
23
+ putOnboardingFile: import('../../../types/actions').PutOnboardingFile;
24
+ getDataSet: import('../../../types/actions').GetDatasetDetails;
25
+ getDataSetData: import('../../../types/actions').GetDatasetData;
26
+ getConstraints: import('../../../types/actions').getConstraints;
27
+ updateCurrentDataQuery: (dataQuery?: import('../../../../../shared-toolkit/src/index').DataQuery) => void;
28
+ updateDataQueries: (dataQueries?: import('../../../../../shared-toolkit/src/index').DataQuery[]) => void;
29
+ updateDatasets: (datasets?: import('../../../../../sdmx-toolkit/src/index').Dataflow[]) => void;
30
+ downloadDataSet: import('../../../../../download-panel/src/types/actions').DownloadDatasetAction;
31
+ };
32
+ sendMessageToConversation: (content: string, data: import('@epam/ai-dial-shared').Conversation | null, customChoiceId?: string) => Promise<void>;
33
+ regenerateMessage: (message: import('../../../../../dial-toolkit/src/index').Message, data: import('@epam/ai-dial-shared').Conversation | null) => Promise<void>;
34
+ editMessage: (message: import('../../../../../dial-toolkit/src/index').Message, data: import('@epam/ai-dial-shared').Conversation | null) => Promise<void>;
35
+ onStopStreaming: () => void;
36
+ isLastMessageFailed: boolean;
37
+ regenerateLastMessage: (() => Promise<void>) | undefined;
38
+ rateResponse: (id: string, rate: import('@epam/ai-dial-shared').LikeState) => void;
39
+ handleCodeAttachmentUpdated: (messageId: string, newRawAttachment: import('@epam/ai-dial-shared').Attachment) => void;
40
+ duplicateConversation: () => Promise<void>;
41
+ handleOpeningOfNewConversation: () => void;
42
+ };
43
+ export type ConversationViewModel = ReturnType<typeof useConversationView>;
@@ -0,0 +1,19 @@
1
+ import { Attachment, Conversation, LikeState } from '@epam/ai-dial-shared';
2
+ import { Dispatch, SetStateAction } from 'react';
3
+ import { ConversationViewActions } from '../../../models/actions';
4
+ export interface UseMessageFeedbackArgs {
5
+ actions: ConversationViewActions;
6
+ conversation: Conversation | null;
7
+ setConversation: Dispatch<SetStateAction<Conversation | null>>;
8
+ saveConversation: (conversation: Conversation) => Promise<void>;
9
+ }
10
+ /**
11
+ * Per-message feedback actions: rating a response (thumbs up/down) and
12
+ * replacing a Python code attachment after an in-place edit. Both persist the
13
+ * resulting conversation. `rateResponse` mutates `conversation.messages` in
14
+ * place — preserved as-is from the original component.
15
+ */
16
+ export declare const useMessageFeedback: ({ actions, conversation, setConversation, saveConversation, }: UseMessageFeedbackArgs) => {
17
+ handleCodeAttachmentUpdated: (messageId: string, newRawAttachment: Attachment) => void;
18
+ rateResponse: (id: string, rate: LikeState) => void;
19
+ };
@@ -0,0 +1,17 @@
1
+ import { Conversation } from '@epam/ai-dial-shared';
2
+ import { Message } from '../../../../../dial-toolkit/src/index';
3
+ import { Dispatch, SetStateAction } from 'react';
4
+ export interface UseMessageMutationsArgs {
5
+ setConversation: Dispatch<SetStateAction<Conversation | null>>;
6
+ }
7
+ /**
8
+ * Local message-state mutations on the in-memory conversation: appending the
9
+ * user message, seeding an empty assistant message, and merging updates
10
+ * (streamed partials, or an error message) into that assistant message by id.
11
+ * Touches React state only — no persistence or network.
12
+ */
13
+ export declare const useMessageMutations: ({ setConversation, }: UseMessageMutationsArgs) => {
14
+ addUserMessageToConversation: (userMessage: Message) => void;
15
+ initializeAssistantMessage: () => Message;
16
+ updateAssistantMessage: (assistantMessage: Message, partialMessage: Partial<Message>) => Message | undefined;
17
+ };
@@ -0,0 +1,11 @@
1
+ import { ConversationViewActions } from '../../../models/actions';
2
+ export interface UseOnboardingSyncArgs {
3
+ actions: ConversationViewActions;
4
+ }
5
+ /**
6
+ * Onboarding side-effects: uploading the onboarding file once its schema is
7
+ * available, and advancing past the "open advanced view" tooltip step when the
8
+ * advanced view is already open (so the user isn't prompted to open something
9
+ * they've already opened).
10
+ */
11
+ export declare const useOnboardingSync: ({ actions }: UseOnboardingSyncArgs) => void;
@@ -0,0 +1,45 @@
1
+ import { Conversation, ConversationInfo } from '@epam/ai-dial-shared';
2
+ import { DataQuery, FormatNumbersType, HttpError } from '../../../../shared-toolkit/src/index';
3
+ import { LimitMessages } from '../../../../ui-components/src/index';
4
+ import { Dispatch, ReactNode, SetStateAction } from 'react';
5
+ import { ShareConversationProps } from '../../../../share-conversation/src/models/share-conversation';
6
+ import { ConversationViewActions } from '../../models/actions';
7
+ import { AttachmentsConfig } from '../../models/attachments';
8
+ import { AttachmentsStyles } from '../../models/attachments-styles';
9
+ import { EditMessageTitles, InputMessageStyles, MessageActionIcons, MessageActionTitles, MessageStyles } from '../../models/message';
10
+ import { MetadataSettings } from '../../models/metadata';
11
+ import { ConversationViewTitles } from '../../models/titles';
12
+ export interface ConversationViewProps {
13
+ conversationKey: string;
14
+ conversation: Conversation | null;
15
+ actions: ConversationViewActions;
16
+ messageStyles?: MessageStyles;
17
+ attachmentsStyles?: AttachmentsStyles;
18
+ inputMessageStyles: InputMessageStyles;
19
+ shareConversationProps?: ShareConversationProps;
20
+ showConversationHeaderAdvancedView?: boolean;
21
+ formattingSettings?: FormatNumbersType;
22
+ metadataSettings?: MetadataSettings;
23
+ titles?: ConversationViewTitles;
24
+ expandStagesIcon?: ReactNode;
25
+ locale: string;
26
+ conversationsRoute?: string;
27
+ token?: string | null;
28
+ dataQuery?: DataQuery;
29
+ signOutTitle?: string;
30
+ setConversation: Dispatch<SetStateAction<Conversation | null>>;
31
+ setConversations: (conversations: ConversationInfo[]) => void;
32
+ openUrl: (url: string) => void;
33
+ signOutAction?: () => void;
34
+ handleInvalidStreaming?: (error: HttpError) => void;
35
+ onConversationNotFound?: () => void;
36
+ messageActionsIcons?: MessageActionIcons;
37
+ messageActionsTitles?: MessageActionTitles;
38
+ editMessageTitles: EditMessageTitles;
39
+ scrollBottomIcon?: ReactNode;
40
+ isFinalMessage?: boolean;
41
+ limitMessages: LimitMessages;
42
+ attachmentsConfig?: AttachmentsConfig;
43
+ headerRightSlot?: ReactNode;
44
+ children?: ReactNode;
45
+ }