@degreesign/chat 1.6.0 → 1.7.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/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ChatModelId, ChatStatus, LlmBackend, LlmPhase, LlmRole, LlmStatus, WebSearchProvider } from './enums';
1
+ import type { ChatModelId, ChatPreloadField, ChatStatus, DescriptionEnhancedStage, EstimateOperation, LlmBackend, LlmPhase, LlmRole, LlmStatus, WebSearchProvider } from './enums';
2
2
  /** Host-owned chat message */
3
3
  interface ChatMessage {
4
4
  role: LlmRole;
@@ -257,10 +257,99 @@ interface ChatInput {
257
257
  onStatus?: (snapshot: ChatStatusSnapshot) => void;
258
258
  }
259
259
  /** Model preload request */
260
- type ChatPreloadInput = Pick<ChatInput, `model` | `limits` | `logging` | `onStatus`>;
260
+ type ChatPreloadInput = Pick<ChatInput, ChatPreloadField>;
261
261
  /** Stop request or model */
262
262
  type CancelChat = () => void;
263
- /** Described image result */
263
+ /** Seconds estimated per operation */
264
+ interface EstimateEntry {
265
+ operation: EstimateOperation;
266
+ /** Seconds */
267
+ est: number;
268
+ }
269
+ /** Estimate handed to the caller */
270
+ interface EstimateReport {
271
+ /** Sum of breakdown, seconds */
272
+ totalEst: number;
273
+ /** Per-operation seconds, call order */
274
+ breakdown: EstimateEntry[];
275
+ }
276
+ /** Options shared by every call */
277
+ interface CallOptions {
278
+ /** Stop request */
279
+ signal?: AbortSignal;
280
+ /** Budget overrides */
281
+ limits?: Partial<LlmLimits>;
282
+ /** Logging option, off */
283
+ logging?: boolean;
284
+ /** Status change callback */
285
+ onStatus?: (snapshot: ChatStatusSnapshot) => void;
286
+ /** Duration estimate callback */
287
+ onEstimate?: (estimate: EstimateReport) => void;
288
+ }
289
+ /** One image description request */
290
+ interface DescribeImageInput extends CallOptions {
291
+ /** One image URL */
292
+ image: string;
293
+ /** Additional rules */
294
+ systemRulesOverride?: string;
295
+ /** Generation speed callback */
296
+ onSpeed?: (tokensPerSecond: number) => void;
297
+ /** Streamed text callback */
298
+ onText?: (text: string) => void;
299
+ }
300
+ /** English text enhancement request */
301
+ interface DescriptionEnhancedInput extends CallOptions {
302
+ /** English description */
303
+ descriptionEN: string;
304
+ /** Target language name */
305
+ targetLanguage: string;
306
+ /** Target language code */
307
+ targetCode: string;
308
+ /** Whether tags are generated */
309
+ withTags?: boolean;
310
+ /** Whether description is translated */
311
+ withDescription?: boolean;
312
+ /** Text model override */
313
+ model?: ChatModelId;
314
+ /** Running stage callback */
315
+ onStage?: (stage: DescriptionEnhancedStage) => void;
316
+ /** Generation speed callback */
317
+ onSpeed?: (tokensPerSecond: number) => void;
318
+ /** Streamed text callback */
319
+ onText?: (text: string, stage: DescriptionEnhancedStage) => void;
320
+ }
321
+ /** Gallery tag with translations */
322
+ interface ImageTag {
323
+ /** English tag */
324
+ en: string;
325
+ /** Translation keyed by language code */
326
+ [code: string]: string;
327
+ }
328
+ /** Stored tags translation request */
329
+ interface TranslateTagsInput extends CallOptions {
330
+ /** Tags to translate */
331
+ tags: ImageTag[];
332
+ /** Target language name */
333
+ targetLanguage: string;
334
+ /** Target language code */
335
+ targetCode: string;
336
+ /** Text model override */
337
+ model?: ChatModelId;
338
+ /** Streamed text callback */
339
+ onText?: (text: string) => void;
340
+ }
341
+ /** Enhanced English description */
342
+ interface DescriptionEnhanced {
343
+ /** Translated description, English fallback */
344
+ description: string;
345
+ /** Whether translation succeeded */
346
+ translated: boolean;
347
+ /** English and translated tags */
348
+ tags: ImageTag[];
349
+ /** Suggestive content flag, undefined unknown */
350
+ nsfw?: boolean;
351
+ }
352
+ /** @deprecated to be removed after Nov 2027 */
264
353
  interface ImageDescription {
265
354
  /** Vision description */
266
355
  descriptionEN: string;
@@ -269,7 +358,7 @@ interface ImageDescription {
269
358
  /** Description duration */
270
359
  durationMs: number;
271
360
  }
272
- /** One batch image description request */
361
+ /** @deprecated to be removed after Nov 2027 */
273
362
  interface DescribeImagesInput {
274
363
  /** Target description language */
275
364
  targetLanguage: string;
@@ -292,7 +381,7 @@ interface DescribeImagesInput {
292
381
  /** Additional rules */
293
382
  additionalRules?: string;
294
383
  }
295
- /** Batch translation request */
384
+ /** @deprecated to be removed after Nov 2027 */
296
385
  interface DescribeTranslatedInput {
297
386
  /** Ordered English descriptions */
298
387
  descriptions: string[];
@@ -745,4 +834,4 @@ interface ImageSize {
745
834
  width: number;
746
835
  height: number;
747
836
  }
748
- export type { ChatMessage, ChatTool, ChatToolCall, ChatToolResult, ChatToolSchema, ChatToolValue, WebSearchConfig, WebSearchResult, WebSearchSettings, FiatSnapshot, CryptoSnapshot, PriceSnapshot, PriceSections, PriceCoin, PriceFeed, CurrencyResult, CalculationResult, WikipediaPage, WikipediaResponse, DuckDuckGoTopic, DuckDuckGoResponse, ChatModel, LlmLimits, ChatStatusSnapshot, ChatInput, ChatPreloadInput, ChatState, CancelChat, ImageDescription, DescribeImagesInput, DescribeTranslatedInput, WllamaAssets, LitertAssets, GpuBuffer, GpuDevice, GpuWasm, GpuThrottleParams, GpuNavigator, MobileNavigator, ActiveCall, RuntimeDeps, RuntimeLoadParams, RuntimeLoadWaiter, RuntimeChatParams, StoredPart, StoredFilePart, StoredModel, StoredModelMeta, ResumePlan, StoreDownloadParams, ModelStore, Runtime, EngineChatParams, StartLlmParams, LlmRuntime, LlmEngine, EngineMessage, ImageSize, EngineContentPart, WllamaContentPart, WllamaMessage, LitertContentPart, LitertMessage, LitertEngine, LitertModule, LitertSettings, LitertSettingsParams, LitertSession, LitertChatParams, StreamLitertParams, EngineDelta, EngineTimings, EnginePromptProgress, EngineChunk, StreamReplyParams, EngineRunParams, };
837
+ export type { ChatMessage, ChatTool, ChatToolCall, ChatToolResult, ChatToolSchema, ChatToolValue, WebSearchConfig, WebSearchResult, WebSearchSettings, FiatSnapshot, CryptoSnapshot, PriceSnapshot, PriceSections, PriceCoin, PriceFeed, CurrencyResult, CalculationResult, WikipediaPage, WikipediaResponse, DuckDuckGoTopic, DuckDuckGoResponse, ChatModel, LlmLimits, ChatStatusSnapshot, ChatInput, ChatPreloadInput, ChatState, CancelChat, CallOptions, EstimateEntry, EstimateReport, DescribeImageInput, DescriptionEnhancedInput, DescriptionEnhancedStage, DescriptionEnhanced, ImageTag, TranslateTagsInput, ImageDescription, DescribeImagesInput, DescribeTranslatedInput, WllamaAssets, LitertAssets, GpuBuffer, GpuDevice, GpuWasm, GpuThrottleParams, GpuNavigator, MobileNavigator, ActiveCall, RuntimeDeps, RuntimeLoadParams, RuntimeLoadWaiter, RuntimeChatParams, StoredPart, StoredFilePart, StoredModel, StoredModelMeta, ResumePlan, StoreDownloadParams, ModelStore, Runtime, EngineChatParams, StartLlmParams, LlmRuntime, LlmEngine, EngineMessage, ImageSize, EngineContentPart, WllamaContentPart, WllamaMessage, LitertContentPart, LitertMessage, LitertEngine, LitertModule, LitertSettings, LitertSettingsParams, LitertSession, LitertChatParams, StreamLitertParams, EngineDelta, EngineTimings, EnginePromptProgress, EngineChunk, StreamReplyParams, EngineRunParams, };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@degreesign/chat",
3
- "version": "1.6.0",
3
+ "version": "1.7.1",
4
4
  "description": "Headless on-device AI chat for browsers and Node with wllama CPU and LiteRT WebGPU engines",
5
5
  "main": "dist/node/chat.node.min.js",
6
6
  "module": "dist/browser/chat.min.mjs",
@@ -64,6 +64,7 @@
64
64
  "dist/"
65
65
  ],
66
66
  "dependencies": {
67
+ "@degreesign/storage": "^1.1.6",
67
68
  "@degreesign/utils": "^1.0.5",
68
69
  "@litert-lm/core": "0.19.0-nightly.20261024",
69
70
  "@wllama/wllama": "^3.8.1",