UNPKG

@makolabs/ripple

Version:

Simple Svelte 5 powered component library ✨

109 lines (108 loc) 2.74 kB
import type { ChatResponse, ChatMessage, QuickAction, StreamingCallback } from '../../index.js'; /** * Base interface for AI adapters */ export interface AIAdapter { /** * Name of the AI provider */ getName(): string; /** * Check if the adapter is properly configured */ isConfigured(): boolean; /** * Send a message to the AI and get a response */ sendMessage(message: string, context?: AIContext): Promise<ChatResponse>; /** * Send a message with streaming support (optional) */ sendMessageStream?(message: string, onStream: StreamingCallback, context?: AIContext): Promise<ChatResponse>; /** * Get conversation history if supported */ getHistory?(): ChatMessage[]; /** * Clear conversation history if supported */ clearHistory?(): void; /** * Set system prompt if supported */ setSystemPrompt?(prompt: string): void; /** * Get current system prompt if supported */ getSystemPrompt?(): string; /** * Get quick actions for this adapter */ getQuickActions?(): QuickAction[]; /** * Set quick actions */ setQuickActions?(actions: QuickAction[]): void; /** * Get memory manager if supported */ getMemoryManager?(): unknown | null; /** * Get memory statistics if supported */ getMemoryStats?(): Record<string, unknown>; /** * Get essential context if supported */ getEssentialContext?(): Record<string, unknown>; /** * Get context prompt if supported */ getContextPrompt?(): string; } /** * Context information passed to AI adapters */ export interface AIContext { /** * Current page or route */ page?: string; /** * User information */ user?: { id?: string; role?: string; preferences?: Record<string, unknown>; }; /** * Application state */ appState?: Record<string, unknown>; /** * Whether thinking/reasoning mode is enabled */ thinkingMode?: boolean; /** * Additional metadata */ metadata?: Record<string, unknown>; } /** * Error types for AI adapters */ export declare class AIAdapterError extends Error { code: string; adapter: string; constructor(message: string, code: string, adapter: string); } export declare class AIConfigurationError extends AIAdapterError { constructor(message: string, adapter: string); } export declare class AINetworkError extends AIAdapterError { constructor(message: string, adapter: string); } export declare class AIRateLimitError extends AIAdapterError { constructor(message: string, adapter: string); }