@qvac/sdk 0.23.0 → 0.24.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 +115 -58
- package/README.md +10 -13
- package/dist/examples/asr/parakeet-sortformer.js +24 -14
- package/dist/examples/asr/parakeet-transcribepsy-filesystem.js +40 -11
- package/dist/examples/asr/parakeet-unified-coreml.js +14 -9
- package/dist/examples/asr/whispercpp-prompt.js +9 -5
- package/dist/examples/assess-model-fit.d.ts +7 -9
- package/dist/examples/assess-model-fit.js +22 -43
- package/dist/examples/calc-tokens.d.ts +2 -0
- package/dist/examples/calc-tokens.js +21 -0
- package/dist/examples/classification/classify-image.js +11 -5
- package/dist/examples/completion-stop-reason.d.ts +3 -3
- package/dist/examples/completion-stop-reason.js +4 -4
- package/dist/examples/diffusion-flux3-klein.d.ts +2 -0
- package/dist/examples/diffusion-flux3-klein.js +102 -0
- package/dist/examples/diffusion-moss-image.d.ts +2 -0
- package/dist/examples/diffusion-moss-image.js +126 -0
- package/dist/examples/diffusion-qwen-image-21.js +15 -4
- package/dist/examples/embed-multimodal.d.ts +2 -0
- package/dist/examples/embed-multimodal.js +80 -0
- package/dist/examples/embed-p2p.js +2 -2
- package/dist/examples/image/megaloc.d.ts +2 -0
- package/dist/examples/image/megaloc.js +37 -0
- package/dist/examples/llamacpp-multimodal.js +18 -0
- package/dist/examples/rag/rag-hyperdb/pipeline.js +2 -2
- package/dist/examples/rag/rag-turbovec.js +2 -2
- package/dist/examples/sessions.d.ts +17 -0
- package/dist/examples/sessions.js +63 -0
- package/dist/examples/tools/llamacpp-deferred-tools.js +8 -4
- package/dist/scripts/check-resource-collectors-packaging.js +7 -6
- package/dist/scripts/contract/build-contract.d.ts +2 -1
- package/dist/scripts/contract/build-contract.js +13 -1
- package/dist/scripts/contract/constants-registry.d.ts +17 -0
- package/dist/scripts/contract/constants-registry.js +8 -2
- package/dist/scripts/contract/method-shapes.d.ts +4 -0
- package/dist/scripts/contract/method-shapes.js +4 -0
- package/dist/scripts/enforce-inference-versions.d.ts +1 -1
- package/dist/scripts/enforce-inference-versions.js +28 -18
- package/dist/scripts/generate-bare-kit-runtimes.js +101 -69
- package/dist/src/client/api/assess-model-fit.d.ts +17 -17
- package/dist/src/client/api/assess-model-fit.js +18 -31
- package/dist/src/client/api/audio-edit.d.ts +5 -3
- package/dist/src/client/api/audio-edit.js +5 -3
- package/dist/src/client/api/audio-gen-result.js +134 -45
- package/dist/src/client/api/audio-gen.d.ts +40 -3
- package/dist/src/client/api/audio-gen.js +40 -3
- package/dist/src/client/api/audio-understand.d.ts +2 -2
- package/dist/src/client/api/audio-understand.js +2 -2
- package/dist/src/client/api/batch-completion.js +2 -1
- package/dist/src/client/api/calc-tokens.d.ts +33 -0
- package/dist/src/client/api/calc-tokens.js +44 -0
- package/dist/src/client/api/cancel.d.ts +2 -2
- package/dist/src/client/api/cancel.js +2 -2
- package/dist/src/client/api/classify.d.ts +12 -5
- package/dist/src/client/api/classify.js +17 -5
- package/dist/src/client/api/client-request-id.d.ts +0 -15
- package/dist/src/client/api/client-request-id.js +15 -12
- package/dist/src/client/api/completion-stream.d.ts +8 -1
- package/dist/src/client/api/completion-stream.js +10 -1
- package/dist/src/client/api/delete-cache.d.ts +9 -2
- package/dist/src/client/api/delete-cache.js +13 -3
- package/dist/src/client/api/diffusion.d.ts +20 -4
- package/dist/src/client/api/diffusion.js +23 -5
- package/dist/src/client/api/embed.d.ts +82 -29
- package/dist/src/client/api/embed.js +64 -19
- package/dist/src/client/api/get-model-info.d.ts +2 -2
- package/dist/src/client/api/get-model-info.js +2 -2
- package/dist/src/client/api/get-system-resources.d.ts +2 -2
- package/dist/src/client/api/get-system-resources.js +2 -2
- package/dist/src/client/api/heartbeat.d.ts +3 -2
- package/dist/src/client/api/heartbeat.js +3 -2
- package/dist/src/client/api/index.d.ts +4 -3
- package/dist/src/client/api/index.js +2 -1
- package/dist/src/client/api/invoke-plugin.d.ts +8 -2
- package/dist/src/client/api/invoke-plugin.js +17 -2
- package/dist/src/client/api/load-model.js +5 -2
- package/dist/src/client/api/ocr.d.ts +5 -3
- package/dist/src/client/api/ocr.js +44 -21
- package/dist/src/client/api/rag.d.ts +1 -1
- package/dist/src/client/api/rag.js +1 -1
- package/dist/src/client/api/registry.d.ts +17 -7
- package/dist/src/client/api/registry.js +37 -12
- package/dist/src/client/api/resume.d.ts +2 -1
- package/dist/src/client/api/resume.js +2 -2
- package/dist/src/client/api/rpc-server.d.ts +4 -4
- package/dist/src/client/api/rpc-server.js +10 -10
- package/dist/src/client/api/state.d.ts +2 -2
- package/dist/src/client/api/state.js +2 -2
- package/dist/src/client/api/subscribe-logs.d.ts +2 -2
- package/dist/src/client/api/subscribe-logs.js +2 -2
- package/dist/src/client/api/suspend.d.ts +4 -2
- package/dist/src/client/api/suspend.js +4 -3
- package/dist/src/client/api/text-to-speech.d.ts +14 -5
- package/dist/src/client/api/text-to-speech.js +83 -29
- package/dist/src/client/api/transcribe.d.ts +6 -2
- package/dist/src/client/api/transcribe.js +7 -1
- package/dist/src/client/api/unload-model.d.ts +19 -7
- package/dist/src/client/api/unload-model.js +29 -11
- package/dist/src/client/api/upscale.d.ts +6 -3
- package/dist/src/client/api/upscale.js +9 -4
- package/dist/src/client/api/vector-index.d.ts +50 -16
- package/dist/src/client/api/vector-index.js +100 -48
- package/dist/src/client/api/video-request.d.ts +5 -5
- package/dist/src/client/api/video.d.ts +3 -2
- package/dist/src/client/api/video.js +3 -2
- package/dist/src/client/api/vla.d.ts +9 -5
- package/dist/src/client/api/vla.js +17 -8
- package/dist/src/client/api/world.d.ts +5 -5
- package/dist/src/client/api/world.js +4 -4
- package/dist/src/client/init-hooks.d.ts +6 -4
- package/dist/src/client/init-hooks.js +12 -15
- package/dist/src/client/logging-stream-registry.d.ts +6 -3
- package/dist/src/client/logging-stream-registry.js +31 -12
- package/dist/src/client/rpc/bundle-stamp.d.ts +29 -0
- package/dist/src/client/rpc/bundle-stamp.js +75 -0
- package/dist/src/client/rpc/expo-home-dir.d.ts +2 -0
- package/dist/src/client/rpc/expo-home-dir.js +4 -0
- package/dist/src/client/rpc/expo-rpc-client.js +189 -135
- package/dist/src/client/rpc/node-rpc-client.js +322 -413
- package/dist/src/client/rpc/pear-runtime.d.ts +12 -0
- package/dist/src/client/rpc/pear-runtime.js +12 -0
- package/dist/src/client/rpc/rpc-client.d.ts +5 -4
- package/dist/src/client/rpc/rpc-client.js +126 -23
- package/dist/src/client/rpc/rpc-error.js +21 -2
- package/dist/src/client/rpc/unbundled-harness.d.ts +16 -0
- package/dist/src/client/rpc/unbundled-harness.js +27 -0
- package/dist/src/client/rpc/worker-failure.d.ts +27 -0
- package/dist/src/client/rpc/worker-failure.js +61 -0
- package/dist/src/client/session-registry.d.ts +75 -0
- package/dist/src/client/session-registry.js +149 -0
- package/dist/src/client/session.d.ts +125 -0
- package/dist/src/client/session.js +148 -0
- package/dist/src/commands/bundle/addons.d.ts +14 -0
- package/dist/src/commands/bundle/addons.js +65 -0
- package/dist/src/commands/bundle/constants.js +1 -0
- package/dist/src/commands/bundle/entry-gen.d.ts +1 -5
- package/dist/src/commands/bundle/entry-gen.js +17 -50
- package/dist/src/commands/bundle/index.d.ts +59 -13
- package/dist/src/commands/bundle/index.js +345 -121
- package/dist/src/commands/bundle/link.d.ts +58 -0
- package/dist/src/commands/bundle/link.js +135 -0
- package/dist/src/commands/bundle/node-support.d.ts +13 -0
- package/dist/src/commands/bundle/node-support.js +23 -0
- package/dist/src/commands/bundle/read-bundle.d.ts +9 -0
- package/dist/src/commands/bundle/read-bundle.js +27 -0
- package/dist/src/commands/bundle/resolve-sdk-import.d.ts +6 -0
- package/dist/src/commands/bundle/resolve-sdk-import.js +24 -28
- package/dist/src/commands/bundle/scratch.d.ts +35 -0
- package/dist/src/commands/bundle/scratch.js +178 -0
- package/dist/src/commands/bundle/targets.d.ts +14 -0
- package/dist/src/commands/bundle/targets.js +37 -0
- package/dist/src/commands/host-prebuilds/index.d.ts +5 -4
- package/dist/src/commands/host-prebuilds/index.js +9 -7
- package/dist/src/commands/index.d.ts +4 -3
- package/dist/src/commands/verify/abi.d.ts +20 -14
- package/dist/src/commands/verify/abi.js +11 -79
- package/dist/src/commands/verify/bare-kit-runtime.d.ts +20 -22
- package/dist/src/commands/verify/bare-kit-runtime.js +102 -150
- package/dist/src/commands/verify/bare-kit-runtimes.d.ts +10 -9
- package/dist/src/commands/verify/bare-kit-runtimes.js +21 -21
- package/dist/src/commands/verify/bundle-source.js +25 -21
- package/dist/src/commands/verify/engines-advice.d.ts +2 -8
- package/dist/src/commands/verify/engines-advice.js +7 -54
- package/dist/src/commands/verify/index.d.ts +30 -29
- package/dist/src/commands/verify/index.js +92 -200
- package/dist/src/commands/verify/prebuilds.d.ts +3 -5
- package/dist/src/commands/verify/prebuilds.js +1 -2
- package/dist/src/commands/verify/resource-collectors.d.ts +0 -6
- package/dist/src/commands/verify/resource-collectors.js +1 -50
- package/dist/src/commands/verify/sidecar-runtime.d.ts +6 -0
- package/dist/src/commands/verify/sidecar-runtime.js +51 -0
- package/dist/src/expo/plugins/withBareKit.d.ts +59 -0
- package/dist/src/expo/plugins/withBareKit.js +204 -0
- package/dist/src/expo/plugins/withMobileBundle.d.ts +4 -11
- package/dist/src/expo/plugins/withMobileBundle.js +36 -57
- package/dist/src/expo/plugins/withQvacSDK.d.ts +1 -0
- package/dist/src/expo/plugins/withQvacSDK.js +3 -0
- package/dist/src/index.d.ts +6 -5
- package/dist/src/index.js +10 -14
- package/dist/src/logging/utils.js +10 -2
- package/dist/src/plugin-ids.d.ts +2 -1
- package/dist/src/plugin-ids.js +2 -0
- package/dist/src/schemas/public.d.ts +1 -1
- package/dist/src/schemas/public.js +1 -1
- package/dist/src/schemas/sdk-errors-client.d.ts +5 -6
- package/dist/src/schemas/sdk-errors-client.js +30 -36
- package/dist/src/schemas/sdk-errors-server.d.ts +11 -1
- package/dist/src/schemas/sdk-errors-server.js +60 -2
- package/dist/src/server/rpc/rpc-utils.d.ts +25 -4
- package/dist/src/server/rpc/rpc-utils.js +39 -5
- package/dist/src/utils/errors-client.d.ts +37 -29
- package/dist/src/utils/errors-client.js +50 -41
- package/dist/src/utils/errors-server.d.ts +59 -1
- package/dist/src/utils/errors-server.js +110 -1
- package/dist/src/utils/withTimeout.js +34 -17
- package/dist/src/worker/handle-request.js +25 -22
- package/dist/src/worker/handler-utils.d.ts +2 -6
- package/dist/src/worker/handler-utils.js +2 -20
- package/dist/src/worker/index.d.ts +2 -4
- package/dist/src/worker/index.js +23 -35
- package/dist/src/worker/plugins/ggml-image-embedding.d.ts +2 -0
- package/dist/src/worker/plugins/ggml-image-embedding.js +1 -0
- package/dist/src/worker/shim.d.ts +4 -0
- package/dist/src/worker/shim.js +7 -0
- package/dist/src/worker/start.d.ts +9 -0
- package/dist/src/worker/start.js +16 -0
- package/dist/src/worker/unbundled-shim.d.ts +2 -0
- package/dist/src/worker/unbundled-shim.js +4 -0
- package/docs/system-resources-support-matrix.md +27 -19
- package/package.json +62 -51
- package/src/electron-forge/index.cjs +65 -91
- package/dist/examples/model-fit-ui/server.d.ts +0 -24
- package/dist/examples/model-fit-ui/server.js +0 -221
- package/dist/src/client/rpc/ensure-worker-ready.d.ts +0 -9
- package/dist/src/client/rpc/ensure-worker-ready.js +0 -17
- package/dist/src/client/rpc/init-timeout.d.ts +0 -26
- package/dist/src/client/rpc/init-timeout.js +0 -25
- package/dist/src/client/rpc/ipc-socket-path.d.ts +0 -11
- package/dist/src/client/rpc/ipc-socket-path.js +0 -30
- package/dist/src/client/rpc/worker-startup-error.d.ts +0 -12
- package/dist/src/client/rpc/worker-startup-error.js +0 -13
- package/dist/src/commands/bundle/bare-pack.d.ts +0 -21
- package/dist/src/commands/bundle/bare-pack.js +0 -77
- package/dist/src/commands/bundle/manifest.d.ts +0 -25
- package/dist/src/commands/bundle/manifest.js +0 -192
- package/dist/src/expo/plugins/link-addons.d.ts +0 -18
- package/dist/src/expo/plugins/link-addons.js +0 -65
- package/dist/src/pear/pre.d.ts +0 -21
- package/dist/src/pear/pre.js +0 -450
- package/dist/src/server/env.d.ts +0 -22
- package/dist/src/server/env.js +0 -59
- package/dist/src/server/utils/qvac-paths.d.ts +0 -2
- package/dist/src/server/utils/qvac-paths.js +0 -5
- package/dist/src/server/utils/worker-lock.d.ts +0 -3
- package/dist/src/server/utils/worker-lock.js +0 -67
- package/dist/src/worker/create-server.d.ts +0 -8
- package/dist/src/worker/create-server.js +0 -51
- package/dist/src/worker/lifecycle.d.ts +0 -23
- package/dist/src/worker/lifecycle.js +0 -149
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// Embed text, an image, and audio with EmbeddingGemma 2 in one shared vector space.
|
|
2
|
+
// Usage: npx tsx embed-multimodal.ts [image.jpg] [audio.wav]
|
|
3
|
+
// Defaults use image/test.jpg and audio/sample-16khz.wav from the source repository.
|
|
4
|
+
import { close, embedBatch, EMBEDDINGGEMMA_2_Q8_0, loadModel, MMPROJ_EMBEDDINGGEMMA_2_Q8_0, unloadModel } from '@qvac/sdk';
|
|
5
|
+
import { resolve } from 'node:path';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
// EmbeddingGemma 2 normalizes its embeddings, so their dot product is cosine similarity.
|
|
8
|
+
function cosineSimilarity(vecA, vecB) {
|
|
9
|
+
let dotProduct = 0;
|
|
10
|
+
for (let i = 0; i < vecA.length; i++) {
|
|
11
|
+
dotProduct += vecA[i] * vecB[i];
|
|
12
|
+
}
|
|
13
|
+
return dotProduct;
|
|
14
|
+
}
|
|
15
|
+
let modelId;
|
|
16
|
+
try {
|
|
17
|
+
const [imagePath = fileURLToPath(new URL('./image/test.jpg', import.meta.url)), audioPath = fileURLToPath(new URL('./audio/sample-16khz.wav', import.meta.url))] = process.argv.slice(2);
|
|
18
|
+
console.error('▸ Loading EmbeddingGemma 2 and its projector');
|
|
19
|
+
modelId = await loadModel({
|
|
20
|
+
modelType: 'llamacpp-embedding',
|
|
21
|
+
modelSrc: EMBEDDINGGEMMA_2_Q8_0,
|
|
22
|
+
modelConfig: {
|
|
23
|
+
projectionModelSrc: MMPROJ_EMBEDDINGGEMMA_2_Q8_0,
|
|
24
|
+
ctxSize: 2048,
|
|
25
|
+
batchSize: 2048
|
|
26
|
+
},
|
|
27
|
+
onProgress: (p) => {
|
|
28
|
+
const mb = (n) => (n / 1e6).toFixed(1);
|
|
29
|
+
const line = `▸ Downloading ${p.percentage.toFixed(0)}% (${mb(p.downloaded)}/${mb(p.total)} MB)`;
|
|
30
|
+
process.stderr.write(process.stderr.isTTY ? `\r${line}` : `${line}\n`);
|
|
31
|
+
if (p.percentage >= 100)
|
|
32
|
+
process.stderr.write('\n');
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
const { embedding, stats } = await embedBatch({
|
|
36
|
+
modelId,
|
|
37
|
+
inputs: [
|
|
38
|
+
'task: search result | query: a newspaper report about the Titanic',
|
|
39
|
+
['title: none | text: ', { media: { type: 'filePath', value: resolve(imagePath) } }],
|
|
40
|
+
[{ media: { type: 'filePath', value: resolve(audioPath) } }]
|
|
41
|
+
]
|
|
42
|
+
});
|
|
43
|
+
const [textEmbedding, imageEmbedding, audioEmbedding] = embedding;
|
|
44
|
+
if (!textEmbedding || !imageEmbedding || !audioEmbedding) {
|
|
45
|
+
throw new Error('Expected text, image, and audio embeddings');
|
|
46
|
+
}
|
|
47
|
+
const labels = ['Text query', `Image: ${imagePath}`, `Audio: ${audioPath}`];
|
|
48
|
+
for (const [index, values] of embedding.entries()) {
|
|
49
|
+
console.log(labels[index]);
|
|
50
|
+
console.log('Embedding dimensions:', values.length);
|
|
51
|
+
console.log('First 10 values:', values.slice(0, 10));
|
|
52
|
+
}
|
|
53
|
+
console.log('Text/image similarity:', cosineSimilarity(textEmbedding, imageEmbedding).toFixed(4));
|
|
54
|
+
console.log('Text/audio similarity:', cosineSimilarity(textEmbedding, audioEmbedding).toFixed(4));
|
|
55
|
+
console.log('Higher scores indicate a closer match to the text query.');
|
|
56
|
+
if (stats)
|
|
57
|
+
console.log('Performance stats:', stats);
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
console.error('✖', error);
|
|
61
|
+
process.exitCode = 1;
|
|
62
|
+
}
|
|
63
|
+
finally {
|
|
64
|
+
if (modelId) {
|
|
65
|
+
try {
|
|
66
|
+
await unloadModel({ modelId });
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
console.error('✖ Failed to unload model:', error);
|
|
70
|
+
process.exitCode = 1;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
await close();
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
console.error('✖ Failed to close SDK connection:', error);
|
|
78
|
+
process.exitCode = 1;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { embed, GTE_LARGE_FP16, loadModel, unloadModel } from '@qvac/sdk';
|
|
1
|
+
import { embed, embedBatch, GTE_LARGE_FP16, loadModel, unloadModel } from '@qvac/sdk';
|
|
2
2
|
function cosineSimilarity(vecA, vecB) {
|
|
3
3
|
let dotProduct = 0;
|
|
4
4
|
for (let i = 0; i < vecA.length; i++) {
|
|
@@ -37,7 +37,7 @@ try {
|
|
|
37
37
|
'A fast auburn fox leaps over a sleepy canine',
|
|
38
38
|
'Python is a programming language'
|
|
39
39
|
];
|
|
40
|
-
const { embedding: batchEmbeddings } = await
|
|
40
|
+
const { embedding: batchEmbeddings } = await embedBatch({ modelId, inputs: texts });
|
|
41
41
|
console.log('Input: Array of', texts.length, 'texts');
|
|
42
42
|
console.log('Output: Array of', batchEmbeddings.length, 'embeddings');
|
|
43
43
|
const [emb1, emb2, emb3] = batchEmbeddings;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compare two images using the MegaLoc F16 model.
|
|
3
|
+
* Pass a GGUF URL or local file after the two JPEG/PNG paths to use custom weights.
|
|
4
|
+
*/
|
|
5
|
+
import { readFile } from 'node:fs/promises';
|
|
6
|
+
import { loadModel, embedBatch, unloadModel, close, ModelType, MEGALOC_F16 } from '@qvac/sdk';
|
|
7
|
+
let modelId;
|
|
8
|
+
try {
|
|
9
|
+
const [firstPath, secondPath, modelSrc = MEGALOC_F16] = process.argv.slice(2);
|
|
10
|
+
if (!firstPath || !secondPath) {
|
|
11
|
+
throw new Error('Usage: megaloc <first.jpg> <second.jpg> [GGUF URL or path]');
|
|
12
|
+
}
|
|
13
|
+
console.log('▸ Loading MegaLoc');
|
|
14
|
+
modelId = await loadModel({ modelSrc, modelType: ModelType.ggmlImageEmbedding });
|
|
15
|
+
const { embedding, stats } = await embedBatch({
|
|
16
|
+
modelId,
|
|
17
|
+
inputs: [{ image: await readFile(firstPath) }, { image: await readFile(secondPath) }]
|
|
18
|
+
});
|
|
19
|
+
const [first, second] = embedding;
|
|
20
|
+
if (!first || !second)
|
|
21
|
+
throw new Error('Expected two image descriptors');
|
|
22
|
+
const similarity = first.reduce((sum, value, index) => sum + value * second[index], 0);
|
|
23
|
+
console.log(JSON.stringify({ similarity, dimensions: first.length, stats }, null, 2));
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
console.error('✖', error instanceof Error ? error.message : String(error));
|
|
27
|
+
process.exitCode = 1;
|
|
28
|
+
}
|
|
29
|
+
finally {
|
|
30
|
+
try {
|
|
31
|
+
if (modelId)
|
|
32
|
+
await unloadModel({ modelId });
|
|
33
|
+
}
|
|
34
|
+
finally {
|
|
35
|
+
await close();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -58,6 +58,24 @@ try {
|
|
|
58
58
|
const stats2 = await result2.stats;
|
|
59
59
|
console.log('\n▸ Performance Stats:', stats2);
|
|
60
60
|
console.log('▸ --------------------------------');
|
|
61
|
+
// Ordered text and media: each image keeps its position in the turn, so the
|
|
62
|
+
// text can sit next to the picture it refers to. Attachments can't do this,
|
|
63
|
+
// because they are all sent before the text.
|
|
64
|
+
const content = [
|
|
65
|
+
{ type: 'text', text: 'Image A: ' },
|
|
66
|
+
{ type: 'media', path: imageFilePath },
|
|
67
|
+
{ type: 'text', text: '\nImage B: ' },
|
|
68
|
+
{ type: 'media', path: imageFilePath2 },
|
|
69
|
+
{ type: 'text', text: '\nWhich image is a newspaper?' }
|
|
70
|
+
];
|
|
71
|
+
const history3 = [{ role: 'user', content }];
|
|
72
|
+
const result3 = completion({ modelId, history: history3, stream: true });
|
|
73
|
+
for await (const token of result3.tokenStream) {
|
|
74
|
+
process.stdout.write(token);
|
|
75
|
+
}
|
|
76
|
+
const stats3 = await result3.stats;
|
|
77
|
+
console.log('\n▸ Performance Stats:', stats3);
|
|
78
|
+
console.log('▸ --------------------------------');
|
|
61
79
|
await unloadModel({ modelId, clearStorage: false });
|
|
62
80
|
}
|
|
63
81
|
catch (error) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { loadModel, unloadModel,
|
|
1
|
+
import { loadModel, unloadModel, embedBatch, GTE_LARGE_FP16, ragChunk, ragSaveEmbeddings, ragSearch, ragCloseWorkspace } from '@qvac/sdk';
|
|
2
2
|
try {
|
|
3
3
|
// Get query from command line or use default
|
|
4
4
|
const query = process.argv[2] || 'machine learning algorithms';
|
|
@@ -36,7 +36,7 @@ try {
|
|
|
36
36
|
console.log(`▸ Created ${chunks.length} chunks`);
|
|
37
37
|
console.log('▸ Step 2: Generating embeddings (batch)...');
|
|
38
38
|
const texts = chunks.map((chunk) => chunk.content);
|
|
39
|
-
const { embedding: embeddings } = await
|
|
39
|
+
const { embedding: embeddings } = await embedBatch({ modelId, inputs: texts });
|
|
40
40
|
const embeddedDocs = chunks.map((chunk, i) => ({
|
|
41
41
|
id: chunk.id,
|
|
42
42
|
content: chunk.content,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createVectorIndex, embed, loadModel, loadVectorIndex, unloadModel, GTE_LARGE_FP16, VectorIndexStorage } from '@qvac/sdk';
|
|
1
|
+
import { createVectorIndex, embed, embedBatch, loadModel, loadVectorIndex, unloadModel, GTE_LARGE_FP16, VectorIndexStorage } from '@qvac/sdk';
|
|
2
2
|
// Retrieval over documents kept in your own store. The SDK holds only the
|
|
3
3
|
// vectors, in a TurboVec index inside the worker; the documents stay in this
|
|
4
4
|
// Map (or any database you choose) and result ids map back to them.
|
|
@@ -22,7 +22,7 @@ try {
|
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
24
|
console.log('▸ Embedding documents...');
|
|
25
|
-
const { embedding: vectors } = await
|
|
25
|
+
const { embedding: vectors } = await embedBatch({ modelId, inputs: [...documents.values()] });
|
|
26
26
|
console.log('▸ Building the vector index...');
|
|
27
27
|
const index = await createVectorIndex({
|
|
28
28
|
dim: vectors[0].length,
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Two caller sessions on one runtime.
|
|
3
|
+
*
|
|
4
|
+
* Each session gets its own requests and model leases:
|
|
5
|
+
*
|
|
6
|
+
* - Both sessions load the same configuration and get the same `modelId`;
|
|
7
|
+
* the second load adds a lease instead of loading the model again.
|
|
8
|
+
* - A session's `cancel({ requestId })` reaches only its own requests, so
|
|
9
|
+
* the second session's cancel leaves the first session's completion
|
|
10
|
+
* running; the first session's own cancel stops it.
|
|
11
|
+
* - `unloadModel()` releases the caller's lease. The model unloads when its
|
|
12
|
+
* last lease is released, here when the second session closes.
|
|
13
|
+
*
|
|
14
|
+
* Only the module-level `close()` stops the runtime; it ends every session.
|
|
15
|
+
*/
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=sessions.d.ts.map
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Two caller sessions on one runtime.
|
|
3
|
+
*
|
|
4
|
+
* Each session gets its own requests and model leases:
|
|
5
|
+
*
|
|
6
|
+
* - Both sessions load the same configuration and get the same `modelId`;
|
|
7
|
+
* the second load adds a lease instead of loading the model again.
|
|
8
|
+
* - A session's `cancel({ requestId })` reaches only its own requests, so
|
|
9
|
+
* the second session's cancel leaves the first session's completion
|
|
10
|
+
* running; the first session's own cancel stops it.
|
|
11
|
+
* - `unloadModel()` releases the caller's lease. The model unloads when its
|
|
12
|
+
* last lease is released, here when the second session closes.
|
|
13
|
+
*
|
|
14
|
+
* Only the module-level `close()` stops the runtime; it ends every session.
|
|
15
|
+
*/
|
|
16
|
+
import { close, getLoadedModelInfo, openSession, QWEN3_600M_INST_Q4 } from '@qvac/sdk';
|
|
17
|
+
try {
|
|
18
|
+
const harness = openSession({ name: 'harness' });
|
|
19
|
+
const skillRunner = openSession({ name: 'skill-runner' });
|
|
20
|
+
const modelId = await harness.loadModel({
|
|
21
|
+
modelSrc: QWEN3_600M_INST_Q4,
|
|
22
|
+
modelConfig: { ctx_size: 4096 }
|
|
23
|
+
});
|
|
24
|
+
const sameModelId = await skillRunner.loadModel({
|
|
25
|
+
modelSrc: QWEN3_600M_INST_Q4,
|
|
26
|
+
modelConfig: { ctx_size: 4096 }
|
|
27
|
+
});
|
|
28
|
+
const { leaseCount } = await getLoadedModelInfo({ modelId });
|
|
29
|
+
console.log(`▸ same model for both sessions: ${modelId === sameModelId}, leases: ${leaseCount}`);
|
|
30
|
+
const run = harness.completion({
|
|
31
|
+
modelId,
|
|
32
|
+
history: [{ role: 'user', content: 'Write a long essay about the history of Rome.' }],
|
|
33
|
+
stream: true
|
|
34
|
+
});
|
|
35
|
+
// The skill runner cannot reach the harness's request.
|
|
36
|
+
await skillRunner.cancel({ requestId: run.requestId });
|
|
37
|
+
let deltasAfterForeignCancel = 0;
|
|
38
|
+
let stopReason;
|
|
39
|
+
for await (const event of run.events) {
|
|
40
|
+
if (event.type === 'contentDelta') {
|
|
41
|
+
deltasAfterForeignCancel++;
|
|
42
|
+
// The harness stops its own completion after a few more tokens.
|
|
43
|
+
if (deltasAfterForeignCancel === 5)
|
|
44
|
+
await harness.cancel({ requestId: run.requestId });
|
|
45
|
+
}
|
|
46
|
+
else if (event.type === 'completionDone') {
|
|
47
|
+
stopReason = event.stopReason;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
console.log(`▸ ${deltasAfterForeignCancel} tokens arrived after skill-runner's cancel; harness's cancel ended the run: stopReason=${stopReason}`);
|
|
51
|
+
const result = await harness.unloadModel({ modelId });
|
|
52
|
+
console.log(`▸ harness unload: released=${result.released}, unloaded=${result.unloaded}`);
|
|
53
|
+
// Closing a session releases its leases; this was the model's last one.
|
|
54
|
+
await skillRunner.close();
|
|
55
|
+
console.log('▸ skill-runner closed and released the last lease');
|
|
56
|
+
await harness.close();
|
|
57
|
+
await close();
|
|
58
|
+
process.exit(0);
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
console.error('✖', error);
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
@@ -33,6 +33,9 @@ try {
|
|
|
33
33
|
modelConfig: { ctx_size: 4096, tools: true }
|
|
34
34
|
});
|
|
35
35
|
console.log(`▸ Model loaded. Model ID: ${modelId}`);
|
|
36
|
+
// One search loads at most two definitions, one unless the model asks for
|
|
37
|
+
// more. Keep these the same for the whole conversation.
|
|
38
|
+
const params = { modelId, tools, toolSearch: { defaultLimit: 1, maxLimit: 2 } };
|
|
36
39
|
const history = [
|
|
37
40
|
{
|
|
38
41
|
role: 'system',
|
|
@@ -41,7 +44,7 @@ try {
|
|
|
41
44
|
{ role: 'user', content: "What's my horoscope for Aquarius?" }
|
|
42
45
|
];
|
|
43
46
|
console.log('\n▸ Turn 1 — only get_weather and tool_search are in the prompt\n');
|
|
44
|
-
const first = completion({
|
|
47
|
+
const first = completion({ ...params, history, stream: true });
|
|
45
48
|
for await (const token of first.tokenStream)
|
|
46
49
|
process.stdout.write(token);
|
|
47
50
|
const calls = await first.toolCalls;
|
|
@@ -53,14 +56,15 @@ try {
|
|
|
53
56
|
console.log(`\n\n▸ The model searched: ${JSON.stringify(search.arguments)}`);
|
|
54
57
|
// Running the search is the SDK's job, not a tool handler's. The result is
|
|
55
58
|
// an ordinary tool message naming what it loaded: keeping it in the history
|
|
56
|
-
// is what declares those definitions on the next turn.
|
|
59
|
+
// is what declares those definitions on the next turn. Passing the same
|
|
60
|
+
// params applies the limits the model was told.
|
|
57
61
|
history.push({ role: 'assistant', content: await first.text });
|
|
58
62
|
history.push({
|
|
59
63
|
role: 'tool',
|
|
60
|
-
content: executeToolSearch(
|
|
64
|
+
content: executeToolSearch(params, search.arguments, history)
|
|
61
65
|
});
|
|
62
66
|
console.log('▸ Definitions loaded. Turn 2 — the model can now call them directly.\n');
|
|
63
|
-
const second = completion({
|
|
67
|
+
const second = completion({ ...params, history, stream: true });
|
|
64
68
|
for await (const token of second.tokenStream)
|
|
65
69
|
process.stdout.write(token);
|
|
66
70
|
for (const call of await second.toolCalls) {
|
|
@@ -60,21 +60,22 @@ export function resolveDesktopHost(platform, arch) {
|
|
|
60
60
|
return validateDesktopHost(`${platform}-${arch}`);
|
|
61
61
|
}
|
|
62
62
|
export async function runResourceCollectorPackagingCheck(options, dependencies = DEFAULT_DEPENDENCIES) {
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
: [resolveDesktopHost(options.platform ?? process.platform, options.arch ?? process.arch)];
|
|
63
|
+
const ownHost = resolveDesktopHost(options.platform ?? process.platform, options.arch ?? process.arch);
|
|
64
|
+
const hosts = options.hosts.length > 0 ? options.hosts : [ownHost];
|
|
66
65
|
const temporaryProjectRoot = await dependencies.createTemporaryProject(options.sdkPackageRoot);
|
|
67
66
|
try {
|
|
67
|
+
// Acceptance reads each host's prebuilds from the collector packages; the
|
|
68
|
+
// bundle only shows which collectors the worker links.
|
|
68
69
|
const bundle = await dependencies.bundleSdk({
|
|
69
70
|
projectRoot: temporaryProjectRoot,
|
|
70
71
|
sdkPath: options.sdkPackageRoot,
|
|
71
|
-
hosts,
|
|
72
|
-
quiet: true
|
|
72
|
+
hosts: [ownHost],
|
|
73
|
+
quiet: true,
|
|
74
|
+
verify: false
|
|
73
75
|
});
|
|
74
76
|
const report = await dependencies.acceptResourceCollectorPackaging({
|
|
75
77
|
projectRoot: temporaryProjectRoot,
|
|
76
78
|
bundlePath: bundle.bundlePath,
|
|
77
|
-
manifestPath: bundle.manifestPath,
|
|
78
79
|
hosts
|
|
79
80
|
});
|
|
80
81
|
const output = options.json
|
|
@@ -21,7 +21,8 @@ export declare function buildContract(): {
|
|
|
21
21
|
condition: string;
|
|
22
22
|
responseSchema: string;
|
|
23
23
|
};
|
|
24
|
-
|
|
24
|
+
ownerOnly?: boolean;
|
|
25
|
+
name: "audioGenStream" | "audioEditStream" | "audioUnderstand" | "startRpcServer" | "stopRpcServer" | "discoverRpcServers" | "heartbeat" | "calcTokens" | "openSession" | "closeSession" | "loadModel" | "downloadAsset" | "completionStream" | "completionOrchestrate" | "batchCompletionStream" | "unloadModel" | "transcribe" | "transcribeStream" | "bciTranscribe" | "bciTranscribeStream" | "loggingStream" | "embed" | "embedBatch" | "translate" | "textToSpeech" | "textToSpeechStream" | "cancel" | "rerank" | "vectorIndex" | "finetune" | "rag" | "deleteCache" | "getModelInfo" | "getLoadedModelInfo" | "getSystemResources" | "assessModelFit" | "ocrStream" | "diffusionStream" | "videoStream" | "upscaleStream" | "worldSceneStream" | "worldStepStream" | "resume" | "pluginInvoke" | "pluginInvokeStream" | "modelRegistryList" | "modelRegistrySearch" | "modelRegistryGetModel" | "suspend" | "state" | "classify" | "decide";
|
|
25
26
|
callShape: "duplex" | "request-reply" | "server-stream";
|
|
26
27
|
requestSchema: string;
|
|
27
28
|
responseSchema: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { fileURLToPath } from 'node:url';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import prettier from 'prettier';
|
|
4
|
-
import { requestSchema, responseSchema } from '@qvac/inference/surface';
|
|
4
|
+
import { OWNER_ONLY_OPERATIONS, requestSchema, responseSchema } from '@qvac/inference/surface';
|
|
5
5
|
import { methodShapes } from './method-shapes.js';
|
|
6
6
|
import { constantsRegistry } from './constants-registry.js';
|
|
7
7
|
import { buildModelsRegistry } from './build-models-registry.js';
|
|
@@ -525,6 +525,17 @@ const progressByMethod = {
|
|
|
525
525
|
responseType: 'finetune:progress'
|
|
526
526
|
}
|
|
527
527
|
};
|
|
528
|
+
/**
|
|
529
|
+
* Methods only the owner client may call: the ones the worker refuses from a
|
|
530
|
+
* session, and session management, since a session must not open or close
|
|
531
|
+
* sessions by naming their ids. Generated clients leave them off a session
|
|
532
|
+
* handle.
|
|
533
|
+
*/
|
|
534
|
+
const ownerOnlyMethods = new Set([
|
|
535
|
+
...OWNER_ONLY_OPERATIONS,
|
|
536
|
+
'openSession',
|
|
537
|
+
'closeSession'
|
|
538
|
+
]);
|
|
528
539
|
export function buildContract() {
|
|
529
540
|
const methodNames = Object.keys(methodShapes).sort();
|
|
530
541
|
const requestByType = collectByWireType(requestSchema.options, 'request');
|
|
@@ -612,6 +623,7 @@ export function buildContract() {
|
|
|
612
623
|
callShape: callShapeByHandlerType[methodShapes[name]],
|
|
613
624
|
requestSchema: `schema.json#/$defs/${name}.request`,
|
|
614
625
|
responseSchema: `schema.json#/$defs/${name}.response`,
|
|
626
|
+
...(ownerOnlyMethods.has(name) && { ownerOnly: true }),
|
|
615
627
|
...(progress && {
|
|
616
628
|
progress: {
|
|
617
629
|
condition: progress.condition,
|
|
@@ -40,6 +40,7 @@ export declare const constantsRegistry: {
|
|
|
40
40
|
readonly sdcppGeneration: "sdcpp-generation";
|
|
41
41
|
readonly audiogenGgml: "audiogen-ggml";
|
|
42
42
|
readonly ggmlVla: "ggml-vla";
|
|
43
|
+
readonly ggmlImageEmbedding: "ggml-image-embedding";
|
|
43
44
|
readonly ggmlClassification: "ggml-classification";
|
|
44
45
|
}>;
|
|
45
46
|
readonly Verbosity: z.ZodEnum<{
|
|
@@ -53,6 +54,7 @@ export declare const constantsRegistry: {
|
|
|
53
54
|
readonly EMBEDDING: "@qvac/sdk/llamacpp-embedding/plugin";
|
|
54
55
|
readonly DECISION: "@qvac/sdk/llamacpp-decision/plugin";
|
|
55
56
|
readonly RERANK: "@qvac/sdk/llamacpp-rerank/plugin";
|
|
57
|
+
readonly IMAGE_EMBEDDING: "@qvac/sdk/ggml-image-embedding/plugin";
|
|
56
58
|
readonly WHISPER: "@qvac/sdk/whispercpp-transcription/plugin";
|
|
57
59
|
readonly BCI: "@qvac/sdk/bci-whispercpp-transcription/plugin";
|
|
58
60
|
readonly MOSS_TRANSCRIBE: "@qvac/sdk/moss-transcribe/plugin";
|
|
@@ -97,6 +99,15 @@ export declare const constantsRegistry: {
|
|
|
97
99
|
readonly TtsCosyvoice3InstructStyle: z.ZodEnum<{
|
|
98
100
|
[k: string]: string;
|
|
99
101
|
}>;
|
|
102
|
+
readonly TtsParlerCoremlComputeUnits: z.ZodEnum<{
|
|
103
|
+
[k: string]: string;
|
|
104
|
+
}>;
|
|
105
|
+
readonly TtsLavasrCoremlComputeUnits: z.ZodEnum<{
|
|
106
|
+
[k: string]: string;
|
|
107
|
+
}>;
|
|
108
|
+
readonly TtsSupertonicPrecision: z.ZodEnum<{
|
|
109
|
+
[k: string]: string;
|
|
110
|
+
}>;
|
|
100
111
|
readonly AudioGenEngine: z.ZodEnum<{
|
|
101
112
|
[k: string]: string;
|
|
102
113
|
}>;
|
|
@@ -112,6 +123,12 @@ export declare const constantsRegistry: {
|
|
|
112
123
|
readonly AudioGenTrack: z.ZodEnum<{
|
|
113
124
|
[k: string]: string;
|
|
114
125
|
}>;
|
|
126
|
+
readonly AudioGenOutputFormat: z.ZodEnum<{
|
|
127
|
+
[k: string]: string;
|
|
128
|
+
}>;
|
|
129
|
+
readonly AudioGenMinimaxCoremlComputeUnits: z.ZodEnum<{
|
|
130
|
+
[k: string]: string;
|
|
131
|
+
}>;
|
|
115
132
|
readonly VectorIndexStorage: z.ZodEnum<{
|
|
116
133
|
readonly F32: "f32";
|
|
117
134
|
readonly Q8: "q8";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { ModelType, VERBOSITY, SUPPORTED_AUDIO_FORMATS, AUDIOGEN_ENGINES, AUDIOGEN_TASK_TYPES, AUDIOGEN_EDIT_OPERATIONS, AUDIOGEN_REPAINT_MODES, AUDIOGEN_TRACKS, TTS_ENGINES, TTS_PACES, TTS_PARLER_EMOTIONS, TTS_SENTENCE_DELIMITER_PRESETS, TTS_CHATTERBOX_LANGUAGES, TTS_SUPERTONIC_LANGUAGES, TTS_COSYVOICE3_EMOTIONS, TTS_COSYVOICE3_INSTRUCT_DIALECTS, TTS_COSYVOICE3_INSTRUCT_VOLUMES, TTS_COSYVOICE3_INSTRUCT_STYLES, VectorIndexStorage } from '@qvac/inference/surface';
|
|
3
|
-
import { PLUGIN_LLM, PLUGIN_EMBEDDING, PLUGIN_DECISION, PLUGIN_RERANK, PLUGIN_WHISPER, PLUGIN_BCI, PLUGIN_MOSS_TRANSCRIBE, PLUGIN_NMT, PLUGIN_TTS, PLUGIN_OCR, PLUGIN_DIFFUSION, PLUGIN_AUDIOGEN, PLUGIN_VLA, PLUGIN_CLASSIFICATION } from '../../src/plugin-ids.js';
|
|
2
|
+
import { ModelType, VERBOSITY, SUPPORTED_AUDIO_FORMATS, AUDIOGEN_ENGINES, AUDIOGEN_TASK_TYPES, AUDIOGEN_EDIT_OPERATIONS, AUDIOGEN_REPAINT_MODES, AUDIOGEN_TRACKS, AUDIOGEN_OUTPUT_FORMATS, AUDIOGEN_MINIMAX_COREML_COMPUTE_UNITS, TTS_ENGINES, TTS_PACES, TTS_PARLER_EMOTIONS, TTS_SENTENCE_DELIMITER_PRESETS, TTS_CHATTERBOX_LANGUAGES, TTS_SUPERTONIC_LANGUAGES, TTS_COSYVOICE3_EMOTIONS, TTS_COSYVOICE3_INSTRUCT_DIALECTS, TTS_COSYVOICE3_INSTRUCT_VOLUMES, TTS_COSYVOICE3_INSTRUCT_STYLES, TTS_PARLER_COREML_COMPUTE_UNITS, TTS_LAVASR_COREML_COMPUTE_UNITS, TTS_SUPERTONIC_PRECISIONS, VectorIndexStorage } from '@qvac/inference/surface';
|
|
3
|
+
import { PLUGIN_LLM, PLUGIN_EMBEDDING, PLUGIN_DECISION, PLUGIN_RERANK, PLUGIN_IMAGE_EMBEDDING, PLUGIN_WHISPER, PLUGIN_BCI, PLUGIN_MOSS_TRANSCRIBE, PLUGIN_NMT, PLUGIN_TTS, PLUGIN_OCR, PLUGIN_DIFFUSION, PLUGIN_AUDIOGEN, PLUGIN_VLA, PLUGIN_CLASSIFICATION } from '../../src/plugin-ids.js';
|
|
4
4
|
// Uppercases each vocabulary value into an identifier-safe varname (e.g.
|
|
5
5
|
// 'slow' -> 'SLOW', 'cover-nofsq' -> 'COVER_NOFSQ'), mirroring the
|
|
6
6
|
// SupportedAudioFormat derivation so names can't drift from the single
|
|
@@ -40,6 +40,7 @@ export const constantsRegistry = {
|
|
|
40
40
|
EMBEDDING: PLUGIN_EMBEDDING,
|
|
41
41
|
DECISION: PLUGIN_DECISION,
|
|
42
42
|
RERANK: PLUGIN_RERANK,
|
|
43
|
+
IMAGE_EMBEDDING: PLUGIN_IMAGE_EMBEDDING,
|
|
43
44
|
WHISPER: PLUGIN_WHISPER,
|
|
44
45
|
BCI: PLUGIN_BCI,
|
|
45
46
|
MOSS_TRANSCRIBE: PLUGIN_MOSS_TRANSCRIBE,
|
|
@@ -67,10 +68,15 @@ export const constantsRegistry = {
|
|
|
67
68
|
TtsCosyvoice3InstructDialect: enumFromVocabulary(TTS_COSYVOICE3_INSTRUCT_DIALECTS),
|
|
68
69
|
TtsCosyvoice3InstructVolume: enumFromVocabulary(TTS_COSYVOICE3_INSTRUCT_VOLUMES),
|
|
69
70
|
TtsCosyvoice3InstructStyle: enumFromVocabulary(TTS_COSYVOICE3_INSTRUCT_STYLES),
|
|
71
|
+
TtsParlerCoremlComputeUnits: enumFromVocabulary(TTS_PARLER_COREML_COMPUTE_UNITS),
|
|
72
|
+
TtsLavasrCoremlComputeUnits: enumFromVocabulary(TTS_LAVASR_COREML_COMPUTE_UNITS),
|
|
73
|
+
TtsSupertonicPrecision: enumFromVocabulary(TTS_SUPERTONIC_PRECISIONS),
|
|
70
74
|
AudioGenEngine: enumFromVocabulary(AUDIOGEN_ENGINES),
|
|
71
75
|
AudioGenTaskType: enumFromVocabulary(AUDIOGEN_TASK_TYPES),
|
|
72
76
|
AudioGenEditOperation: enumFromVocabulary(AUDIOGEN_EDIT_OPERATIONS),
|
|
73
77
|
AudioGenRepaintMode: enumFromVocabulary(AUDIOGEN_REPAINT_MODES),
|
|
74
78
|
AudioGenTrack: enumFromVocabulary(AUDIOGEN_TRACKS),
|
|
79
|
+
AudioGenOutputFormat: enumFromVocabulary(AUDIOGEN_OUTPUT_FORMATS),
|
|
80
|
+
AudioGenMinimaxCoremlComputeUnits: enumFromVocabulary(AUDIOGEN_MINIMAX_COREML_COMPUTE_UNITS),
|
|
75
81
|
VectorIndexStorage: z.enum(VectorIndexStorage)
|
|
76
82
|
};
|
|
@@ -17,14 +17,17 @@ export declare const methodShapes: {
|
|
|
17
17
|
readonly batchCompletionStream: "stream";
|
|
18
18
|
readonly bciTranscribe: "stream";
|
|
19
19
|
readonly bciTranscribeStream: "duplex";
|
|
20
|
+
readonly calcTokens: "reply";
|
|
20
21
|
readonly cancel: "reply";
|
|
21
22
|
readonly classify: "stream";
|
|
23
|
+
readonly closeSession: "reply";
|
|
22
24
|
readonly completionOrchestrate: "duplex";
|
|
23
25
|
readonly completionStream: "stream";
|
|
24
26
|
readonly deleteCache: "reply";
|
|
25
27
|
readonly diffusionStream: "stream";
|
|
26
28
|
readonly downloadAsset: "reply";
|
|
27
29
|
readonly embed: "reply";
|
|
30
|
+
readonly embedBatch: "reply";
|
|
28
31
|
readonly decide: "reply";
|
|
29
32
|
readonly rerank: "reply";
|
|
30
33
|
readonly finetune: "reply";
|
|
@@ -38,6 +41,7 @@ export declare const methodShapes: {
|
|
|
38
41
|
readonly modelRegistryList: "reply";
|
|
39
42
|
readonly modelRegistrySearch: "reply";
|
|
40
43
|
readonly ocrStream: "stream";
|
|
44
|
+
readonly openSession: "reply";
|
|
41
45
|
readonly pluginInvoke: "reply";
|
|
42
46
|
readonly pluginInvokeStream: "stream";
|
|
43
47
|
readonly rag: "reply";
|
|
@@ -17,14 +17,17 @@ export const methodShapes = {
|
|
|
17
17
|
batchCompletionStream: 'stream',
|
|
18
18
|
bciTranscribe: 'stream',
|
|
19
19
|
bciTranscribeStream: 'duplex',
|
|
20
|
+
calcTokens: 'reply',
|
|
20
21
|
cancel: 'reply',
|
|
21
22
|
classify: 'stream',
|
|
23
|
+
closeSession: 'reply',
|
|
22
24
|
completionOrchestrate: 'duplex',
|
|
23
25
|
completionStream: 'stream',
|
|
24
26
|
deleteCache: 'reply',
|
|
25
27
|
diffusionStream: 'stream',
|
|
26
28
|
downloadAsset: 'reply',
|
|
27
29
|
embed: 'reply',
|
|
30
|
+
embedBatch: 'reply',
|
|
28
31
|
decide: 'reply',
|
|
29
32
|
rerank: 'reply',
|
|
30
33
|
finetune: 'reply',
|
|
@@ -38,6 +41,7 @@ export const methodShapes = {
|
|
|
38
41
|
modelRegistryList: 'reply',
|
|
39
42
|
modelRegistrySearch: 'reply',
|
|
40
43
|
ocrStream: 'stream',
|
|
44
|
+
openSession: 'reply',
|
|
41
45
|
pluginInvoke: 'reply',
|
|
42
46
|
pluginInvokeStream: 'stream',
|
|
43
47
|
rag: 'reply',
|
|
@@ -11,7 +11,7 @@ export interface Manifest {
|
|
|
11
11
|
}
|
|
12
12
|
export declare function checkAddonRanges(inferencePkg: Manifest, sdkPkg: Manifest): string[];
|
|
13
13
|
export declare function checkSharedMajorMinor(sdkPkg: Manifest): string[];
|
|
14
|
-
export declare function
|
|
14
|
+
export declare function checkDesktopBare(inferencePkg: Manifest, bareVersion: string | null): string[];
|
|
15
15
|
export declare function collectVersionFailures(inferencePkg: Manifest, sdkPkg: Manifest): string[];
|
|
16
16
|
export declare function runEnforceInferenceVersionsCli(): void;
|
|
17
17
|
export {};
|
|
@@ -14,9 +14,8 @@
|
|
|
14
14
|
// below 1.0.0 (^0.19.0 is >=0.19.0 <0.20.0) but not from 1.0.0 up (^1.19.0
|
|
15
15
|
// also allows 1.20.0), so a tilde is required there.
|
|
16
16
|
//
|
|
17
|
-
// 3. Bare runtime
|
|
18
|
-
// must satisfy inference's engines.bare
|
|
19
|
-
// retained by a consumer's existing lockfile.
|
|
17
|
+
// 3. Desktop Bare. The Bare runtime bare-sidecar ships, which runs the desktop
|
|
18
|
+
// worker, must satisfy inference's engines.bare.
|
|
20
19
|
//
|
|
21
20
|
// The second rule reads @qvac/sdk's manifest alone and never
|
|
22
21
|
// packages/inference's version. The two move independently between releases —
|
|
@@ -26,9 +25,10 @@
|
|
|
26
25
|
// The checks take manifests rather than reading them, so test/enforce-inference-
|
|
27
26
|
// versions.test.ts can drive them over manifest shapes the repo does not hold.
|
|
28
27
|
import { readFileSync } from 'fs';
|
|
28
|
+
import { createRequire } from 'module';
|
|
29
29
|
import { join, resolve, dirname } from 'path';
|
|
30
30
|
import { fileURLToPath } from 'url';
|
|
31
|
-
import {
|
|
31
|
+
import { satisfies, validRange } from 'semver';
|
|
32
32
|
const dependency = '@qvac/inference';
|
|
33
33
|
const sdkManifest = 'packages/sdk/package.json';
|
|
34
34
|
export function checkAddonRanges(inferencePkg, sdkPkg) {
|
|
@@ -111,39 +111,49 @@ export function checkSharedMajorMinor(sdkPkg) {
|
|
|
111
111
|
}
|
|
112
112
|
return [];
|
|
113
113
|
}
|
|
114
|
-
export function
|
|
114
|
+
export function checkDesktopBare(inferencePkg, bareVersion) {
|
|
115
115
|
const required = inferencePkg.engines?.['bare'];
|
|
116
116
|
if (required === undefined)
|
|
117
117
|
return [];
|
|
118
118
|
if (validRange(required) === null) {
|
|
119
|
-
return [
|
|
119
|
+
return [`${dependency} engines.bare "${required}" is not a valid semver range.`];
|
|
120
120
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
return [`${sdkManifest} must declare a valid bare-runtime dependency range.`];
|
|
121
|
+
if (bareVersion === null) {
|
|
122
|
+
return ['Could not read the Bare version that bare-sidecar ships.'];
|
|
124
123
|
}
|
|
125
|
-
if (!
|
|
124
|
+
if (!satisfies(bareVersion, required)) {
|
|
126
125
|
return [
|
|
127
|
-
`
|
|
128
|
-
'
|
|
126
|
+
`bare-sidecar ships Bare ${bareVersion}, outside ${dependency} engines.bare "${required}". ` +
|
|
127
|
+
'Move the SDK to a bare-sidecar release whose Bare satisfies it.'
|
|
129
128
|
];
|
|
130
129
|
}
|
|
131
130
|
return [];
|
|
132
131
|
}
|
|
133
132
|
export function collectVersionFailures(inferencePkg, sdkPkg) {
|
|
134
|
-
return [
|
|
135
|
-
...checkAddonRanges(inferencePkg, sdkPkg),
|
|
136
|
-
...checkSharedMajorMinor(sdkPkg),
|
|
137
|
-
...checkBareRuntimeRange(inferencePkg, sdkPkg)
|
|
138
|
-
];
|
|
133
|
+
return [...checkAddonRanges(inferencePkg, sdkPkg), ...checkSharedMajorMinor(sdkPkg)];
|
|
139
134
|
}
|
|
140
135
|
function readManifest(dir) {
|
|
141
136
|
return JSON.parse(readFileSync(join(dir, 'package.json'), 'utf8'));
|
|
142
137
|
}
|
|
138
|
+
/** The Bare the installed bare-sidecar ships, from its `versions.json`. */
|
|
139
|
+
function readSidecarBareVersion(sdkDir) {
|
|
140
|
+
try {
|
|
141
|
+
const sidecarDir = dirname(createRequire(join(sdkDir, 'package.json')).resolve('bare-sidecar/package'));
|
|
142
|
+
const { bare } = JSON.parse(readFileSync(join(sidecarDir, 'versions.json'), 'utf8'));
|
|
143
|
+
return typeof bare === 'string' ? bare : null;
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
143
149
|
export function runEnforceInferenceVersionsCli() {
|
|
144
150
|
const sdkDir = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
145
151
|
const inferenceDir = resolve(sdkDir, '..', 'inference');
|
|
146
|
-
const
|
|
152
|
+
const inferencePkg = readManifest(inferenceDir);
|
|
153
|
+
const failures = [
|
|
154
|
+
...collectVersionFailures(inferencePkg, readManifest(sdkDir)),
|
|
155
|
+
...checkDesktopBare(inferencePkg, readSidecarBareVersion(sdkDir))
|
|
156
|
+
];
|
|
147
157
|
if (failures.length > 0) {
|
|
148
158
|
console.error(failures.join('\n\n'));
|
|
149
159
|
process.exit(1);
|