UNPKG

mobile-ai-toolkit

Version:

On-device AI for React Native. Zero cloud costs. One unified API.

176 lines 4.56 kB
/** * @openslm/mobile-ai-toolkit * Mobile-first AI toolkit with on-device capabilities for React Native 0.76+ * * Features: * - On-device AI processing (iOS/Android) * - Cloud AI fallback * - Turbo Module performance * - Privacy-first architecture */ export type * from './specs/NativeAIToolkitSpec'; export interface AIConfig { proxyURL?: string; apiKey?: string; timeout?: number; preferOnDevice?: boolean; enablePrivateMode?: boolean; cacheEnabled?: boolean; cacheTTL?: number; preloadModels?: string[]; maxRetries?: number; } export interface ChatResponse { message: string; fromCache?: boolean; fromDevice?: boolean; model?: string; usage?: { tokens: number; cost: number; }; } export interface AnalysisResponse { sentiment?: number; entities?: Array<{ text: string; type: string; confidence: number; }>; summary?: string; language?: string; fromCache?: boolean; fromDevice?: boolean; } export interface VisionResponse { objects?: Array<{ label: string; confidence: number; bounds?: { x: number; y: number; width: number; height: number; }; }>; text?: string; faces?: Array<{ bounds: { x: number; y: number; width: number; height: number; }; emotions?: Record<string, number>; }>; fromCache?: boolean; fromDevice?: boolean; } export interface VoiceResponse { transcript: string; confidence: number; language?: string; words?: Array<{ text: string; confidence: number; startTime: number; endTime: number; }>; fromCache?: boolean; fromDevice?: boolean; } export interface UsageStats { totalRequests: number; onDeviceRequests: number; cloudRequests: number; cacheHits: number; costs: number; lastUsed: string; } /** * Main AI class - Hybrid on-device + cloud processing */ export declare class AI { private static config; private static deviceCapabilities; private static initialized; /** * Configure the AI toolkit */ static configure(config: AIConfig): void; /** * Initialize the toolkit (call once at app start) */ static initialize(): Promise<void>; /** * Check if on-device AI is available */ static isOnDeviceAvailable(): boolean; /** * Get device AI capabilities */ static getDeviceCapabilities(): any; /** * Chat with AI - Smart routing (on-device or cloud) */ static chat(message: string, options?: { model?: string; temperature?: number; maxTokens?: number; forceCloud?: boolean; }): Promise<ChatResponse>; /** * Analyze text - On-device when possible */ static analyze(text: string, options?: { includeSentiment?: boolean; includeEntities?: boolean; includeSummary?: boolean; language?: string; forceCloud?: boolean; }): Promise<AnalysisResponse>; /** * Understand images - On-device Vision processing */ static understand(imageBase64: string, options?: { detectObjects?: boolean; extractText?: boolean; detectFaces?: boolean; forceCloud?: boolean; }): Promise<VisionResponse>; /** * Transcribe voice - On-device Speech processing */ static transcribe(audioBase64: string, options?: { language?: string; forceCloud?: boolean; }): Promise<VoiceResponse>; /** * Generate smart replies - Uses on-device intelligence */ static smartReply(message: string, context?: string): Promise<string[]>; /** * Writing Tools integration (iOS 18.1+) */ static enhanceText(text: string, style: 'friendly' | 'professional' | 'concise' | 'creative'): Promise<string>; /** * Proofread text using on-device capabilities */ static proofread(text: string): Promise<{ correctedText: string; corrections: any[]; }>; /** * Get usage statistics */ static getUsage(): Promise<UsageStats>; private static shouldUseOnDevice; private static canProcessOnDevice; private static processInCloud; private static getFromCache; private static saveToCache; private static updateUsageStats; private static hashString; } export default AI; //# sourceMappingURL=index.d.ts.map