@degreesign/chat 1.7.0 → 1.7.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 +17 -7
- package/dist/browser/chat.min.mjs +1 -1
- package/dist/chat/chat.d.ts +12 -0
- package/dist/chat/service.d.ts +3 -0
- package/dist/chat.d.ts +5 -6
- package/dist/core/log.d.ts +3 -0
- package/dist/core/models.d.ts +26 -0
- package/dist/deprecated.d.ts +5 -4
- package/dist/describe/deprecated.d.ts +11 -0
- package/dist/describe/describe.d.ts +22 -0
- package/dist/describe/estimate.d.ts +13 -0
- package/dist/describe/prompts.d.ts +18 -0
- package/dist/describe.d.ts +10 -9
- package/dist/engines/engine.d.ts +7 -9
- package/dist/engines/images.d.ts +6 -6
- package/dist/engines/litert.d.ts +8 -9
- package/dist/engines/store.d.ts +2 -2
- package/dist/engines/wllama.d.ts +3 -3
- package/dist/index.d.ts +5 -5
- package/dist/node/chat.node.min.js +1 -1
- package/dist/node/chat.node.min.mjs +1 -1
- package/dist/service.d.ts +1 -2
- package/dist/tools/calculator.d.ts +4 -4
- package/dist/tools/currency.d.ts +4 -4
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/search.d.ts +4 -4
- package/dist/tools/text.d.ts +4 -3
- package/dist/types/enums.d.ts +80 -0
- package/dist/types/index.d.ts +837 -0
- package/package.json +1 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ChatModelId } from '../types/enums';
|
|
2
|
+
import type { DescribeImageInput, DescriptionEnhanced, DescriptionEnhancedInput, ImageTag, Runtime, TranslateTagsInput } from '../types';
|
|
3
|
+
declare const
|
|
4
|
+
/** Reply budget, about 100 words */
|
|
5
|
+
imageReplyTokens = 128,
|
|
6
|
+
/** Translation reply budget, doubled */
|
|
7
|
+
imageTranslateTokens: number,
|
|
8
|
+
/** Describer model, Q4 CPU build */
|
|
9
|
+
describeModelId = ChatModelId.qwen3_vl_2b_instruct,
|
|
10
|
+
/** Build image description over one runtime */
|
|
11
|
+
createDescribeImageOn: (service: Runtime) => (input: DescribeImageInput) => Promise<string>,
|
|
12
|
+
/** Build tag translation over one runtime */
|
|
13
|
+
createTranslateTagsOn: (service: Runtime) => (input: TranslateTagsInput) => Promise<ImageTag[]>,
|
|
14
|
+
/** Build text enhancement over one runtime */
|
|
15
|
+
createDescriptionEnhancedOn: (service: Runtime) => (input: DescriptionEnhancedInput) => Promise<DescriptionEnhanced>,
|
|
16
|
+
/** Describe one image in English */
|
|
17
|
+
describeImage: (input: DescribeImageInput) => Promise<string>,
|
|
18
|
+
/** Enhance one English description */
|
|
19
|
+
descriptionEnhanced: (input: DescriptionEnhancedInput) => Promise<DescriptionEnhanced>,
|
|
20
|
+
/** Translate stored tags */
|
|
21
|
+
translateTags: (input: TranslateTagsInput) => Promise<ImageTag[]>;
|
|
22
|
+
export { createDescribeImageOn, createDescriptionEnhancedOn, createTranslateTagsOn, describeImage, describeModelId, descriptionEnhanced, imageReplyTokens, imageTranslateTokens, translateTags, };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { EstimateOperation } from '../types/enums';
|
|
2
|
+
import type { EstimateReport } from '../types';
|
|
3
|
+
declare const
|
|
4
|
+
/** Build report of operations */
|
|
5
|
+
estimateReport: (operations: EstimateOperation[]) => EstimateReport,
|
|
6
|
+
/** Record one measured operation */
|
|
7
|
+
recordEstimate: ({ operation, seconds, }: {
|
|
8
|
+
operation: EstimateOperation;
|
|
9
|
+
seconds: number;
|
|
10
|
+
}) => void,
|
|
11
|
+
/** Clear measured estimates */
|
|
12
|
+
resetEstimates: () => void;
|
|
13
|
+
export { estimateReport, recordEstimate, resetEstimates };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
declare const
|
|
2
|
+
/** System message of the describer */
|
|
3
|
+
imageSystem: string,
|
|
4
|
+
/** Request for every image */
|
|
5
|
+
imageNote: string,
|
|
6
|
+
/** Nsfw flag tag word */
|
|
7
|
+
nsfwTag = "nsfw",
|
|
8
|
+
/** System message of the tagger */
|
|
9
|
+
tagSystem: (imageTags: number) => string,
|
|
10
|
+
/** System message of the tag translator */
|
|
11
|
+
tagTranslateSystem: (language: string) => string,
|
|
12
|
+
/** System message of the translator */
|
|
13
|
+
translateSystem: string,
|
|
14
|
+
/** Prompt preparing for translation */
|
|
15
|
+
translatePreMessage = "describe this image in English very accurately",
|
|
16
|
+
/** Prompt asking for one translation */
|
|
17
|
+
translatePrompt: (language: string) => string;
|
|
18
|
+
export { imageNote, imageSystem, nsfwTag, tagSystem, tagTranslateSystem, translateSystem, translatePreMessage, translatePrompt, };
|
package/dist/describe.d.ts
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { ChatModelId } from './enums';
|
|
2
2
|
import type { DescribeImageInput, DescriptionEnhanced, DescriptionEnhancedInput, ImageTag, Runtime, TranslateTagsInput } from './types';
|
|
3
|
+
declare const
|
|
3
4
|
/** Reply budget, about 100 words */
|
|
4
|
-
|
|
5
|
+
imageReplyTokens = 128,
|
|
5
6
|
/** Translation reply budget, doubled */
|
|
6
|
-
|
|
7
|
+
imageTranslateTokens: number,
|
|
7
8
|
/** Describer model, Q4 CPU build */
|
|
8
|
-
|
|
9
|
+
describeModelId = ChatModelId.qwen3_vl_2b_instruct,
|
|
9
10
|
/** Build image description over one runtime */
|
|
10
|
-
|
|
11
|
+
createDescribeImageOn: (service: Runtime) => (input: DescribeImageInput) => Promise<string>,
|
|
11
12
|
/** Build tag translation over one runtime */
|
|
12
|
-
|
|
13
|
+
createTranslateTagsOn: (service: Runtime) => (input: TranslateTagsInput) => Promise<ImageTag[]>,
|
|
13
14
|
/** Build text enhancement over one runtime */
|
|
14
|
-
|
|
15
|
+
createDescriptionEnhancedOn: (service: Runtime) => (input: DescriptionEnhancedInput) => Promise<DescriptionEnhanced>,
|
|
15
16
|
/** Describe one image in English */
|
|
16
|
-
|
|
17
|
+
describeImage: (input: DescribeImageInput) => Promise<string>,
|
|
17
18
|
/** Enhance one English description */
|
|
18
|
-
|
|
19
|
+
descriptionEnhanced: (input: DescriptionEnhancedInput) => Promise<DescriptionEnhanced>,
|
|
19
20
|
/** Translate stored tags */
|
|
20
|
-
|
|
21
|
+
translateTags: (input: TranslateTagsInput) => Promise<ImageTag[]>;
|
|
21
22
|
export { createDescribeImageOn, createDescriptionEnhancedOn, createTranslateTagsOn, describeImage, describeModelId, descriptionEnhanced, imageReplyTokens, imageTranslateTokens, translateTags, };
|
package/dist/engines/engine.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { ChatMessage, ChatModel, EngineMessage, EngineRunParams, LlmLimits, StreamReplyParams } from '../types';
|
|
2
|
+
declare const
|
|
2
3
|
/** Default engine budgets */
|
|
3
|
-
|
|
4
|
+
defaultLlmLimits: LlmLimits,
|
|
4
5
|
/** Merge budgets over backend defaults */
|
|
5
|
-
|
|
6
|
+
resolveLlmLimits: (overrides?: Partial<LlmLimits>, gpu?: boolean) => LlmLimits,
|
|
6
7
|
/** Sampling options for every stream */
|
|
7
|
-
|
|
8
|
+
replyOptions: (limits: LlmLimits, reasoning: boolean, temperature?: number) => {
|
|
8
9
|
stream: true;
|
|
9
10
|
temperature: number;
|
|
10
11
|
max_tokens: number;
|
|
11
|
-
}
|
|
12
|
-
declare const
|
|
12
|
+
},
|
|
13
13
|
/** Resolve one model file URL */
|
|
14
14
|
modelUrl: (repo: string, file: string) => string,
|
|
15
15
|
/** Declared download size or zero */
|
|
@@ -17,8 +17,7 @@ contentLength: (response: Response) => number,
|
|
|
17
17
|
/** Any turn carries an image */
|
|
18
18
|
hasImages: (messages: EngineMessage[]) => boolean,
|
|
19
19
|
/** Whether any turn carries audio */
|
|
20
|
-
hasAudio: (messages: EngineMessage[]) => boolean
|
|
21
|
-
declare const
|
|
20
|
+
hasAudio: (messages: EngineMessage[]) => boolean,
|
|
22
21
|
/** Map host messages to turns */
|
|
23
22
|
buildMessages: (messages: ChatMessage[], limits?: LlmLimits) => EngineMessage[],
|
|
24
23
|
/** Split reasoning markers from content */
|
|
@@ -30,8 +29,7 @@ declare const
|
|
|
30
29
|
/** Log chat call, text censored */
|
|
31
30
|
logChatCall: (model: ChatModel, messages: EngineMessage[]) => void,
|
|
32
31
|
/** Stream reply, undefined when stopped */
|
|
33
|
-
streamReply: ({ model, logging, onReason, onText, onSpeed, onPromptSpeed, promptTokens, start, stopped, firstTimeoutMs, idleTimeoutMs, onStall, }: StreamReplyParams) => Promise<string | undefined
|
|
34
|
-
declare const
|
|
32
|
+
streamReply: ({ model, logging, onReason, onText, onSpeed, onPromptSpeed, promptTokens, start, stopped, firstTimeoutMs, idleTimeoutMs, onStall, }: StreamReplyParams) => Promise<string | undefined>,
|
|
35
33
|
/** Build prompt, stream through engine */
|
|
36
34
|
runEngineChat: ({ model, params, start, stopped, onStall, }: EngineRunParams) => Promise<string | undefined>;
|
|
37
35
|
export { buildMessages, createThinkSplitter, logChatCall, runEngineChat, streamReply, replyOptions, defaultLlmLimits, resolveLlmLimits, hasImages, hasAudio, modelUrl, contentLength, };
|
package/dist/engines/images.d.ts
CHANGED
|
@@ -5,15 +5,15 @@ imageTokens = 128,
|
|
|
5
5
|
/** Pixels per vision token */
|
|
6
6
|
tokenCell = 32,
|
|
7
7
|
/** Tokens allowed above the target */
|
|
8
|
-
tokenSlack = 8
|
|
8
|
+
tokenSlack = 8,
|
|
9
9
|
/** Square size for WebGPU encoding */
|
|
10
|
-
|
|
10
|
+
gpuImageSize: ImageSize,
|
|
11
11
|
/** Decode URL into engine bytes */
|
|
12
|
-
|
|
12
|
+
contentBuffer: (url: string) => Promise<ArrayBuffer>,
|
|
13
13
|
/** Full-frame size near token target */
|
|
14
|
-
|
|
14
|
+
visionSize: (width: number, height: number, tokens?: number) => ImageSize,
|
|
15
15
|
/** Fit image to token grid */
|
|
16
|
-
|
|
16
|
+
resizeImageUrl: (url: string, size?: ImageSize, tokens?: number) => Promise<string>,
|
|
17
17
|
/** Fit image parts before engine */
|
|
18
|
-
|
|
18
|
+
resizeImages: (messages: EngineMessage[], size?: ImageSize, tokens?: number) => Promise<EngineMessage[]>;
|
|
19
19
|
export { gpuImageSize, imageTokens, tokenCell, tokenSlack, visionSize, contentBuffer, resizeImageUrl, resizeImages, };
|
package/dist/engines/litert.d.ts
CHANGED
|
@@ -9,20 +9,19 @@ gpuShare = 0.5,
|
|
|
9
9
|
maxRestMs = 500;
|
|
10
10
|
declare const
|
|
11
11
|
/** Rest owed for busy interval */
|
|
12
|
-
restFor: (busyMs: number, share?: number) => number
|
|
12
|
+
restFor: (busyMs: number, share?: number) => number,
|
|
13
13
|
/** WebGPU device resting after readback */
|
|
14
|
-
|
|
14
|
+
throttledDevice: ({ device, pace, }: GpuThrottleParams) => GpuDevice,
|
|
15
15
|
/** Drop device and wasm module */
|
|
16
|
-
|
|
16
|
+
releaseDevice: (mod: Awaited<ReturnType<typeof loadLitert>>) => void,
|
|
17
17
|
/** Cache one file per URL */
|
|
18
|
-
|
|
18
|
+
cacheModel: (url: string, cache: Cache, signal: AbortSignal | undefined, onProgress: StartLlmParams[`onProgress`]) => Promise<void>,
|
|
19
19
|
/** Map messages to LiteRT turns */
|
|
20
|
-
|
|
20
|
+
toLitertMessages: (messages: EngineMessage[], keepMedia?: boolean) => Promise<LitertMessage[]>,
|
|
21
21
|
/** Whether conversation holds incoming history */
|
|
22
|
-
|
|
22
|
+
continuesHistory: (sent: EngineMessage[], history: EngineMessage[]) => boolean,
|
|
23
23
|
/** Stream LiteRT reply as chunks */
|
|
24
|
-
|
|
24
|
+
streamLitert: ({ engine, mod, params, messages, session, }: StreamLitertParams) => AsyncGenerator<EngineChunk>,
|
|
25
25
|
/** Engine settings with vision budget */
|
|
26
|
-
|
|
27
|
-
declare const litertEngine: LlmEngine;
|
|
26
|
+
litertSettings: ({ model, limits, contextSize, source, mod, }: LitertSettingsParams) => LitertSettings, litertEngine: LlmEngine;
|
|
28
27
|
export { cacheModel, continuesHistory, gpuShare, litertEngine, litertSettings, maxRestMs, releaseDevice, restFor, streamLitert, throttledDevice, toLitertMessages, visionTokens, };
|
package/dist/engines/store.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ resumePlan: (response: Response, part: StoredPart) => ResumePlan | undefined,
|
|
|
7
7
|
/** Whether store failure disables storage */
|
|
8
8
|
isStoreError: (error: unknown) => boolean,
|
|
9
9
|
/** Whether storage quota is full */
|
|
10
|
-
isQuotaError: (error: unknown) => boolean
|
|
10
|
+
isQuotaError: (error: unknown) => boolean,
|
|
11
11
|
/** Create engine resumable file store */
|
|
12
|
-
|
|
12
|
+
createModelStore: (dirName: string) => ModelStore;
|
|
13
13
|
export { chainParts, createModelStore, isQuotaError, isStoreError, resumePlan, };
|
package/dist/engines/wllama.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { ChatModel, EngineMessage, LlmEngine, LlmRuntime, StartLlmParams, WllamaMessage } from '../types';
|
|
2
|
+
declare const
|
|
2
3
|
/** Image limits of one model */
|
|
3
|
-
|
|
4
|
+
visionLimits: (model: ChatModel) => {
|
|
4
5
|
image_min_tokens: number;
|
|
5
6
|
image_max_tokens: number;
|
|
6
7
|
} | {
|
|
7
8
|
image_min_tokens?: undefined;
|
|
8
9
|
image_max_tokens?: undefined;
|
|
9
|
-
}
|
|
10
|
-
declare const
|
|
10
|
+
},
|
|
11
11
|
/** CPU file names and URLs */
|
|
12
12
|
cpuFiles: (model: ChatModel) => Array<{
|
|
13
13
|
name: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { clearModelCache, createChat, preloadModel } from './chat';
|
|
2
|
-
export { describeImage, describeModelId, descriptionEnhanced, imageReplyTokens, translateTags, } from './describe';
|
|
3
|
-
export { describeImages, describeTranslated } from './deprecated';
|
|
4
|
-
export { gpuAdapter } from './models';
|
|
1
|
+
export { clearModelCache, createChat, preloadModel } from './chat/chat';
|
|
2
|
+
export { describeImage, describeModelId, descriptionEnhanced, imageReplyTokens, translateTags, } from './describe/describe';
|
|
3
|
+
export { describeImages, describeTranslated } from './describe/deprecated';
|
|
4
|
+
export { gpuAdapter } from './core/models';
|
|
5
5
|
export { builtinTools, calculateTool, currencyTool, webSearchTool, } from './tools';
|
|
6
|
-
export { LlmRole, ChatStatus, LlmStatus, LlmBackend, LlmPhase, EstimateOperation, DescriptionEnhancedStage, ChatPreloadField, ChatModelId, BuiltinTool, WebSearchProvider, } from './enums';
|
|
6
|
+
export { LlmRole, ChatStatus, LlmStatus, LlmBackend, LlmPhase, EstimateOperation, DescriptionEnhancedStage, ChatPreloadField, ChatModelId, BuiltinTool, WebSearchProvider, } from './types/enums';
|
|
7
7
|
export type { ChatMessage, LlmLimits, ChatStatusSnapshot, ChatInput, ChatPreloadInput, CancelChat, CallOptions, EstimateEntry, EstimateReport, DescribeImageInput, DescriptionEnhancedInput, DescriptionEnhanced, ImageTag, TranslateTagsInput, ImageDescription, DescribeImagesInput, DescribeTranslatedInput, WllamaAssets, ChatTool, ChatToolCall, ChatToolResult, ChatToolSchema, ChatToolValue, WebSearchConfig, WebSearchResult, } from './types';
|