/** * MediaPipe LLM Inference adapter for local Gemma models * * This adapter integrates with Google's MediaPipe LLM Inference Task API * to run Gemma models locally using WebGPU acceleration. * * Supported models: * - Gemma 2B / 7B * - Gemma 2 2B * - Gemma 3n (2B, 4B parameters) * * Requirements: * - WebGPU-capable browser or Node.js with WebGPU support * - @mediapipe/tasks-genai package * - Downloaded model weights (.bin file) * * @packageDocumentation */ import type { LLMProvider, MediaPipeConfig, CompletionRequest, CompletionResponse } from '../../types/llm.js'; import { BaseLLMAdapter } from './base.js'; /** * Gemma model variants for MediaPipe */ export declare const MEDIAPIPE_MODELS: { readonly 'gemma-2b': "gemma-2b-it-gpu-int4.bin"; readonly 'gemma-7b': "gemma-7b-it-gpu-int8.bin"; readonly 'gemma2-2b': "gemma2-2b-it-gpu-int4.bin"; readonly 'gemma3n-e2b': "gemma-3n-E2B-it-int4.task"; readonly 'gemma3n-e4b': "gemma-3n-E4B-it-int4.task"; }; /** * Adapter for MediaPipe LLM Inference API * * Runs Gemma models locally using WebGPU acceleration. * The adapter lazily loads the model on first use. * * @example * ```typescript * import { MediaPipeAdapter } from 'learngraph/llm'; * * const adapter = new MediaPipeAdapter({ * provider: 'mediapipe', * model: 'gemma3n-e2b', * modelPath: '/models/gemma-3n-E2B-it-int4.task', * }); * * // Use with orchestrator * const orchestrator = createOrchestrator(adapter); * ``` */ export declare class MediaPipeAdapter extends BaseLLMAdapter { private inference; private readonly modelPath; private readonly randomSeed?; private readonly topK; private readonly loraRanks?; private initPromise; constructor(config: MediaPipeConfig); get provider(): LLMProvider; /** * Check if MediaPipe is configured (model path exists) */ isConfigured(): boolean; /** * Initialize the MediaPipe LLM Inference engine * Called automatically on first request */ initialize(): Promise; private doInitialize; /** * Load MediaPipe library dynamically */ private loadMediaPipe; complete(request: CompletionRequest): Promise; /** * Build a prompt string from chat messages * Uses Gemma's instruction format */ private buildPrompt; /** * Parse the generated response */ private parseGeneratedResponse; /** * Close the inference engine and release resources */ close(): void; } /** * Create a MediaPipe adapter for local Gemma models * * @param modelPath - Path to the model file (.bin or .task) * @param model - Model identifier (for reference) * @param overrides - Additional configuration options * * @example * ```typescript * // Using a Gemma 3n model * const adapter = createMediaPipeAdapter( * '/models/gemma-3n-E2B-it-int4.task', * 'gemma3n-e2b' * ); * * // With custom options * const adapter = createMediaPipeAdapter( * '/models/gemma2-2b-it-gpu-int4.bin', * 'gemma2-2b', * { maxTokens: 2048, temperature: 0.5 } * ); * ``` */ export declare function createMediaPipeAdapter(modelPath: string, model?: string, overrides?: Partial>): MediaPipeAdapter; //# sourceMappingURL=mediapipe.d.ts.map