UNPKG

@llamaindex/ui

Version:

A comprehensive UI component library built with React, TypeScript, and Tailwind CSS for LlamaIndex applications

142 lines (132 loc) 6.36 kB
import { R as RunStatus, S as StopEvent, c as WorkflowEvent, J as JSONValue } from '../workflow-event-CFyLs7Zw.js'; export { C as ChatDeltaEvent, E as EventsQueueChanged, H as HumanResponseEvent, I as InputRequiredEvent, e as InternalDispatchEvent, d as StartEvent, f as StepStateChanged, a as WorkflowEventType, W as WorkflowProgressState, b as builtInEventTypes, o as isBuiltInEvent, k as isChatDeltaEvent, q as isCustomEvent, n as isEventsQueueChanged, j as isHumanResponseEvent, h as isInputRequiredEvent, l as isInternalDispatchEvent, p as isOverriddenBuiltInEvent, i as isStartEvent, m as isStepStateChanged, g as isStopEvent } from '../workflow-event-CFyLs7Zw.js'; import * as _llamaindex_workflows_client from '@llamaindex/workflows-client'; import { Handler, Client, EventEnvelopeWithMetadata } from '@llamaindex/workflows-client'; import { a as StreamSubscriber, S as StreamOperation } from '../shared-streaming-Bb5S8Tx3.js'; import * as react_jsx_runtime from 'react/jsx-runtime'; import { f as FileUploaderProps, a as FileUploadData } from '../index-0yWBjFA2.js'; import 'react'; import '../file-utils-CUHxYCcA.js'; interface HandlerState extends Omit<Handler, "status" | "result" | "updated_at" | "completed_at"> { status: RunStatus; updated_at?: Date; completed_at?: Date; result?: StopEvent; loading: boolean; loadingError?: string; } declare const createState$3: (rawHandler?: Partial<Handler>) => HandlerState; declare function createActions$3(state: HandlerState, client: Client): { sendEvent(event: WorkflowEvent | EventEnvelopeWithMetadata, step?: string): Promise<{ status: "sent"; } | undefined>; sync(): Promise<void>; subscribeToEvents(callbacks?: StreamSubscriber<WorkflowEvent>, includeInternal?: boolean): StreamOperation<WorkflowEvent>; }; interface HandlersQuery { workflow_name?: string[]; status?: ("running" | "completed" | "failed" | "cancelled")[]; } interface HandlersState { query: HandlersQuery; handlers: Record<string, HandlerState>; loading: boolean; loadingError?: string; } declare const createState$2: ({ query, }?: { query?: HandlersQuery; }) => HandlersState; declare function createActions$2(state: HandlersState, client: Client): { sync(): Promise<void>; setHandler(handler: HandlerState): void; actions(handlerId: string): ReturnType<typeof createActions$3>; }; interface WorkflowState { name: string; graph: unknown | null; loading: boolean; loadingError?: string; } declare function createState$1(name: string): WorkflowState; declare function createActions$1(state: WorkflowState, client: Client): { sync(): Promise<void>; runToCompletion(input: JSONValue): Promise<HandlerState>; createHandler(input: JSONValue, handlerId?: string): Promise<HandlerState>; }; interface WorkflowsState { workflows: Record<string, { name: string; }>; loading: boolean; loadingError?: string; } declare function createState(): WorkflowsState; declare function createActions(state: WorkflowsState, client: Client): { sync(): Promise<void>; setWorkflow(workflow: Omit<WorkflowState, "graph">): void; }; declare function useHandlers({ query, sync, }?: { query?: HandlersQuery; sync?: boolean; }): { sync(): Promise<void>; setHandler(handler: HandlerState): void; actions(handlerId: string): ReturnType<typeof createActions$3>; state: HandlersState; }; declare function useWorkflows({ sync }?: { sync?: boolean; }): { sync(): Promise<void>; setWorkflow(workflow: Omit<WorkflowState, "graph">): void; state: WorkflowsState; }; declare function useWorkflow(name: string): { sync(): Promise<void>; runToCompletion(input: JSONValue): Promise<HandlerState>; createHandler(input: JSONValue, handlerId?: string): Promise<HandlerState>; state: WorkflowState; }; /** * * @param handlerId - The handler ID to use. If null, the handler will be initialized with an empty state. * @param sync - Whether to sync the handler state. If true, the handler will be synced when the handler ID * is changed. You can set to false and manually call sync if this is not the desired behavior. * Default is `true`. * @returns A hook that returns the handler state and actions. */ declare function useHandler(handlerId: string | null, { sync }?: { sync?: boolean; }): { sendEvent(event: WorkflowEvent | _llamaindex_workflows_client.EventEnvelopeWithMetadata, step?: string): Promise<{ status: "sent"; } | undefined>; sync(): Promise<void>; subscribeToEvents(callbacks?: StreamSubscriber<WorkflowEvent>, includeInternal?: boolean): StreamOperation<WorkflowEvent>; state: HandlerState; }; interface WorkflowTriggerProps extends Omit<FileUploaderProps, "onSuccess"> { workflowName: string; customWorkflowInput?: (data: FileUploadData[], fieldValues: Record<string, string>) => JSONValue; onSuccess?: (handler: HandlerState) => void; onError?: (error: Error) => void; } declare function WorkflowTrigger({ workflowName, customWorkflowInput, onSuccess, onError, title, description, ...fileUploaderProps }: WorkflowTriggerProps): react_jsx_runtime.JSX.Element; /** * HandlerList Component * Displays a list of workflow handlers with their status */ interface HandlerListProps { onSelectHandler?: (handlerId: string) => void; } declare function HandlerList({ onSelectHandler }: HandlerListProps): react_jsx_runtime.JSX.Element; /** * HandlerDetails Component * Displays detailed information about a workflow handler and its events */ interface HandlerDetailsProps { handlerId: string; onBack?: () => void; } declare function HandlerDetails({ handlerId, onBack }: HandlerDetailsProps): react_jsx_runtime.JSX.Element; export { HandlerDetails, HandlerList, type HandlerState, type HandlersState, RunStatus, StopEvent, WorkflowEvent, type WorkflowState, WorkflowTrigger, type WorkflowsState, createActions$3 as createHandlerActions, createState$3 as createHandlerState, createActions$2 as createHandlersActions, createState$2 as createHandlersState, createActions$1 as createWorkflowActions, createState$1 as createWorkflowState, createActions as createWorkflowsActions, createState as createWorkflowsState, useHandler, useHandlers, useWorkflow, useWorkflows };