/** * Model Registry * * Defines all downloadable models known to expo-ai-kit. * getDownloadableModels() reads from this registry and enriches * each entry with on-device status from the native layer. */ import type { DownloadableModel } from './types'; export type ModelRegistryEntry = { /** Unique model identifier used in setModel/downloadModel */ id: string; /** Human-readable model name */ name: string; /** Parameter count label */ parameterCount: string; /** Quantization variant */ quantization: string; /** URL to download the LiteRT-LM model file */ downloadUrl: string; /** SHA256 hash for integrity verification after download */ sha256: string; /** Download file size in bytes */ sizeBytes: number; /** * Practical context window (max tokens) for this model on constrained devices. * * These are conservative defaults, NOT the base model's theoretical max. * These values should be benchmarked and adjusted during testing with * real devices. */ contextWindow: number; /** Minimum device RAM in bytes required to run this model */ minRamBytes: number; /** Platforms this model can run on */ supportedPlatforms: ('ios' | 'android')[]; /** * License the model weights are distributed under — an SPDX identifier * (e.g. 'Apache-2.0', 'MIT') or a family name for non-OSI terms (e.g. 'Gemma', * 'Llama-3.2'). Surfaced on {@link DownloadableModel} so app developers can * check their obligations before shipping a model to users. */ license: string; }; export declare const MODEL_REGISTRY: ModelRegistryEntry[]; /** * Validate a model entry, returning a list of human-readable problems * (empty ⇒ valid). Pure — used by {@link registerModel} and unit-tested. */ export declare function validateModelEntry(entry: ModelRegistryEntry): string[]; /** * Register a custom downloadable model at runtime. * * After registering, the id works with `downloadModel` / `setModel` / * `getDownloadableModels` exactly like a built-in. The download is integrity- * checked against the `sha256` you provide — pin a value you trust (see * {@link fetchModelMetadata}). Throws if the entry is invalid or the id * collides with a built-in (curated or native) model. * * @example * ```ts * const { sha256, sizeBytes } = await fetchModelMetadata(url); // dev-time * registerModel({ * id: 'qwen3-8b', name: 'Qwen3 8B', parameterCount: '8B', quantization: 'int4', * downloadUrl: url, sha256, sizeBytes, * contextWindow: 4096, minRamBytes: 6_000_000_000, * supportedPlatforms: ['ios', 'android'], license: 'Apache-2.0', * }); * ``` */ export declare function registerModel(entry: ModelRegistryEntry): void; /** * Remove a previously {@link registerModel}'d custom model. * Returns true if one was removed. Does not delete any downloaded file — * use `deleteModel` for that. No-op for built-in models. */ export declare function unregisterModel(modelId: string): boolean; /** All custom models registered via {@link registerModel}, in registration order. */ export declare function getRegisteredModels(): ModelRegistryEntry[]; /** Built-in registry plus all custom models. */ export declare function getAllModels(): ModelRegistryEntry[]; /** * Look up a model registry entry by ID (built-in or custom). * Returns undefined if not found. */ export declare function getRegistryEntry(modelId: string): ModelRegistryEntry | undefined; /** * Parse a HuggingFace "resolve" download URL into its parts. * Returns null if the URL isn't a HuggingFace resolve URL. Pure — unit-tested. * * e.g. https://huggingface.co/litert-community/Qwen3-0.6B/resolve/main/model.litertlm * → { repo: 'litert-community/Qwen3-0.6B', revision: 'main', path: 'model.litertlm' } */ export declare function parseHuggingFaceUrl(url: string): { repo: string; revision: string; path: string; } | null; /** * Look up a model file's SHA256 and byte size from HuggingFace, so you can fill * in a {@link registerModel} entry without computing them by hand. * * Trust note: this reads the hash from the same host you'll download from, so it * only guards against download corruption — NOT a maliciously changed upstream * repo. For a real supply-chain guarantee, run this once at dev time and PIN the * returned `sha256` in your source, exactly like the built-in registry. * * @param downloadUrl - A HuggingFace resolve URL (the one you'll register). * @returns `{ sha256, sizeBytes }` ready to spread into a registry entry. * @throws if the URL isn't a HuggingFace resolve URL, the API call fails, or the * file isn't an LFS object (no hash/size available). */ export declare function fetchModelMetadata(downloadUrl: string): Promise<{ sha256: string; sizeBytes: number; }>; /** * Filter a list of downloadable models to only include models that are * available for use on-device. * * A model is considered available if it has been fully downloaded, is * currently being loaded, or is already initialized and ready for inference. * This excludes models that have not been downloaded or are unavailable. * * @param models - List of downloadable models with their current download status. * @returns A new array containing only downloaded, loading, or ready models. */ export declare function filterDownloadedModels(models: DownloadableModel[]): DownloadableModel[]; //# sourceMappingURL=models.d.ts.map