import * as _vn_sdk_react_core_dist_hooks_use_tree from '@vn-sdk/react-core/dist/hooks/use-tree'; import * as _vn_sdk_shared from '@vn-sdk/shared'; import { Message, AiErrorHandler, AiSDKError } from '@vn-sdk/shared'; import * as _vn_sdk_react_core_dist_ai_context_2768aadc from '@vn-sdk/react-core/dist/ai-context-2768aadc'; import * as _vn_sdk_react_core from '@vn-sdk/react-core'; import { SuggestionItem, SystemMessageFunction, HintFunction } from '@vn-sdk/react-core'; import * as _vn_sdk_runtime_client_gql from '@vn-sdk/runtime-client-gql'; import * as react_jsx_runtime from 'react/jsx-runtime'; import { AiChatIcons, AiChatLabels } from './ChatContext.js'; import React__default from 'react'; import { ComponentsMap, AssistantMessageProps, UserMessageProps, ErrorMessageProps, MessagesProps, RenderMessageProps, RenderSuggestionsListProps, InputProps, ImageRendererProps, AiObservabilityHooks } from './props.js'; import '../../types/suggestions.js'; /** * The type of suggestions to use in the chat. * * `auto` - Suggestions are generated automatically. * `manual` - Suggestions are controlled programmatically. * `SuggestionItem[]` - Static suggestions array. */ type ChatSuggestions = "auto" | "manual" | SuggestionItem[]; /** * Props for AiChat component. */ interface AiChatProps { /** * Custom instructions to be added to the system message. Use this property to * provide additional context or guidance to the language model, influencing * its responses. These instructions can include specific directions, * preferences, or criteria that the model should consider when generating * its output, thereby tailoring the conversation more precisely to the * user's needs or the application's requirements. */ instructions?: string; /** * Controls the behavior of suggestions in the chat interface. * * `auto` (default) - Suggestions are generated automatically: * - When the chat is first opened (empty state) * - After each message exchange completes * - Uses configuration from `useAiChatSuggestions` hooks * * `manual` - Suggestions are controlled programmatically: * - Use `setSuggestions()` to set custom suggestions * - Use `generateSuggestions()` to trigger AI generation * - Access via `useAiChat` hook * * `SuggestionItem[]` - Static suggestions array: * - Always shows the same suggestions * - No AI generation involved */ suggestions?: ChatSuggestions; /** * A callback that gets called when the in progress state changes. */ onInProgress?: (inProgress: boolean) => void; /** * A callback that gets called when a new message it submitted. */ onSubmitMessage?: (message: string) => void | Promise; /** * A custom stop generation function. */ onStopGeneration?: OnStopGeneration; /** * A custom reload messages function. */ onReloadMessages?: OnReloadMessages; /** * A callback function to regenerate the assistant's response */ onRegenerate?: (messageId: string) => void; /** * A callback function when the message is copied */ onCopy?: (message: string) => void; /** * A callback function for thumbs up feedback */ onThumbsUp?: (message: Message) => void; /** * A callback function for thumbs down feedback */ onThumbsDown?: (message: Message) => void; /** * A list of markdown components to render in assistant message. * Useful when you want to render custom elements in the message (e.g a reference tag element) */ markdownTagRenderers?: ComponentsMap; /** * Icons can be used to set custom icons for the chat window. */ icons?: AiChatIcons; /** * Labels can be used to set custom labels for the chat window. */ labels?: AiChatLabels; /** * Enable image upload button (image inputs only supported on some models) */ imageUploadsEnabled?: boolean; /** * The 'accept' attribute for the file input used for image uploads. * Defaults to "image/*". */ inputFileAccept?: string; /** * A function that takes in context string and instructions and returns * the system message to include in the chat request. * Use this to completely override the system message, when providing * instructions is not enough. */ makeSystemMessage?: SystemMessageFunction; /** * Disables inclusion of VN SDK's default system message. When true, no system message is sent (this also suppresses any custom message from makeSystemMessage). */ disableSystemMessage?: boolean; /** * A custom assistant message component to use instead of the default. */ AssistantMessage?: React__default.ComponentType; /** * A custom user message component to use instead of the default. */ UserMessage?: React__default.ComponentType; /** * A custom error message component to use instead of the default. */ ErrorMessage?: React__default.ComponentType; /** * A custom Messages component to use instead of the default. */ Messages?: React__default.ComponentType; /** * @deprecated - use RenderMessage instead */ RenderTextMessage?: React__default.ComponentType; /** * @deprecated - use RenderMessage instead */ RenderActionExecutionMessage?: React__default.ComponentType; /** * @deprecated - use RenderMessage instead */ RenderAgentStateMessage?: React__default.ComponentType; /** * @deprecated - use RenderMessage instead */ RenderResultMessage?: React__default.ComponentType; /** * @deprecated - use RenderMessage instead */ RenderImageMessage?: React__default.ComponentType; /** * A custom RenderMessage component to use instead of the default. * * **Warning**: This is a break-glass solution to allow for custom * rendering of messages. You are most likely looking to swap out * the AssistantMessage and UserMessage components instead which * are also props. */ RenderMessage?: React__default.ComponentType; /** * A custom suggestions list component to use instead of the default. */ RenderSuggestionsList?: React__default.ComponentType; /** * A custom Input component to use instead of the default. */ Input?: React__default.ComponentType; /** * A custom image rendering component to use instead of the default. */ ImageRenderer?: React__default.ComponentType; /** * A class name to apply to the root element. */ className?: string; /** * Children to render. */ children?: React__default.ReactNode; hideStopButton?: boolean; /** * Event hooks for VN SDK chat events. * These hooks only work when publicApiKey is provided. */ observabilityHooks?: AiObservabilityHooks; /** * Custom error renderer for chat-specific errors. * When provided, errors will be displayed inline within the chat interface. */ renderError?: (error: { message: string; operation?: string; timestamp: number; onDismiss: () => void; onRetry?: () => void; }) => React__default.ReactNode; /** * Optional handler for comprehensive debugging and observability. */ onError?: AiErrorHandler; } interface OnStopGenerationArguments { /** * The name of the currently executing agent. */ currentAgentName: string | undefined; /** * The messages in the chat. */ messages: Message[]; /** * Set the messages in the chat. */ setMessages: (messages: Message[]) => void; /** * Stop chat generation. */ stopGeneration: () => void; /** * Restart the currently executing agent. */ restartCurrentAgent: () => void; /** * Stop the currently executing agent. */ stopCurrentAgent: () => void; /** * Run the currently executing agent. */ runCurrentAgent: (hint?: HintFunction) => Promise; /** * Set the state of the currently executing agent. */ setCurrentAgentState: (state: any) => void; } type OnReloadMessagesArguments = OnStopGenerationArguments & { /** * The message on which "regenerate" was pressed */ messageId: string; }; type OnStopGeneration = (args: OnStopGenerationArguments) => void; type OnReloadMessages = (args: OnReloadMessagesArguments) => void; type ImageUpload = { contentType: string; bytes: string; }; declare function AiChat({ instructions, suggestions, onSubmitMessage, makeSystemMessage, disableSystemMessage, onInProgress, onStopGeneration, onReloadMessages, onRegenerate, onCopy, onThumbsUp, onThumbsDown, markdownTagRenderers, Messages, RenderMessage, RenderSuggestionsList, Input, className, icons, labels, AssistantMessage, UserMessage, ImageRenderer, ErrorMessage, imageUploadsEnabled, inputFileAccept, hideStopButton, observabilityHooks, renderError, onError, RenderTextMessage, RenderActionExecutionMessage, RenderAgentStateMessage, RenderResultMessage, RenderImageMessage, }: AiChatProps): react_jsx_runtime.JSX.Element; declare function WrappedAiChat({ children, icons, labels, className, }: { children: React__default.ReactNode; icons?: AiChatIcons; labels?: AiChatLabels; className?: string; }): react_jsx_runtime.JSX.Element; declare const useAiChatLogic: (chatSuggestions: ChatSuggestions, makeSystemMessage?: SystemMessageFunction, disableSystemMessage?: boolean, onInProgress?: (isLoading: boolean) => void, onSubmitMessage?: (messageContent: string) => Promise | void, onStopGeneration?: OnStopGeneration, onReloadMessages?: OnReloadMessages) => { messages: Message[]; isLoading: boolean; suggestions: SuggestionItem[]; sendMessage: (messageContent: string, imagesToUse?: Array<{ contentType: string; bytes: string; }>) => Promise; stopGeneration: () => void; reloadMessages: (messageId: string) => void; resetSuggestions: () => void; context: { messages: _vn_sdk_runtime_client_gql.Message[]; setMessages: React__default.Dispatch>; suggestions: SuggestionItem[]; setSuggestions: React__default.Dispatch>; actions: Record>; setAction: (id: string, action: _vn_sdk_react_core.FrontendAction) => void; removeAction: (id: string) => void; aiAgentStateRenders: Record>; setAiAgentStateRender: (id: string, stateRender: _vn_sdk_react_core.AiAgentStateRender) => void; removeAiAgentStateRender: (id: string) => void; chatComponentsCache: React__default.RefObject<_vn_sdk_react_core_dist_ai_context_2768aadc.C>; getFunctionCallHandler: (customEntryPoints?: Record>) => _vn_sdk_shared.FunctionCallHandler; addContext: (context: string, parentId? /** * A callback that gets called when a new message it submitted. */: string, categories?: string[]) => _vn_sdk_react_core_dist_hooks_use_tree.TreeNodeId; removeContext: (id: _vn_sdk_react_core_dist_hooks_use_tree.TreeNodeId) => void; getAllContext: () => _vn_sdk_react_core.Tree; getContextString: (documents: _vn_sdk_react_core.DocumentPointer[], categories: string[]) => string; addDocumentContext: (documentPointer: _vn_sdk_react_core.DocumentPointer, categories?: string[]) => _vn_sdk_react_core_dist_hooks_use_tree.TreeNodeId; removeDocumentContext: (documentId: string) => void; getDocumentsContext: (categories: string[]) => _vn_sdk_react_core.DocumentPointer[]; isLoading: boolean; setIsLoading: React__default.Dispatch>; chatSuggestionConfiguration: { [key: string]: _vn_sdk_react_core.AiChatSuggestionConfiguration; }; addChatSuggestionConfiguration: (id: string, suggestion: _vn_sdk_react_core.AiChatSuggestionConfiguration) => void; removeChatSuggestionConfiguration: (id: string) => void; chatInstructions: string; setChatInstructions: React__default.Dispatch>; additionalInstructions?: string[]; setAdditionalInstructions: React__default.Dispatch>; aiApiConfig: _vn_sdk_react_core.AiApiConfig; showDevConsole: boolean; aiAgentStates: Record; setAiAgentStates: React__default.Dispatch>>; aiAgentStatesRef: React__default.RefObject>; setAiAgentStatesWithRef: (value: Record | ((prev: Record) => Record)) => void; agentSession: _vn_sdk_react_core_dist_ai_context_2768aadc.d | null; setAgentSession: React__default.Dispatch>; agentLock: string | null; threadId: string; setThreadId: React__default.Dispatch>; runId: string | null; setRunId: React__default.Dispatch>; chatAbortControllerRef: React__default.MutableRefObject; runtimeClient: _vn_sdk_runtime_client_gql.AiRuntimeClient; forwardedParameters?: Partial>; availableAgents: _vn_sdk_runtime_client_gql.Agent[]; authStates_c?: Record<_vn_sdk_react_core_dist_ai_context_2768aadc.k, _vn_sdk_react_core_dist_ai_context_2768aadc.g>; setAuthStates_c?: React__default.Dispatch>>; authConfig_c?: { SignInComponent: React__default.ComponentType<{ onSignInComplete: (authState: _vn_sdk_react_core_dist_ai_context_2768aadc.g) => void; }>; }; extensions: _vn_sdk_runtime_client_gql.ExtensionsInput; setExtensions: React__default.Dispatch>; langGraphInterruptAction: _vn_sdk_react_core_dist_ai_context_2768aadc.L | null; setLangGraphInterruptAction: _vn_sdk_react_core_dist_ai_context_2768aadc.e; removeLangGraphInterruptAction: (threadId: string) => void; onError: AiErrorHandler; bannerError: AiSDKError | null; setBannerError: React__default.Dispatch>; internalErrorHandlers: Record; setInternalErrorHandler: (handler: Record) => void; removeInternalErrorHandler: (id: string) => void; }; actions: Record>; }; export { AiChat, AiChatProps, ChatSuggestions, ImageUpload, OnReloadMessages, OnReloadMessagesArguments, OnStopGeneration, WrappedAiChat, useAiChatLogic };