@tryhamster/gerbil 1.7.0 → 1.9.0
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/browser/index.d.ts +8 -0
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js +10 -0
- 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-D7gfxZXW.d.mts → gerbil-Bc6-CoH7.d.mts} +24 -3
- package/dist/gerbil-Bc6-CoH7.d.mts.map +1 -0
- package/dist/gerbil-CJci0igh.mjs +4 -0
- package/dist/{gerbil-CJjj7BD_.mjs → gerbil-Cj2Yllj9.mjs} +48 -2
- package/dist/gerbil-Cj2Yllj9.mjs.map +1 -0
- package/dist/gpu/hooks.d.mts +8 -1
- package/dist/gpu/hooks.d.mts.map +1 -1
- package/dist/gpu/hooks.mjs +5 -3
- package/dist/gpu/hooks.mjs.map +1 -1
- package/dist/gpu/index.d.mts +2 -2
- package/dist/gpu/index.mjs +4 -4
- package/dist/{gpu-DOK8RgIN.mjs → gpu-C5Ez0lSl.mjs} +124 -24
- package/dist/gpu-C5Ez0lSl.mjs.map +1 -0
- package/dist/{index-HgdjgsLb.d.mts → index-BBAaLqdK.d.mts} +133 -28
- package/dist/index-BBAaLqdK.d.mts.map +1 -0
- package/dist/index.d.mts +3 -3
- package/dist/index.d.mts.map +1 -1
- 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-DaQJ2bie.mjs → mcp-IK-hR3S8.mjs} +3 -3
- package/dist/{mcp-DaQJ2bie.mjs.map → mcp-IK-hR3S8.mjs.map} +1 -1
- package/dist/{moonshine-stt-Teic6SbK.mjs → moonshine-stt-9wc6t11v.mjs} +340 -126
- package/dist/moonshine-stt-9wc6t11v.mjs.map +1 -0
- package/dist/moonshine-stt-B7rDn6Q9.mjs +4 -0
- package/dist/{one-liner-BnBYesLF.mjs → one-liner-CdA1YTku.mjs} +2 -2
- package/dist/{one-liner-BnBYesLF.mjs.map → one-liner-CdA1YTku.mjs.map} +1 -1
- package/dist/{repl-DMur1t4G.mjs → repl-Dk9UxWyt.mjs} +3 -3
- package/dist/skills/index.d.mts +5 -5
- package/dist/skills/index.mjs +3 -3
- package/dist/{skills-BfJI3GNK.mjs → skills-Dl7Yl7ui.mjs} +2 -2
- package/dist/{skills-BfJI3GNK.mjs.map → skills-Dl7Yl7ui.mjs.map} +1 -1
- package/dist/tune/index.d.mts.map +1 -1
- package/dist/tune/index.mjs +1 -1
- package/dist/{types-DW-OBuAC.d.mts → types-BzbBDoaP.d.mts} +9 -1
- package/dist/types-BzbBDoaP.d.mts.map +1 -0
- package/package.json +1 -1
- package/dist/gerbil-BKCknsZ6.mjs +0 -4
- package/dist/gerbil-CJjj7BD_.mjs.map +0 -1
- package/dist/gerbil-D7gfxZXW.d.mts.map +0 -1
- package/dist/gpu-DOK8RgIN.mjs.map +0 -1
- package/dist/index-HgdjgsLb.d.mts.map +0 -1
- package/dist/moonshine-stt-CrTu77ps.mjs +0 -4
- package/dist/moonshine-stt-Teic6SbK.mjs.map +0 -1
- package/dist/types-DW-OBuAC.d.mts.map +0 -1
package/dist/gpu/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { a as OuteSpeakerWord, c as buildOutePromptString, i as OuteSpeaker, l as loadOuteSpeaker, n as OuteSpeakOptions, o as OuteTTS, r as OuteSpeakResult, s as OuteTTSOptions, t as OuteDType } from "../outetts-CAL3_K3j.mjs";
|
|
2
|
-
import { $ as Gemma4VisionGridConfig, A as generateDacSpeechDecoderGraph, At as
|
|
3
|
-
export { AgentStep, AgentTool, ChatMessage, DEFAULT_MODELS, EmbedOptions, EncodeImageResult, Executor, GEMMA4_IMAGE_PROCESSOR, GPUDiagnosticResult, Gemma4VisionGraphInfo, Gemma4VisionGridConfig, Gemma4VisionPositionTensors, GenerateObjectOptions, GenerateObjectResult, GenerateOptions, GenerateResult, GraphDType, ImageProcessorConfig, IntegrityCheckEntry, IntegrityCheckResult, KVDType, KaniDType, KaniTTS, KaniTTSOptions, KvMode, LoadedKaniTTS, LoadedMoonshine, MOONSHINE_REMAINING_WORK, ModelArchConfig, ModelCapabilities, MoonshineEncoderExecutor, MoonshineSTT, MoonshineSTTOptions, OUTETTS_ASSETS, OUTETTS_PRESET_VOICES, ObjectSchema, ObjectValidator, OuteDType, OuteSpeakOptions, OuteSpeakResult, OuteSpeaker, OuteSpeakerWord, OuteTTS, OuteTTSOptions, ParlerSpeakOptions, ParlerSpeakResult, ParlerTTS, ParlerTTSOptions, PreprocessedImage, QWEN3_5_IMAGE_PROCESSOR, SamplingParams, SpeakOptions, SpeakResult, Tokenizer, TranscribeOptions, TranscribeResult, VisionExecutor, VisionGridConfig, VisionInputs, VisionPositionTensors, WebGPUEngine, WebGPUEngineOptions, audioTokensToCodes, audioTokensToDacCodes, buildGemma4PoolMatrix, buildGemma4PosEmbeds, buildGemma4RotaryCosSin, buildGemma4VisionPositionTensors, buildMRoPECosSin, buildMRoPEPositionIds, buildOutePromptString, buildPosEmbeds, buildPositionIds, buildRotaryCosSin, buildVisionPositionTensors, dacOutputLength, dequantizeGemma4VisionProjection, dequantizeMLXProjection, generateDacSpeechDecoderGraph, generateGemma4VisionGraph, generateKaniTtsGraph, generateMoonshineDecoderGraph, generateMoonshineEncoderGraph, generateNanoCodecDecoderGraph, generateOuteTtsBackboneGraph, generateQwen3_5VisionGraph, initGPU, loadKaniTTS, loadModel, loadMoonshine, loadOuteSpeaker, moonshineEncoderFrames, mropeFreqDims, parseKaniConfig, parseMoonshineConfig, parseOuteTtsConfig, patchGemma4VisionClips, preprocessImage, preprocessImageGemma4, quantizeKaniBackbone, resolveDefaultRepo, resolveGemma4VisionInfo, smartResize };
|
|
2
|
+
import { $ as Gemma4VisionGridConfig, A as generateDacSpeechDecoderGraph, At as AdapterSource, B as generateNanoCodecDecoderGraph, Bt as GPUDiagnosticResult, C as TranscribeOptions, Ct as loadKaniTTS, D as generateQwen3_5VisionGraph, Dt as ChatMessage, E as Executor, Et as quantizeKaniBackbone, F as generateMoonshineEncoderGraph, Ft as KaniDType, G as generateGemma4VisionGraph, Gt as ModelArchConfig, H as Gemma4VisionGraphInfo, Ht as GraphDType, I as moonshineEncoderFrames, It as KaniTTS, J as DEFAULT_MODELS, K as patchGemma4VisionClips, Kt as ModelCapabilities, L as parseMoonshineConfig, Lt as KaniTTSOptions, M as parseOuteTtsConfig, Mt as applyLoRAToStore, N as MOONSHINE_REMAINING_WORK, Nt as buildLoRADeltas, O as audioTokensToDacCodes, Ot as Tokenizer, P as generateMoonshineDecoderGraph, Pt as fetchAdapter, Q as GEMMA4_IMAGE_PROCESSOR, R as audioTokensToCodes, Rt as SpeakOptions, S as MoonshineSTTOptions, St as LoadedMoonshine, T as MoonshineEncoderExecutor, Tt as loadMoonshine, U as dequantizeGemma4VisionProjection, Ut as KVDType, V as parseKaniConfig, Vt as initGPU, W as dequantizeMLXProjection, Wt as KvMode, X as OUTETTS_PRESET_VOICES, Y as OUTETTS_ASSETS, Z as resolveDefaultRepo, _ as ParlerSpeakOptions, _t as preprocessImage, a as GenerateObjectOptions, at as VisionPositionTensors, b as ParlerTTSOptions, bt as SamplingParams, c as GenerateResult, ct as buildGemma4RotaryCosSin, d as ObjectSchema, dt as buildMRoPEPositionIds, et as Gemma4VisionPositionTensors, f as ObjectValidator, ft as buildPosEmbeds, g as VisionInputs, gt as mropeFreqDims, h as VisionExecutor, ht as buildVisionPositionTensors, i as EncodeImageResult, it as VisionGridConfig, j as generateOuteTtsBackboneGraph, jt as LoRADelta, k as dacOutputLength, kt as AdapterConfig, l as IntegrityCheckEntry, lt as buildGemma4VisionPositionTensors, m as WebGPUEngineOptions, mt as buildRotaryCosSin, n as AgentTool, nt as PreprocessedImage, o as GenerateObjectResult, ot as buildGemma4PoolMatrix, p as WebGPUEngine, pt as buildPositionIds, q as resolveGemma4VisionInfo, qt as createDefaultHFKeyMapper, r as EmbedOptions, rt as QWEN3_5_IMAGE_PROCESSOR, s as GenerateOptions, st as buildGemma4PosEmbeds, t as AgentStep, tt as ImageProcessorConfig, u as IntegrityCheckResult, ut as buildMRoPECosSin, v as ParlerSpeakResult, vt as preprocessImageGemma4, w as TranscribeResult, wt as loadModel, x as MoonshineSTT, xt as LoadedKaniTTS, y as ParlerTTS, yt as smartResize, z as generateKaniTtsGraph, zt as SpeakResult } from "../index-BBAaLqdK.mjs";
|
|
3
|
+
export { AdapterConfig, AdapterSource, AgentStep, AgentTool, ChatMessage, DEFAULT_MODELS, EmbedOptions, EncodeImageResult, Executor, GEMMA4_IMAGE_PROCESSOR, GPUDiagnosticResult, Gemma4VisionGraphInfo, Gemma4VisionGridConfig, Gemma4VisionPositionTensors, GenerateObjectOptions, GenerateObjectResult, GenerateOptions, GenerateResult, GraphDType, ImageProcessorConfig, IntegrityCheckEntry, IntegrityCheckResult, KVDType, KaniDType, KaniTTS, KaniTTSOptions, KvMode, LoRADelta, LoadedKaniTTS, LoadedMoonshine, MOONSHINE_REMAINING_WORK, ModelArchConfig, ModelCapabilities, MoonshineEncoderExecutor, MoonshineSTT, MoonshineSTTOptions, OUTETTS_ASSETS, OUTETTS_PRESET_VOICES, ObjectSchema, ObjectValidator, OuteDType, OuteSpeakOptions, OuteSpeakResult, OuteSpeaker, OuteSpeakerWord, OuteTTS, OuteTTSOptions, ParlerSpeakOptions, ParlerSpeakResult, ParlerTTS, ParlerTTSOptions, PreprocessedImage, QWEN3_5_IMAGE_PROCESSOR, SamplingParams, SpeakOptions, SpeakResult, Tokenizer, TranscribeOptions, TranscribeResult, VisionExecutor, VisionGridConfig, VisionInputs, VisionPositionTensors, WebGPUEngine, WebGPUEngineOptions, applyLoRAToStore, audioTokensToCodes, audioTokensToDacCodes, buildGemma4PoolMatrix, buildGemma4PosEmbeds, buildGemma4RotaryCosSin, buildGemma4VisionPositionTensors, buildLoRADeltas, buildMRoPECosSin, buildMRoPEPositionIds, buildOutePromptString, buildPosEmbeds, buildPositionIds, buildRotaryCosSin, buildVisionPositionTensors, createDefaultHFKeyMapper, dacOutputLength, dequantizeGemma4VisionProjection, dequantizeMLXProjection, fetchAdapter, generateDacSpeechDecoderGraph, generateGemma4VisionGraph, generateKaniTtsGraph, generateMoonshineDecoderGraph, generateMoonshineEncoderGraph, generateNanoCodecDecoderGraph, generateOuteTtsBackboneGraph, generateQwen3_5VisionGraph, initGPU, loadKaniTTS, loadModel, loadMoonshine, loadOuteSpeaker, moonshineEncoderFrames, mropeFreqDims, parseKaniConfig, parseMoonshineConfig, parseOuteTtsConfig, patchGemma4VisionClips, preprocessImage, preprocessImageGemma4, quantizeKaniBackbone, resolveDefaultRepo, resolveGemma4VisionInfo, smartResize };
|
package/dist/gpu/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as resolveDefaultRepo, n as OUTETTS_ASSETS, r as OUTETTS_PRESET_VOICES, t as DEFAULT_MODELS } from "../defaults-C_bJK9zs.mjs";
|
|
2
|
-
import { a as generateMoonshineEncoderGraph, h as generateNanoCodecDecoderGraph, i as generateMoonshineDecoderGraph, m as generateKaniTtsGraph, o as moonshineEncoderFrames, r as MOONSHINE_REMAINING_WORK, s as parseMoonshineConfig, u as audioTokensToCodes, x as parseKaniConfig } from "../architectures-BHkqQ9xp.mjs";
|
|
3
|
-
import { A as dequantizeGemma4VisionProjection, C as audioTokensToDacCodes, D as parseOuteTtsConfig, E as generateOuteTtsBackboneGraph, M as generateGemma4VisionGraph, N as patchGemma4VisionClips, O as KaniTTS, P as resolveGemma4VisionInfo, S as loadOuteSpeaker, T as generateDacSpeechDecoderGraph, _ as smartResize, a as buildGemma4PosEmbeds, b as OuteTTS, c as buildMRoPECosSin, d as buildPositionIds, f as buildRotaryCosSin, g as preprocessImageGemma4, h as preprocessImage, i as buildGemma4PoolMatrix, j as dequantizeMLXProjection, k as generateQwen3_5VisionGraph, l as buildMRoPEPositionIds, m as mropeFreqDims, n as GEMMA4_IMAGE_PROCESSOR, o as buildGemma4RotaryCosSin, p as buildVisionPositionTensors, r as QWEN3_5_IMAGE_PROCESSOR, s as buildGemma4VisionPositionTensors, t as WebGPUEngine, u as buildPosEmbeds, v as VisionExecutor, w as dacOutputLength, x as buildOutePromptString, y as ParlerTTS } from "../gpu-
|
|
4
|
-
import { a as loadMoonshine, d as Tokenizer, f as Executor, i as loadModel, l as quantizeKaniBackbone, n as MoonshineEncoderExecutor, r as loadKaniTTS, t as MoonshineSTT,
|
|
2
|
+
import { D as createDefaultHFKeyMapper, a as generateMoonshineEncoderGraph, h as generateNanoCodecDecoderGraph, i as generateMoonshineDecoderGraph, m as generateKaniTtsGraph, o as moonshineEncoderFrames, r as MOONSHINE_REMAINING_WORK, s as parseMoonshineConfig, u as audioTokensToCodes, x as parseKaniConfig } from "../architectures-BHkqQ9xp.mjs";
|
|
3
|
+
import { A as dequantizeGemma4VisionProjection, C as audioTokensToDacCodes, D as parseOuteTtsConfig, E as generateOuteTtsBackboneGraph, M as generateGemma4VisionGraph, N as patchGemma4VisionClips, O as KaniTTS, P as resolveGemma4VisionInfo, S as loadOuteSpeaker, T as generateDacSpeechDecoderGraph, _ as smartResize, a as buildGemma4PosEmbeds, b as OuteTTS, c as buildMRoPECosSin, d as buildPositionIds, f as buildRotaryCosSin, g as preprocessImageGemma4, h as preprocessImage, i as buildGemma4PoolMatrix, j as dequantizeMLXProjection, k as generateQwen3_5VisionGraph, l as buildMRoPEPositionIds, m as mropeFreqDims, n as GEMMA4_IMAGE_PROCESSOR, o as buildGemma4RotaryCosSin, p as buildVisionPositionTensors, r as QWEN3_5_IMAGE_PROCESSOR, s as buildGemma4VisionPositionTensors, t as WebGPUEngine, u as buildPosEmbeds, v as VisionExecutor, w as dacOutputLength, x as buildOutePromptString, y as ParlerTTS } from "../gpu-C5Ez0lSl.mjs";
|
|
4
|
+
import { a as loadMoonshine, d as Tokenizer, f as applyLoRAToStore, h as Executor, i as loadModel, l as quantizeKaniBackbone, m as fetchAdapter, n as MoonshineEncoderExecutor, p as buildLoRADeltas, r as loadKaniTTS, t as MoonshineSTT, w as initGPU } from "../moonshine-stt-9wc6t11v.mjs";
|
|
5
5
|
|
|
6
|
-
export { DEFAULT_MODELS, Executor, GEMMA4_IMAGE_PROCESSOR, KaniTTS, MOONSHINE_REMAINING_WORK, MoonshineEncoderExecutor, MoonshineSTT, OUTETTS_ASSETS, OUTETTS_PRESET_VOICES, OuteTTS, ParlerTTS, QWEN3_5_IMAGE_PROCESSOR, Tokenizer, VisionExecutor, WebGPUEngine, audioTokensToCodes, audioTokensToDacCodes, buildGemma4PoolMatrix, buildGemma4PosEmbeds, buildGemma4RotaryCosSin, buildGemma4VisionPositionTensors, buildMRoPECosSin, buildMRoPEPositionIds, buildOutePromptString, buildPosEmbeds, buildPositionIds, buildRotaryCosSin, buildVisionPositionTensors, dacOutputLength, dequantizeGemma4VisionProjection, dequantizeMLXProjection, generateDacSpeechDecoderGraph, generateGemma4VisionGraph, generateKaniTtsGraph, generateMoonshineDecoderGraph, generateMoonshineEncoderGraph, generateNanoCodecDecoderGraph, generateOuteTtsBackboneGraph, generateQwen3_5VisionGraph, initGPU, loadKaniTTS, loadModel, loadMoonshine, loadOuteSpeaker, moonshineEncoderFrames, mropeFreqDims, parseKaniConfig, parseMoonshineConfig, parseOuteTtsConfig, patchGemma4VisionClips, preprocessImage, preprocessImageGemma4, quantizeKaniBackbone, resolveDefaultRepo, resolveGemma4VisionInfo, smartResize };
|
|
6
|
+
export { DEFAULT_MODELS, Executor, GEMMA4_IMAGE_PROCESSOR, KaniTTS, MOONSHINE_REMAINING_WORK, MoonshineEncoderExecutor, MoonshineSTT, OUTETTS_ASSETS, OUTETTS_PRESET_VOICES, OuteTTS, ParlerTTS, QWEN3_5_IMAGE_PROCESSOR, Tokenizer, VisionExecutor, WebGPUEngine, applyLoRAToStore, audioTokensToCodes, audioTokensToDacCodes, buildGemma4PoolMatrix, buildGemma4PosEmbeds, buildGemma4RotaryCosSin, buildGemma4VisionPositionTensors, buildLoRADeltas, buildMRoPECosSin, buildMRoPEPositionIds, buildOutePromptString, buildPosEmbeds, buildPositionIds, buildRotaryCosSin, buildVisionPositionTensors, createDefaultHFKeyMapper, dacOutputLength, dequantizeGemma4VisionProjection, dequantizeMLXProjection, fetchAdapter, generateDacSpeechDecoderGraph, generateGemma4VisionGraph, generateKaniTtsGraph, generateMoonshineDecoderGraph, generateMoonshineEncoderGraph, generateNanoCodecDecoderGraph, generateOuteTtsBackboneGraph, generateQwen3_5VisionGraph, initGPU, loadKaniTTS, loadModel, loadMoonshine, loadOuteSpeaker, moonshineEncoderFrames, mropeFreqDims, parseKaniConfig, parseMoonshineConfig, parseOuteTtsConfig, patchGemma4VisionClips, preprocessImage, preprocessImageGemma4, quantizeKaniBackbone, resolveDefaultRepo, resolveGemma4VisionInfo, smartResize };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as resolveDefaultRepo, n as OUTETTS_ASSETS, r as OUTETTS_PRESET_VOICES, t as DEFAULT_MODELS } from "./defaults-C_bJK9zs.mjs";
|
|
2
2
|
import { E as GEMMA4_VIS_KEYS, S as DEFAULT_GROUP_SIZE, T as DTYPE_BYTES, _ as kaniCosTensor, c as KANI_END_OF_HUMAN, d as buildKaniLayerCosSin, f as computeKaniPositions, g as kaniAttentionLayerIndices, h as generateNanoCodecDecoderGraph, l as KANI_START_OF_HUMAN, m as generateKaniTtsGraph, u as audioTokensToCodes, v as kaniLayerAlpha, w as CANONICAL_KEYS, x as parseKaniConfig, y as kaniSinTensor } from "./architectures-BHkqQ9xp.mjs";
|
|
3
|
-
import { S as verifyGPU, _ as
|
|
3
|
+
import { C as getOrCreatePipeline, S as destroyBuffers, T as verifyGPU, _ as MATMUL_BIAS_F16C_SPEC, b as createStorageBuffer, c as quantizeBackboneInt4, g as KERNEL_REGISTRY, h as Executor, i as loadModel, l as quantizeKaniBackbone, o as loadOuteTTS, r as loadKaniTTS, s as loadParlerTTS, u as remapPrunedToken, v as clearPipelineCache, w as initGPU, x as createUniformBuffer, y as createBindGroup } from "./moonshine-stt-9wc6t11v.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/gpu/architectures/gemma4_vision.ts
|
|
6
6
|
/**
|
|
@@ -1123,6 +1123,108 @@ var KaniTTS = class KaniTTS {
|
|
|
1123
1123
|
}
|
|
1124
1124
|
};
|
|
1125
1125
|
|
|
1126
|
+
//#endregion
|
|
1127
|
+
//#region src/gpu/autocomplete-clean.ts
|
|
1128
|
+
const DEFAULT_MAX_SUGGESTION_CHARS = 140;
|
|
1129
|
+
const DEFAULT_RESTATEMENT_MIN_WORDS = 3;
|
|
1130
|
+
const DEFAULT_INTERNAL_REPEAT_MIN_RUN = 6;
|
|
1131
|
+
const LEADING_PUNCT = /^[.,;:!?)\]}'"”’%]/;
|
|
1132
|
+
const WRAPPING_QUOTES_START = /^["'“”‘’`]+/;
|
|
1133
|
+
const WRAPPING_QUOTES_END = /["'“”‘’`]+$/;
|
|
1134
|
+
const TRAILING_WHITESPACE = /\s+$/;
|
|
1135
|
+
const WHITESPACE_RUN = /\s+/g;
|
|
1136
|
+
const AFTER_FIRST_NEWLINE = /\r?\n[\s\S]*$/;
|
|
1137
|
+
const ENDS_WITH_SPACE = /\s$/;
|
|
1138
|
+
/**
|
|
1139
|
+
* Longest span of characters that is both a suffix of `typed` and a prefix of
|
|
1140
|
+
* `suggestion`, dropped from the start of `suggestion`. Trailing whitespace on
|
|
1141
|
+
* `typed` is ignored so a duplicated word at the cursor ("the " + "the store")
|
|
1142
|
+
* is caught. Returns `suggestion` unchanged when there is no overlap.
|
|
1143
|
+
*/
|
|
1144
|
+
function stripLeadingOverlap(typed, suggestion) {
|
|
1145
|
+
const t = typed.replace(TRAILING_WHITESPACE, "");
|
|
1146
|
+
const max = Math.min(t.length, suggestion.length);
|
|
1147
|
+
for (let k = max; k > 0; k--) if (t.slice(t.length - k) === suggestion.slice(0, k)) return suggestion.slice(k);
|
|
1148
|
+
return suggestion;
|
|
1149
|
+
}
|
|
1150
|
+
/**
|
|
1151
|
+
* Drop a leading run of words from `suggestion` when that run already appears as
|
|
1152
|
+
* a contiguous phrase anywhere in `typed`. This catches the model restating an
|
|
1153
|
+
* EARLIER phrase (not just the immediate tail). Matching is case-insensitive,
|
|
1154
|
+
* whitespace-normalized, and word-boundary aware so it never strips on a
|
|
1155
|
+
* partial-word coincidence. Only strips runs of at least `minWords` words to
|
|
1156
|
+
* avoid nuking a legitimate short continuation.
|
|
1157
|
+
*/
|
|
1158
|
+
function stripRestatement(typed, suggestion, minWords = DEFAULT_RESTATEMENT_MIN_WORDS) {
|
|
1159
|
+
const normTyped = ` ${typed.toLowerCase().replace(WHITESPACE_RUN, " ").trim()} `;
|
|
1160
|
+
const words = suggestion.split(WHITESPACE_RUN).filter(Boolean);
|
|
1161
|
+
let matched = 0;
|
|
1162
|
+
for (let n = 1; n <= words.length; n++) {
|
|
1163
|
+
const phrase = ` ${words.slice(0, n).join(" ").toLowerCase()} `;
|
|
1164
|
+
if (normTyped.includes(phrase)) matched = n;
|
|
1165
|
+
else break;
|
|
1166
|
+
}
|
|
1167
|
+
if (matched >= minWords) return words.slice(matched).join(" ");
|
|
1168
|
+
return suggestion;
|
|
1169
|
+
}
|
|
1170
|
+
/**
|
|
1171
|
+
* Truncate `text` right before the first point where a span of `minRun` or more
|
|
1172
|
+
* consecutive words repeats a span seen earlier — the classic small-model loop
|
|
1173
|
+
* ("…endless sands …endless sands…"). Returns `text` unchanged (spacing
|
|
1174
|
+
* preserved) when no such repeat exists.
|
|
1175
|
+
*/
|
|
1176
|
+
function truncateInternalRepeat(text, minRun = DEFAULT_INTERNAL_REPEAT_MIN_RUN) {
|
|
1177
|
+
const words = text.split(WHITESPACE_RUN).filter(Boolean);
|
|
1178
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1179
|
+
for (let j = 0; j + minRun <= words.length; j++) {
|
|
1180
|
+
const gram = words.slice(j, j + minRun).join(" ").toLowerCase();
|
|
1181
|
+
if (seen.has(gram)) return words.slice(0, j).join(" ");
|
|
1182
|
+
seen.add(gram);
|
|
1183
|
+
}
|
|
1184
|
+
return text;
|
|
1185
|
+
}
|
|
1186
|
+
/**
|
|
1187
|
+
* Cap `text` to at most `max` characters, cutting on a word boundary when a
|
|
1188
|
+
* reasonable one exists in the back half of the window.
|
|
1189
|
+
*/
|
|
1190
|
+
function capLength(text, max) {
|
|
1191
|
+
if (text.length <= max) return text;
|
|
1192
|
+
const cut = text.slice(0, max);
|
|
1193
|
+
const lastSpace = cut.lastIndexOf(" ");
|
|
1194
|
+
return (lastSpace > max * .5 ? cut.slice(0, lastSpace) : cut).trimEnd();
|
|
1195
|
+
}
|
|
1196
|
+
/**
|
|
1197
|
+
* Turn a raw model completion into a clean inline ghost continuation:
|
|
1198
|
+
* 1. keep only the first line (when `singleLine`),
|
|
1199
|
+
* 2. strip wrapping quotes,
|
|
1200
|
+
* 3. drop a full verbatim echo of the typed text,
|
|
1201
|
+
* 4. drop a leading character overlap with the typed tail,
|
|
1202
|
+
* 5. drop a leading word-run that restates an earlier typed phrase,
|
|
1203
|
+
* 6. truncate an internal phrase loop,
|
|
1204
|
+
* 7. cap the length,
|
|
1205
|
+
* 8. add a single smart leading space so the ghost joins the caret naturally.
|
|
1206
|
+
*
|
|
1207
|
+
* Returns "" when nothing novel is left — the ghost then simply shows nothing,
|
|
1208
|
+
* which is the correct behavior for a suggestion that only repeats the input.
|
|
1209
|
+
*/
|
|
1210
|
+
function cleanSuggestion(raw, typed, options = {}) {
|
|
1211
|
+
const { singleLine = true, maxChars = DEFAULT_MAX_SUGGESTION_CHARS } = options;
|
|
1212
|
+
let s = singleLine ? raw.replace(AFTER_FIRST_NEWLINE, "") : raw;
|
|
1213
|
+
s = s.replace(WRAPPING_QUOTES_START, "").replace(WRAPPING_QUOTES_END, "");
|
|
1214
|
+
s = s.trim();
|
|
1215
|
+
if (!s) return "";
|
|
1216
|
+
const typedTrim = typed.trim();
|
|
1217
|
+
if (typedTrim && s.startsWith(typedTrim)) s = s.slice(typedTrim.length).trimStart();
|
|
1218
|
+
s = stripLeadingOverlap(typed, s).trimStart();
|
|
1219
|
+
s = stripRestatement(typed, s);
|
|
1220
|
+
s = truncateInternalRepeat(s);
|
|
1221
|
+
s = capLength(s.trim(), maxChars).trim();
|
|
1222
|
+
if (!s) return "";
|
|
1223
|
+
const startsWithPunct = LEADING_PUNCT.test(s);
|
|
1224
|
+
const typedEndsWithSpace = ENDS_WITH_SPACE.test(typed) || typed.length === 0;
|
|
1225
|
+
return startsWithPunct || typedEndsWithSpace ? s : ` ${s}`;
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1126
1228
|
//#endregion
|
|
1127
1229
|
//#region src/gpu/architectures/outetts.ts
|
|
1128
1230
|
const OUTETTS_C1_BASE = 151669;
|
|
@@ -5516,22 +5618,6 @@ const AUTOCOMPLETE_SYSTEM = [
|
|
|
5516
5618
|
"Do not answer questions; just continue the writing.",
|
|
5517
5619
|
"Example — input: \"The quick brown fox\" → continuation: \" jumps over the lazy dog.\""
|
|
5518
5620
|
].join(" ");
|
|
5519
|
-
/**
|
|
5520
|
-
* Turn raw model output into a clean inline continuation: cut after the first
|
|
5521
|
-
* newline (single-line), strip wrapping quotes, drop an echoed copy of the typed
|
|
5522
|
-
* text, and add a single leading space unless the suggestion hugs punctuation or
|
|
5523
|
-
* the typed text already ends with whitespace.
|
|
5524
|
-
*/
|
|
5525
|
-
function normalizeContinuation(raw, typed, singleLine) {
|
|
5526
|
-
let s = singleLine ? raw.replace(/\n[\s\S]*$/, "") : raw;
|
|
5527
|
-
s = s.replace(/^["'“”']+/, "").replace(/["'“”']+$/, "");
|
|
5528
|
-
if (s.startsWith(typed)) s = s.slice(typed.length);
|
|
5529
|
-
s = s.replace(/^\s+/, "");
|
|
5530
|
-
if (!s) return "";
|
|
5531
|
-
const startsWithPunct = /^[.,;:!?)\]}'"”’%]/.test(s);
|
|
5532
|
-
const typedEndsWithSpace = /\s$/.test(typed) || typed.length === 0;
|
|
5533
|
-
return startsWithPunct || typedEndsWithSpace ? s : ` ${s}`;
|
|
5534
|
-
}
|
|
5535
5621
|
function formatAgentToolsPrompt(tools) {
|
|
5536
5622
|
return `You are a helpful assistant with access to tools.
|
|
5537
5623
|
|
|
@@ -6062,9 +6148,17 @@ var WebGPUEngine = class WebGPUEngine {
|
|
|
6062
6148
|
}
|
|
6063
6149
|
/**
|
|
6064
6150
|
* Inline autocomplete: continue `prefix` with a brief, single-line continuation.
|
|
6065
|
-
* Wraps `generate` with low-latency defaults (16 tokens, temp 0.3,
|
|
6066
|
-
* first newline) + a continuation system prompt,
|
|
6067
|
-
* after newline, dequote, drop an echoed prefix,
|
|
6151
|
+
* Wraps `generate` with low-latency defaults (16 tokens, temp 0.3, a repetition
|
|
6152
|
+
* penalty of 1.25, stop at the first newline) + a continuation system prompt,
|
|
6153
|
+
* then cleans the output: strip after newline, dequote, drop an echoed prefix,
|
|
6154
|
+
* drop a leading overlap with the typed tail, drop a leading word-run that
|
|
6155
|
+
* restates an earlier typed phrase, truncate an internal phrase loop, cap the
|
|
6156
|
+
* length, and add a smart leading space.
|
|
6157
|
+
*
|
|
6158
|
+
* The repetition penalty plus the overlap/restatement/loop cleanup keep small
|
|
6159
|
+
* quantized models (e.g. Qwen3.5-0.8B) from echoing the typed text or looping
|
|
6160
|
+
* on a phrase. Both are on by default; `repetitionPenalty` and `maxChars` are
|
|
6161
|
+
* overridable.
|
|
6068
6162
|
*
|
|
6069
6163
|
* ```ts
|
|
6070
6164
|
* const suggestion = await engine.autocomplete("The quick brown fox");
|
|
@@ -6072,12 +6166,18 @@ var WebGPUEngine = class WebGPUEngine {
|
|
|
6072
6166
|
* ```
|
|
6073
6167
|
*/
|
|
6074
6168
|
async autocomplete(prefix, opts = {}) {
|
|
6075
|
-
return
|
|
6169
|
+
return cleanSuggestion((await this.generate(prefix, {
|
|
6076
6170
|
systemPrompt: AUTOCOMPLETE_SYSTEM,
|
|
6077
6171
|
maxTokens: opts.maxTokens ?? 16,
|
|
6078
|
-
sampling: {
|
|
6172
|
+
sampling: {
|
|
6173
|
+
temperature: opts.temperature ?? .3,
|
|
6174
|
+
repetitionPenalty: opts.repetitionPenalty ?? 1.25
|
|
6175
|
+
},
|
|
6079
6176
|
stopSequences: opts.stop ?? ["\n"]
|
|
6080
|
-
})).text, prefix,
|
|
6177
|
+
})).text, prefix, {
|
|
6178
|
+
singleLine: opts.singleLine ?? true,
|
|
6179
|
+
maxChars: opts.maxChars
|
|
6180
|
+
});
|
|
6081
6181
|
}
|
|
6082
6182
|
/**
|
|
6083
6183
|
* Rewrite `text` in a target tone (e.g. "professional", "friendly", "concise",
|
|
@@ -7076,4 +7176,4 @@ var WebGPUEngine = class WebGPUEngine {
|
|
|
7076
7176
|
|
|
7077
7177
|
//#endregion
|
|
7078
7178
|
export { dequantizeGemma4VisionProjection as A, audioTokensToDacCodes as C, parseOuteTtsConfig as D, generateOuteTtsBackboneGraph as E, generateGemma4VisionGraph as M, patchGemma4VisionClips as N, KaniTTS as O, resolveGemma4VisionInfo as P, loadOuteSpeaker as S, generateDacSpeechDecoderGraph as T, smartResize as _, buildGemma4PosEmbeds as a, OuteTTS as b, buildMRoPECosSin as c, buildPositionIds as d, buildRotaryCosSin as f, preprocessImageGemma4 as g, preprocessImage as h, buildGemma4PoolMatrix as i, dequantizeMLXProjection as j, generateQwen3_5VisionGraph as k, buildMRoPEPositionIds as l, mropeFreqDims as m, GEMMA4_IMAGE_PROCESSOR as n, buildGemma4RotaryCosSin as o, buildVisionPositionTensors as p, QWEN3_5_IMAGE_PROCESSOR as r, buildGemma4VisionPositionTensors as s, WebGPUEngine as t, buildPosEmbeds as u, VisionExecutor as v, dacOutputLength as w, buildOutePromptString as x, ParlerTTS as y };
|
|
7079
|
-
//# sourceMappingURL=gpu-
|
|
7179
|
+
//# sourceMappingURL=gpu-C5Ez0lSl.mjs.map
|