UNPKG

@mencraft/lore-headless

Version:
74 lines (73 loc) 2.22 kB
import { LoreClient, AuthCredentials } from '../api'; import { ChatRequest, ChatStreamCallbacks, FeedbackRequest, LLMRole, GraphChatRequest } from '../types'; /** * Message interface for chat messages */ export interface ChatMessage { id: string; role: LLMRole | 'error'; content: string; timestamp: Date; isStreaming?: boolean; } export interface CMessage { id: string; text: string; sender: "user" | "assistant" | "error" | "system" | "developer"; timestamp: Date; } /** * Image message interface */ export interface ImageMessage { id: string; imageId: string; storageType: string; role: LLMRole; timestamp: Date; url?: string; } /** * File message interface */ export interface FileMessage { id: string; filename: string; mediaType: string; role: LLMRole; timestamp: Date; url?: string; } /** * Union type for all message types */ export type Message = ChatMessage | ImageMessage | FileMessage; /** * Hook for using the chat stream in React * @param apiClient API client * @param auth Authentication credentials * @param callbacks Optional callbacks for stream events * @returns Chat stream functions and messages */ export declare const useChatStream: (apiClient: LoreClient, auth: AuthCredentials, callbacks?: ChatStreamCallbacks) => { messages: (ChatMessage | ImageMessage | FileMessage)[]; isStreaming: boolean; startChatStream: (request: ChatRequest | GraphChatRequest, graphId: string, useAdminServer: boolean) => Promise<void>; cancelStream: () => void; startGraphChatStream: (request: ChatRequest, graphId: string, skipValidation?: boolean) => Promise<void>; clearMessages: () => void; startVerification: (request: ChatRequest, graphId: string) => Promise<boolean>; }; /** * Hook for using feedback in React * @param loreClient API client * @param auth Authentication credentials * @param graphId Graph ID * @returns Feedback function and state */ export declare const useFeedback: (loreClient: LoreClient, auth: AuthCredentials, graphId?: string) => { sendFeedback: (feedback: FeedbackRequest) => Promise<any>; loading: boolean; error: Error | null; data: any; };