/** Portable model artifacts — a chat model or an embedding model, packed as a * zip you can move to a machine with no internet. * * manifest.json { kind: 'model', modelId, createdAt, files: [{file, url}] } * files/0.bin each file's bytes, in manifest order * * Import restores every file into the Cache API under the URL the runtime * will request, so the next `load()` makes zero network calls. That is the * same mechanism offline-llm-knowledge-system uses for its embed model. */ import { type ArchiveSource, type ZipOptions } from './archive.ts'; /** Files a converted Transformers.js model folder can contain. Missing ones * are skipped, so this list can stay generous. */ export declare const MODEL_FILES: readonly ["config.json", "generation_config.json", "tokenizer.json", "tokenizer_config.json", "special_tokens_map.json", "preprocessor_config.json", "vocab.json", "merges.txt", "added_tokens.json", "chat_template.jinja"]; export declare const ONNX_FILES: readonly ["onnx/model_q4.onnx", "onnx/model_quantized.onnx", "onnx/model_fp16.onnx", "onnx/model.onnx", "onnx/model.onnx_data"]; export interface ModelManifest { kind: 'model'; modelId: string; createdAt: string; /** Which onnx variants are inside. */ dtypes: string[]; files: Array<{ file: string; url: string; path: string; }>; } export interface ExportModelOptions extends ZipOptions { /** Where the model is served from. Default '/models/'. */ modelsUrl?: string; /** Full base URL to fetch files from, overriding `modelsUrl + modelId`. * Use `hfRoot(repo)` to pack straight from the Hugging Face Hub. */ root?: string; /** Only include these dtypes (e.g. ['q4']). Default: every variant present. */ dtypes?: string[]; /** Extra relative paths to include. */ extraFiles?: string[]; onProgress?: (file: string, index: number, total: number) => void; } /** Pack a served model into a portable zip. */ export declare function exportModel(modelId: string, opts?: ExportModelOptions): Promise; export interface ImportModelOptions extends ZipOptions { /** Re-point the recorded URLs (e.g. when the app is served elsewhere now). */ rewriteUrl?: (url: string, path: string, modelId: string) => string; /** Also register under this base, so `load()` from a local path hits cache. */ modelsUrl?: string; } /** Restore a model zip into the browser cache. After this, loading the model * needs no network. Returns the manifest so callers know what they got. */ export declare function importModel(source: ArchiveSource, opts?: ImportModelOptions): Promise; /** Read a model archive's manifest without restoring anything. */ export declare function inspectModel(source: ArchiveSource, opts?: ZipOptions): Promise;