@tryhamster/gerbil 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +85 -34
- package/dist/browser/index.d.ts +12 -2
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js +12 -5
- package/dist/browser/index.js.map +1 -1
- package/dist/cli.mjs +7 -7
- package/dist/cli.mjs.map +1 -1
- package/dist/frameworks/express.d.mts +1 -1
- package/dist/frameworks/express.mjs +1 -1
- package/dist/frameworks/fastify.d.mts +1 -1
- package/dist/frameworks/fastify.mjs +1 -1
- package/dist/frameworks/hono.d.mts +1 -1
- package/dist/frameworks/hono.mjs +1 -1
- package/dist/frameworks/next.d.mts +3 -3
- package/dist/frameworks/next.mjs +1 -1
- package/dist/frameworks/react.d.mts +1 -1
- package/dist/frameworks/trpc.d.mts +1 -1
- package/dist/frameworks/trpc.mjs +1 -1
- package/dist/{gerbil-BT9fCydo.d.mts → gerbil-BetB5xb0.d.mts} +3 -3
- package/dist/{gerbil-BT9fCydo.d.mts.map → gerbil-BetB5xb0.d.mts.map} +1 -1
- package/dist/gerbil-CTZUa8EZ.mjs +4 -0
- package/dist/{gerbil-BHrJJIa4.mjs → gerbil-DNniplr4.mjs} +2 -2
- package/dist/{gerbil-BHrJJIa4.mjs.map → gerbil-DNniplr4.mjs.map} +1 -1
- package/dist/gpu/hooks.d.mts +122 -2
- package/dist/gpu/hooks.d.mts.map +1 -1
- package/dist/gpu/hooks.mjs +187 -6
- package/dist/gpu/hooks.mjs.map +1 -1
- package/dist/gpu/index.d.mts +2 -2
- package/dist/gpu/index.mjs +2 -2
- package/dist/{gpu-33qCAtHW.mjs → gpu-DFuglcEx.mjs} +178 -3
- package/dist/gpu-DFuglcEx.mjs.map +1 -0
- package/dist/{index-jEAL2s-A.d.mts → index-DukkJRMj.d.mts} +104 -12
- package/dist/{index-jEAL2s-A.d.mts.map → index-DukkJRMj.d.mts.map} +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +4 -4
- package/dist/integrations/ai-sdk.d.mts +1 -1
- package/dist/integrations/ai-sdk.mjs +1 -1
- package/dist/integrations/langchain.d.mts +1 -1
- package/dist/integrations/langchain.mjs +1 -1
- package/dist/integrations/llamaindex.d.mts +1 -1
- package/dist/integrations/llamaindex.mjs +1 -1
- package/dist/integrations/mcp.d.mts +3 -3
- package/dist/integrations/mcp.mjs +4 -4
- package/dist/{mcp-1DaMsaBc.mjs → mcp-D2vvH1Xc.mjs} +3 -3
- package/dist/{mcp-1DaMsaBc.mjs.map → mcp-D2vvH1Xc.mjs.map} +1 -1
- package/dist/moonshine-stt-17dpP1kr.mjs +4 -0
- package/dist/{moonshine-stt-v_P_Ci_m.mjs → moonshine-stt-4ojLtMq7.mjs} +30 -4
- package/dist/{moonshine-stt-v_P_Ci_m.mjs.map → moonshine-stt-4ojLtMq7.mjs.map} +1 -1
- package/dist/{one-liner-DnQn7HJK.mjs → one-liner-JhdIPxzF.mjs} +2 -2
- package/dist/{one-liner-DnQn7HJK.mjs.map → one-liner-JhdIPxzF.mjs.map} +1 -1
- package/dist/{repl-jV5gcJFA.mjs → repl-BDRkwPGX.mjs} +3 -3
- package/dist/skills/index.d.mts +3 -3
- package/dist/skills/index.mjs +3 -3
- package/dist/{skills-DX8D59UH.mjs → skills-CU694Dc8.mjs} +2 -2
- package/dist/{skills-DX8D59UH.mjs.map → skills-CU694Dc8.mjs.map} +1 -1
- package/dist/{types-D6FiR_oh.d.mts → types-LlyYILII.d.mts} +7 -3
- package/dist/types-LlyYILII.d.mts.map +1 -0
- package/package.json +1 -1
- package/dist/gerbil-DomNfIr1.mjs +0 -4
- package/dist/gpu-33qCAtHW.mjs.map +0 -1
- package/dist/moonshine-stt-BLyVoRpB.mjs +0 -4
- package/dist/types-D6FiR_oh.d.mts.map +0 -1
package/README.md
CHANGED
|
@@ -9,14 +9,15 @@
|
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
11
|
<p align="center">
|
|
12
|
+
<a href="https://gerbilsdk.com"><strong>gerbilsdk.com</strong></a> •
|
|
12
13
|
<a href="#install">Install</a> •
|
|
13
14
|
<a href="#native-webgpu-engine">Engine</a> •
|
|
14
15
|
<a href="#react-quickstart">React</a> •
|
|
15
16
|
<a href="#embeddings">Embeddings</a> •
|
|
16
17
|
<a href="#vision">Vision</a> •
|
|
17
18
|
<a href="#speech">Speech</a> •
|
|
18
|
-
<a href="
|
|
19
|
-
<a href="
|
|
19
|
+
<a href="https://gerbilsdk.com/docs/frameworks/ai-sdk">AI SDK</a> •
|
|
20
|
+
<a href="https://gerbilsdk.com/docs/cli">CLI</a>
|
|
20
21
|
</p>
|
|
21
22
|
|
|
22
23
|
<p align="center">
|
|
@@ -43,13 +44,14 @@ const engine = await WebGPUEngine.create({ repo: "mlx-community/Qwen3.5-0.8B-4bi
|
|
|
43
44
|
const { text } = await engine.generate("Explain recursion in one sentence");
|
|
44
45
|
```
|
|
45
46
|
|
|
46
|
-
> **
|
|
47
|
-
> native engine surface below is the path going forward; APIs may still shift before 1.0.
|
|
47
|
+
> **📚 Full docs → [gerbilsdk.com/docs](https://gerbilsdk.com/docs)** · live playground & demos at **[gerbilsdk.com](https://gerbilsdk.com)**
|
|
48
48
|
|
|
49
49
|
## Why Gerbil?
|
|
50
50
|
|
|
51
51
|
- **One native engine** — a from-scratch WebGPU/WGSL engine, pure compute shaders, nothing
|
|
52
52
|
extra to ship.
|
|
53
|
+
- **~90 KB gzipped** — the _entire_ multimodal engine. No heavyweight ML runtime; model
|
|
54
|
+
weights stream from the HuggingFace Hub at run time.
|
|
53
55
|
- **Multimodal, all native** — text, vision (image→text), embeddings, and speech run on the
|
|
54
56
|
same engine, loading safetensors directly from the HuggingFace Hub.
|
|
55
57
|
- **Browser & Node** — Chrome 113+, Safari 26+ (iOS 26+), Firefox 141+, and Node via Dawn
|
|
@@ -209,7 +211,7 @@ const doc = await engine.embed("Paris is the capital of France", { taskType: "do
|
|
|
209
211
|
const sim = query.reduce((s, v, i) => s + v * doc[i], 0);
|
|
210
212
|
```
|
|
211
213
|
|
|
212
|
-
📖 **[Full Embeddings Documentation →](
|
|
214
|
+
📖 **[Full Embeddings Documentation →](https://gerbilsdk.com/docs)**
|
|
213
215
|
|
|
214
216
|
## Vision
|
|
215
217
|
|
|
@@ -230,7 +232,7 @@ const { text } = await engine.describeImage(
|
|
|
230
232
|
);
|
|
231
233
|
```
|
|
232
234
|
|
|
233
|
-
📖 **[Full Vision Documentation →](
|
|
235
|
+
📖 **[Full Vision Documentation →](https://gerbilsdk.com/docs/vision)**
|
|
234
236
|
|
|
235
237
|
## Speech
|
|
236
238
|
|
|
@@ -249,10 +251,13 @@ via the dedicated `MoonshineSTT` class.
|
|
|
249
251
|
import { MoonshineSTT } from "@tryhamster/gerbil/gpu";
|
|
250
252
|
|
|
251
253
|
const stt = await MoonshineSTT.create({ repo: "UsefulSensors/moonshine-base" });
|
|
252
|
-
const { text } = await stt.transcribe(pcm16kMono); //
|
|
254
|
+
const { text, noSpeech } = await stt.transcribe(pcm16kMono); // noSpeech flags silence
|
|
253
255
|
```
|
|
254
256
|
|
|
255
|
-
|
|
257
|
+
`transcribe` returns `noSpeech` (RMS VAD + min-duration + marker denylist) so you can skip
|
|
258
|
+
silent/empty clips; `useSTT` surfaces it too, with an `onNoSpeech` callback.
|
|
259
|
+
|
|
260
|
+
📖 **[Full TTS Documentation →](https://gerbilsdk.com/docs/tts)** · **[Full STT Documentation →](https://gerbilsdk.com/docs/stt)**
|
|
256
261
|
|
|
257
262
|
## Skills
|
|
258
263
|
|
|
@@ -286,7 +291,7 @@ await loadSkills("./skills"); // loads *.skill.ts
|
|
|
286
291
|
const skill = useSkill("my-skill");
|
|
287
292
|
```
|
|
288
293
|
|
|
289
|
-
📖 **[Full Skills Documentation →](
|
|
294
|
+
📖 **[Full Skills Documentation →](https://gerbilsdk.com/docs/skills)**
|
|
290
295
|
|
|
291
296
|
## Tools & Agents
|
|
292
297
|
|
|
@@ -303,6 +308,27 @@ const weatherTool = defineTool({
|
|
|
303
308
|
});
|
|
304
309
|
```
|
|
305
310
|
|
|
311
|
+
**Agentic loop, on-device.** `engine.generateWithTools` (and the `useAgent` React hook)
|
|
312
|
+
run the whole loop — generate → call a tool → feed the result back → repeat — and return a
|
|
313
|
+
step trace for UIs:
|
|
314
|
+
|
|
315
|
+
```tsx
|
|
316
|
+
import { useAgent } from "@tryhamster/gerbil/gpu/hooks";
|
|
317
|
+
|
|
318
|
+
const { run, steps, answer, isRunning } = useAgent({
|
|
319
|
+
model: "mlx-community/Qwen3.5-0.8B-4bit",
|
|
320
|
+
tools: [
|
|
321
|
+
{
|
|
322
|
+
name: "get_weather",
|
|
323
|
+
description: "Get the weather for a city",
|
|
324
|
+
parameters: { city: "string" },
|
|
325
|
+
execute: ({ city }) => `Weather in ${city}: 72°F, sunny`,
|
|
326
|
+
},
|
|
327
|
+
],
|
|
328
|
+
});
|
|
329
|
+
await run("What's the weather in Paris?"); // steps[]: tool_call → tool_result → answer
|
|
330
|
+
```
|
|
331
|
+
|
|
306
332
|
**Built-in tools:**
|
|
307
333
|
- `gerbil_docs` — Search Gerbil documentation
|
|
308
334
|
- `run_skill` — Execute any Gerbil skill
|
|
@@ -316,7 +342,28 @@ npx @tryhamster/gerbil repl
|
|
|
316
342
|
# Gerbil will call the docs tool and synthesize an answer
|
|
317
343
|
```
|
|
318
344
|
|
|
319
|
-
📖 **[Full Tools Documentation →](
|
|
345
|
+
📖 **[Full Tools Documentation →](https://gerbilsdk.com/docs/tools)**
|
|
346
|
+
|
|
347
|
+
## Autocomplete & Rewrite
|
|
348
|
+
|
|
349
|
+
Inline autocomplete — `engine.autocomplete(prefix)` and the debounced `useAutocomplete`
|
|
350
|
+
hook return a brief single-line continuation (low-latency defaults + cleanup):
|
|
351
|
+
|
|
352
|
+
```tsx
|
|
353
|
+
import { useAutocomplete } from "@tryhamster/gerbil/gpu/hooks";
|
|
354
|
+
|
|
355
|
+
const { suggestion, onInput, accept, dismiss } = useAutocomplete({
|
|
356
|
+
model: "mlx-community/Qwen3.5-0.8B-4bit",
|
|
357
|
+
});
|
|
358
|
+
// <input onChange={(e) => onInput(e.target.value)} /> — render `suggestion` as ghost text;
|
|
359
|
+
// Tab → accept(), Esc → dismiss()
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
Tone rewrite — `engine.rewrite(text, { tone })` (and `useEngine().rewrite`) re-generates
|
|
363
|
+
text in a target tone (`"professional"`, `"friendly"`, `"concise"`, `"playful"`,
|
|
364
|
+
`"pirate"`) or with free-form `instructions`.
|
|
365
|
+
|
|
366
|
+
📖 **[Full Autocomplete Documentation →](https://gerbilsdk.com/docs/autocomplete)**
|
|
320
367
|
|
|
321
368
|
## CLI
|
|
322
369
|
|
|
@@ -339,7 +386,7 @@ gerbil update # Update to latest version
|
|
|
339
386
|
|
|
340
387
|
> **Updates**: Gerbil checks for updates but never installs without permission. Press `u` in REPL or run `gerbil update`.
|
|
341
388
|
|
|
342
|
-
📖 **[Full CLI Documentation →](
|
|
389
|
+
📖 **[Full CLI Documentation →](https://gerbilsdk.com/docs/cli)**
|
|
343
390
|
|
|
344
391
|
## Browser Usage
|
|
345
392
|
|
|
@@ -363,22 +410,22 @@ function Chat() {
|
|
|
363
410
|
}
|
|
364
411
|
```
|
|
365
412
|
|
|
366
|
-
`@tryhamster/gerbil/browser`
|
|
413
|
+
`@tryhamster/gerbil/browser` exports the device & storage utilities
|
|
367
414
|
(`isModelSafeForDevice`, `detectMemoryCrash`, `downloadModelChunked`,
|
|
368
|
-
`
|
|
415
|
+
`getRecommendedModels`, `requestPersistentStorage`, …).
|
|
369
416
|
|
|
370
|
-
📖 **[Full Browser Documentation →](
|
|
417
|
+
📖 **[Full Browser Documentation →](https://gerbilsdk.com/docs/browser)**
|
|
371
418
|
|
|
372
419
|
## Integrations
|
|
373
420
|
|
|
374
421
|
| Integration | Import | Docs |
|
|
375
422
|
|-------------|--------|------|
|
|
376
|
-
| **Browser** | `@tryhamster/gerbil/browser` | [📖 Browser](
|
|
377
|
-
| **AI SDK v5** | `@tryhamster/gerbil/ai` | [📖 AI SDK](
|
|
378
|
-
| **Next.js** | `@tryhamster/gerbil/next` | [📖
|
|
379
|
-
| **Express** | `@tryhamster/gerbil/express` | [📖
|
|
380
|
-
| **LangChain** | `@tryhamster/gerbil/langchain` | [📖
|
|
381
|
-
| **MCP Server** | `npx @tryhamster/gerbil serve --mcp` | [📖 MCP](
|
|
423
|
+
| **Browser** | `@tryhamster/gerbil/browser` | [📖 Browser](https://gerbilsdk.com/docs/browser) |
|
|
424
|
+
| **AI SDK v5** | `@tryhamster/gerbil/ai` | [📖 AI SDK](https://gerbilsdk.com/docs/frameworks/ai-sdk) |
|
|
425
|
+
| **Next.js** | `@tryhamster/gerbil/next` | [📖 Next.js](https://gerbilsdk.com/docs/frameworks/nextjs) |
|
|
426
|
+
| **Express** | `@tryhamster/gerbil/express` | [📖 Express](https://gerbilsdk.com/docs/frameworks/express) |
|
|
427
|
+
| **LangChain** | `@tryhamster/gerbil/langchain` | [📖 LangChain](https://gerbilsdk.com/docs/frameworks/langchain) |
|
|
428
|
+
| **MCP Server** | `npx @tryhamster/gerbil serve --mcp` | [📖 MCP](https://gerbilsdk.com/docs/mcp) |
|
|
382
429
|
|
|
383
430
|
**Native engine:** `import { WebGPUEngine } from "@tryhamster/gerbil/gpu"` (or `useEngine` from `@tryhamster/gerbil/gpu/hooks` for React) is the primary surface for text, vision, embeddings, and speech.
|
|
384
431
|
|
|
@@ -444,22 +491,26 @@ HiFi-GAN (NanoCodec decoder), and more.
|
|
|
444
491
|
|
|
445
492
|
## Documentation
|
|
446
493
|
|
|
494
|
+
Full documentation, guides, and a live playground live at **[gerbilsdk.com/docs](https://gerbilsdk.com/docs)**.
|
|
495
|
+
|
|
447
496
|
| Guide | Description |
|
|
448
497
|
|-------|-------------|
|
|
449
|
-
| [📖
|
|
450
|
-
| [📖
|
|
451
|
-
| [📖
|
|
452
|
-
| [📖
|
|
453
|
-
| [📖
|
|
454
|
-
| [📖
|
|
455
|
-
| [📖
|
|
456
|
-
| [📖
|
|
457
|
-
| [📖
|
|
458
|
-
| [📖
|
|
459
|
-
| [📖
|
|
460
|
-
| [📖
|
|
461
|
-
| [📖
|
|
462
|
-
| [📖
|
|
498
|
+
| [📖 Getting Started](https://gerbilsdk.com/docs/getting-started) | Install, load a model, core concepts |
|
|
499
|
+
| [📖 Structured Output](https://gerbilsdk.com/docs) | `generateObject` / `useObject` — validated JSON with retries |
|
|
500
|
+
| [📖 Embeddings](https://gerbilsdk.com/docs) | EmbeddingGemma semantic search, similarity, RAG |
|
|
501
|
+
| [📖 Vision](https://gerbilsdk.com/docs/vision) | Image → text with Qwen3.5 ViT & Gemma 4 ViT |
|
|
502
|
+
| [📖 Text-to-Speech](https://gerbilsdk.com/docs/tts) | Native Kani-TTS-2 (`engine.speak()`) |
|
|
503
|
+
| [📖 Speech-to-Text](https://gerbilsdk.com/docs/stt) | Native Moonshine (`MoonshineSTT`) |
|
|
504
|
+
| [📖 Browser](https://gerbilsdk.com/docs/browser) | WebGPU inference, React hooks |
|
|
505
|
+
| [📖 Hooks](https://gerbilsdk.com/docs/hooks) | `useEngine` / `useObject` / `useTTS` / `useSTT` |
|
|
506
|
+
| [📖 Skills](https://gerbilsdk.com/docs/skills) | Built-in skills, custom skill development |
|
|
507
|
+
| [📖 Tools](https://gerbilsdk.com/docs/tools) | Tool calling, agentic workflows |
|
|
508
|
+
| [📖 REPL](https://gerbilsdk.com/docs/repl) | Interactive terminal dashboard |
|
|
509
|
+
| [📖 AI SDK](https://gerbilsdk.com/docs/frameworks/ai-sdk) | Vercel AI SDK v5 (LLM, TTS, STT, Embeddings) |
|
|
510
|
+
| [📖 Frameworks](https://gerbilsdk.com/docs/frameworks) | Next.js, Express, React, LangChain |
|
|
511
|
+
| [📖 CLI](https://gerbilsdk.com/docs/cli) | All CLI commands and options |
|
|
512
|
+
| [📖 Mobile](https://gerbilsdk.com/docs/mobile) | iOS / iPadOS guidance & memory guards |
|
|
513
|
+
| [📖 MCP](https://gerbilsdk.com/docs/mcp) | MCP server for Claude Desktop & Cursor |
|
|
463
514
|
|
|
464
515
|
## Requirements
|
|
465
516
|
|
package/dist/browser/index.d.ts
CHANGED
|
@@ -41,8 +41,12 @@ type GenerateOptions = {
|
|
|
41
41
|
system?: string;
|
|
42
42
|
/** Enable thinking/reasoning mode (Qwen3) */
|
|
43
43
|
thinking?: boolean;
|
|
44
|
-
/** Callback for each token (streaming) */
|
|
45
|
-
onToken?: (token: string
|
|
44
|
+
/** Callback for each token (streaming); `meta` carries live decode-only tok/s */
|
|
45
|
+
onToken?: (token: string, meta?: {
|
|
46
|
+
tokenIndex: number;
|
|
47
|
+
tps: number;
|
|
48
|
+
elapsedMs: number;
|
|
49
|
+
}) => void;
|
|
46
50
|
/** Images to include (only used if model supports vision) */
|
|
47
51
|
images?: ImageInput[];
|
|
48
52
|
/** Enable response caching (default: false) */
|
|
@@ -581,6 +585,12 @@ declare const MODEL_SIZES: Record<string, number>;
|
|
|
581
585
|
*/
|
|
582
586
|
declare function isModelSafeForDevice(modelId: string): {
|
|
583
587
|
safe: boolean;
|
|
588
|
+
/**
|
|
589
|
+
* Borderline: may run on the newest hardware but is prone to OOM. Reported
|
|
590
|
+
* unsafe (`safe: false`) so callers block by default; a UI can use `risky` to
|
|
591
|
+
* offer an explicit "load anyway" on capable devices.
|
|
592
|
+
*/
|
|
593
|
+
risky: boolean;
|
|
584
594
|
reason: string;
|
|
585
595
|
recommendation?: string;
|
|
586
596
|
maxSafeModel?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/core/types.ts","../../src/core/models.ts","../../src/browser/pwa.ts","../../src/browser/audio.ts","../../src/browser/device-guards.ts","../../src/browser/download.ts"],"sourcesContent":[],"mappings":";;;;AAyBY,KAfA,WAAA,GAeW;EASX,EAAA,EAAA,MAAA;EAWA,IAAA,EAAA,MAAA;EAmCA,WAAA,EAAA,MAAc;EA8Bd,IAAA,EAAA,MAAA;EAkBA,aAAA,EAAY,MAAA;EAQZ,gBAAW,EAAA,OAAA;EAWX,YAAA,EAAA,OAAY;EAWZ;EAkBA,cAAW,CAAA,EAAA,OAAA;EAqBX;EAOA,iBAAY,CAAA,EAAA,MAAA;EAYZ,MAAA,EAAA,MAAA,GAAY,QAAA,GAAA,KAAA,GAAA,SAAA,GAAA,OAAA,GAAA,OAAA;CAWd;AAGG,KA7MD,WAAA,GA6MC;EAGC,IAAA,EAAA,SAAA,GAAA,aAAA,GAAA,OAAA;EAGE,IAAA,EAAA,MAAA;CAAiB;AAGrB,KA7MA,UAAA,GA6MW;EAiBX;EAqBA,MAAA,EAAA,MAAA;EAUA;EAOA,GAAA,CAAA,EAAA,MAAA;AAyBZ,CAAA;AAWY,KA7RA,eAAA,GA6RsB;EAYtB;EAeA,SAAA,CAAA,EAAA,MAAc;EAmBd;EAWA,WAAA,CAAA,EAAU,MAAA;EAWV;EAaA,IAAA,CAAA,EAAA,MAAA;EAWA;EAiBA,IAAA,CAAA,EAAA,MAAA;EASA;EASA,aAAA,CAAA,EAAA,MAAgB,EAAA;EAahB;EAWA,MAAA,CAAA,EAAA,MAAA;EAeA;EAES,QAAA,CAAA,EAAA,OAAA;EAEN;EAID,OAAA,CAAA,EAAA,CAAA,KAAA,EAAA,MAAA,EAAA,GAAA,IAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/core/types.ts","../../src/core/models.ts","../../src/browser/pwa.ts","../../src/browser/audio.ts","../../src/browser/device-guards.ts","../../src/browser/download.ts"],"sourcesContent":[],"mappings":";;;;AAyBY,KAfA,WAAA,GAeW;EASX,EAAA,EAAA,MAAA;EAWA,IAAA,EAAA,MAAA;EAmCA,WAAA,EAAA,MAAc;EA8Bd,IAAA,EAAA,MAAA;EAkBA,aAAA,EAAY,MAAA;EAQZ,gBAAW,EAAA,OAAA;EAWX,YAAA,EAAA,OAAY;EAWZ;EAkBA,c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OLlG9C,CAAA;EAAiB,UAAA,EAAA,OAAA;EAGrB,eAAW,CAAA,EAAA,MAAA;EAiBX,UAAA,CAAA,EAAA,MAAc;EAqBd,OAAA,CAAA,EAAA,MAAY;AAUxB,CAAA,CAAA;AAOA;AAyBA;AAWA;AAYY,iBK4BU,uBAAA,CL5BD,OAAA,EAAA,MAAA,CAAA,EK4B2C,OL5B3C,CAAA,IAAA,CAAA;AAerB;AAmBA;AAWA;AAWA;AAaY,iBK3BU,iBAAA,CL6BA,UAAY,CAAA,EAAA,MAAA,CAAA,EK7BiC,OL6BjC,CAAA;EAStB,EAAA,EAAA,OAAA;EAiBA,WAAA,EAAA,MAAA;EASA,MAAA,EAAA,MAAA;EASA,OAAA,EAAA,MAAA;EAaA,OAAA,CAAA,EAAA,MAAA;AAWZ,CAAA,CAAA"}
|
package/dist/browser/index.js
CHANGED
|
@@ -280,8 +280,8 @@ function normalizeId(modelId) {
|
|
|
280
280
|
* - blocked: too large for the WKWebView memory ceiling on iPhone — will crash.
|
|
281
281
|
* gemma-4-e2b (~3.6GB) plus any vision checkpoint (the vision encoder pushes
|
|
282
282
|
* the working set well past what an iPhone can hold).
|
|
283
|
-
* - risky:
|
|
284
|
-
*
|
|
283
|
+
* - risky: Qwen3.5-2B (~1.7GB) OOM-crashes iPhone WKWebView in practice — now
|
|
284
|
+
* treated as unsafe to auto-load (flagged `risky` so a UI can offer to force it).
|
|
285
285
|
* - everything else (Qwen3.5-0.8B ~0.65GB, LFM2.5-350M) is allowed everywhere.
|
|
286
286
|
*/
|
|
287
287
|
const IOS_MODEL_LIMITS = {
|
|
@@ -314,41 +314,48 @@ function isModelSafeForDevice(modelId) {
|
|
|
314
314
|
if (isIPhone) {
|
|
315
315
|
if (isBlocked) return {
|
|
316
316
|
safe: false,
|
|
317
|
+
risky: false,
|
|
317
318
|
reason: `Model ${modelId} will crash on iPhone${isIOSChrome ? " (iOS Chrome uses WKWebView, same limits as Safari)" : ""}. ${isVision ? "Vision checkpoints need a separate image encoder in memory" : "It is too large (~3.6GB)"}, which exceeds the WKWebView memory ceiling.`,
|
|
318
319
|
recommendation: `Use ${SAFE_MOBILE_CHAT} (Qwen3.5-0.8B) on iPhone, or run larger models on desktop.`,
|
|
319
320
|
maxSafeModel: SAFE_MOBILE_CHAT
|
|
320
321
|
};
|
|
321
322
|
if (isRisky) return {
|
|
322
|
-
safe:
|
|
323
|
-
|
|
324
|
-
|
|
323
|
+
safe: false,
|
|
324
|
+
risky: true,
|
|
325
|
+
reason: `Model ${modelId} (~1.7GB) exceeds the iPhone WKWebView memory budget and is likely to crash.`,
|
|
326
|
+
recommendation: `Use ${SAFE_MOBILE_CHAT} (Qwen3.5-0.8B) on iPhone; run Qwen3.5-2B on iPad or desktop.`,
|
|
325
327
|
maxSafeModel: SAFE_MOBILE_CHAT
|
|
326
328
|
};
|
|
327
329
|
return {
|
|
328
330
|
safe: true,
|
|
331
|
+
risky: false,
|
|
329
332
|
reason: "Model is within iPhone memory limits."
|
|
330
333
|
};
|
|
331
334
|
}
|
|
332
335
|
if (isIPad) {
|
|
333
336
|
if (isBlocked) return {
|
|
334
337
|
safe: false,
|
|
338
|
+
risky: false,
|
|
335
339
|
reason: `Model ${modelId} may crash on iPad. ${isVision ? "Vision checkpoints need a separate image encoder in memory" : "It is too large (~3.6GB)"}, which can exceed the WKWebView memory ceiling.`,
|
|
336
340
|
recommendation: `Use ${SAFE_MOBILE_CHAT} (Qwen3.5-0.8B) or Qwen3.5-2B on iPad.`,
|
|
337
341
|
maxSafeModel: "mlx-community/Qwen3.5-2B-4bit"
|
|
338
342
|
};
|
|
339
343
|
return {
|
|
340
344
|
safe: true,
|
|
345
|
+
risky: false,
|
|
341
346
|
reason: "Model is within iPad memory limits."
|
|
342
347
|
};
|
|
343
348
|
}
|
|
344
349
|
if (/Android/.test(ua) && isBlocked) return {
|
|
345
350
|
safe: false,
|
|
351
|
+
risky: false,
|
|
346
352
|
reason: `Model ${modelId} is very large and may crash on Android devices.`,
|
|
347
353
|
recommendation: `Use ${SAFE_MOBILE_CHAT} (Qwen3.5-0.8B) or Qwen3.5-2B on Android.`,
|
|
348
354
|
maxSafeModel: "mlx-community/Qwen3.5-2B-4bit"
|
|
349
355
|
};
|
|
350
356
|
return {
|
|
351
357
|
safe: true,
|
|
358
|
+
risky: false,
|
|
352
359
|
reason: "Desktop browser has sufficient memory."
|
|
353
360
|
};
|
|
354
361
|
}
|