@llamaindex/ui
Version:
A comprehensive UI component library built with React, TypeScript, and Tailwind CSS for LlamaIndex applications
113 lines (100 loc) • 4.24 kB
TypeScript
import * as zustand from 'zustand';
import { Client } from '@llamaindex/workflows-client';
import * as react_jsx_runtime from 'react/jsx-runtime';
import { F as FileUploaderProps, m as FileUploadData } from '../file-uploader-DZW0tk1P.js';
import 'react';
type JSONValue = null | string | number | boolean | {
[key: string]: JSONValue;
} | Array<JSONValue>;
type RunStatus = "idle" | "running" | "complete" | "failed";
interface WorkflowHandlerSummary {
handler_id: string;
status: RunStatus;
workflowName?: string;
result?: unknown;
error?: unknown;
}
interface WorkflowEvent {
type: string;
data?: JSONValue | undefined;
}
interface WorkflowProgressState {
current: number;
total: number;
status: RunStatus;
}
interface HandlerStoreState {
handlers: Record<string, WorkflowHandlerSummary>;
events: Record<string, WorkflowEvent[]>;
clearCompleted(): void;
createHandler(workflowName: string, input: JSONValue): Promise<WorkflowHandlerSummary>;
clearEvents(handlerId: string): void;
sync(): Promise<void>;
subscribe(handlerId: string, cfg?: {
includeInternal?: boolean;
}): void;
unsubscribe(handlerId: string): void;
isSubscribed(handlerId: string): boolean;
}
declare const createHandlerStore: (client: Client) => zustand.UseBoundStore<zustand.StoreApi<HandlerStoreState>>;
interface UseWorkflowRunResult {
runWorkflow: (workflowName: string, input: JSONValue) => Promise<WorkflowHandlerSummary>;
isCreating: boolean;
error: Error | null;
}
declare function useWorkflowRun(): UseWorkflowRunResult;
interface UseWorkflowHandlerListResult {
handlers: WorkflowHandlerSummary[];
clearCompleted: () => void;
loading: boolean;
error: string | null;
}
declare function useWorkflowHandlerList(workflowName: string): UseWorkflowHandlerListResult;
interface UseWorkflowHandlerResult {
handler: WorkflowHandlerSummary | null;
events: WorkflowEvent[];
isStreaming: boolean;
stopStreaming: () => void;
clearEvents: () => void;
sendEvent: (event: WorkflowEvent) => Promise<void>;
}
declare function useWorkflowHandler(handlerId: string, autoStream?: boolean, { includeInternal, }?: {
includeInternal?: boolean;
}): UseWorkflowHandlerResult;
declare function useWorkflowProgress(workflowName: string): WorkflowProgressState;
/**
* Task Store Hook that uses client from context
* Provides both selector API and direct store access
*/
declare function useHandlerStore(): HandlerStoreState;
declare function useHandlerStore<T>(selector: (state: HandlerStoreState) => T): T;
/**
* AgentStreamDisplay Component
* Displays real-time agent processing events from workflow handlers
*/
interface AgentStreamDisplayProps {
handlerId: string;
title?: string;
maxEvents?: number;
className?: string;
}
declare function AgentStreamDisplay({ handlerId, title, maxEvents, className, }: AgentStreamDisplayProps): react_jsx_runtime.JSX.Element | null;
interface WorkflowProgressBarProps {
className?: string;
/**
* Controls auto-show/hide behavior
* - 'auto': Show when there are tasks or status is not 'idle', hide when no tasks and status is 'idle'
* - 'always': Always show the component
*/
mode?: "auto" | "always";
workflowName: string;
}
declare function WorkflowProgressBar({ className, mode, workflowName, }: WorkflowProgressBarProps): react_jsx_runtime.JSX.Element | null;
interface WorkflowTriggerProps extends Omit<FileUploaderProps, "onSuccess"> {
workflowName: string;
customWorkflowInput?: (data: FileUploadData[], fieldValues: Record<string, string>) => JSONValue;
onSuccess?: (handler: WorkflowHandlerSummary) => void;
onError?: (error: Error) => void;
}
declare function WorkflowTrigger({ workflowName, customWorkflowInput, onSuccess, onError, title, description, ...fileUploaderProps }: WorkflowTriggerProps): react_jsx_runtime.JSX.Element;
export { AgentStreamDisplay, type RunStatus, type WorkflowEvent, type WorkflowHandlerSummary, WorkflowProgressBar, type WorkflowProgressState, WorkflowTrigger, createHandlerStore, useHandlerStore, useWorkflowHandler, useWorkflowHandlerList, useWorkflowProgress, useWorkflowRun };