@qvac/inference 0.19.1 → 0.20.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/NOTICE +43 -11
- package/dist/api/audio-gen.d.ts +42 -1
- package/dist/api/audio-gen.js +137 -51
- package/dist/api/index.d.ts +2 -1
- package/dist/api/index.js +2 -1
- package/dist/api/text-to-speech.d.ts +31 -4
- package/dist/api/text-to-speech.js +117 -21
- package/dist/api/vector-index.d.ts +142 -0
- package/dist/api/vector-index.js +168 -0
- package/dist/api/world.d.ts +2 -2
- package/dist/errors/index.d.ts +12 -0
- package/dist/errors/index.js +21 -0
- package/dist/handlers/vector-index.d.ts +2 -0
- package/dist/handlers/vector-index.js +40 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/models/registry/models.d.ts +351 -12
- package/dist/models/registry/models.js +2271 -1957
- package/dist/models/registry/resource-profiles.js +135 -0
- package/dist/plugins/builtin/audiogen-ggml/ops/audio-edit-stream.d.ts +2 -0
- package/dist/plugins/builtin/audiogen-ggml/ops/audio-edit-stream.js +65 -0
- package/dist/plugins/builtin/audiogen-ggml/ops/audio-gen-input.d.ts +9 -1
- package/dist/plugins/builtin/audiogen-ggml/ops/audio-gen-input.js +24 -7
- package/dist/plugins/builtin/audiogen-ggml/ops/audio-gen-run.d.ts +46 -0
- package/dist/plugins/builtin/audiogen-ggml/ops/audio-gen-run.js +218 -0
- package/dist/plugins/builtin/audiogen-ggml/ops/audio-gen-stream.d.ts +1 -1
- package/dist/plugins/builtin/audiogen-ggml/ops/audio-gen-stream.js +56 -225
- package/dist/plugins/builtin/audiogen-ggml/ops/audio-understand.d.ts +8 -0
- package/dist/plugins/builtin/audiogen-ggml/ops/audio-understand.js +28 -0
- package/dist/plugins/builtin/audiogen-ggml/plugin.d.ts +248 -0
- package/dist/plugins/builtin/audiogen-ggml/plugin.js +17 -1
- package/dist/plugins/builtin/bci-whispercpp-transcription/plugin.d.ts +5 -2
- package/dist/plugins/builtin/bci-whispercpp-transcription/plugin.js +1 -2
- package/dist/plugins/builtin/ggml-ocr/plugin.d.ts +1 -1
- package/dist/plugins/builtin/ggml-ocr/plugin.js +1 -2
- package/dist/plugins/builtin/llamacpp-completion/ops/batch-completion-stream.js +6 -4
- package/dist/plugins/builtin/llamacpp-completion/ops/cache-logger.d.ts +1 -2
- package/dist/plugins/builtin/llamacpp-completion/ops/cache-logger.js +0 -4
- package/dist/plugins/builtin/llamacpp-completion/ops/completion-stats.d.ts +1 -0
- package/dist/plugins/builtin/llamacpp-completion/ops/completion-stats.js +3 -0
- package/dist/plugins/builtin/llamacpp-completion/ops/completion-stream.d.ts +9 -0
- package/dist/plugins/builtin/llamacpp-completion/ops/completion-stream.js +96 -89
- package/dist/plugins/builtin/llamacpp-completion/ops/context-overflow.d.ts +0 -1
- package/dist/plugins/builtin/llamacpp-completion/ops/context-overflow.js +0 -31
- package/dist/plugins/builtin/llamacpp-completion/ops/kv-cache-session.d.ts +40 -24
- package/dist/plugins/builtin/llamacpp-completion/ops/kv-cache-session.js +187 -123
- package/dist/plugins/builtin/llamacpp-completion/ops/kv-cache-state.d.ts +11 -4
- package/dist/plugins/builtin/llamacpp-completion/ops/kv-cache-state.js +18 -16
- package/dist/plugins/builtin/llamacpp-completion/plugin.d.ts +8 -4
- package/dist/plugins/builtin/llamacpp-completion/plugin.js +1 -2
- package/dist/plugins/builtin/llamacpp-embedding/plugin.d.ts +1 -2
- package/dist/plugins/builtin/llamacpp-embedding/plugin.js +2 -38
- package/dist/plugins/builtin/llamacpp-embedding/transform.d.ts +9 -0
- package/dist/plugins/builtin/llamacpp-embedding/transform.js +42 -0
- package/dist/plugins/builtin/nmtcpp-translation/plugin.d.ts +1 -1
- package/dist/plugins/builtin/nmtcpp-translation/plugin.js +1 -2
- package/dist/plugins/builtin/parakeet-transcription/plugin.d.ts +1 -1
- package/dist/plugins/builtin/parakeet-transcription/plugin.js +1 -2
- package/dist/plugins/builtin/sdcpp-generation/ops/video.d.ts +1 -0
- package/dist/plugins/builtin/sdcpp-generation/ops/video.js +8 -2
- package/dist/plugins/builtin/sdcpp-generation/plugin.d.ts +9 -4
- package/dist/plugins/builtin/sdcpp-generation/plugin.js +51 -19
- package/dist/plugins/builtin/tts-ggml/ops/cancel-binding.d.ts +29 -0
- package/dist/plugins/builtin/tts-ggml/ops/cancel-binding.js +66 -0
- package/dist/plugins/builtin/tts-ggml/ops/parler-options.js +10 -0
- package/dist/plugins/builtin/tts-ggml/ops/text-to-speech-stream.d.ts +3 -5
- package/dist/plugins/builtin/tts-ggml/ops/text-to-speech-stream.js +143 -28
- package/dist/plugins/builtin/tts-ggml/ops/text-to-speech.d.ts +5 -2
- package/dist/plugins/builtin/tts-ggml/ops/text-to-speech.js +182 -66
- package/dist/plugins/builtin/tts-ggml/plugin.d.ts +267 -22
- package/dist/plugins/builtin/tts-ggml/plugin.js +94 -35
- package/dist/plugins/builtin/whispercpp-transcription/plugin.d.ts +1 -1
- package/dist/plugins/builtin/whispercpp-transcription/plugin.js +1 -2
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/index.js +1 -1
- package/dist/plugins/ops/load-model.js +22 -2
- package/dist/plugins/ops/translate.js +58 -12
- package/dist/plugins/ops/translatepsy-utils.d.ts +17 -0
- package/dist/plugins/ops/translatepsy-utils.js +32 -0
- package/dist/plugins/registry.d.ts +15 -0
- package/dist/plugins/registry.js +133 -15
- package/dist/plugins/turbovec-backend.d.ts +17 -0
- package/dist/plugins/turbovec-backend.js +99 -0
- package/dist/registry.js +4 -0
- package/dist/resources/model-fit/native-probe/advisory-fit.d.ts +46 -0
- package/dist/resources/model-fit/native-probe/advisory-fit.js +214 -0
- package/dist/resources/model-fit/native-probe/create-llama-fit-request.d.ts +26 -0
- package/dist/resources/model-fit/native-probe/create-llama-fit-request.js +171 -0
- package/dist/resources/model-fit/native-probe/run-in-process-fit.d.ts +42 -0
- package/dist/resources/model-fit/native-probe/run-in-process-fit.js +192 -0
- package/dist/resources/model-fit/native-probe/run-isolated-fit.d.ts +70 -0
- package/dist/resources/model-fit/native-probe/run-isolated-fit.js +372 -0
- package/dist/runtime/env.d.ts +2 -0
- package/dist/runtime/env.js +9 -2
- package/dist/runtime/lifecycle.js +2 -0
- package/dist/runtime/model-registry.d.ts +3 -1
- package/dist/runtime/model-registry.js +2 -1
- package/dist/runtime/request-context.js +17 -0
- package/dist/runtime/vector-index-backend.d.ts +25 -0
- package/dist/runtime/vector-index-backend.js +1 -0
- package/dist/runtime/vector-index-registry.d.ts +76 -0
- package/dist/runtime/vector-index-registry.js +161 -0
- package/dist/schemas/assess-model-fit.d.ts +44 -0
- package/dist/schemas/assess-model-fit.js +40 -0
- package/dist/schemas/audio-gen.d.ts +479 -4
- package/dist/schemas/audio-gen.js +376 -17
- package/dist/schemas/batch-completion-stream.d.ts +7 -0
- package/dist/schemas/batch-completion-stream.js +5 -3
- package/dist/schemas/common.d.ts +749 -15
- package/dist/schemas/common.js +8 -1
- package/dist/schemas/completion-event.d.ts +11 -1
- package/dist/schemas/completion-event.js +3 -0
- package/dist/schemas/completion-stream.d.ts +20 -0
- package/dist/schemas/completion-stream.js +41 -4
- package/dist/schemas/config.d.ts +48 -30
- package/dist/schemas/errors.d.ts +4 -0
- package/dist/schemas/errors.js +22 -0
- package/dist/schemas/index.d.ts +1 -0
- package/dist/schemas/index.js +1 -0
- package/dist/schemas/llamacpp-config.d.ts +4 -8
- package/dist/schemas/llamacpp-config.js +4 -4
- package/dist/schemas/load-model.d.ts +2503 -139
- package/dist/schemas/model-config-schemas.d.ts +228 -5
- package/dist/schemas/plugin.d.ts +10 -0
- package/dist/schemas/sdcpp-config.d.ts +221 -4
- package/dist/schemas/sdcpp-config.js +128 -22
- package/dist/schemas/text-to-speech.d.ts +780 -19
- package/dist/schemas/text-to-speech.js +298 -44
- package/dist/schemas/transcription-config.js +7 -4
- package/dist/schemas/vector-index.d.ts +194 -0
- package/dist/schemas/vector-index.js +185 -0
- package/dist/utils/addon-responses.d.ts +29 -3
- package/dist/utils/aggregate-events.d.ts +3 -1
- package/dist/utils/aggregate-events.js +7 -1
- package/dist/utils/tts-stats.d.ts +15 -11
- package/dist/utils/tts-stats.js +33 -11
- package/package.json +28 -25
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import ttsAddonLogging from '@qvac/tts-ggml/addonLogging';
|
|
2
1
|
import TTSGgml from '@qvac/tts-ggml';
|
|
3
2
|
import { definePlugin, defineHandler, defineDuplexHandler, ttsRequestSchema, ttsResponseSchema, textToSpeechStreamRequestSchema, textToSpeechStreamResponseSchema, ModelType, ttsConfigSchema, ADDON_TTS, LEGACY_TTS_ONNX_MODEL_CONFIG_FIELDS } from '../../../schemas/index.js';
|
|
4
3
|
import { createStreamLogger, registerAddonLogger } from '../../../logging/index.js';
|
|
@@ -6,6 +5,19 @@ import { TtsArtifactsRequiredError, LegacyTtsModelDeprecatedError } from '../../
|
|
|
6
5
|
import { textToSpeech } from './ops/text-to-speech.js';
|
|
7
6
|
import { textToSpeechStream } from './ops/text-to-speech-stream.js';
|
|
8
7
|
import { attachModelExecutionMs } from '../../../profiling/model-execution.js';
|
|
8
|
+
// Everything a TTS frame carries beyond its PCM, forwarded verbatim from the
|
|
9
|
+
// op yield onto the wire frame. Both handlers use it so the two response
|
|
10
|
+
// shapes cannot drift apart.
|
|
11
|
+
function ttsFrameMetadata(value) {
|
|
12
|
+
return {
|
|
13
|
+
...(value.sampleRate !== undefined ? { sampleRate: value.sampleRate } : {}),
|
|
14
|
+
...(value.chunkIndex !== undefined ? { chunkIndex: value.chunkIndex } : {}),
|
|
15
|
+
...(typeof value.sentenceChunk === 'string' && value.sentenceChunk.length > 0
|
|
16
|
+
? { sentenceChunk: value.sentenceChunk }
|
|
17
|
+
: {}),
|
|
18
|
+
...(value.isLast !== undefined ? { isLast: value.isLast } : {})
|
|
19
|
+
};
|
|
20
|
+
}
|
|
9
21
|
function rejectLegacyOnnxFields(cfg) {
|
|
10
22
|
const record = cfg;
|
|
11
23
|
const legacyFields = LEGACY_TTS_ONNX_MODEL_CONFIG_FIELDS.filter((name) => record[name] !== undefined);
|
|
@@ -63,17 +75,34 @@ async function resolveSupertonicConfig(config, ctx) {
|
|
|
63
75
|
const lavasrArtifacts = await resolveLavasrArtifacts(lavasrEnhancerModelSrc, lavasrDenoiserModelSrc, ctx);
|
|
64
76
|
return { config: runtime, artifacts: lavasrArtifacts };
|
|
65
77
|
}
|
|
66
|
-
function resolveParlerConfig(config) {
|
|
67
|
-
return { config, artifacts: {} };
|
|
68
|
-
}
|
|
69
|
-
// CosyVoice3's multi-file layout (flow/HiFT GGUFs, voice.gguf, vocab.json,
|
|
70
|
-
// merges.txt) rides the primary model's registry companion set, so only the
|
|
71
|
-
// optional LavaSR post-processing sources need resolution here.
|
|
72
|
-
async function resolveCosyvoice3Config(config, ctx) {
|
|
78
|
+
async function resolveParlerConfig(config, ctx) {
|
|
73
79
|
const { lavasrEnhancerModelSrc, lavasrDenoiserModelSrc, ...runtime } = config;
|
|
74
80
|
const lavasrArtifacts = await resolveLavasrArtifacts(lavasrEnhancerModelSrc, lavasrDenoiserModelSrc, ctx);
|
|
75
81
|
return { config: runtime, artifacts: lavasrArtifacts };
|
|
76
82
|
}
|
|
83
|
+
// CosyVoice3's multi-file layout (flow/HiFT GGUFs, voice.gguf, vocab.json,
|
|
84
|
+
// merges.txt) rides the primary model's registry companion set. The voice
|
|
85
|
+
// cloning add-ons are deliberately not in that set — they are a ~300 MB opt-in
|
|
86
|
+
// — so they are resolved here alongside the optional LavaSR sources.
|
|
87
|
+
async function resolveCosyvoice3Config(config, ctx) {
|
|
88
|
+
const { lavasrEnhancerModelSrc, lavasrDenoiserModelSrc, referenceAudioSrc, cosyvoice3S3tokModelSrc, cosyvoice3CampplusModelSrc, ...runtime } = config;
|
|
89
|
+
const resolve = ctx.resolveModelPath;
|
|
90
|
+
const [lavasrArtifacts, referenceAudioPath, cosyvoiceS3tokPath, cosyvoiceCampplusPath] = await Promise.all([
|
|
91
|
+
resolveLavasrArtifacts(lavasrEnhancerModelSrc, lavasrDenoiserModelSrc, ctx),
|
|
92
|
+
referenceAudioSrc ? resolve(referenceAudioSrc) : Promise.resolve(undefined),
|
|
93
|
+
cosyvoice3S3tokModelSrc ? resolve(cosyvoice3S3tokModelSrc) : Promise.resolve(undefined),
|
|
94
|
+
cosyvoice3CampplusModelSrc ? resolve(cosyvoice3CampplusModelSrc) : Promise.resolve(undefined)
|
|
95
|
+
]);
|
|
96
|
+
return {
|
|
97
|
+
config: runtime,
|
|
98
|
+
artifacts: {
|
|
99
|
+
...lavasrArtifacts,
|
|
100
|
+
...(referenceAudioPath ? { referenceAudioPath } : {}),
|
|
101
|
+
...(cosyvoiceS3tokPath ? { cosyvoiceS3tokPath } : {}),
|
|
102
|
+
...(cosyvoiceCampplusPath ? { cosyvoiceCampplusPath } : {})
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
}
|
|
77
106
|
async function resolveAudio8Config(config, ctx) {
|
|
78
107
|
const { audio8CodecDecoderModelSrc, audio8CodecEncoderModelSrc, referenceAudioSrc, ...runtime } = config;
|
|
79
108
|
if (!audio8CodecDecoderModelSrc) {
|
|
@@ -94,6 +123,16 @@ async function resolveAudio8Config(config, ctx) {
|
|
|
94
123
|
}
|
|
95
124
|
};
|
|
96
125
|
}
|
|
126
|
+
// The generic ggml backend-loading knobs, forwarded on `config` the same way
|
|
127
|
+
// Supertonic's vulkanCacheDir already is. Parler and Audio8 configs carry no
|
|
128
|
+
// `openclCacheDir` (their native builders do not read it), so it is simply
|
|
129
|
+
// absent for them.
|
|
130
|
+
function ggmlBackendConfig(config) {
|
|
131
|
+
return {
|
|
132
|
+
...(config.backendsDir !== undefined ? { backendsDir: config.backendsDir } : {}),
|
|
133
|
+
...(config.openclCacheDir !== undefined ? { openclCacheDir: config.openclCacheDir } : {})
|
|
134
|
+
};
|
|
135
|
+
}
|
|
97
136
|
// Build the optional LavaSR `files` entries from resolved artifacts. Supplying
|
|
98
137
|
// a path is what enables the stage in @qvac/tts-ggml — there is no on/off flag.
|
|
99
138
|
function lavasrFiles(artifacts) {
|
|
@@ -132,12 +171,20 @@ function createChatterboxModel(modelId, config, params, artifacts) {
|
|
|
132
171
|
: {}),
|
|
133
172
|
...(config.cfmSteps !== undefined ? { cfmSteps: config.cfmSteps } : {}),
|
|
134
173
|
...(config.cfgRate !== undefined ? { cfgRate: config.cfgRate } : {}),
|
|
174
|
+
...(config.nCtx !== undefined ? { nCtx: config.nCtx } : {}),
|
|
175
|
+
...(config.kvCacheType !== undefined ? { kvCacheType: config.kvCacheType } : {}),
|
|
176
|
+
// Chatterbox has no pace channel; `speed` is its only rate control.
|
|
177
|
+
...(config.ttsSpeed !== undefined ? { speed: config.ttsSpeed } : {}),
|
|
135
178
|
...(config.threads !== undefined ? { threads: config.threads } : {}),
|
|
136
179
|
...(config.nGpuLayers !== undefined ? { nGpuLayers: config.nGpuLayers } : {}),
|
|
137
180
|
...(config.seed !== undefined ? { seed: config.seed } : {}),
|
|
138
181
|
config: {
|
|
139
182
|
language: config.language ?? 'en',
|
|
140
|
-
...(config.useGPU !== undefined ? { useGPU: config.useGPU } : {})
|
|
183
|
+
...(config.useGPU !== undefined ? { useGPU: config.useGPU } : {}),
|
|
184
|
+
...(config.outputSampleRate !== undefined
|
|
185
|
+
? { outputSampleRate: config.outputSampleRate }
|
|
186
|
+
: {}),
|
|
187
|
+
...ggmlBackendConfig(config)
|
|
141
188
|
},
|
|
142
189
|
logger,
|
|
143
190
|
opts: { stats: true },
|
|
@@ -157,16 +204,26 @@ function createSupertonicModel(modelId, config, params, artifacts) {
|
|
|
157
204
|
files: { supertonicModel, ...lavasrFiles(artifacts) },
|
|
158
205
|
voice: config.voice ?? 'F1',
|
|
159
206
|
...(config.ttsSpeed !== undefined ? { speed: config.ttsSpeed } : {}),
|
|
207
|
+
// Supertonic conditions pace when the engine is built, so it arrives as a
|
|
208
|
+
// constructor option rather than a per-request field.
|
|
209
|
+
...(config.pace !== undefined ? { pace: config.pace } : {}),
|
|
160
210
|
...(config.ttsNumInferenceSteps !== undefined
|
|
161
211
|
? { numInferenceSteps: config.ttsNumInferenceSteps }
|
|
162
212
|
: {}),
|
|
213
|
+
...(config.threads !== undefined ? { threads: config.threads } : {}),
|
|
214
|
+
...(config.nGpuLayers !== undefined ? { nGpuLayers: config.nGpuLayers } : {}),
|
|
215
|
+
...(config.seed !== undefined ? { seed: config.seed } : {}),
|
|
163
216
|
config: {
|
|
164
217
|
language: config.language ?? 'en',
|
|
165
|
-
|
|
218
|
+
// Supertonic defaults to CPU, but the addon rejects a stated `useGPU`
|
|
219
|
+
// that contradicts `nGpuLayers`. Deriving the default from the layer
|
|
220
|
+
// count keeps `nGpuLayers: 99` on its own usable instead of throwing.
|
|
221
|
+
useGPU: config.useGPU ?? (config.nGpuLayers !== undefined && config.nGpuLayers !== 0),
|
|
166
222
|
...(config.outputSampleRate !== undefined
|
|
167
223
|
? { outputSampleRate: config.outputSampleRate }
|
|
168
224
|
: {}),
|
|
169
|
-
...(config.vulkanCacheDir !== undefined ? { vulkanCacheDir: config.vulkanCacheDir } : {})
|
|
225
|
+
...(config.vulkanCacheDir !== undefined ? { vulkanCacheDir: config.vulkanCacheDir } : {}),
|
|
226
|
+
...ggmlBackendConfig(config)
|
|
170
227
|
},
|
|
171
228
|
logger,
|
|
172
229
|
opts: { stats: true },
|
|
@@ -175,7 +232,7 @@ function createSupertonicModel(modelId, config, params, artifacts) {
|
|
|
175
232
|
registerAddonLogger(modelId, ModelType.ttsGgml, logger);
|
|
176
233
|
return { model };
|
|
177
234
|
}
|
|
178
|
-
function createParlerModel(modelId, config, params) {
|
|
235
|
+
function createParlerModel(modelId, config, params, artifacts) {
|
|
179
236
|
const parlerModel = params.modelPath;
|
|
180
237
|
if (!parlerModel) {
|
|
181
238
|
throw new TtsArtifactsRequiredError();
|
|
@@ -183,7 +240,7 @@ function createParlerModel(modelId, config, params) {
|
|
|
183
240
|
const logger = createStreamLogger(modelId, ModelType.ttsGgml);
|
|
184
241
|
const model = new TTSGgml({
|
|
185
242
|
engine: TTSGgml.ENGINE_PARLER,
|
|
186
|
-
files: { parlerModel },
|
|
243
|
+
files: { parlerModel, ...lavasrFiles(artifacts) },
|
|
187
244
|
...(config.description !== undefined ? { description: config.description } : {}),
|
|
188
245
|
...(config.voiceDescription !== undefined ? { voiceDescription: config.voiceDescription } : {}),
|
|
189
246
|
...(config.voice !== undefined ? { voice: config.voice } : {}),
|
|
@@ -213,7 +270,8 @@ function createParlerModel(modelId, config, params) {
|
|
|
213
270
|
...(config.useGPU !== undefined ? { useGPU: config.useGPU } : {}),
|
|
214
271
|
...(config.outputSampleRate !== undefined
|
|
215
272
|
? { outputSampleRate: config.outputSampleRate }
|
|
216
|
-
: {})
|
|
273
|
+
: {}),
|
|
274
|
+
...ggmlBackendConfig(config)
|
|
217
275
|
},
|
|
218
276
|
logger,
|
|
219
277
|
opts: { stats: true },
|
|
@@ -238,6 +296,9 @@ function createCosyvoice3Model(modelId, config, params, artifacts) {
|
|
|
238
296
|
if (!cosyvoiceLlmModel) {
|
|
239
297
|
throw new TtsArtifactsRequiredError();
|
|
240
298
|
}
|
|
299
|
+
const referenceAudioPath = artifacts['referenceAudioPath'];
|
|
300
|
+
const cosyvoiceS3tokModel = artifacts['cosyvoiceS3tokPath'];
|
|
301
|
+
const cosyvoiceCampplusModel = artifacts['cosyvoiceCampplusPath'];
|
|
241
302
|
const logger = createStreamLogger(modelId, ModelType.ttsGgml);
|
|
242
303
|
const model = new TTSGgml({
|
|
243
304
|
engine: TTSGgml.ENGINE_COSYVOICE3,
|
|
@@ -247,8 +308,14 @@ function createCosyvoice3Model(modelId, config, params, artifacts) {
|
|
|
247
308
|
files: {
|
|
248
309
|
cosyvoiceModelDir: dirname(cosyvoiceLlmModel),
|
|
249
310
|
cosyvoiceLlmModel,
|
|
311
|
+
// Cloning add-ons live outside the companion set, so pass explicit paths
|
|
312
|
+
// rather than relying on the addon's name-prefix discovery in the dir.
|
|
313
|
+
...(cosyvoiceS3tokModel ? { cosyvoiceS3tokModel } : {}),
|
|
314
|
+
...(cosyvoiceCampplusModel ? { cosyvoiceCampplusModel } : {}),
|
|
250
315
|
...lavasrFiles(artifacts)
|
|
251
316
|
},
|
|
317
|
+
...(referenceAudioPath ? { referenceAudio: referenceAudioPath } : {}),
|
|
318
|
+
...(config.promptText !== undefined ? { promptText: config.promptText } : {}),
|
|
252
319
|
...(config.emotion !== undefined ? { emotion: config.emotion } : {}),
|
|
253
320
|
...(config.pace !== undefined ? { pace: config.pace } : {}),
|
|
254
321
|
...(config.instruct !== undefined ? { instruct: toAddonInstruct(config.instruct) } : {}),
|
|
@@ -265,7 +332,8 @@ function createCosyvoice3Model(modelId, config, params, artifacts) {
|
|
|
265
332
|
...(config.useGPU !== undefined ? { useGPU: config.useGPU } : {}),
|
|
266
333
|
...(config.outputSampleRate !== undefined
|
|
267
334
|
? { outputSampleRate: config.outputSampleRate }
|
|
268
|
-
: {})
|
|
335
|
+
: {}),
|
|
336
|
+
...ggmlBackendConfig(config)
|
|
269
337
|
},
|
|
270
338
|
logger,
|
|
271
339
|
opts: { stats: true },
|
|
@@ -304,7 +372,8 @@ function createAudio8Model(modelId, config, params, artifacts) {
|
|
|
304
372
|
...(config.useGPU !== undefined ? { useGPU: config.useGPU } : {}),
|
|
305
373
|
...(config.outputSampleRate !== undefined
|
|
306
374
|
? { outputSampleRate: config.outputSampleRate }
|
|
307
|
-
: {})
|
|
375
|
+
: {}),
|
|
376
|
+
...ggmlBackendConfig(config)
|
|
308
377
|
},
|
|
309
378
|
logger,
|
|
310
379
|
opts: { stats: true },
|
|
@@ -322,7 +391,7 @@ export const ttsPlugin = definePlugin({
|
|
|
322
391
|
const { ttsEngine } = cfg;
|
|
323
392
|
// Same default as the former onnx-tts plugin: omitting `ttsEngine` → Chatterbox.
|
|
324
393
|
if (ttsEngine === 'parler') {
|
|
325
|
-
return resolveParlerConfig(cfg);
|
|
394
|
+
return resolveParlerConfig(cfg, ctx);
|
|
326
395
|
}
|
|
327
396
|
if (ttsEngine === 'cosyvoice3') {
|
|
328
397
|
return resolveCosyvoice3Config(cfg, ctx);
|
|
@@ -339,7 +408,7 @@ export const ttsPlugin = definePlugin({
|
|
|
339
408
|
const config = (params.modelConfig ?? {});
|
|
340
409
|
const artifacts = params.artifacts ?? {};
|
|
341
410
|
if (config.ttsEngine === 'parler') {
|
|
342
|
-
return createParlerModel(params.modelId, config, params);
|
|
411
|
+
return createParlerModel(params.modelId, config, params, artifacts);
|
|
343
412
|
}
|
|
344
413
|
if (config.ttsEngine === 'cosyvoice3') {
|
|
345
414
|
return createCosyvoice3Model(params.modelId, config, params, artifacts);
|
|
@@ -367,21 +436,16 @@ export const ttsPlugin = definePlugin({
|
|
|
367
436
|
type: 'textToSpeech',
|
|
368
437
|
buffer: result.value.buffer,
|
|
369
438
|
done: false,
|
|
370
|
-
...(result.value
|
|
371
|
-
? { chunkIndex: result.value.chunkIndex }
|
|
372
|
-
: {}),
|
|
373
|
-
...(typeof result.value.sentenceChunk === 'string' &&
|
|
374
|
-
result.value.sentenceChunk.length > 0
|
|
375
|
-
? { sentenceChunk: result.value.sentenceChunk }
|
|
376
|
-
: {})
|
|
439
|
+
...ttsFrameMetadata(result.value)
|
|
377
440
|
};
|
|
378
441
|
result = await stream.next();
|
|
379
442
|
}
|
|
380
|
-
const { modelExecutionMs, stats } = result.value;
|
|
443
|
+
const { modelExecutionMs, stats, cancelled } = result.value;
|
|
381
444
|
yield attachModelExecutionMs({
|
|
382
445
|
type: 'textToSpeech',
|
|
383
446
|
buffer: [],
|
|
384
447
|
done: true,
|
|
448
|
+
stopReason: cancelled ? 'cancelled' : 'completed',
|
|
385
449
|
...(stats && { stats })
|
|
386
450
|
}, modelExecutionMs);
|
|
387
451
|
}
|
|
@@ -405,21 +469,16 @@ export const ttsPlugin = definePlugin({
|
|
|
405
469
|
type: 'textToSpeechStream',
|
|
406
470
|
buffer: result.value.buffer,
|
|
407
471
|
done: false,
|
|
408
|
-
...(result.value
|
|
409
|
-
? { chunkIndex: result.value.chunkIndex }
|
|
410
|
-
: {}),
|
|
411
|
-
...(typeof result.value.sentenceChunk === 'string' &&
|
|
412
|
-
result.value.sentenceChunk.length > 0
|
|
413
|
-
? { sentenceChunk: result.value.sentenceChunk }
|
|
414
|
-
: {})
|
|
472
|
+
...ttsFrameMetadata(result.value)
|
|
415
473
|
};
|
|
416
474
|
result = await stream.next();
|
|
417
475
|
}
|
|
418
|
-
const { modelExecutionMs, stats } = result.value;
|
|
476
|
+
const { modelExecutionMs, stats, cancelled } = result.value;
|
|
419
477
|
yield attachModelExecutionMs({
|
|
420
478
|
type: 'textToSpeechStream',
|
|
421
479
|
buffer: [],
|
|
422
480
|
done: true,
|
|
481
|
+
stopReason: cancelled ? 'cancelled' : 'completed',
|
|
423
482
|
...(stats && { stats })
|
|
424
483
|
}, modelExecutionMs);
|
|
425
484
|
}
|
|
@@ -430,7 +489,7 @@ export const ttsPlugin = definePlugin({
|
|
|
430
489
|
})
|
|
431
490
|
},
|
|
432
491
|
logging: {
|
|
433
|
-
module:
|
|
492
|
+
module: () => import('@qvac/tts-ggml/addonLogging'),
|
|
434
493
|
namespace: ModelType.ttsGgml
|
|
435
494
|
}
|
|
436
495
|
});
|
|
@@ -340,7 +340,7 @@ export declare const whisperPlugin: {
|
|
|
340
340
|
}, import("zod/v4/core").$strip>>;
|
|
341
341
|
};
|
|
342
342
|
logging: {
|
|
343
|
-
module: import("@qvac/asr-ggml/addonLogging")
|
|
343
|
+
module: () => Promise<typeof import("@qvac/asr-ggml/addonLogging")>;
|
|
344
344
|
namespace: "@qvac/asr-ggml";
|
|
345
345
|
};
|
|
346
346
|
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import asrAddonLogging from '@qvac/asr-ggml/addonLogging';
|
|
2
1
|
import ASRGgml from '@qvac/asr-ggml';
|
|
3
2
|
import { definePlugin, defineHandler, defineDuplexHandler, transcribeRequestSchema, transcribeResponseSchema, transcribeStreamRequestSchema, transcribeStreamResponseSchema, ModelType, whisperConfigSchema, ADDON_ASR } from '../../../schemas/index.js';
|
|
4
3
|
import { transcribe, transcribeStream } from '../../ops/transcribe.js';
|
|
@@ -172,7 +171,7 @@ export const whisperPlugin = definePlugin({
|
|
|
172
171
|
})
|
|
173
172
|
},
|
|
174
173
|
logging: {
|
|
175
|
-
module:
|
|
174
|
+
module: () => import('@qvac/asr-ggml/addonLogging'),
|
|
176
175
|
namespace: ADDON_ASR
|
|
177
176
|
}
|
|
178
177
|
});
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as hostApi from '../api/index.js';
|
|
2
2
|
import type { QvacPlugin } from '../schemas/plugin.js';
|
|
3
|
-
export { registerPlugin, registerPlugins, getPlugin, getPluginHandler, getTurboVecIndexProvider, hasPlugin, getAllPlugins, clearPlugins, unregisterPlugin } from './registry.js';
|
|
3
|
+
export { registerPlugin, registerPlugins, ensureAddonLoggerReady, getPlugin, getPluginHandler, getTurboVecIndexProvider, hasPlugin, getAllPlugins, clearPlugins, unregisterPlugin } from './registry.js';
|
|
4
4
|
/**
|
|
5
5
|
* Register a set of plugins and return the host API bound to them. The
|
|
6
6
|
* ergonomic entry point for assembling an explicit plugin subset — we ship
|
package/dist/plugins/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { registerPlugins } from './registry.js';
|
|
2
2
|
import * as hostApi from '../api/index.js';
|
|
3
|
-
export { registerPlugin, registerPlugins, getPlugin, getPluginHandler, getTurboVecIndexProvider, hasPlugin, getAllPlugins, clearPlugins, unregisterPlugin } from './registry.js';
|
|
3
|
+
export { registerPlugin, registerPlugins, ensureAddonLoggerReady, getPlugin, getPluginHandler, getTurboVecIndexProvider, hasPlugin, getAllPlugins, clearPlugins, unregisterPlugin } from './registry.js';
|
|
4
4
|
/**
|
|
5
5
|
* Register a set of plugins and return the host API bound to them. The
|
|
6
6
|
* ergonomic entry point for assembling an explicit plugin subset — we ship
|
|
@@ -5,7 +5,8 @@ import { isModelLoaded, registerModel } from '../../runtime/model-registry.js';
|
|
|
5
5
|
import { startLogBuffering, stopLogBufferingWithTimeout } from '../../runtime/logging-stream-registry.js';
|
|
6
6
|
import { detectShardedModel, generateShardFilenames, validateShardedModelCache } from '../../utils/index.js';
|
|
7
7
|
import { PluginNotFoundError, ModelFileNotFoundError, ModelFileNotFoundInDirError, ModelFileLocateFailedError } from '../../errors/index.js';
|
|
8
|
-
import { getPlugin } from '../index.js';
|
|
8
|
+
import { ensureAddonLoggerReady, getPlugin } from '../index.js';
|
|
9
|
+
import { runAdvisoryFitCheck } from '../../resources/model-fit/native-probe/advisory-fit.js';
|
|
9
10
|
import { promises as fsPromises } from 'bare-fs';
|
|
10
11
|
import path from 'bare-path';
|
|
11
12
|
import { getEngineLogger } from '../../logging/index.js';
|
|
@@ -52,6 +53,24 @@ export async function loadModel(params, options) {
|
|
|
52
53
|
throw new ModelFileLocateFailedError(modelType, modelPath, error);
|
|
53
54
|
}
|
|
54
55
|
}
|
|
56
|
+
// Advisory: every outcome — including a projected insufficiency — continues
|
|
57
|
+
// to the ordinary load below. Runs after config resolution and path
|
|
58
|
+
// validation so it sees the same state the real load uses, and before
|
|
59
|
+
// `createModel()` so it never competes with the native load for device
|
|
60
|
+
// memory. The outcome is stored on the registry entry for internal use;
|
|
61
|
+
// it is deliberately not exposed on any public API yet.
|
|
62
|
+
const fitProbe = await runAdvisoryFitCheck({
|
|
63
|
+
modelId,
|
|
64
|
+
modelType: modelType,
|
|
65
|
+
modelPath,
|
|
66
|
+
modelConfig,
|
|
67
|
+
artifacts,
|
|
68
|
+
isShardedModel
|
|
69
|
+
});
|
|
70
|
+
// Load the addon's logger before the addon itself runs. Plugins that defer
|
|
71
|
+
// their logging module do so to keep registration free of native loads, so
|
|
72
|
+
// this is the first point their addon is genuinely required.
|
|
73
|
+
await ensureAddonLoggerReady(plugin);
|
|
55
74
|
logger.info(`${modelType}: Loading model ${modelId}...`);
|
|
56
75
|
startLogBuffering(modelId);
|
|
57
76
|
try {
|
|
@@ -71,7 +90,8 @@ export async function loadModel(params, options) {
|
|
|
71
90
|
path: modelPath,
|
|
72
91
|
config: modelConfig,
|
|
73
92
|
modelType: modelType,
|
|
74
|
-
name: modelName
|
|
93
|
+
name: modelName,
|
|
94
|
+
fitProbe
|
|
75
95
|
});
|
|
76
96
|
const loadResult = modelInitializationTimeMs !== undefined ? { timing: { modelInitializationTimeMs } } : {};
|
|
77
97
|
return forwardBackendDiagnostics(loadResult, result);
|
|
@@ -62,12 +62,50 @@ import { isAddonContextOverflowError } from '../builtin/llamacpp-completion/ops/
|
|
|
62
62
|
import { generateRandomRequestId } from '../../runtime/request-id.js';
|
|
63
63
|
import { getModelParallel } from '../../utils/config-transform.js';
|
|
64
64
|
import { getEngineLogger } from '../../logging/index.js';
|
|
65
|
+
import { isTranslatePsyModel, buildTranslatePsyMessages, TRANSLATEPSY_GENERATION_PARAMS } from './translatepsy-utils.js';
|
|
66
|
+
const AFRICAN_LANGUAGE_ALIASES = new Map([
|
|
67
|
+
['af', 'afr_Latn'],
|
|
68
|
+
['sw', 'swh_Latn'],
|
|
69
|
+
['so', 'som_Latn'],
|
|
70
|
+
['am', 'amh_Ethi'],
|
|
71
|
+
['ha', 'hau_Latn'],
|
|
72
|
+
['rw', 'kin_Latn'],
|
|
73
|
+
['ln', 'lin_Latn'],
|
|
74
|
+
['lg', 'lug_Latn'],
|
|
75
|
+
['zu', 'zul_Latn'],
|
|
76
|
+
['ig', 'ibo_Latn'],
|
|
77
|
+
['mg', 'plt_Latn'],
|
|
78
|
+
['xh', 'xho_Latn'],
|
|
79
|
+
['sn', 'sna_Latn'],
|
|
80
|
+
['yo', 'yor_Latn'],
|
|
81
|
+
['wo', 'wol_Latn'],
|
|
82
|
+
['ny', 'nya_Latn'],
|
|
83
|
+
['st', 'sot_Latn'],
|
|
84
|
+
['ti', 'tir_Ethi'],
|
|
85
|
+
['om', 'gaz_Latn'],
|
|
86
|
+
['tn', 'tsn_Latn'],
|
|
87
|
+
['swa', 'swh_Latn'],
|
|
88
|
+
['mlg', 'plt_Latn'],
|
|
89
|
+
['orm', 'gaz_Latn']
|
|
90
|
+
]);
|
|
91
|
+
// Names missing from langdetect-text, kept separate from Afrique prompt selection.
|
|
92
|
+
const ADDITIONAL_LANGUAGE_NAMES = new Map([
|
|
93
|
+
['lin', 'Lingala'],
|
|
94
|
+
['lug', 'Luganda'],
|
|
95
|
+
['wol', 'Wolof']
|
|
96
|
+
]);
|
|
65
97
|
export function getLanguage(code) {
|
|
66
98
|
if (!code)
|
|
67
99
|
return '';
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
100
|
+
const languageCode = AFRICAN_LANGUAGE_ALIASES.get(code) ?? code;
|
|
101
|
+
if (AFRICAN_LANGUAGES_MAP.has(languageCode))
|
|
102
|
+
return AFRICAN_LANGUAGES_MAP.get(languageCode);
|
|
103
|
+
for (const [scriptCode, name] of AFRICAN_LANGUAGES_MAP) {
|
|
104
|
+
if (scriptCode.split('_')[0] === languageCode)
|
|
105
|
+
return name;
|
|
106
|
+
}
|
|
107
|
+
const baseCode = languageCode.split('_')[0];
|
|
108
|
+
const fullName = ADDITIONAL_LANGUAGE_NAMES.get(baseCode) ?? getLangName(baseCode);
|
|
71
109
|
return fullName ?? code.toUpperCase();
|
|
72
110
|
}
|
|
73
111
|
export function isAfrican(code) {
|
|
@@ -119,6 +157,7 @@ export async function* translate(params, requestId) {
|
|
|
119
157
|
from = detected.code;
|
|
120
158
|
}
|
|
121
159
|
const afriquePrompt = isLlm && (isAfrican(from) || isAfrican(to));
|
|
160
|
+
const translatePsy = isLlm && isTranslatePsyModel(entry.local);
|
|
122
161
|
const fromLanguage = getLanguage(from);
|
|
123
162
|
const toLanguage = getLanguage(to);
|
|
124
163
|
// Open a request-scoped lifecycle for both engine branches. The LLM
|
|
@@ -184,14 +223,16 @@ export async function* translate(params, requestId) {
|
|
|
184
223
|
// Prepare input based on model type
|
|
185
224
|
const input = canonicalModelType === ModelType.nmtcppTranslation
|
|
186
225
|
? singleText
|
|
187
|
-
:
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
:
|
|
193
|
-
|
|
194
|
-
|
|
226
|
+
: translatePsy
|
|
227
|
+
? buildTranslatePsyMessages(fromLanguage, toLanguage, singleText)
|
|
228
|
+
: [
|
|
229
|
+
{
|
|
230
|
+
role: afriquePrompt ? 'user' : 'system',
|
|
231
|
+
content: afriquePrompt
|
|
232
|
+
? `Translate ${fromLanguage} to ${toLanguage}.\n${fromLanguage}: ${singleText}\n${toLanguage}:`
|
|
233
|
+
: `${context ? `${context}. ` : ''}Translate the following text from ${fromLanguage} into ${toLanguage}. Only output the translation, nothing else.\n\n${fromLanguage}: ${singleText}\n${toLanguage}:`
|
|
234
|
+
}
|
|
235
|
+
];
|
|
195
236
|
// A translate cancelled before native work (queued-cancel, or the model being
|
|
196
237
|
// unloaded) must not call run(): LLM could decode against an exclusive finetune
|
|
197
238
|
// holding the lane, and either engine would run against a model being torn
|
|
@@ -203,7 +244,12 @@ export async function* translate(params, requestId) {
|
|
|
203
244
|
}
|
|
204
245
|
const modelStart = nowMs();
|
|
205
246
|
let response;
|
|
206
|
-
if (
|
|
247
|
+
if (translatePsy) {
|
|
248
|
+
response = await model.run(input, {
|
|
249
|
+
generationParams: TRANSLATEPSY_GENERATION_PARAMS
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
else if (canonicalModelType === ModelType.llamacppCompletion &&
|
|
207
253
|
!shouldSkipPerCallSampling(entry.local.name)) {
|
|
208
254
|
response = await model.run(input, {
|
|
209
255
|
generationParams: LLM_TRANSLATE_GENERATION_PARAMS
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare function isTranslatePsyModel(model: {
|
|
2
|
+
name?: string | undefined;
|
|
3
|
+
path: string;
|
|
4
|
+
}): boolean;
|
|
5
|
+
export declare const TRANSLATEPSY_GENERATION_PARAMS: {
|
|
6
|
+
temp: number;
|
|
7
|
+
top_k: number;
|
|
8
|
+
top_p: number;
|
|
9
|
+
repeat_penalty: number;
|
|
10
|
+
predict: number;
|
|
11
|
+
seed: number;
|
|
12
|
+
reasoning_budget: number;
|
|
13
|
+
};
|
|
14
|
+
export declare function buildTranslatePsyMessages(from: string, to: string, text: string): {
|
|
15
|
+
role: string;
|
|
16
|
+
content: string;
|
|
17
|
+
}[];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export function isTranslatePsyModel(model) {
|
|
2
|
+
const filename = model.path.split(/[/\\]/).pop() ?? '';
|
|
3
|
+
return (/^TRANSLATEPSY_AFRISLM_/.test(model.name ?? '') ||
|
|
4
|
+
/^(?:[a-f0-9]{16}_)?TranslatePsy-AfriSLM-(?:0\.8|2|4)B-(?:Q4_K_M|Q8_0)-imat\.gguf$/i.test(filename));
|
|
5
|
+
}
|
|
6
|
+
export const TRANSLATEPSY_GENERATION_PARAMS = {
|
|
7
|
+
temp: 0,
|
|
8
|
+
top_k: 1,
|
|
9
|
+
top_p: 1,
|
|
10
|
+
repeat_penalty: 1,
|
|
11
|
+
predict: 256,
|
|
12
|
+
seed: 0,
|
|
13
|
+
reasoning_budget: 0
|
|
14
|
+
};
|
|
15
|
+
export function buildTranslatePsyMessages(from, to, text) {
|
|
16
|
+
// Match the model card exactly.
|
|
17
|
+
return [
|
|
18
|
+
{
|
|
19
|
+
role: 'system',
|
|
20
|
+
content: `You are a professional ${from} to ${to} translator. ` +
|
|
21
|
+
`Your goal is to accurately convey the meaning and nuances of the ` +
|
|
22
|
+
`original ${from} text while adhering to ${to} grammar, ` +
|
|
23
|
+
`vocabulary, and cultural sensitivities. Produce only the ` +
|
|
24
|
+
`${to} translation, without any additional explanations ` +
|
|
25
|
+
'or commentary. '
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
role: 'user',
|
|
29
|
+
content: `Please translate the following ${from} text into ${to}: ${text}.\n\nTranslation:`
|
|
30
|
+
}
|
|
31
|
+
];
|
|
32
|
+
}
|
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
import { type QvacPlugin, type PluginHandlerDefinition } from '../schemas/plugin.js';
|
|
2
2
|
export declare function registerPlugin(plugin: QvacPlugin): void;
|
|
3
3
|
export declare function registerPlugins(pluginList: readonly QvacPlugin[]): void;
|
|
4
|
+
/**
|
|
5
|
+
* Wires the addon logger of a plugin that supplied a resolver, loading the
|
|
6
|
+
* addon on the way. Call it once a model of this type is actually being
|
|
7
|
+
* created: it is the point where the addon is needed anyway, so a host
|
|
8
|
+
* missing that addon's platform package fails the load it asked for instead
|
|
9
|
+
* of failing every plugin registration at startup.
|
|
10
|
+
*
|
|
11
|
+
* A no-op for plugins that passed their module directly — those are already
|
|
12
|
+
* wired by `registerPlugin` — and for a namespace that is already wired,
|
|
13
|
+
* which is how two plugins over one addon (whisper and Parakeet over ASR)
|
|
14
|
+
* share a single `setLogger` call. Also a no-op when the registry was cleared
|
|
15
|
+
* while the addon was loading, so a shutdown that races a load leaves no
|
|
16
|
+
* logger behind.
|
|
17
|
+
*/
|
|
18
|
+
export declare function ensureAddonLoggerReady(plugin: QvacPlugin): Promise<void>;
|
|
4
19
|
export declare function getPlugin(modelType: string): QvacPlugin | undefined;
|
|
5
20
|
export declare function getPluginHandler(modelType: string, handlerName: string): PluginHandlerDefinition | undefined;
|
|
6
21
|
export declare function hasPlugin(modelType: string): boolean;
|