Skip to content

v1.2.0 — Built-in Transformers.js Browser-Side AI Provider

Choose a tag to compare

@xezpeleta xezpeleta released this 27 Jun 11:14

🤖 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-local AiCompletionProvider backed by Transformers.js
  • transformersJs: true in aiCompletion config — one-line opt-in to browser-side AI
  • getTransformersJsState() — query loading/ready/error state for UI
  • preload() — 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/transformers loaded 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/transformers v4 (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