@degreesign/chat 1.7.6 → 1.7.8
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 +10 -0
- package/dist/browser/chat.min.mjs +1 -1
- package/dist/node/chat.node.min.js +1 -1
- package/dist/node/chat.node.min.mjs +1 -1
- package/dist/types/enums.d.ts +2 -1
- package/package.json +2 -2
- package/dist/chat.d.ts +0 -12
- package/dist/deprecated.d.ts +0 -11
- package/dist/describe.d.ts +0 -22
- package/dist/enums.d.ts +0 -80
- package/dist/estimate.d.ts +0 -13
- package/dist/log.d.ts +0 -3
- package/dist/models.d.ts +0 -26
- package/dist/prompts.d.ts +0 -18
- package/dist/service.d.ts +0 -3
- package/dist/types.d.ts +0 -837
package/dist/types.d.ts
DELETED
|
@@ -1,837 +0,0 @@
|
|
|
1
|
-
import type { ChatModelId, ChatPreloadField, ChatStatus, DescriptionEnhancedStage, EstimateOperation, LlmBackend, LlmPhase, LlmRole, LlmStatus, WebSearchProvider } from './enums';
|
|
2
|
-
/** Host-owned chat message */
|
|
3
|
-
interface ChatMessage {
|
|
4
|
-
role: LlmRole;
|
|
5
|
-
content: string;
|
|
6
|
-
/** Turn image URLs */
|
|
7
|
-
images?: string[];
|
|
8
|
-
/** Turn audio URLs */
|
|
9
|
-
audio?: string[];
|
|
10
|
-
}
|
|
11
|
-
/** JSON-safe tool value */
|
|
12
|
-
type ChatToolValue = string | number | boolean | null | ChatToolValue[] | {
|
|
13
|
-
[key: string]: ChatToolValue;
|
|
14
|
-
};
|
|
15
|
-
/** Tool parameter JSON schema */
|
|
16
|
-
interface ChatToolSchema {
|
|
17
|
-
type?: `object` | `array` | `string` | `number` | `integer` | `boolean` | `null`;
|
|
18
|
-
description?: string;
|
|
19
|
-
properties?: Record<string, ChatToolSchema>;
|
|
20
|
-
required?: string[];
|
|
21
|
-
items?: ChatToolSchema;
|
|
22
|
-
enum?: string[];
|
|
23
|
-
}
|
|
24
|
-
/** Host-run tool */
|
|
25
|
-
interface ChatTool {
|
|
26
|
-
/** Unique tool name */
|
|
27
|
-
name: string;
|
|
28
|
-
/** What the tool does */
|
|
29
|
-
description?: string;
|
|
30
|
-
parameters?: ChatToolSchema;
|
|
31
|
-
execute: (args: Record<string, ChatToolValue>) => ChatToolValue | Promise<ChatToolValue>;
|
|
32
|
-
}
|
|
33
|
-
/** Parsed tool call */
|
|
34
|
-
interface ChatToolCall {
|
|
35
|
-
id: number;
|
|
36
|
-
name: string;
|
|
37
|
-
arguments: Record<string, ChatToolValue>;
|
|
38
|
-
}
|
|
39
|
-
/** Finished tool result */
|
|
40
|
-
interface ChatToolResult extends ChatToolCall {
|
|
41
|
-
result?: ChatToolValue;
|
|
42
|
-
error?: string;
|
|
43
|
-
}
|
|
44
|
-
/** Websearch provider settings */
|
|
45
|
-
interface WebSearchConfig {
|
|
46
|
-
provider?: WebSearchProvider;
|
|
47
|
-
/** Wikipedia language code */
|
|
48
|
-
language?: string;
|
|
49
|
-
/** Provider result count */
|
|
50
|
-
limit?: number;
|
|
51
|
-
/** Characters kept per snippet */
|
|
52
|
-
snippetLength?: number;
|
|
53
|
-
/** Request budget in milliseconds */
|
|
54
|
-
timeout?: number;
|
|
55
|
-
}
|
|
56
|
-
/** Websearch result hit */
|
|
57
|
-
interface WebSearchResult {
|
|
58
|
-
title: string;
|
|
59
|
-
url: string;
|
|
60
|
-
snippet: string;
|
|
61
|
-
}
|
|
62
|
-
/** Resolved websearch settings */
|
|
63
|
-
interface WebSearchSettings {
|
|
64
|
-
provider: WebSearchProvider;
|
|
65
|
-
language: string;
|
|
66
|
-
limit: number;
|
|
67
|
-
snippetLength: number;
|
|
68
|
-
timeout: number;
|
|
69
|
-
}
|
|
70
|
-
/** Fiat and metal rates */
|
|
71
|
-
interface FiatSnapshot {
|
|
72
|
-
/** Local fetch time, milliseconds */
|
|
73
|
-
fetchedAt: number;
|
|
74
|
-
/** Feed timestamp, milliseconds */
|
|
75
|
-
sourceAt: number;
|
|
76
|
-
rates: Record<string, number>;
|
|
77
|
-
yesterday: Record<string, number>;
|
|
78
|
-
}
|
|
79
|
-
/** Crypto prices in EUR */
|
|
80
|
-
interface CryptoSnapshot {
|
|
81
|
-
fetchedAt: number;
|
|
82
|
-
sourceAt: number;
|
|
83
|
-
prices: Record<string, number>;
|
|
84
|
-
yesterday: Record<string, number>;
|
|
85
|
-
}
|
|
86
|
-
/** Cached price sections */
|
|
87
|
-
interface PriceSnapshot {
|
|
88
|
-
fiat?: FiatSnapshot;
|
|
89
|
-
crypto?: CryptoSnapshot;
|
|
90
|
-
}
|
|
91
|
-
/** Required price sections */
|
|
92
|
-
interface PriceSections {
|
|
93
|
-
fiat: boolean;
|
|
94
|
-
crypto: boolean;
|
|
95
|
-
}
|
|
96
|
-
/** Currency conversion result */
|
|
97
|
-
interface CurrencyResult {
|
|
98
|
-
from: string;
|
|
99
|
-
to: string;
|
|
100
|
-
amount: number;
|
|
101
|
-
rate: number;
|
|
102
|
-
previousRate?: number;
|
|
103
|
-
change?: number;
|
|
104
|
-
changePercent?: number;
|
|
105
|
-
result: number;
|
|
106
|
-
updatedAt: string;
|
|
107
|
-
stale: boolean;
|
|
108
|
-
}
|
|
109
|
-
/** One evaluated arithmetic expression */
|
|
110
|
-
interface CalculationResult {
|
|
111
|
-
/** Normalized expression that was evaluated */
|
|
112
|
-
expression: string;
|
|
113
|
-
result: number;
|
|
114
|
-
}
|
|
115
|
-
/** Wikipedia search page */
|
|
116
|
-
interface WikipediaPage {
|
|
117
|
-
key?: string;
|
|
118
|
-
title?: string;
|
|
119
|
-
description?: string;
|
|
120
|
-
excerpt?: string;
|
|
121
|
-
}
|
|
122
|
-
/** One Wikipedia search response */
|
|
123
|
-
interface WikipediaResponse {
|
|
124
|
-
pages?: WikipediaPage[];
|
|
125
|
-
}
|
|
126
|
-
/** DuckDuckGo topic group */
|
|
127
|
-
interface DuckDuckGoTopic {
|
|
128
|
-
FirstURL?: string;
|
|
129
|
-
Text?: string;
|
|
130
|
-
Topics?: DuckDuckGoTopic[];
|
|
131
|
-
}
|
|
132
|
-
/** One DuckDuckGo instant answer response */
|
|
133
|
-
interface DuckDuckGoResponse {
|
|
134
|
-
Heading?: string;
|
|
135
|
-
AbstractText?: string;
|
|
136
|
-
AbstractURL?: string;
|
|
137
|
-
Results?: DuckDuckGoTopic[];
|
|
138
|
-
RelatedTopics?: DuckDuckGoTopic[];
|
|
139
|
-
}
|
|
140
|
-
/** Crypto price row */
|
|
141
|
-
interface PriceCoin {
|
|
142
|
-
/** Price in EUR per unit */
|
|
143
|
-
pr?: number;
|
|
144
|
-
/** Price 24 hours ago */
|
|
145
|
-
yst?: number;
|
|
146
|
-
}
|
|
147
|
-
/** Validated CoinExams feed */
|
|
148
|
-
interface PriceFeed {
|
|
149
|
-
rates?: {
|
|
150
|
-
/** Fiat feed timestamp */
|
|
151
|
-
date?: number;
|
|
152
|
-
/** Symbol units per EUR */
|
|
153
|
-
current?: Record<string, number>;
|
|
154
|
-
/** Rates 24 hours ago */
|
|
155
|
-
yesterday?: Record<string, number>;
|
|
156
|
-
};
|
|
157
|
-
coins?: Record<string, PriceCoin>;
|
|
158
|
-
/** Crypto feed timestamp */
|
|
159
|
-
date?: number;
|
|
160
|
-
}
|
|
161
|
-
/** One on-device model */
|
|
162
|
-
interface ChatModel {
|
|
163
|
-
/** Stable catalog id */
|
|
164
|
-
id: ChatModelId;
|
|
165
|
-
/** Model reasoning support */
|
|
166
|
-
reasoning: boolean;
|
|
167
|
-
/** wllama (CPU) artifact */
|
|
168
|
-
cpu?: {
|
|
169
|
-
repo: string;
|
|
170
|
-
file: string;
|
|
171
|
-
/** Optional CPU vision projector */
|
|
172
|
-
mmproj?: {
|
|
173
|
-
/** Projector repository override */
|
|
174
|
-
repo?: string;
|
|
175
|
-
file: string;
|
|
176
|
-
/** Projector audio support */
|
|
177
|
-
audio?: boolean;
|
|
178
|
-
};
|
|
179
|
-
};
|
|
180
|
-
/** LiteRT-LM (WebGPU) artifact */
|
|
181
|
-
litert?: {
|
|
182
|
-
repo: string;
|
|
183
|
-
/** Model repository file name */
|
|
184
|
-
file: string;
|
|
185
|
-
/** Whether the build accepts images */
|
|
186
|
-
vision: boolean;
|
|
187
|
-
/** Whether the build accepts audio */
|
|
188
|
-
audio: boolean;
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
/** Generation budget settings */
|
|
192
|
-
interface LlmLimits {
|
|
193
|
-
/** Max answer tokens */
|
|
194
|
-
maxReplyTokens: number;
|
|
195
|
-
/** Max reasoning tokens */
|
|
196
|
-
maxThinkingTokens: number;
|
|
197
|
-
/** Reasoning output budget */
|
|
198
|
-
maxReasoningTokens: number;
|
|
199
|
-
/** Max prompt images */
|
|
200
|
-
maxImages: number;
|
|
201
|
-
/** Vision tokens per image */
|
|
202
|
-
imageTokens: number;
|
|
203
|
-
/** Max prompt audio clips */
|
|
204
|
-
maxAudio: number;
|
|
205
|
-
/** Max characters kept per message */
|
|
206
|
-
maxContentLength: number;
|
|
207
|
-
/** Max prompt characters */
|
|
208
|
-
promptCharBudget: number;
|
|
209
|
-
/** Max CPU threads */
|
|
210
|
-
maxThreads: number;
|
|
211
|
-
/** GPU busy share */
|
|
212
|
-
gpuShare: number;
|
|
213
|
-
}
|
|
214
|
-
/** Reported model and request state */
|
|
215
|
-
interface ChatStatusSnapshot {
|
|
216
|
-
/** Device-specific model build */
|
|
217
|
-
model?: ChatModelId;
|
|
218
|
-
/** Derived engine availability */
|
|
219
|
-
availability: ChatStatus;
|
|
220
|
-
status: LlmStatus;
|
|
221
|
-
backend: LlmBackend;
|
|
222
|
-
/** Model image support */
|
|
223
|
-
supportsImages: boolean;
|
|
224
|
-
/** Model audio support */
|
|
225
|
-
supportsAudio: boolean;
|
|
226
|
-
ready: boolean;
|
|
227
|
-
loading: boolean;
|
|
228
|
-
/** Reply streaming flag */
|
|
229
|
-
requesting: boolean;
|
|
230
|
-
phase: LlmPhase;
|
|
231
|
-
/** Download or load progress, 0..100 */
|
|
232
|
-
percent: number;
|
|
233
|
-
/** Last request error */
|
|
234
|
-
error?: string;
|
|
235
|
-
}
|
|
236
|
-
/** Chat request callback */
|
|
237
|
-
interface ChatInput {
|
|
238
|
-
/** Model that answers */
|
|
239
|
-
model?: ChatModelId;
|
|
240
|
-
/** Complete chat prompt */
|
|
241
|
-
messages: ChatMessage[];
|
|
242
|
-
/** Budget overrides */
|
|
243
|
-
limits?: Partial<LlmLimits>;
|
|
244
|
-
/** Reasoning option, off */
|
|
245
|
-
reasoning?: boolean;
|
|
246
|
-
/** Logging option, off */
|
|
247
|
-
logging?: boolean;
|
|
248
|
-
/** Streamed reasoning text */
|
|
249
|
-
onThinking?: (text: string) => void;
|
|
250
|
-
/** Streamed reply text */
|
|
251
|
-
onResponse: (text: string) => void;
|
|
252
|
-
/** Generation speed callback */
|
|
253
|
-
onSpeed?: (tokensPerSecond: number) => void;
|
|
254
|
-
/** Prompt processing speed callback */
|
|
255
|
-
onPromptSpeed?: (tokensPerSecond: number) => void;
|
|
256
|
-
/** Status change callback */
|
|
257
|
-
onStatus?: (snapshot: ChatStatusSnapshot) => void;
|
|
258
|
-
}
|
|
259
|
-
/** Model preload request */
|
|
260
|
-
type ChatPreloadInput = Pick<ChatInput, ChatPreloadField>;
|
|
261
|
-
/** Stop request or model */
|
|
262
|
-
type CancelChat = () => void;
|
|
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 */
|
|
353
|
-
interface ImageDescription {
|
|
354
|
-
/** Vision description */
|
|
355
|
-
descriptionEN: string;
|
|
356
|
-
/** Description translation */
|
|
357
|
-
description: string;
|
|
358
|
-
/** Description duration */
|
|
359
|
-
durationMs: number;
|
|
360
|
-
}
|
|
361
|
-
/** @deprecated to be removed after Nov 2027 */
|
|
362
|
-
interface DescribeImagesInput {
|
|
363
|
-
/** Target description language */
|
|
364
|
-
targetLanguage: string;
|
|
365
|
-
/** Ordered image URLs */
|
|
366
|
-
images: string[];
|
|
367
|
-
/** Stop batch, keep finished */
|
|
368
|
-
signal?: AbortSignal;
|
|
369
|
-
/** Description progress callback */
|
|
370
|
-
currentIndex?: (index: number, descriptionEN?: string, description?: string, durationMs?: number) => void;
|
|
371
|
-
/** Image speed callback */
|
|
372
|
-
onSpeed?: (index: number, tokensPerSecond: number) => void;
|
|
373
|
-
/** Image text callback */
|
|
374
|
-
onText?: (index: number, text: string, stage: `describe` | `translate`) => void;
|
|
375
|
-
/** Budget overrides */
|
|
376
|
-
limits?: Partial<LlmLimits>;
|
|
377
|
-
/** Logging option, off */
|
|
378
|
-
logging?: boolean;
|
|
379
|
-
/** Status change callback */
|
|
380
|
-
onStatus?: (snapshot: ChatStatusSnapshot) => void;
|
|
381
|
-
/** Additional rules */
|
|
382
|
-
additionalRules?: string;
|
|
383
|
-
}
|
|
384
|
-
/** @deprecated to be removed after Nov 2027 */
|
|
385
|
-
interface DescribeTranslatedInput {
|
|
386
|
-
/** Ordered English descriptions */
|
|
387
|
-
descriptions: string[];
|
|
388
|
-
/** Target translation language */
|
|
389
|
-
targetLanguage: string;
|
|
390
|
-
/** Stop batch, keep finished */
|
|
391
|
-
signal?: AbortSignal;
|
|
392
|
-
/** Translation progress callback */
|
|
393
|
-
currentIndex?: (index: number, descriptionEN?: string, description?: string) => void;
|
|
394
|
-
/** Translation speed callback */
|
|
395
|
-
onSpeed?: (index: number, tokensPerSecond: number) => void;
|
|
396
|
-
/** Translation text callback */
|
|
397
|
-
onText?: (index: number, text: string, stage: `translate`) => void;
|
|
398
|
-
/** Budget overrides */
|
|
399
|
-
limits?: Partial<LlmLimits>;
|
|
400
|
-
/** Logging option, off */
|
|
401
|
-
logging?: boolean;
|
|
402
|
-
/** Status change callback */
|
|
403
|
-
onStatus?: (snapshot: ChatStatusSnapshot) => void;
|
|
404
|
-
}
|
|
405
|
-
/** CPU wasm assets */
|
|
406
|
-
interface WllamaAssets {
|
|
407
|
-
/** wllama wasm URL */
|
|
408
|
-
wasm: string;
|
|
409
|
-
/** Compat wasm URL */
|
|
410
|
-
compatWasm: string;
|
|
411
|
-
/** Compat worker URL */
|
|
412
|
-
compatWorker: string;
|
|
413
|
-
}
|
|
414
|
-
/** GPU wasm assets */
|
|
415
|
-
interface LitertAssets {
|
|
416
|
-
/** LiteRT glue URL */
|
|
417
|
-
script: string;
|
|
418
|
-
/** LiteRT wasm URL */
|
|
419
|
-
wasm: string;
|
|
420
|
-
}
|
|
421
|
-
/** WebGPU navigator type */
|
|
422
|
-
interface GpuNavigator extends Navigator {
|
|
423
|
-
gpu?: {
|
|
424
|
-
/** Request WebGPU adapter */
|
|
425
|
-
requestAdapter: (options?: {
|
|
426
|
-
powerPreference?: `low-power` | `high-performance`;
|
|
427
|
-
}) => Promise<unknown>;
|
|
428
|
-
};
|
|
429
|
-
}
|
|
430
|
-
/** Minimal WebGPU buffer */
|
|
431
|
-
interface GpuBuffer {
|
|
432
|
-
/** Map buffer after work */
|
|
433
|
-
mapAsync: (...args: unknown[]) => Promise<void>;
|
|
434
|
-
}
|
|
435
|
-
/** Minimal WebGPU device */
|
|
436
|
-
interface GpuDevice {
|
|
437
|
-
/** Create engine buffer */
|
|
438
|
-
createBuffer?: (...args: unknown[]) => GpuBuffer;
|
|
439
|
-
/** Release device resources */
|
|
440
|
-
destroy?: () => void;
|
|
441
|
-
}
|
|
442
|
-
/** Reset wasm fields */
|
|
443
|
-
interface GpuWasm {
|
|
444
|
-
preinitializedWebGPUDevice?: GpuDevice;
|
|
445
|
-
WebGPU?: {
|
|
446
|
-
preinitializedDeviceId?: number;
|
|
447
|
-
};
|
|
448
|
-
}
|
|
449
|
-
/** GPU throttle state */
|
|
450
|
-
interface GpuThrottleParams {
|
|
451
|
-
device: GpuDevice;
|
|
452
|
-
/** Rest after one GPU readback */
|
|
453
|
-
pace: () => Promise<void>;
|
|
454
|
-
}
|
|
455
|
-
/** Mobile detection fields */
|
|
456
|
-
type MobileNavigator = Pick<Navigator, `userAgent` | `maxTouchPoints`> & {
|
|
457
|
-
/** Chromium mobile hint */
|
|
458
|
-
userAgentData?: {
|
|
459
|
-
mobile?: boolean;
|
|
460
|
-
};
|
|
461
|
-
};
|
|
462
|
-
/** Status snapshot state */
|
|
463
|
-
interface ChatState {
|
|
464
|
-
/** Reply streaming flag */
|
|
465
|
-
requesting: boolean;
|
|
466
|
-
phase: LlmPhase;
|
|
467
|
-
/** Download or load progress, 0..100 */
|
|
468
|
-
percent: number;
|
|
469
|
-
/** Last request error */
|
|
470
|
-
error?: string;
|
|
471
|
-
}
|
|
472
|
-
/** One live chat request */
|
|
473
|
-
interface ActiveCall extends ChatState {
|
|
474
|
-
token: number;
|
|
475
|
-
input: ChatInput;
|
|
476
|
-
controller: AbortController;
|
|
477
|
-
cancelled: boolean;
|
|
478
|
-
/** Model resolved for this call */
|
|
479
|
-
model?: ChatModelId;
|
|
480
|
-
}
|
|
481
|
-
/** Test engine overrides */
|
|
482
|
-
interface RuntimeDeps {
|
|
483
|
-
engines?: {
|
|
484
|
-
cpu?: LlmEngine;
|
|
485
|
-
litert?: LlmEngine;
|
|
486
|
-
};
|
|
487
|
-
backend?: LlmBackend;
|
|
488
|
-
/** Device class override, tests only */
|
|
489
|
-
mobile?: () => boolean;
|
|
490
|
-
}
|
|
491
|
-
/** One model load request */
|
|
492
|
-
interface RuntimeLoadParams {
|
|
493
|
-
model: ChatModel;
|
|
494
|
-
limits: LlmLimits;
|
|
495
|
-
assets?: Partial<WllamaAssets>;
|
|
496
|
-
/** Engine logging flag */
|
|
497
|
-
logging?: boolean;
|
|
498
|
-
/** Stop awaiting shared load */
|
|
499
|
-
signal?: AbortSignal;
|
|
500
|
-
onProgress: (progress: number, phase: LlmPhase) => void;
|
|
501
|
-
}
|
|
502
|
-
/** Waiting load caller */
|
|
503
|
-
interface RuntimeLoadWaiter {
|
|
504
|
-
/** Report caller progress */
|
|
505
|
-
report: RuntimeLoadParams[`onProgress`];
|
|
506
|
-
/** Resolve waiting caller */
|
|
507
|
-
settle: (loaded: boolean) => void;
|
|
508
|
-
}
|
|
509
|
-
/** Stored model file bytes */
|
|
510
|
-
interface StoredPart {
|
|
511
|
-
/** Bytes already stored */
|
|
512
|
-
size: number;
|
|
513
|
-
/** File size, zero unknown */
|
|
514
|
-
total: number;
|
|
515
|
-
/** Stored bytes entity tag */
|
|
516
|
-
etag: string;
|
|
517
|
-
}
|
|
518
|
-
/** Model part file */
|
|
519
|
-
interface StoredFilePart {
|
|
520
|
-
/** Part byte offset */
|
|
521
|
-
start: number;
|
|
522
|
-
/** Bytes stored in the part */
|
|
523
|
-
size: number;
|
|
524
|
-
}
|
|
525
|
-
/** Stored model file */
|
|
526
|
-
interface StoredModel extends StoredPart {
|
|
527
|
-
/** Stored file snapshot */
|
|
528
|
-
file: Blob;
|
|
529
|
-
/** Complete file flag */
|
|
530
|
-
complete: boolean;
|
|
531
|
-
}
|
|
532
|
-
/** Stored download metadata */
|
|
533
|
-
interface StoredModelMeta {
|
|
534
|
-
total: number;
|
|
535
|
-
etag: string;
|
|
536
|
-
complete: boolean;
|
|
537
|
-
}
|
|
538
|
-
/** Stored part continuation */
|
|
539
|
-
interface ResumePlan {
|
|
540
|
-
/** Response start byte */
|
|
541
|
-
start: number;
|
|
542
|
-
/** File size, zero unknown */
|
|
543
|
-
total: number;
|
|
544
|
-
etag: string;
|
|
545
|
-
}
|
|
546
|
-
/** Model download into store */
|
|
547
|
-
interface StoreDownloadParams {
|
|
548
|
-
url: string;
|
|
549
|
-
/** Stop download, keep bytes */
|
|
550
|
-
signal?: AbortSignal;
|
|
551
|
-
onProgress: StartLlmParams[`onProgress`];
|
|
552
|
-
}
|
|
553
|
-
/** Engine resumable file store */
|
|
554
|
-
interface ModelStore {
|
|
555
|
-
/** Stored model file info */
|
|
556
|
-
stored: (url: string) => Promise<StoredModel | undefined>;
|
|
557
|
-
/** Resume model file download */
|
|
558
|
-
download: (params: StoreDownloadParams) => Promise<StoredModel | undefined>;
|
|
559
|
-
/** Delete model file */
|
|
560
|
-
remove: (url: string) => Promise<void>;
|
|
561
|
-
/** Delete entire store */
|
|
562
|
-
purge: () => Promise<void>;
|
|
563
|
-
}
|
|
564
|
-
/** One generation request */
|
|
565
|
-
interface RuntimeChatParams {
|
|
566
|
-
/** Resolved answer model */
|
|
567
|
-
model?: ChatModelId;
|
|
568
|
-
messages: ChatMessage[];
|
|
569
|
-
limits: LlmLimits;
|
|
570
|
-
reasoning: boolean;
|
|
571
|
-
/** Repetition penalty */
|
|
572
|
-
repeatPenalty?: number;
|
|
573
|
-
/** Sampling temperature */
|
|
574
|
-
temperature?: number;
|
|
575
|
-
/** Engine logging flag */
|
|
576
|
-
logging?: boolean;
|
|
577
|
-
onReason: (text: string) => void;
|
|
578
|
-
onText: (text: string) => void;
|
|
579
|
-
/** Generation speed */
|
|
580
|
-
onSpeed?: (tokensPerSecond: number) => void;
|
|
581
|
-
/** Prompt processing speed */
|
|
582
|
-
onPromptSpeed?: (tokensPerSecond: number) => void;
|
|
583
|
-
signal?: AbortSignal;
|
|
584
|
-
}
|
|
585
|
-
/** Shared on-device runtime */
|
|
586
|
-
interface Runtime {
|
|
587
|
-
/** Load or join model */
|
|
588
|
-
load: (params: RuntimeLoadParams) => Promise<boolean>;
|
|
589
|
-
chat: (params: RuntimeChatParams) => Promise<string | undefined>;
|
|
590
|
-
/** Release one or all models */
|
|
591
|
-
unload: (model?: ChatModelId) => Promise<void>;
|
|
592
|
-
/** Release and delete caches */
|
|
593
|
-
clear: () => Promise<void>;
|
|
594
|
-
/** Model loaded check */
|
|
595
|
-
ready: (model?: ChatModelId) => boolean;
|
|
596
|
-
/** Model loading check */
|
|
597
|
-
loading: (model?: ChatModelId) => boolean;
|
|
598
|
-
/** Model load status */
|
|
599
|
-
status: (model?: ChatModelId) => LlmStatus;
|
|
600
|
-
/** Model backend */
|
|
601
|
-
backend: (model?: ChatModelId) => LlmBackend;
|
|
602
|
-
/** Latest model load error */
|
|
603
|
-
error: (model?: ChatModelId) => string | undefined;
|
|
604
|
-
/** Last active model */
|
|
605
|
-
model: () => ChatModel | undefined;
|
|
606
|
-
}
|
|
607
|
-
/** Single chat generation params */
|
|
608
|
-
interface EngineChatParams {
|
|
609
|
-
messages: ChatMessage[];
|
|
610
|
-
limits: LlmLimits;
|
|
611
|
-
/** Opt-in reasoning preference */
|
|
612
|
-
reasoning: boolean;
|
|
613
|
-
/** Repetition penalty */
|
|
614
|
-
repeatPenalty?: number;
|
|
615
|
-
/** Sampling temperature */
|
|
616
|
-
temperature?: number;
|
|
617
|
-
/** Engine logging flag */
|
|
618
|
-
logging?: boolean;
|
|
619
|
-
/** Streamed reasoning delta */
|
|
620
|
-
onReason: (text: string) => void;
|
|
621
|
-
/** Streamed reply delta */
|
|
622
|
-
onText: (text: string) => void;
|
|
623
|
-
/** Generation speed */
|
|
624
|
-
onSpeed?: (tokensPerSecond: number) => void;
|
|
625
|
-
/** Prompt processing speed */
|
|
626
|
-
onPromptSpeed?: (tokensPerSecond: number) => void;
|
|
627
|
-
signal?: AbortSignal;
|
|
628
|
-
}
|
|
629
|
-
/** Params of the engine startLLM */
|
|
630
|
-
interface StartLlmParams {
|
|
631
|
-
model: ChatModel;
|
|
632
|
-
/** Engine load budgets */
|
|
633
|
-
limits: LlmLimits;
|
|
634
|
-
/** Download progress callback */
|
|
635
|
-
onProgress: (progress: number, phase?: LlmPhase) => void;
|
|
636
|
-
/** Cancel download or load */
|
|
637
|
-
signal?: AbortSignal;
|
|
638
|
-
/** Engine logging flag */
|
|
639
|
-
logging?: boolean;
|
|
640
|
-
/** CPU engine asset override */
|
|
641
|
-
assets?: Partial<WllamaAssets>;
|
|
642
|
-
}
|
|
643
|
-
/** Engine start result */
|
|
644
|
-
interface LlmRuntime {
|
|
645
|
-
/** Model this runtime serves */
|
|
646
|
-
model: ChatModel;
|
|
647
|
-
/** Backend that accepted the model */
|
|
648
|
-
backend: LlmBackend;
|
|
649
|
-
/** Requested context window */
|
|
650
|
-
contextSize: number;
|
|
651
|
-
/** Stream reply text */
|
|
652
|
-
chat: (params: EngineChatParams) => Promise<string | undefined>;
|
|
653
|
-
/** Release model, keep cache */
|
|
654
|
-
unload: () => Promise<void>;
|
|
655
|
-
}
|
|
656
|
-
/** Engine-backed model runner */
|
|
657
|
-
interface LlmEngine {
|
|
658
|
-
backend: LlmBackend;
|
|
659
|
-
/** Load model runtime */
|
|
660
|
-
startLLM: (params: StartLlmParams) => Promise<LlmRuntime>;
|
|
661
|
-
/** Model files stored check */
|
|
662
|
-
cached: (model: ChatModel) => Promise<boolean>;
|
|
663
|
-
/** Delete engine artifacts */
|
|
664
|
-
purge: () => Promise<void>;
|
|
665
|
-
}
|
|
666
|
-
/** User turn content part */
|
|
667
|
-
type EngineContentPart = {
|
|
668
|
-
type: `text`;
|
|
669
|
-
text: string;
|
|
670
|
-
} | {
|
|
671
|
-
type: `image`;
|
|
672
|
-
url: string;
|
|
673
|
-
} | {
|
|
674
|
-
type: `audio`;
|
|
675
|
-
url: string;
|
|
676
|
-
};
|
|
677
|
-
/** One wllama content segment */
|
|
678
|
-
type WllamaContentPart = {
|
|
679
|
-
type: `text`;
|
|
680
|
-
text: string;
|
|
681
|
-
} | {
|
|
682
|
-
type: `image`;
|
|
683
|
-
data: ArrayBuffer;
|
|
684
|
-
} | {
|
|
685
|
-
type: `audio`;
|
|
686
|
-
data: ArrayBuffer;
|
|
687
|
-
};
|
|
688
|
-
/** One wllama chat turn */
|
|
689
|
-
type WllamaMessage = {
|
|
690
|
-
role: `system`;
|
|
691
|
-
content: string;
|
|
692
|
-
} | {
|
|
693
|
-
role: `user`;
|
|
694
|
-
content: string | WllamaContentPart[];
|
|
695
|
-
} | {
|
|
696
|
-
role: `assistant`;
|
|
697
|
-
content: string;
|
|
698
|
-
};
|
|
699
|
-
/** OpenAI-style chat message */
|
|
700
|
-
type EngineMessage = {
|
|
701
|
-
role: `system`;
|
|
702
|
-
content: string;
|
|
703
|
-
} | {
|
|
704
|
-
role: `user`;
|
|
705
|
-
content: string | EngineContentPart[];
|
|
706
|
-
} | {
|
|
707
|
-
role: `assistant`;
|
|
708
|
-
content: string;
|
|
709
|
-
};
|
|
710
|
-
/** One LiteRT-LM content segment */
|
|
711
|
-
type LitertContentPart = import('@litert-lm/core').ContentPart;
|
|
712
|
-
/** One LiteRT-LM chat turn */
|
|
713
|
-
type LitertMessage = import('@litert-lm/core').Message;
|
|
714
|
-
/** One LiteRT-LM engine */
|
|
715
|
-
type LitertEngine = import('@litert-lm/core').Engine;
|
|
716
|
-
/** The LiteRT-LM module namespace */
|
|
717
|
-
type LitertModule = typeof import('@litert-lm/core');
|
|
718
|
-
/** LiteRT engine settings */
|
|
719
|
-
type LitertSettings = import('@litert-lm/core').EngineSettings;
|
|
720
|
-
/** LiteRT settings params */
|
|
721
|
-
interface LitertSettingsParams {
|
|
722
|
-
/** Model with the artifact */
|
|
723
|
-
model: ChatModel;
|
|
724
|
-
/** Image budgets */
|
|
725
|
-
limits: LlmLimits;
|
|
726
|
-
/** Requested context window */
|
|
727
|
-
contextSize: number;
|
|
728
|
-
/** Model file stream */
|
|
729
|
-
source: ReadableStream<Uint8Array>;
|
|
730
|
-
/** Loaded LiteRT module */
|
|
731
|
-
mod: LitertModule;
|
|
732
|
-
}
|
|
733
|
-
/** Reused LiteRT conversation */
|
|
734
|
-
interface LitertSession {
|
|
735
|
-
/** Live LiteRT conversation */
|
|
736
|
-
conversation?: import('@litert-lm/core').Conversation;
|
|
737
|
-
/** Sent conversation turns */
|
|
738
|
-
sent: EngineMessage[];
|
|
739
|
-
/** Conversation reasoning flag */
|
|
740
|
-
reasoning: boolean;
|
|
741
|
-
/** Conversation output budget */
|
|
742
|
-
maxTokens: number;
|
|
743
|
-
}
|
|
744
|
-
/** LiteRT chat params */
|
|
745
|
-
interface LitertChatParams {
|
|
746
|
-
engine: LitertEngine;
|
|
747
|
-
model: ChatModel;
|
|
748
|
-
mod: LitertModule;
|
|
749
|
-
params: EngineChatParams;
|
|
750
|
-
session: LitertSession;
|
|
751
|
-
}
|
|
752
|
-
/** Params of one LiteRT-LM stream */
|
|
753
|
-
interface StreamLitertParams {
|
|
754
|
-
engine: LitertEngine;
|
|
755
|
-
mod: LitertModule;
|
|
756
|
-
params: EngineChatParams;
|
|
757
|
-
messages: EngineMessage[];
|
|
758
|
-
session: LitertSession;
|
|
759
|
-
}
|
|
760
|
-
/** Streamed reasoning delta */
|
|
761
|
-
interface EngineDelta {
|
|
762
|
-
content?: string;
|
|
763
|
-
reasoning?: string;
|
|
764
|
-
reasoning_content?: string;
|
|
765
|
-
}
|
|
766
|
-
/** Engine stream timings */
|
|
767
|
-
interface EngineTimings {
|
|
768
|
-
/** Prompt tokens per second */
|
|
769
|
-
prompt_per_second?: number;
|
|
770
|
-
/** Prompt tokens evaluated */
|
|
771
|
-
prompt_n?: number;
|
|
772
|
-
}
|
|
773
|
-
/** Engine prefill progress */
|
|
774
|
-
interface EnginePromptProgress {
|
|
775
|
-
/** Prompt tokens total */
|
|
776
|
-
total?: number;
|
|
777
|
-
/** Processed prompt tokens */
|
|
778
|
-
processed?: number;
|
|
779
|
-
/** Prefill time, milliseconds */
|
|
780
|
-
time_ms?: number;
|
|
781
|
-
/** wllama total token field */
|
|
782
|
-
n_prompt_tokens?: number;
|
|
783
|
-
/** wllama processed token field */
|
|
784
|
-
n_prompt_tokens_processed?: number;
|
|
785
|
-
}
|
|
786
|
-
/** Engine stream chunk */
|
|
787
|
-
interface EngineChunk {
|
|
788
|
-
choices?: Array<{
|
|
789
|
-
finish_reason?: string;
|
|
790
|
-
delta?: EngineDelta;
|
|
791
|
-
}>;
|
|
792
|
-
timings?: EngineTimings;
|
|
793
|
-
prompt_progress?: EnginePromptProgress;
|
|
794
|
-
}
|
|
795
|
-
/** Params of one streamed reply */
|
|
796
|
-
interface StreamReplyParams {
|
|
797
|
-
model: ChatModel;
|
|
798
|
-
/** Streamed reasoning delta */
|
|
799
|
-
onReason: (text: string) => void;
|
|
800
|
-
/** Streamed reply delta */
|
|
801
|
-
onText: (text: string) => void;
|
|
802
|
-
/** Generation speed */
|
|
803
|
-
onSpeed?: (tokensPerSecond: number) => void;
|
|
804
|
-
/** Prompt processing speed */
|
|
805
|
-
onPromptSpeed?: (tokensPerSecond: number) => void;
|
|
806
|
-
/** Estimated prompt tokens */
|
|
807
|
-
promptTokens?: number;
|
|
808
|
-
/** Open engine stream */
|
|
809
|
-
start: () => Promise<AsyncIterable<unknown>>;
|
|
810
|
-
/** Generation stopped flag */
|
|
811
|
-
stopped: () => boolean;
|
|
812
|
-
/** Engine logging flag */
|
|
813
|
-
logging?: boolean;
|
|
814
|
-
/** First chunk timeout */
|
|
815
|
-
firstTimeoutMs?: number;
|
|
816
|
-
/** Budget between two chunks, milliseconds */
|
|
817
|
-
idleTimeoutMs?: number;
|
|
818
|
-
/** Slow stream callback */
|
|
819
|
-
onStall?: () => void;
|
|
820
|
-
}
|
|
821
|
-
/** Engine chat params */
|
|
822
|
-
interface EngineRunParams {
|
|
823
|
-
model: ChatModel;
|
|
824
|
-
params: EngineChatParams;
|
|
825
|
-
/** Open engine stream */
|
|
826
|
-
start: (messages: EngineMessage[]) => Promise<AsyncIterable<unknown>>;
|
|
827
|
-
/** Generation stopped flag */
|
|
828
|
-
stopped: () => boolean;
|
|
829
|
-
/** Slow stream callback */
|
|
830
|
-
onStall?: () => void;
|
|
831
|
-
}
|
|
832
|
-
/** Engine image pixel size */
|
|
833
|
-
interface ImageSize {
|
|
834
|
-
width: number;
|
|
835
|
-
height: number;
|
|
836
|
-
}
|
|
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, };
|