@degreesign/chat 0.9.0 → 0.9.2
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 +37 -16
- package/dist/assets/litert/litertlm_wasm_internal.js +15 -1
- package/dist/browser/chat.min.mjs +1 -1
- package/dist/chat.d.ts +5 -2
- package/dist/log.d.ts +3 -0
- package/dist/models.d.ts +3 -3
- package/dist/node/chat.node.min.js +1 -1
- package/dist/node/chat.node.min.mjs +1 -1
- package/dist/types.d.ts +5 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -306,20 +306,26 @@ describeImages(input: DescribeImagesInput): Promise<ImageDescription[]>
|
|
|
306
306
|
Describe every image in English with `qwen3_vl_2b_instruct`, the Unsloth
|
|
307
307
|
Qwen3-VL 2B Instruct build, one image at a time. When a WebGPU adapter exists
|
|
308
308
|
and `targetLanguage` is not English, the English descriptions are then
|
|
309
|
-
translated one by one with `gemma4_e2b_limited`. Without a GPU,
|
|
310
|
-
translation model cannot load,
|
|
311
|
-
|
|
309
|
+
translated one by one with `gemma4_e2b_limited`. Without a GPU, when the
|
|
310
|
+
translation model cannot load, or when the translator replies
|
|
311
|
+
`CANNOT_TRANSLATE`, `description` stays equal to `descriptionEN`. Both the
|
|
312
|
+
description and translation calls use a 2048-token reply budget unless
|
|
312
313
|
`limits.maxReplyTokens` overrides it.
|
|
313
314
|
|
|
315
|
+
The describer and translator each receive a system message that puts accuracy
|
|
316
|
+
first: the describer reports only visible detail and the translator preserves
|
|
317
|
+
meaning, names and numbers without adding or omitting anything.
|
|
318
|
+
|
|
314
319
|
`DescribeImagesInput`:
|
|
315
320
|
|
|
316
321
|
| Field | Description |
|
|
317
322
|
| ----- | ----------- |
|
|
318
323
|
| `targetLanguage` | Language of `description`; `en`, `English` or a tag such as `en-US` skips translation. |
|
|
319
324
|
| `images` | Image data URLs or URLs, described in this order. |
|
|
320
|
-
| `currentIndex?` | Receives `index`, then `index` and `descriptionEN`, then `index`, `descriptionEN` and
|
|
325
|
+
| `currentIndex?` | Receives `index`, then `index` and `descriptionEN`, then `index`, `descriptionEN`, `description` and the description time in milliseconds. |
|
|
321
326
|
| `limits?` | Partial `LlmLimits` for both the description and translation calls. |
|
|
322
327
|
| `logging?` | Whether package and engine console logs are written. Defaults to `false`. |
|
|
328
|
+
| `onStatus?` | Receives a `ChatStatusSnapshot` while the describer and translator load and run. |
|
|
323
329
|
|
|
324
330
|
The promise resolves one `ImageDescription` per image, in input order:
|
|
325
331
|
|
|
@@ -327,12 +333,21 @@ The promise resolves one `ImageDescription` per image, in input order:
|
|
|
327
333
|
| ----- | ----------- |
|
|
328
334
|
| `descriptionEN` | The English description from the vision model. |
|
|
329
335
|
| `description` | The translated description, or `descriptionEN` without a GPU. |
|
|
336
|
+
| `durationMs` | Time the describer took for this image, in milliseconds. |
|
|
330
337
|
|
|
331
338
|
`currentIndex` fires once per image at the start of its description, once when
|
|
332
339
|
the English text is ready, and once when the final description is ready. The
|
|
333
|
-
first call carries the index alone, the second adds `descriptionEN
|
|
334
|
-
third adds `description
|
|
335
|
-
|
|
340
|
+
first call carries the index alone, the second adds `descriptionEN` and
|
|
341
|
+
`durationMs`, and the third adds `description` while keeping `durationMs`. The
|
|
342
|
+
function uses the shared runtime, so it loads the describer and then the
|
|
343
|
+
translator, replacing whichever model was loaded before.
|
|
344
|
+
|
|
345
|
+
`onStatus` follows the same snapshots as `createChat`. The describer reports
|
|
346
|
+
first, with `supportsImages: true`. When a translation pass follows, the
|
|
347
|
+
snapshots switch to `gemma4_e2b_limited` while it loads and translates. The
|
|
348
|
+
final snapshot has `requesting: false`; when the translator cannot load, it also
|
|
349
|
+
carries that error and the descriptions stay English. An empty `images` list
|
|
350
|
+
touches no model and reports nothing.
|
|
336
351
|
|
|
337
352
|
## Tools
|
|
338
353
|
|
|
@@ -384,17 +399,22 @@ search and currency tools fetch over the network; `calculate` does not.
|
|
|
384
399
|
| `error?` | The last failure, cleared when a reply starts. |
|
|
385
400
|
|
|
386
401
|
The first snapshot fires synchronously inside `createChat`. A final snapshot
|
|
387
|
-
with `requesting: false` marks the end of the call.
|
|
402
|
+
with `requesting: false` marks the end of the call. `describeImages` reports the
|
|
403
|
+
same snapshot for each model it loads: `qwen3_vl_2b_instruct` while it
|
|
404
|
+
describes, then `gemma4_e2b_limited` while it translates.
|
|
388
405
|
|
|
389
406
|
A stream that never produces its first chunk ends with an error after 180
|
|
390
|
-
seconds
|
|
391
|
-
|
|
407
|
+
seconds, or after 420 seconds when the prompt carries an image, because a CPU
|
|
408
|
+
vision prefill takes minutes. Once a chunk has arrived, 30 seconds of silence
|
|
409
|
+
ends the stream and keeps the text already delivered.
|
|
392
410
|
|
|
393
411
|
## Logging
|
|
394
412
|
|
|
395
413
|
Console output stays off by default. Pass `logging: true` in a call to receive
|
|
396
414
|
the package's censored engine logs, the wllama engine's own logs and the
|
|
397
|
-
LiteRT-LM wasm diagnostics for that call.
|
|
415
|
+
LiteRT-LM wasm diagnostics for that call. `describeImages` also logs every stage
|
|
416
|
+
from the model load to the generated English description, including the image
|
|
417
|
+
URL or data URL size and the raw reply. The flag is per call, so a later call
|
|
398
418
|
without it goes quiet again.
|
|
399
419
|
|
|
400
420
|
## Models
|
|
@@ -420,9 +440,9 @@ next attempt, including after a reload.
|
|
|
420
440
|
|
|
421
441
|
Qwen3-VL 2B downloads a vision projector of about 445 MB with the model, so its
|
|
422
442
|
total download is about 1.5 GB. It runs on the CPU engine, with a 4096 token
|
|
423
|
-
context on a phone and 8192 on a desktop. Its projector
|
|
424
|
-
|
|
425
|
-
|
|
443
|
+
context on a phone and 8192 on a desktop. Its projector uses the same CPU thread
|
|
444
|
+
budget as the text pass, so image turns are slower than the Gemma 4 WebGPU path.
|
|
445
|
+
Use the GPU model when images need to be fast.
|
|
426
446
|
|
|
427
447
|
`qwen3_vl_2b_instruct` is the Unsloth Qwen3-VL 2B Instruct build that
|
|
428
448
|
`describeImages` loads for the English pass. Its Q4_K_M file and F16 projector
|
|
@@ -493,7 +513,8 @@ matches the requested model.
|
|
|
493
513
|
|
|
494
514
|
The CPU engine derives a raw thread count from the device, then caps it at
|
|
495
515
|
`limits.maxThreads`, default 6. The cap is applied after the raw maximum, so the
|
|
496
|
-
engine never exceeds the device or the caller budget.
|
|
516
|
+
engine never exceeds the device or the caller budget. Every CPU model uses the
|
|
517
|
+
same count, including the vision projector models.
|
|
497
518
|
|
|
498
519
|
The CPU engine needs cross-origin isolation for its threads. Serve the page with
|
|
499
520
|
both headers:
|
|
@@ -617,7 +638,7 @@ const useReply = () => {
|
|
|
617
638
|
| `ChatInput` | One request: model, messages, budgets, reasoning and callbacks. |
|
|
618
639
|
| `ChatPreloadInput` | Model, limits, logging and status, the subset `preloadModel` needs. |
|
|
619
640
|
| `DescribeImagesInput` | Target language, images, progress callback, limits and logging. |
|
|
620
|
-
| `ImageDescription` | `descriptionEN
|
|
641
|
+
| `ImageDescription` | `descriptionEN`, the translated `description` and `durationMs`. |
|
|
621
642
|
| `CancelChat` | The function returned by `createChat`. |
|
|
622
643
|
| `ChatMessage` | One prompt turn, `role`, `content` and optional `images` and `audio`. |
|
|
623
644
|
| `ChatStatusSnapshot` | Availability, engine status, backend, progress and request state. |
|