@llamaindex/ui
Version:
A comprehensive UI component library built with React, TypeScript, and Tailwind CSS for LlamaIndex applications
39 lines (31 loc) • 958 B
text/typescript
import { MessagePart } from "./message-parts/types";
// Message roles
export const MessageRole = {
System: "system",
User: "user",
Assistant: "assistant",
} as const;
export type MessageRoleType = (typeof MessageRole)[keyof typeof MessageRole];
export interface Message {
id: string;
role: MessageRoleType;
parts: MessagePart[];
}
export type ChatRequestOptions = {
headers?: Record<string, string> | Headers;
};
export type ChatHandler = {
messages: Message[];
status: "idle" | "submitted" | "streaming" | "ready" | "error";
sendMessage: (msg: Message, opts?: ChatRequestOptions) => Promise<void>;
stop?: () => Promise<void>;
regenerate?: (opts?: { messageId?: string } & ChatRequestOptions) => void;
setMessages?: (messages: Message[]) => void;
};
export type ChatContext = ChatHandler & {
// user input state
input: string;
setInput: (input: string) => void;
// computed state from status
isLoading: boolean;
};