/**
 * React Integration for Local LLM
 *
 * Provides React context, hooks, and components for easy LLM integration.
 *
 * @example
 * ```tsx
 * import { LLMProvider, useChat } from 'local-llm/react';
 *
 * function App() {
 *   return (
 *     <LLMProvider model="qwen-2.5-0.5b">
 *       <ChatComponent />
 *     </LLMProvider>
 *   );
 * }
 *
 * function ChatComponent() {
 *   const { messages, send, isGenerating } = useChat();
 *
 *   return (
 *     <div>
 *       {messages.map((m, i) => <p key={i}>{m.content}</p>)}
 *       <button onClick={() => send('Hello!')}>Send</button>
 *     </div>
 *   );
 * }
 * ```
 */
import * as React from 'react';
import type { LLMConfig, ChatMessage, GenerateOptions, LoadProgress, Backend } from '../types';
import { type LocalLLM } from '../core';
export type { ChatMessage, GenerateOptions, LoadProgress, Backend } from '../types';
export type { LocalLLM } from '../core';
export interface LLMContextValue {
    /** The LLM instance (null while loading) */
    llm: LocalLLM | null;
    /** Whether the model is currently loading */
    isLoading: boolean;
    /** Whether the model is ready for inference */
    isReady: boolean;
    /** Current loading progress */
    loadProgress: LoadProgress | null;
    /** Error if loading failed */
    error: Error | null;
    /** Current model ID */
    modelId: string | null;
    /** Backend being used */
    backend: Backend | null;
    /** Manually reload the model */
    reload: () => Promise<void>;
    /** Unload the model */
    unload: () => Promise<void>;
}
export interface LLMProviderProps extends Omit<LLMConfig, 'onLoadProgress'> {
    children: React.ReactNode;
    /**
     * Auto-load the model on mount
     * @default true
     */
    autoLoad?: boolean;
    /**
     * Callback when model finishes loading
     */
    onLoad?: (llm: LocalLLM) => void;
    /**
     * Callback on loading progress
     */
    onProgress?: (progress: LoadProgress) => void;
    /**
     * Callback on error
     */
    onError?: (error: Error) => void;
}
/**
 * Provider component that manages LLM lifecycle
 *
 * @example
 * ```tsx
 * <LLMProvider
 *   model="qwen-2.5-0.5b"
 *   backend="auto"
 *   onProgress={(p) => console.log(p.progress)}
 * >
 *   <App />
 * </LLMProvider>
 * ```
 */
export declare function LLMProvider({ children, autoLoad, onLoad, onProgress, onError, ...config }: LLMProviderProps): import("react/jsx-runtime").JSX.Element;
/**
 * Access the LLM context
 *
 * @throws If used outside of LLMProvider
 *
 * @example
 * ```tsx
 * const { llm, isReady, loadProgress } = useLLM();
 * ```
 */
export declare function useLLM(): LLMContextValue;
export interface UseChatOptions {
    /** Initial messages */
    initialMessages?: ChatMessage[];
    /** System prompt */
    systemPrompt?: string;
    /** Generation options */
    generateOptions?: GenerateOptions;
    /**
     * Queue messages while model is loading
     * When true, users can send messages before model loads - they'll be processed once ready
     * @default true
     */
    queueWhileLoading?: boolean;
    /** Called when generation starts */
    onStart?: () => void;
    /** Called on each token (streaming) */
    onToken?: (token: string, fullText: string) => void;
    /** Called when generation completes */
    onFinish?: (response: string) => void;
    /** Called on error */
    onError?: (error: Error) => void;
}
export interface UseChatReturn {
    /** All messages in the conversation */
    messages: ChatMessage[];
    /** Current input value (for controlled input) */
    input: string;
    /** Set the input value */
    setInput: (input: string) => void;
    /** Whether currently generating a response */
    isGenerating: boolean;
    /** Whether a message is queued waiting for model to load */
    isPending: boolean;
    /** Current streaming text (while generating) */
    streamingText: string;
    /** Send a message and get a response */
    send: (content?: string) => Promise<string>;
    /** Stop the current generation */
    stop: () => void;
    /** Clear all messages */
    clear: () => void;
    /** Add a message without generating a response */
    append: (message: ChatMessage) => void;
    /** Reload/regenerate the last assistant message */
    reload: () => Promise<string>;
}
/**
 * Hook for managing a chat conversation with the LLM
 *
 * Supports **eager loading** - users can send messages while the model loads.
 * Messages are queued and processed automatically once the model is ready.
 *
 * @example
 * ```tsx
 * function ChatComponent() {
 *   const { isLoading, loadProgress } = useLLM();
 *   const {
 *     messages,
 *     input,
 *     setInput,
 *     send,
 *     isGenerating,
 *     isPending,  // true if message is queued waiting for model
 *     streamingText,
 *   } = useChat({
 *     systemPrompt: 'You are a helpful assistant.',
 *     queueWhileLoading: true,  // default: true
 *   });
 *
 *   return (
 *     <div>
 *       {isLoading && <p>Loading model... {loadProgress?.progress}%</p>}
 *
 *       {messages.map((m, i) => (
 *         <div key={i} className={m.role}>
 *           {m.content}
 *         </div>
 *       ))}
 *
 *       {isPending && <p className="pending">Waiting for model to load...</p>}
 *       {isGenerating && <div className="assistant">{streamingText}</div>}
 *
 *       {/* Users can type immediately, even before model loads *\/}
 *       <input
 *         value={input}
 *         onChange={(e) => setInput(e.target.value)}
 *         onKeyDown={(e) => e.key === 'Enter' && send()}
 *         placeholder={isLoading ? 'Type now, send when ready...' : 'Type a message...'}
 *       />
 *       <button onClick={() => send()} disabled={isGenerating}>
 *         {isPending ? 'Queued...' : 'Send'}
 *       </button>
 *     </div>
 *   );
 * }
 * ```
 */
export declare function useChat(options?: UseChatOptions): UseChatReturn;
export interface UseStreamOptions {
    /** Generation options */
    generateOptions?: GenerateOptions;
    /** Called on each token */
    onToken?: (token: string, fullText: string) => void;
    /** Called when complete */
    onFinish?: (response: string) => void;
    /** Called on error */
    onError?: (error: Error) => void;
}
export interface UseStreamReturn {
    /** Current streamed text */
    text: string;
    /** Whether currently streaming */
    isStreaming: boolean;
    /** Start streaming a response */
    stream: (messages: ChatMessage[] | string) => Promise<string>;
    /** Stop streaming */
    stop: () => void;
    /** Clear the text */
    clear: () => void;
}
/**
 * Hook for simple streaming generation
 *
 * @example
 * ```tsx
 * function StreamComponent() {
 *   const { text, isStreaming, stream, clear } = useStream();
 *
 *   return (
 *     <div>
 *       <pre>{text}</pre>
 *       <button onClick={() => stream('Tell me a story')} disabled={isStreaming}>
 *         Generate
 *       </button>
 *       <button onClick={clear}>Clear</button>
 *     </div>
 *   );
 * }
 * ```
 */
export declare function useStream(options?: UseStreamOptions): UseStreamReturn;
export interface UseCompletionOptions {
    /** Generation options */
    generateOptions?: GenerateOptions;
}
export interface UseCompletionReturn {
    /** Current completion text */
    completion: string;
    /** Whether currently generating */
    isLoading: boolean;
    /** Generate a completion (non-streaming) */
    complete: (prompt: string) => Promise<string>;
    /** Clear the completion */
    clear: () => void;
}
/**
 * Hook for simple non-streaming completion
 *
 * @example
 * ```tsx
 * function CompletionComponent() {
 *   const { completion, isLoading, complete } = useCompletion();
 *
 *   return (
 *     <div>
 *       <p>{completion}</p>
 *       <button onClick={() => complete('Summarize this')} disabled={isLoading}>
 *         Complete
 *       </button>
 *     </div>
 *   );
 * }
 * ```
 */
export declare function useCompletion(options?: UseCompletionOptions): UseCompletionReturn;
export interface LLMLoadingProps {
    /** Custom loading UI */
    children?: React.ReactNode;
    /** Class name for the wrapper */
    className?: string;
}
/**
 * Component that shows loading state while LLM is loading
 *
 * @example
 * ```tsx
 * <LLMLoading>
 *   <p>Loading model...</p>
 * </LLMLoading>
 * ```
 */
export declare function LLMLoading({ children, className }: LLMLoadingProps): import("react/jsx-runtime").JSX.Element | null;
export interface LLMReadyProps {
    /** Content to show when ready */
    children: React.ReactNode;
    /** Content to show while loading */
    fallback?: React.ReactNode;
}
/**
 * Component that only renders children when LLM is ready
 *
 * @example
 * ```tsx
 * <LLMReady fallback={<Loading />}>
 *   <ChatInterface />
 * </LLMReady>
 * ```
 */
export declare function LLMReady({ children, fallback }: LLMReadyProps): import("react/jsx-runtime").JSX.Element;
//# sourceMappingURL=index.d.ts.map