import * as react_jsx_runtime from 'react/jsx-runtime'; import { LucideIcon } from 'lucide-react'; import { ChatEvent as ChatEvent$2, MarkdownProps, DocumentFile } from '../widgets/index.js'; import * as react from 'react'; import * as _llamaindex_llama_deploy from '@llamaindex/llama-deploy'; import { TaskDefinition, Client } from '@llamaindex/llama-deploy'; type FileData = { filename: string; mediaType: string; url: string; }; declare function isEqualArtifact(a: Artifact, b: Artifact): boolean; declare function extractArtifactsFromAllMessages(messages: Message[]): Artifact[]; declare function extractArtifactsFromMessage(message: Message): Artifact[]; type CodeArtifactError = { artifact: CodeArtifact; errors: string[]; }; /** * Generic artifact type definition * @typeParam T - The type of the data payload (e.g., \{ imageUrl: string, caption: string \}) * @typeParam K - The artifact type identifier string (e.g., 'image', 'code', 'document') */ type Artifact = { created_at: number; type: K; data: T; }; type CodeArtifact = Artifact<{ file_name: string; code: string; language: string; }, 'code'>; type DocumentArtifact = Artifact<{ title: string; content: string; type: string; sources?: { id: string; }[]; }, 'document'>; type ChatEvent$1 = { title: string; description?: string; status: 'pending' | 'success' | 'error'; data?: any; }; declare function ChatEvent$1({ event, className, renderData, }: { event: ChatEvent$1; className?: string; renderData?: (data: ChatEvent$1['data']) => React.ReactNode; }): react_jsx_runtime.JSX.Element; type SourceNode = { id: string; metadata: Record; score?: number; text: string; url?: string; }; type SourceData = { nodes: SourceNode[]; }; type SuggestedQuestionsData = string[]; type MessagePart = TextPart | DataPart | FilePart | AnyPart; declare const TextPartType: "text"; declare const FilePartType: "data-file"; declare const ArtifactPartType: "data-artifact"; declare const EventPartType: "data-event"; declare const SourcesPartType: "data-sources"; declare const SuggestionPartType: "data-suggested_questions"; type TextPart = { type: typeof TextPartType; text: string; }; type DataPart = { id?: string; type: T; data: D; }; type FilePart = DataPart; type ArtifactPart = DataPart; type EventPart = DataPart; type SourcesPart = DataPart; type SuggestionPart = DataPart; type AnyPart = { id?: string; type: T; data?: any; }; type JSONValue = null | string | number | boolean | { [value: string]: JSONValue; } | JSONValue[]; interface Message { id: string; role: 'system' | 'user' | 'assistant'; parts: MessagePart[]; } type ChatRequestOptions = { headers?: Record | Headers; body?: object; }; type ChatHandler = { messages: Message[]; status: 'submitted' | 'streaming' | 'ready' | 'error'; sendMessage: (msg: Message, opts?: ChatRequestOptions) => Promise; stop?: () => Promise; regenerate?: (opts?: { messageId?: string; } & ChatRequestOptions) => void; setMessages?: (messages: Message[]) => void; }; type ChatContext = ChatHandler & { input: string; setInput: (input: string) => void; requestData: any; setRequestData: (data: any) => void; isLoading: boolean; }; interface ChatSectionProps extends React.PropsWithChildren { handler: ChatHandler; className?: string; autoOpenCanvas?: boolean; } declare function ChatSection(props: ChatSectionProps): react_jsx_runtime.JSX.Element; interface ChatCanvasActionsProps { children?: React.ReactNode; className?: string; } declare function ChatCanvasActions(props: ChatCanvasActionsProps): react_jsx_runtime.JSX.Element; declare namespace ChatCanvasActions { var History: typeof ArtifactVersionHistory; var Copy: typeof ArtifactContentCopy; var Download: typeof ArtifactDownloadButton; var Close: typeof CanvasCloseButton; } declare function ArtifactVersionHistory(): react_jsx_runtime.JSX.Element | null; declare function ArtifactContentCopy(): react_jsx_runtime.JSX.Element | null; declare function ArtifactDownloadButton(): react_jsx_runtime.JSX.Element | null; declare function CanvasCloseButton(): react_jsx_runtime.JSX.Element; interface CodeArtifactViewerProps { className?: string; tabListClassName?: string; defaultTab?: string; tabs?: Record; } declare function CodeArtifactViewer({ className, tabs, defaultTab, }: CodeArtifactViewerProps): react_jsx_runtime.JSX.Element | null; interface DocumentArtifactViewerProps { className?: string; children?: React.ReactNode; } declare function DocumentArtifactViewer({ className, children, }: DocumentArtifactViewerProps): react_jsx_runtime.JSX.Element | null; declare function ArtifactCard({ data, getTitle, iconMap, className, }: { data: Artifact; getTitle?: (data: Artifact) => string; iconMap?: Record; className?: string; }): react_jsx_runtime.JSX.Element; interface ChatCanvasProps { children?: React.ReactNode; className?: string; } declare function ChatCanvas({ children, className }: ChatCanvasProps): react_jsx_runtime.JSX.Element | null; declare namespace ChatCanvas { var CodeArtifact: typeof CodeArtifactViewer; var DocumentArtifact: typeof DocumentArtifactViewer; var Artifact: typeof ArtifactCard; var Actions: typeof ChatCanvasActions; } interface EventPartProps { className?: string; renderData?: (data: ChatEvent$2['data']) => React.ReactNode; } /** * Render an event inside a ChatMessage, return null if current part is not event type * This component is useful to show an event from the assistant. * Normally, it will start with "Loading" status and then change to "Success" with a result * @param className - custom styles for the event */ declare function EventPartUI({ className, renderData }: EventPartProps): react_jsx_runtime.JSX.Element | null; /** * Render a file part inside a ChatMessage, return null if current part is not file type * This component is useful to show an uploaded file from the user or generated file from the assistant * @param className - custom styles for the file */ declare function FilePartUI({ className }: { className?: string; }): react_jsx_runtime.JSX.Element | null; interface ChatMarkdownProps extends React.PropsWithChildren { components?: MarkdownProps['components']; citationComponent?: MarkdownProps['citationComponent']; className?: string; languageRenderers?: MarkdownProps['languageRenderers']; } /** * Render TextPart as a Markdown component. */ declare function MarkdownPartUI(props: ChatMarkdownProps): react_jsx_runtime.JSX.Element | null; /** * Render a list of sources inside a ChatMessage, return null if current part is not sources type * This component is useful to show a list of sources from the assistant. * @param className - custom styles for the sources */ declare function SourcesPartUI({ className }: { className?: string; }): react_jsx_runtime.JSX.Element | null; /** * Render a suggested questions part inside a ChatMessage, return null if current part is not suggested questions type * This component is useful to show a list of suggested questions from the assistant. * @param className - custom styles for the suggested questions */ declare function SuggestionPartUI({ className }: { className?: string; }): react_jsx_runtime.JSX.Element | null; /** * Display an artifact card in the chat message when artifact part is available * @param className - custom styles for the artifact */ declare function ArtifactPartUI({ className }: { className?: string; }): react_jsx_runtime.JSX.Element | null; interface ChatPartContext { part: MessagePart; } declare const chatPartContext: react.Context; declare const ChatPartProvider: react.Provider; declare function usePart(type: typeof TextPartType): TextPart | null; declare function usePart(type: typeof FilePartType): FilePart | null; declare function usePart(type: typeof ArtifactPartType): ArtifactPart | null; declare function usePart(type: typeof EventPartType): EventPart | null; declare function usePart(type: typeof SourcesPartType): SourcesPart | null; declare function usePart(type: typeof SuggestionPartType): SuggestionPart | null; declare function usePart(type: string): T | null; declare function getParts(message: Message, type: typeof TextPartType): TextPart[]; declare function getParts(message: Message, type: typeof FilePartType): FilePart[]; declare function getParts(message: Message, type: typeof ArtifactPartType): ArtifactPart[]; declare function getParts(message: Message, type: typeof EventPartType): EventPart[]; declare function getParts(message: Message, type: typeof SourcesPartType): SourcesPart[]; declare function getParts(message: Message, type: typeof SuggestionPartType): SuggestionPart[]; declare function getParts(message: Message, type: string): T[]; interface ChatInputProps extends React.PropsWithChildren { className?: string; resetUploadedFiles?: () => void; attachments?: MessagePart[]; } interface ChatInputFormProps extends React.PropsWithChildren { className?: string; } interface ChatInputFieldProps { className?: string; placeholder?: string; } interface ChatInputUploadProps { className?: string; onUpload?: (file: File) => Promise | undefined; allowedExtensions?: string[]; multiple?: boolean; } interface ChatInputSubmitProps extends React.PropsWithChildren { className?: string; disabled?: boolean; } interface ChatInputContext { isDisabled: boolean; handleKeyDown: (e: React.KeyboardEvent) => void; handleSubmit: (e: React.FormEvent) => void; isComposing: boolean; setIsComposing: (value: boolean) => void; } declare const useChatInput: () => ChatInputContext; declare function ChatInput(props: ChatInputProps): react_jsx_runtime.JSX.Element; declare namespace ChatInput { var Form: typeof ChatInputForm; var Field: typeof ChatInputField; var Upload: typeof ChatInputUpload; var Submit: typeof ChatInputSubmit; } declare function ChatInputForm(props: ChatInputFormProps): react_jsx_runtime.JSX.Element; declare function ChatInputField(props: ChatInputFieldProps): react_jsx_runtime.JSX.Element; declare function ChatInputUpload(props: ChatInputUploadProps): react_jsx_runtime.JSX.Element; declare function ChatInputSubmit(props: ChatInputSubmitProps): react_jsx_runtime.JSX.Element; interface ChatMessagesProps extends React.PropsWithChildren { className?: string; } interface ChatMessagesListProps extends React.PropsWithChildren { className?: string; } interface ChatMessagesLoadingProps extends React.PropsWithChildren { className?: string; } interface ChatMessagesEmptyProps extends React.PropsWithChildren { className?: string; heading?: string; subheading?: string; } interface ChatActionsProps extends React.PropsWithChildren { className?: string; } interface ChatMessagesContext { isPending: boolean; showReload?: boolean; showStop?: boolean; messageLength: number; lastMessage: Message; } declare const useChatMessages: () => ChatMessagesContext; declare function ChatMessages(props: ChatMessagesProps): react_jsx_runtime.JSX.Element; declare namespace ChatMessages { var List: typeof ChatMessagesList; var Loading: typeof ChatMessagesLoading; var Empty: typeof ChatMessagesEmpty; var Actions: typeof ChatActions; } declare function ChatMessagesList(props: ChatMessagesListProps): react_jsx_runtime.JSX.Element; declare function ChatMessagesEmpty(props: ChatMessagesEmptyProps): react_jsx_runtime.JSX.Element | null; declare function ChatMessagesLoading(props: ChatMessagesLoadingProps): react_jsx_runtime.JSX.Element | null; declare function ChatActions(props: ChatActionsProps): react_jsx_runtime.JSX.Element | null; interface ChatMessageProps extends React.PropsWithChildren { message: Message; isLast: boolean; className?: string; } interface ChatMessageAvatarProps extends React.PropsWithChildren { className?: string; } interface ChatMessageContentProps extends React.PropsWithChildren { className?: string; } interface ChatMessageActionsProps extends React.PropsWithChildren { className?: string; } declare function ChatMessage(props: ChatMessageProps): react_jsx_runtime.JSX.Element; declare function ChatMessageAvatar(props: ChatMessageAvatarProps): react_jsx_runtime.JSX.Element | null; declare function ChatMessageContent(props: ChatMessageContentProps): react_jsx_runtime.JSX.Element; declare function ChatMessageActions(props: ChatMessageActionsProps): react_jsx_runtime.JSX.Element | null; type ComposibleChatMessagePart = typeof ChatMessageContent & { File: typeof FilePartUI; Event: typeof EventPartUI; Markdown: typeof MarkdownPartUI; Source: typeof SourcesPartUI; Suggestion: typeof SuggestionPartUI; Artifact: typeof ArtifactPartUI; }; type ComposibleChatMessage = typeof ChatMessage & { Avatar: typeof ChatMessageAvatar; Content: ComposibleChatMessagePart; Part: ComposibleChatMessagePart; Actions: typeof ChatMessageActions; }; declare const PrimiviteChatMessage: ComposibleChatMessage; declare const useChatUI: () => ChatContext; interface ChatCanvasContextType { allArtifacts: Artifact[]; getArtifactsByType: (type: Artifact['type']) => Artifact[]; displayedArtifact: Artifact | undefined; isCanvasOpen: boolean; openArtifactInCanvas: (artifact: Artifact) => void; closeCanvas: () => void; appendErrors: (artifact: CodeArtifact, errors: string[]) => void; clearCodeErrors: (artifact: CodeArtifact) => void; getCodeErrors: (artifact: CodeArtifact) => string[]; fixCodeErrors: (artifact: CodeArtifact) => void; getArtifactVersion: (artifact: Artifact) => { versionNumber: number; isLatest: boolean; }; restoreArtifact: (artifact: Artifact) => void; updateArtifact: (artifact: Artifact, content: string) => void; } declare function useChatCanvas(): ChatCanvasContextType; interface ChatMessageContext { message: Message; isLast: boolean; } declare const useChatMessage: () => ChatMessageContext; declare function useFile({ uploadAPI }: { uploadAPI: string; }): { image: { filename: string; mediaType: string; url: string; } | null; setImage: react.Dispatch>; files: DocumentFile[]; removeDoc: (file: DocumentFile) => void; reset: () => void; getAttachments: () => FilePart[]; uploadFile: (file: File, requestParams?: any) => Promise; }; interface WorkflowEvent { type: string; data?: JSONValue | undefined; } type RunStatus = 'idle' | 'running' | 'complete' | 'error'; interface WorkflowHookParams { baseUrl?: string; deployment: string; runId?: string; workflow?: string; onData?: (event: WorkflowEvent) => void; onStopEvent?: (event: E) => void; onError?: (error: any) => void; } interface WorkflowHookHandler { runId?: string; start: (eventData: E['data']) => Promise; stop: (data?: E['data']) => Promise; sendEvent: (event: E) => Promise; events: E[]; status?: RunStatus; } type WorkflowTask = TaskDefinition & { session_id: string; task_id: string; service_id: string; }; declare enum WorkflowEventType { StartEvent = "llama_index.core.workflow.events.StartEvent", StopEvent = "llama_index.core.workflow.events.StopEvent", AgentStream = "llama_index.core.agent.workflow.workflow_events.AgentStream", SourceNodesEvent = "llama_index.core.chat_ui.events.SourceNodesEvent", ArtifactEvent = "llama_index.core.chat_ui.events.ArtifactEvent", UIEvent = "llama_index.core.chat_ui.events.UIEvent", ToolCall = "llama_index.core.agent.workflow.workflow_events.ToolCall", ToolCallResult = "llama_index.core.agent.workflow.workflow_events.ToolCallResult" } interface StreamingEventCallback { onStart?: () => void; onData?: (event: E) => void; onError?: (error: Error) => void; onStopEvent?: (event: E) => void; onFinish?: (allEvents: E[]) => void; } type RawEvent = { __is_pydantic: boolean; value: JSONValue; qualified_name: string; }; declare function useWorkflow(params: WorkflowHookParams): WorkflowHookHandler; declare function getExistingTask(params: { client: Client; deploymentName: string; taskId: string; }): Promise; declare function createTask(params: { client: Client; deploymentName: string; eventData: E['data']; workflow?: string; }): Promise; declare function fetchTaskEvents(params: { client: Client; deploymentName: string; task: WorkflowTask; }, callback?: StreamingEventCallback): Promise; declare function sendEventToTask(params: { client: Client; deploymentName: string; task: WorkflowTask; event: E; }): Promise<_llamaindex_llama_deploy.EventDefinition | undefined>; interface ChatEvent extends WorkflowEvent { type: WorkflowEventType.StartEvent; data: { user_msg: string; chat_history: Omit[]; }; } interface AgentStreamEvent extends WorkflowEvent { type: WorkflowEventType.AgentStream; data: { delta: string; }; } type RawNodeWithScore = { node: { id_: string; metadata: { file_name: string | null; pipeline_id: string | null; pipeline_file_id: string | null; page_label: string | null; file_path: string | null; file_type: string | null; file_size: number | null; creation_date: string | null; last_modified_date: string | null; URL: string | null; }; text: string; }; score: number; }; interface SourceNodesEvent extends WorkflowEvent { type: WorkflowEventType.SourceNodesEvent; data: { nodes: RawNodeWithScore[]; }; } interface UIEvent extends WorkflowEvent { type: WorkflowEventType.UIEvent; data: { type: string; data: JSONValue; }; } interface ToolCallEvent extends WorkflowEvent { type: WorkflowEventType.ToolCall; data: { tool_id: string; tool_name: string; tool_kwargs: JSONValue; }; } interface ToolCallResultEvent extends WorkflowEvent { type: WorkflowEventType.ToolCallResult; data: { tool_id: string; tool_name: string; tool_kwargs: JSONValue; tool_output: { raw_output: JSONValue; }; }; } type ChatWorkflowHookParams = Pick & { fileServerUrl?: string; }; type ChatWorkflowHookHandler = ChatHandler & { resume: ChatWorkflowResume; }; type ChatWorkflowResume = (eventType: string, eventData: JSONValue) => Promise; declare function useChatWorkflow({ deployment, workflow, baseUrl, onError, fileServerUrl, }: ChatWorkflowHookParams): ChatWorkflowHookHandler; /** * Transform a workflow event to message parts * - if event is an agent stream event, return the delta * - if event is an inline event, convert the data to inline annotation and return the delta * - otherwise, return input event as Vercel annotation * @param event - The event to transform * @returns The message parts (delta and annotations) */ declare function transformEventToMessageParts(event: WorkflowEvent, fileServerUrl?: string): MessagePart[]; export { Artifact, ArtifactPartType, ArtifactPartUI, ChatCanvas, ChatInput, PrimiviteChatMessage as ChatMessage, ChatMessages, ChatPartProvider, ChatSection, CodeArtifact, DocumentArtifact, EventPartType, EventPartUI, FilePartType, FilePartUI, MarkdownPartUI, SourcesPartType, SourcesPartUI, SuggestionPartType, SuggestionPartUI, TextPartType, WorkflowEventType, chatPartContext, createTask, extractArtifactsFromAllMessages, extractArtifactsFromMessage, fetchTaskEvents, getExistingTask, getParts, isEqualArtifact, sendEventToTask, transformEventToMessageParts, useChatCanvas, useChatInput, useChatMessage, useChatMessages, useChatUI, useChatWorkflow, useFile, usePart, useWorkflow }; export type { AgentStreamEvent, AnyPart, ArtifactPart, ChatContext, ChatEvent, ChatHandler, ChatPartContext, ChatRequestOptions, ChatWorkflowHookHandler, ChatWorkflowHookParams, ChatWorkflowResume, CodeArtifactError, DataPart, EventPart, EventPartProps, FilePart, JSONValue, Message, MessagePart, RawEvent, RawNodeWithScore, RunStatus, SourceNodesEvent, SourcesPart, StreamingEventCallback, SuggestionPart, TextPart, ToolCallEvent, ToolCallResultEvent, UIEvent, WorkflowEvent, WorkflowHookHandler, WorkflowHookParams, WorkflowTask };