v1.2.0 — Built-in Transformers.js Browser-Side AI Provider
🤖 Transformers.js AI Provider (Browser-Side)
Run AI ghost text completions entirely in the browser — no server, no API keys, no setup. Powered by Transformers.js + SmolLM3-135M-Instruct with WebGPU acceleration.
✨ What's New
createTransformersJsProvider()— Creates a fully-localAiCompletionProviderbacked by Transformers.jstransformersJs: trueinaiCompletionconfig — one-line opt-in to browser-side AIgetTransformersJsState()— query loading/ready/error state for UIpreload()— trigger model download programmatically (e.g., when user clicks "Enable AI")- Zero API keys — model runs on the user's machine using WebGPU or WASM fallback
- ~30MB download — SmolLM3-135M-Instruct, q4 quantized, cached in IndexedDB
- Optional peer dependency —
@huggingface/transformersloaded dynamically, core library stays lean
📋 Usage
With the shorthand:
new IdaztianEditor({
extensions: {
aiCompletion: { transformersJs: true },
},
})With full configuration:
import { createTransformersJsProvider } from 'idaztian'
const provider = createTransformersJsProvider({
modelId: 'HuggingFaceTB/SmolLM3-135M-Instruct',
dtype: 'q4',
maxNewTokens: 30,
temperature: 0.3,
onProgress: (pct, status) => console.log(`${pct}%: ${status}`),
onReady: () => console.log('AI ready!'),
})
new IdaztianEditor({
extensions: {
aiCompletion: { provider },
},
})🚀 GitHub Pages Demo
The Idaztian web demo now includes an AI button in the header. Click it to download and load the SmolLM3 model — once cached, completions appear as inline ghost text when you type. Ctrl+Shift+I toggles AI on/off.
🔧 Technical
- Uses
@huggingface/transformersv4 (WebGPU runtime, C++ ONNX backend) - Model:
HuggingFaceTB/SmolLM3-135M-Instruct(q4, ~30MB) - Automatically falls back from WebGPU to WASM if WebGPU is unavailable
- English-only completions (configurable via
systemPrompt) - Works in Chrome, Edge, Firefox (WebGPU), and Safari (WASM fallback)
Full Changelog: v1.1.0...v1.2.0