@qvac/sdk 0.22.0 → 0.23.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 +123 -83
- package/README.md +22 -460
- package/dist/examples/asr/parakeet-transcribepsy-filesystem.d.ts +2 -0
- package/dist/examples/asr/parakeet-transcribepsy-filesystem.js +76 -0
- package/dist/examples/diffusion-img2vid-ltx.js +7 -14
- package/dist/examples/diffusion-qwen-image-21.d.ts +2 -0
- package/dist/examples/diffusion-qwen-image-21.js +104 -0
- package/dist/examples/diffusion-txt2vid-ltx.js +7 -14
- package/dist/examples/finetune/llamacpp-finetune.js +9 -4
- package/dist/examples/llamacpp-multimodal.js +3 -1
- package/dist/examples/mcp-websearch.js +1 -1
- package/dist/examples/plugins.js +1 -1
- package/dist/examples/rerank.d.ts +2 -0
- package/dist/examples/rerank.js +33 -0
- package/dist/examples/tools/llamacpp-deferred-tools.js +5 -5
- package/dist/examples/tools/llamacpp-tools-auto-dialect.js +4 -3
- package/dist/examples/tools/llamacpp-tools-gemma4.js +3 -3
- package/dist/examples/tools/llamacpp-tools-qwen35.js +4 -3
- package/dist/scripts/contract/build-contract.d.ts +1 -1
- package/dist/scripts/contract/constants-registry.d.ts +2 -0
- package/dist/scripts/contract/constants-registry.js +2 -1
- package/dist/scripts/contract/method-shapes.d.ts +1 -0
- package/dist/scripts/contract/method-shapes.js +1 -0
- package/dist/src/client/api/assess-model-fit.js +1 -1
- package/dist/src/client/api/audio-edit.js +2 -2
- package/dist/src/client/api/audio-gen-result.js +2 -2
- package/dist/src/client/api/audio-gen.js +2 -2
- package/dist/src/client/api/audio-understand.js +2 -2
- package/dist/src/client/api/batch-completion.js +2 -2
- package/dist/src/client/api/bci-transcribe.js +3 -3
- package/dist/src/client/api/cancel.js +1 -1
- package/dist/src/client/api/classify.js +1 -1
- package/dist/src/client/api/completion-stream.d.ts +2 -1
- package/dist/src/client/api/completion-stream.js +5 -3
- package/dist/src/client/api/decide.d.ts +1 -1
- package/dist/src/client/api/decide.js +3 -3
- package/dist/src/client/api/delete-cache.js +1 -1
- package/dist/src/client/api/diffusion.d.ts +18 -1
- package/dist/src/client/api/diffusion.js +19 -2
- package/dist/src/client/api/download-asset.js +3 -3
- package/dist/src/client/api/embed.js +2 -2
- package/dist/src/client/api/finetune.js +3 -3
- package/dist/src/client/api/get-loaded-model-info.js +1 -1
- package/dist/src/client/api/get-model-info.js +1 -1
- package/dist/src/client/api/get-system-resources.js +1 -1
- package/dist/src/client/api/heartbeat.js +1 -1
- package/dist/src/client/api/index.d.ts +4 -3
- package/dist/src/client/api/index.js +4 -3
- package/dist/src/client/api/invoke-plugin.js +1 -1
- package/dist/src/client/api/load-model.js +4 -4
- package/dist/src/client/api/logging-stream.d.ts +11 -2
- package/dist/src/client/api/logging-stream.js +12 -3
- package/dist/src/client/api/ocr.js +1 -1
- package/dist/src/client/api/rag.js +2 -2
- package/dist/src/client/api/registry.d.ts +2 -1
- package/dist/src/client/api/registry.js +6 -5
- package/dist/src/client/api/rerank.d.ts +22 -0
- package/dist/src/client/api/rerank.js +39 -0
- package/dist/src/client/api/resume.js +1 -1
- package/dist/src/client/api/rpc-server.js +2 -2
- package/dist/src/client/api/state.js +1 -1
- package/dist/src/client/api/subscribe-logs.js +3 -2
- package/dist/src/client/api/suspend.js +1 -1
- package/dist/src/client/api/text-to-speech.js +3 -3
- package/dist/src/client/api/transcribe.d.ts +1 -1
- package/dist/src/client/api/transcribe.js +2 -2
- package/dist/src/client/api/translate.js +2 -2
- package/dist/src/client/api/unload-model.js +2 -2
- package/dist/src/client/api/upscale.js +1 -1
- package/dist/src/client/api/vector-index.d.ts +1 -1
- package/dist/src/client/api/vector-index.js +1 -1
- package/dist/src/client/api/video.js +3 -3
- package/dist/src/client/api/world-result.js +2 -2
- package/dist/src/client/api/world.d.ts +1 -1
- package/dist/src/client/api/world.js +2 -2
- package/dist/src/client/logging-stream-registry.js +9 -6
- package/dist/src/client/plugins-factory.d.ts +1 -1
- package/dist/src/client/plugins-factory.js +1 -1
- package/dist/src/client/rpc/expo-rpc-client.js +3 -3
- package/dist/src/client/rpc/ipc-socket-path.d.ts +11 -0
- package/dist/src/client/rpc/ipc-socket-path.js +30 -0
- package/dist/src/client/rpc/node-rpc-client.js +14 -25
- package/dist/src/client/rpc/rpc-client.d.ts +3 -2
- package/dist/src/client/rpc/rpc-client.js +46 -12
- package/dist/src/client/rpc/rpc-error.js +4 -1
- package/dist/src/commands/bundle/constants.js +1 -0
- package/dist/src/commands/bundle/entry-gen.js +1 -1
- package/dist/src/commands/bundle/index.d.ts +1 -1
- package/dist/src/commands/bundle/index.js +11 -11
- package/dist/src/commands/bundle/plugins.js +1 -1
- package/dist/src/commands/host-prebuilds/index.d.ts +3 -3
- package/dist/src/commands/host-prebuilds/index.js +4 -4
- package/dist/src/commands/index.d.ts +12 -12
- package/dist/src/commands/index.js +7 -7
- package/dist/src/commands/verify/abi.d.ts +1 -1
- package/dist/src/commands/verify/abi.js +1 -1
- package/dist/src/commands/verify/bare-kit-runtime.d.ts +1 -1
- package/dist/src/commands/verify/bare-kit-runtime.js +1 -1
- package/dist/src/commands/verify/bundle-source.d.ts +1 -1
- package/dist/src/commands/verify/bundle-source.js +3 -3
- package/dist/src/commands/verify/engines-advice.d.ts +4 -4
- package/dist/src/commands/verify/engines-advice.js +4 -4
- package/dist/src/commands/verify/index.d.ts +5 -5
- package/dist/src/commands/verify/index.js +7 -7
- package/dist/src/commands/verify/node-modules-source.d.ts +1 -1
- package/dist/src/commands/verify/node-modules-source.js +1 -1
- package/dist/src/commands/verify/prebuilds.d.ts +1 -1
- package/dist/src/commands/verify/prebuilds.js +2 -2
- package/dist/src/commands/verify/resource-collectors.js +2 -2
- package/dist/src/expo/plugins/get-project-root.d.ts +1 -1
- package/dist/src/expo/plugins/link-addons.js +1 -1
- package/dist/src/expo/plugins/withAndroidArchitecture.d.ts +1 -1
- package/dist/src/expo/plugins/withAndroidNdkVersion.d.ts +1 -1
- package/dist/src/expo/plugins/withAndroidNdkVersion.js +16 -10
- package/dist/src/expo/plugins/withDeviceInfo.d.ts +1 -1
- package/dist/src/expo/plugins/withDeviceInfo.js +19 -5
- package/dist/src/expo/plugins/withMobileBundle.d.ts +4 -4
- package/dist/src/expo/plugins/withMobileBundle.js +6 -6
- package/dist/src/expo/plugins/withOpenCL.d.ts +1 -1
- package/dist/src/expo/plugins/withQvacSDK.d.ts +1 -1
- package/dist/src/index.d.ts +4 -4
- package/dist/src/index.js +3 -3
- package/dist/src/logging/addon.d.ts +1 -1
- package/dist/src/logging/base-logger.js +1 -1
- package/dist/src/logging/utils.js +1 -1
- package/dist/src/pear/pre.js +2 -0
- 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-server.d.ts +1 -0
- package/dist/src/schemas/sdk-errors-server.js +6 -1
- package/dist/src/server/rpc/rpc-utils.d.ts +5 -0
- package/dist/src/server/rpc/rpc-utils.js +7 -0
- package/dist/src/server/utils/qvac-paths.js +1 -1
- package/dist/src/server/utils/worker-lock.js +1 -1
- package/dist/src/utils/aggregate-events.d.ts +1 -1
- package/dist/src/utils/aggregate-events.js +2 -2
- package/dist/src/utils/errors-server.d.ts +6 -0
- package/dist/src/utils/errors-server.js +12 -0
- package/dist/src/utils/mcp-adapter.d.ts +1 -1
- package/dist/src/utils/mcp-adapter.js +1 -1
- package/dist/src/utils/tool-helpers.js +1 -1
- package/dist/src/worker/handle-request.js +4 -2
- package/dist/src/worker/handler-utils.js +1 -1
- package/dist/src/worker/index.js +3 -1
- package/dist/src/worker/lifecycle.js +1 -1
- package/dist/src/worker/plugins/llamacpp-rerank.d.ts +2 -0
- package/dist/src/worker/plugins/llamacpp-rerank.js +1 -0
- package/package.json +46 -40
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { close, diffusion, loadModel, unloadModel } from '@qvac/sdk';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
// Combine two reference images into an RGBA image with a transparent background.
|
|
5
|
+
// Use the pinned model revisions from the diffusion addon's Qwen-Image-2.1 downloader.
|
|
6
|
+
// Model terms: https://huggingface.co/Qwen/Qwen-Image-2.1/blob/d26bb61231c349cf6b7896fa83353113880e1ba3/LICENSE
|
|
7
|
+
const HF = 'https://huggingface.co';
|
|
8
|
+
const encoderRepo = `${HF}/Qwen/Qwen3-VL-8B-Instruct-GGUF/resolve/f982a07559d4a2f6c8744d840bf6fccab30eea96`;
|
|
9
|
+
const referencePathA = process.argv[2];
|
|
10
|
+
const referencePathB = process.argv[3];
|
|
11
|
+
const prompt = process.argv[4] ||
|
|
12
|
+
'Place the subjects from both reference images side by side. Generate an RGBA image with a transparent background and no scenery.';
|
|
13
|
+
const outputDir = process.argv[5] || '.';
|
|
14
|
+
const diffusionModelSrc = process.argv[6] ||
|
|
15
|
+
`${HF}/leejet/Qwen-Image-2.1-GGUF/resolve/cc11433936a06e9765f7c0c0b1f0436cfd2b9856/qwen_image_2.1-Q4_K.gguf`;
|
|
16
|
+
const llmModelSrc = process.argv[7] || `${encoderRepo}/Qwen3VL-8B-Instruct-Q4_K_M.gguf`;
|
|
17
|
+
const vaeModelSrc = process.argv[8] ||
|
|
18
|
+
`${HF}/Comfy-Org/Qwen-Image-2.1/resolve/a8342359c61979b06a8dafb1a47991fe1f30e994/vae/qwen_image_2.1_vae_bf16.safetensors`;
|
|
19
|
+
const projectionModelSrc = process.argv[9] || `${encoderRepo}/mmproj-Qwen3VL-8B-Instruct-F16.gguf`;
|
|
20
|
+
const usage = 'Usage: node --import tsx examples/diffusion-qwen-image-21.ts <referenceA> <referenceB> [prompt] [outputDir] [model] [llm] [vae] [projector]';
|
|
21
|
+
if (process.argv.includes('--help')) {
|
|
22
|
+
console.log(usage);
|
|
23
|
+
console.log('▸ Defaults download pinned Hugging Face weights. Model overrides accept paths or URLs.');
|
|
24
|
+
console.log('▸ The default prompt combines both subjects on a transparent background.');
|
|
25
|
+
process.exit(0);
|
|
26
|
+
}
|
|
27
|
+
if (!referencePathA || !referencePathB) {
|
|
28
|
+
console.error('✖ two reference image paths are required');
|
|
29
|
+
console.error(usage);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
function modelSource(source) {
|
|
33
|
+
return /^https?:\/\//.test(source) ? source : path.resolve(source);
|
|
34
|
+
}
|
|
35
|
+
let modelId;
|
|
36
|
+
try {
|
|
37
|
+
const init_images = [referencePathA, referencePathB].map((file) => new Uint8Array(fs.readFileSync(file)));
|
|
38
|
+
console.log('▸ Loading Qwen-Image-2.1 split-layout model...');
|
|
39
|
+
modelId = await loadModel({
|
|
40
|
+
modelSrc: modelSource(diffusionModelSrc),
|
|
41
|
+
modelType: 'sdcpp-generation',
|
|
42
|
+
modelConfig: {
|
|
43
|
+
llmModelSrc: modelSource(llmModelSrc),
|
|
44
|
+
vaeModelSrc: modelSource(vaeModelSrc),
|
|
45
|
+
projectionModelSrc: modelSource(projectionModelSrc),
|
|
46
|
+
flash_attn: true
|
|
47
|
+
},
|
|
48
|
+
onProgress: (progress) => {
|
|
49
|
+
const mb = (bytes) => (bytes / 1e6).toFixed(1);
|
|
50
|
+
const line = `▸ Downloading ${progress.percentage.toFixed(0)}% (${mb(progress.downloaded)}/${mb(progress.total)} MB)`;
|
|
51
|
+
process.stderr.write(process.stderr.isTTY ? `\r${line}` : `${line}\n`);
|
|
52
|
+
if (progress.percentage >= 100)
|
|
53
|
+
process.stderr.write('\n');
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
console.log(`▸ Model loaded: ${modelId}`);
|
|
57
|
+
console.log(`▸ Generating from "${referencePathA}" and "${referencePathB}": "${prompt}"`);
|
|
58
|
+
const { progressStream, outputs, stats } = diffusion({
|
|
59
|
+
modelId,
|
|
60
|
+
prompt,
|
|
61
|
+
init_images,
|
|
62
|
+
width: 512,
|
|
63
|
+
height: 512,
|
|
64
|
+
steps: 30,
|
|
65
|
+
cfg_scale: 6,
|
|
66
|
+
sampling_method: 'euler',
|
|
67
|
+
seed: 42
|
|
68
|
+
});
|
|
69
|
+
for await (const { step, totalSteps } of progressStream) {
|
|
70
|
+
console.log(`▸ step ${step}/${totalSteps}`);
|
|
71
|
+
}
|
|
72
|
+
const buffers = await outputs;
|
|
73
|
+
if (buffers.length === 0)
|
|
74
|
+
throw new Error('Qwen-Image-2.1 returned no image.');
|
|
75
|
+
for (let i = 0; i < buffers.length; i++) {
|
|
76
|
+
const outputPath = path.join(outputDir, `qwen_image_21_${i}.png`);
|
|
77
|
+
fs.writeFileSync(outputPath, buffers[i]);
|
|
78
|
+
console.log(`▸ Saved ${outputPath}`);
|
|
79
|
+
}
|
|
80
|
+
console.log('▸ Stats:', await stats);
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
console.error('✖', error);
|
|
84
|
+
process.exitCode = 1;
|
|
85
|
+
}
|
|
86
|
+
finally {
|
|
87
|
+
try {
|
|
88
|
+
if (modelId)
|
|
89
|
+
await unloadModel({ modelId, clearStorage: false });
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
console.error('✖ Unload failed:', error);
|
|
93
|
+
process.exitCode = 1;
|
|
94
|
+
}
|
|
95
|
+
try {
|
|
96
|
+
await close();
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
console.error('✖ Cleanup failed:', error);
|
|
100
|
+
process.exitCode = 1;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (!process.exitCode)
|
|
104
|
+
console.log('▸ Done');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { loadModel, unloadModel, video } from '@qvac/sdk';
|
|
1
|
+
import { GEMMA_3_12B_Q4_K_XL, loadModel, LTX_2_3_22B_DISTILLED_EMBEDDINGS_CONNECTORS, LTX_2_3_22B_Q5_K_M, LTX_2_3_AUDIO_VAE, LTX_2_3_VIDEO_VAE, unloadModel, video } from '@qvac/sdk';
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
// Text-to-video (+ synchronized audio) with LTX-2. Unlike Wan, LTX-2 uses a
|
|
@@ -10,19 +10,12 @@ import path from 'path';
|
|
|
10
10
|
// This example needs powerful hardware: LTX-2.3 is a ~21B model, budget at
|
|
11
11
|
// least 20+ GB of video / unified memory.
|
|
12
12
|
//
|
|
13
|
-
//
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
const llmModelSrc = process.argv[3] || `${HF}/unsloth/gemma-3-12b-it-GGUF/resolve/main/gemma-3-12b-it-UD-Q4_K_XL.gguf`;
|
|
20
|
-
const vaeModelSrc = process.argv[4] ||
|
|
21
|
-
`${HF}/unsloth/LTX-2.3-GGUF/resolve/main/vae/ltx-2.3-22b-distilled_video_vae.safetensors`;
|
|
22
|
-
const audioVaeModelSrc = process.argv[5] ||
|
|
23
|
-
`${HF}/unsloth/LTX-2.3-GGUF/resolve/main/vae/ltx-2.3-22b-distilled_audio_vae.safetensors`;
|
|
24
|
-
const embeddingsConnectorsModelSrc = process.argv[6] ||
|
|
25
|
-
`${HF}/unsloth/LTX-2.3-GGUF/resolve/main/text_encoders/ltx-2.3-22b-distilled_embeddings_connectors.safetensors`;
|
|
13
|
+
// Pass your own paths / URLs via argv to override any of the five sources.
|
|
14
|
+
const diffusionModelSrc = process.argv[2] || LTX_2_3_22B_Q5_K_M;
|
|
15
|
+
const llmModelSrc = process.argv[3] || GEMMA_3_12B_Q4_K_XL;
|
|
16
|
+
const vaeModelSrc = process.argv[4] || LTX_2_3_VIDEO_VAE;
|
|
17
|
+
const audioVaeModelSrc = process.argv[5] || LTX_2_3_AUDIO_VAE;
|
|
18
|
+
const embeddingsConnectorsModelSrc = process.argv[6] || LTX_2_3_22B_DISTILLED_EMBEDDINGS_CONNECTORS;
|
|
26
19
|
const prompt = process.argv[7] || 'a claymation cat playing jazz on a piano';
|
|
27
20
|
const outputDir = process.argv[8] || '.';
|
|
28
21
|
try {
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
1
3
|
import { finetune, loadModel, QWEN3_600M_INST_Q4, unloadModel } from '@qvac/sdk';
|
|
2
4
|
const pauseResumeEnabled = process.argv.includes('--pause-resume');
|
|
5
|
+
// The worker resolves dataset paths against the process working directory, so
|
|
6
|
+
// derive them from this file's own folder instead.
|
|
7
|
+
const datasetDir = path.dirname(fileURLToPath(import.meta.url));
|
|
3
8
|
let modelId;
|
|
4
9
|
let exitCode = 0;
|
|
5
10
|
async function readProgress(handle, onTick) {
|
|
@@ -22,10 +27,10 @@ try {
|
|
|
22
27
|
const finetuneParams = {
|
|
23
28
|
modelId: loadedModelId,
|
|
24
29
|
options: {
|
|
25
|
-
trainDatasetDir: '
|
|
30
|
+
trainDatasetDir: path.join(datasetDir, 'train.jsonl'),
|
|
26
31
|
validation: {
|
|
27
32
|
type: 'dataset',
|
|
28
|
-
path: '
|
|
33
|
+
path: path.join(datasetDir, 'eval.jsonl')
|
|
29
34
|
},
|
|
30
35
|
numberOfEpochs: 2,
|
|
31
36
|
learningRate: 1e-4,
|
|
@@ -33,8 +38,8 @@ try {
|
|
|
33
38
|
loraModules: 'attn_q,attn_k,attn_v,attn_o,ffn_gate,ffn_up,ffn_down',
|
|
34
39
|
assistantLossOnly: true,
|
|
35
40
|
checkpointSaveSteps: 2,
|
|
36
|
-
checkpointSaveDir: './
|
|
37
|
-
outputParametersDir: './
|
|
41
|
+
checkpointSaveDir: './finetune-output/checkpoints',
|
|
42
|
+
outputParametersDir: './finetune-output'
|
|
38
43
|
}
|
|
39
44
|
};
|
|
40
45
|
const handle = finetune(finetuneParams);
|
|
@@ -10,7 +10,9 @@ try {
|
|
|
10
10
|
const modelId = await loadModel({
|
|
11
11
|
modelSrc: SMOLVLM2_500M_MULTIMODAL_Q8_0,
|
|
12
12
|
modelConfig: {
|
|
13
|
-
|
|
13
|
+
// An image is tiled into hundreds of context units before a single word
|
|
14
|
+
// of the prompt is counted, and the comparison below sends two at once.
|
|
15
|
+
ctx_size: 8192,
|
|
14
16
|
projectionModelSrc: MMPROJ_SMOLVLM2_500M_MULTIMODAL_Q8_0
|
|
15
17
|
},
|
|
16
18
|
onProgress: (p) => {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*
|
|
10
10
|
* Run with: npx tsx examples/mcp-websearch.ts
|
|
11
11
|
*/
|
|
12
|
-
import { completion, loadModel, unloadModel, QWEN3_1_7B_INST_Q4 } from '
|
|
12
|
+
import { completion, loadModel, unloadModel, QWEN3_1_7B_INST_Q4 } from '@qvac/sdk';
|
|
13
13
|
// MCP SDK is a user-installed optional dependency
|
|
14
14
|
// Install with: npm install @modelcontextprotocol/sdk
|
|
15
15
|
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
package/dist/examples/plugins.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* 3. Embeddings -> fails (plugin not selected)
|
|
11
11
|
*
|
|
12
12
|
*/
|
|
13
|
-
import { bundleSdk } from '
|
|
13
|
+
import { bundleSdk } from '@qvac/sdk/commands';
|
|
14
14
|
import { existsSync, rmSync } from 'fs';
|
|
15
15
|
import path from 'path';
|
|
16
16
|
const configDir = import.meta.dirname ?? process.cwd();
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { loadModel, rerank, unloadModel, close } from '@qvac/sdk';
|
|
2
|
+
// Any reranker (cross-encoder) GGUF, such as bge-reranker, jina-reranker or Qwen3-Reranker.
|
|
3
|
+
const modelSrc = process.argv[2] ??
|
|
4
|
+
'https://huggingface.co/ggml-org/models/resolve/499bc8821c6b12b4e53c5bffcb21ec206f212d81/jina-reranker-v1-tiny-en/ggml-model-f16.gguf';
|
|
5
|
+
const query = 'How do I get a refund for a duplicate charge?';
|
|
6
|
+
const documents = [
|
|
7
|
+
'Refunds for duplicate or failed payments are issued within 5 business days.',
|
|
8
|
+
'Our office is open Monday to Friday, 9am to 5pm.',
|
|
9
|
+
'To change your password, open Settings and choose Security.',
|
|
10
|
+
'If you were charged twice, contact billing with both transaction IDs.'
|
|
11
|
+
];
|
|
12
|
+
let modelId;
|
|
13
|
+
try {
|
|
14
|
+
console.error('▸ Loading reranker');
|
|
15
|
+
modelId = await loadModel({ modelSrc, modelType: 'llamacpp-rerank' });
|
|
16
|
+
// One score per document, in input order. Higher is more relevant.
|
|
17
|
+
const scores = await rerank({ modelId, query, documents });
|
|
18
|
+
const ranked = documents
|
|
19
|
+
.map((document, index) => ({ score: scores[index], document }))
|
|
20
|
+
.sort((a, b) => b.score - a.score);
|
|
21
|
+
console.log(`Query: ${query}\n`);
|
|
22
|
+
for (const { score, document } of ranked)
|
|
23
|
+
console.log(`${score.toFixed(3)} ${document}`);
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
console.error('✖', error);
|
|
27
|
+
process.exitCode = 1;
|
|
28
|
+
}
|
|
29
|
+
finally {
|
|
30
|
+
if (modelId)
|
|
31
|
+
await unloadModel({ modelId });
|
|
32
|
+
await close();
|
|
33
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Deferred tool loading: a large tool set stays out of the prompt until the
|
|
2
2
|
// model asks for it. Only `get_weather` and the built-in `tool_search` (whose
|
|
3
3
|
// description carries a name-and-description catalog of the rest) are in the
|
|
4
|
-
// initial prompt;
|
|
5
|
-
//
|
|
4
|
+
// initial prompt; a deferred schema is declared in the prompt once the model
|
|
5
|
+
// has searched for it.
|
|
6
6
|
import { TOOL_SEARCH_NAME, completion, executeToolSearch, loadModel, unloadModel, QWEN3_1_7B_INST_Q4 } from '@qvac/sdk';
|
|
7
7
|
import { z } from 'zod';
|
|
8
8
|
import { weatherSchema, horoscopeSchema, mockExecute } from './shared.js';
|
|
@@ -52,14 +52,14 @@ try {
|
|
|
52
52
|
else {
|
|
53
53
|
console.log(`\n\n▸ The model searched: ${JSON.stringify(search.arguments)}`);
|
|
54
54
|
// Running the search is the SDK's job, not a tool handler's. The result is
|
|
55
|
-
// an ordinary tool message
|
|
56
|
-
//
|
|
55
|
+
// an ordinary tool message naming what it loaded: keeping it in the history
|
|
56
|
+
// is what declares those definitions on the next turn.
|
|
57
57
|
history.push({ role: 'assistant', content: await first.text });
|
|
58
58
|
history.push({
|
|
59
59
|
role: 'tool',
|
|
60
60
|
content: executeToolSearch(tools, search.arguments, history)
|
|
61
61
|
});
|
|
62
|
-
console.log('▸ Definitions
|
|
62
|
+
console.log('▸ Definitions loaded. Turn 2 — the model can now call them directly.\n');
|
|
63
63
|
const second = completion({ modelId, history, stream: true, tools });
|
|
64
64
|
for await (const token of second.tokenStream)
|
|
65
65
|
process.stdout.write(token);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Tool-calling example with automatic dialect detection.
|
|
3
3
|
*
|
|
4
|
-
* The SDK infers the tool-call format from the model name
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* The SDK infers the tool-call format from the model name or file name, and
|
|
5
|
+
* from the GGUF architecture when the name matches no known pattern. It
|
|
6
|
+
* supports model families such as Qwen3.5/3.6/3.8, Gemma4, GPT-OSS,
|
|
7
|
+
* DeepSeek V3.2/V4, and LFM without requiring a toolDialect override.
|
|
7
8
|
*
|
|
8
9
|
* Usage:
|
|
9
10
|
* node dist/examples/tools/llamacpp-tools-auto-dialect.js <model-src>
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
* frames, which are stripped from contentDelta and forwarded as thinkingDelta
|
|
9
9
|
* when captureThinking is true.
|
|
10
10
|
*
|
|
11
|
-
* The dialect is auto-detected
|
|
12
|
-
*
|
|
13
|
-
* completion() if
|
|
11
|
+
* The dialect is auto-detected when the model name or file name contains
|
|
12
|
+
* "gemma4" or "gemma-4", or when the GGUF architecture is `gemma4`. Pass
|
|
13
|
+
* toolDialect: "gemma4" explicitly to completion() if detection does not pick it up.
|
|
14
14
|
*
|
|
15
15
|
* Usage:
|
|
16
16
|
* node dist/examples/tools/llamacpp-tools-gemma4.js <model-url>
|
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
* Qwen3.5 emits tool calls in a Pythonic-XML format:
|
|
5
5
|
* <tool_call><function=NAME><parameter=KEY>VALUE</parameter></function></tool_call>
|
|
6
6
|
*
|
|
7
|
-
* The dialect is auto-detected
|
|
8
|
-
*
|
|
9
|
-
* toolDialect: "qwen35" explicitly if
|
|
7
|
+
* The dialect is auto-detected when the model name or file name contains
|
|
8
|
+
* "qwen3.5", "qwen3-5", "qwen3.6", or "qwen3-6", or when the GGUF architecture is
|
|
9
|
+
* `qwen35` or `qwen35moe`. Pass toolDialect: "qwen35" explicitly if detection
|
|
10
|
+
* does not pick it up.
|
|
10
11
|
*
|
|
11
12
|
* Usage:
|
|
12
13
|
* node dist/examples/tools/llamacpp-tools-qwen35.js <model-url>
|
|
@@ -21,7 +21,7 @@ export declare function buildContract(): {
|
|
|
21
21
|
condition: string;
|
|
22
22
|
responseSchema: string;
|
|
23
23
|
};
|
|
24
|
-
name: "audioGenStream" | "audioEditStream" | "audioUnderstand" | "startRpcServer" | "stopRpcServer" | "discoverRpcServers" | "heartbeat" | "loadModel" | "downloadAsset" | "completionStream" | "completionOrchestrate" | "batchCompletionStream" | "unloadModel" | "transcribe" | "transcribeStream" | "bciTranscribe" | "bciTranscribeStream" | "loggingStream" | "embed" | "translate" | "textToSpeech" | "textToSpeechStream" | "cancel" | "finetune" | "rag" | "vectorIndex" | "deleteCache" | "getModelInfo" | "getLoadedModelInfo" | "getSystemResources" | "assessModelFit" | "ocrStream" | "diffusionStream" | "videoStream" | "upscaleStream" | "worldSceneStream" | "worldStepStream" | "resume" | "pluginInvoke" | "pluginInvokeStream" | "modelRegistryList" | "modelRegistrySearch" | "modelRegistryGetModel" | "suspend" | "state" | "classify" | "decide";
|
|
24
|
+
name: "audioGenStream" | "audioEditStream" | "audioUnderstand" | "startRpcServer" | "stopRpcServer" | "discoverRpcServers" | "heartbeat" | "loadModel" | "downloadAsset" | "completionStream" | "completionOrchestrate" | "batchCompletionStream" | "unloadModel" | "transcribe" | "transcribeStream" | "bciTranscribe" | "bciTranscribeStream" | "loggingStream" | "embed" | "translate" | "textToSpeech" | "textToSpeechStream" | "cancel" | "rerank" | "finetune" | "rag" | "vectorIndex" | "deleteCache" | "getModelInfo" | "getLoadedModelInfo" | "getSystemResources" | "assessModelFit" | "ocrStream" | "diffusionStream" | "videoStream" | "upscaleStream" | "worldSceneStream" | "worldStepStream" | "resume" | "pluginInvoke" | "pluginInvokeStream" | "modelRegistryList" | "modelRegistrySearch" | "modelRegistryGetModel" | "suspend" | "state" | "classify" | "decide";
|
|
25
25
|
callShape: "duplex" | "request-reply" | "server-stream";
|
|
26
26
|
requestSchema: string;
|
|
27
27
|
responseSchema: string;
|
|
@@ -30,6 +30,7 @@ export declare const constantsRegistry: {
|
|
|
30
30
|
readonly bciWhispercppTranscription: "bci-whispercpp-transcription";
|
|
31
31
|
readonly llamacppEmbedding: "llamacpp-embedding";
|
|
32
32
|
readonly llamacppDecision: "llamacpp-decision";
|
|
33
|
+
readonly llamacppRerank: "llamacpp-rerank";
|
|
33
34
|
readonly nmtcppTranslation: "nmtcpp-translation";
|
|
34
35
|
readonly onnxTts: "onnx-tts";
|
|
35
36
|
readonly ttsGgml: "tts-ggml";
|
|
@@ -51,6 +52,7 @@ export declare const constantsRegistry: {
|
|
|
51
52
|
readonly LLM: "@qvac/sdk/llamacpp-completion/plugin";
|
|
52
53
|
readonly EMBEDDING: "@qvac/sdk/llamacpp-embedding/plugin";
|
|
53
54
|
readonly DECISION: "@qvac/sdk/llamacpp-decision/plugin";
|
|
55
|
+
readonly RERANK: "@qvac/sdk/llamacpp-rerank/plugin";
|
|
54
56
|
readonly WHISPER: "@qvac/sdk/whispercpp-transcription/plugin";
|
|
55
57
|
readonly BCI: "@qvac/sdk/bci-whispercpp-transcription/plugin";
|
|
56
58
|
readonly MOSS_TRANSCRIBE: "@qvac/sdk/moss-transcribe/plugin";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
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_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';
|
|
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';
|
|
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
|
|
@@ -39,6 +39,7 @@ export const constantsRegistry = {
|
|
|
39
39
|
LLM: PLUGIN_LLM,
|
|
40
40
|
EMBEDDING: PLUGIN_EMBEDDING,
|
|
41
41
|
DECISION: PLUGIN_DECISION,
|
|
42
|
+
RERANK: PLUGIN_RERANK,
|
|
42
43
|
WHISPER: PLUGIN_WHISPER,
|
|
43
44
|
BCI: PLUGIN_BCI,
|
|
44
45
|
MOSS_TRANSCRIBE: PLUGIN_MOSS_TRANSCRIBE,
|
|
@@ -26,6 +26,7 @@ export declare const methodShapes: {
|
|
|
26
26
|
readonly downloadAsset: "reply";
|
|
27
27
|
readonly embed: "reply";
|
|
28
28
|
readonly decide: "reply";
|
|
29
|
+
readonly rerank: "reply";
|
|
29
30
|
readonly finetune: "reply";
|
|
30
31
|
readonly getLoadedModelInfo: "reply";
|
|
31
32
|
readonly getModelInfo: "reply";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { assessModelFitInputSchema, inferModelTypeFromModelSrc } from '@qvac/inference/surface';
|
|
2
|
-
import { send } from '
|
|
2
|
+
import { send } from '../../client/rpc/rpc-client.js';
|
|
3
3
|
import { InvalidResponseError, ModelTypeRequiredError } from '../../utils/errors-client.js';
|
|
4
4
|
/**
|
|
5
5
|
* Names the engine a candidate omitted, from the source it carries.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { stream as streamRpc } from '
|
|
2
|
-
import { createAudioEditResult } from '
|
|
1
|
+
import { stream as streamRpc } from '../../client/rpc/rpc-client.js';
|
|
2
|
+
import { createAudioEditResult } from '../../client/api/audio-gen-result.js';
|
|
3
3
|
/**
|
|
4
4
|
* Edits a source recording with a loaded ACE-Step AudioGen model: an ordered
|
|
5
5
|
* pipeline of `flow-edit` and `repaint` operations, executed in array order.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { audioEditClientParamsSchema, audioEditStreamResponseSchema, audioGenClientParamsSchema, audioGenStreamResponseSchema, audioUnderstandClientParamsSchema, audioUnderstandResponseSchema } from '@qvac/inference/surface';
|
|
2
|
-
import { parseClientInput } from '
|
|
3
|
-
import { generateClientRequestId } from '
|
|
2
|
+
import { parseClientInput } from '../../client/parse-input.js';
|
|
3
|
+
import { generateClientRequestId } from '../../client/api/client-request-id.js';
|
|
4
4
|
import { decodeBase64 } from '../../utils/encoding.js';
|
|
5
5
|
import { InvalidResponseError } from '../../utils/errors-client.js';
|
|
6
6
|
import { InferenceCancelledError } from '../../utils/errors-server.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { stream as streamRpc } from '
|
|
2
|
-
import { createAudioGenResult } from '
|
|
1
|
+
import { stream as streamRpc } from '../../client/rpc/rpc-client.js';
|
|
2
|
+
import { createAudioGenResult } from '../../client/api/audio-gen-result.js';
|
|
3
3
|
/**
|
|
4
4
|
* Generates PCM audio using a loaded AudioGen model.
|
|
5
5
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { stream as streamRpc } from '
|
|
2
|
-
import { createAudioUnderstandResult } from '
|
|
1
|
+
import { stream as streamRpc } from '../../client/rpc/rpc-client.js';
|
|
2
|
+
import { createAudioUnderstandResult } from '../../client/api/audio-gen-result.js';
|
|
3
3
|
/**
|
|
4
4
|
* Describes a recording with a loaded ACE-Step AudioGen model, running the
|
|
5
5
|
* engine's reverse pipeline: the PCM is encoded, its FSQ semantic codes are
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { stream as streamRpc } from '
|
|
2
|
-
import { generateClientRequestId } from '
|
|
1
|
+
import { stream as streamRpc } from '../../client/rpc/rpc-client.js';
|
|
2
|
+
import { generateClientRequestId } from '../../client/api/client-request-id.js';
|
|
3
3
|
import { getClientLogger } from '../../logging/index.js';
|
|
4
4
|
import { batchCompletionStreamResponseSchema } from '@qvac/inference/surface';
|
|
5
5
|
import { buildFinalFromEvents } from '../../utils/aggregate-events.js';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { bciTranscribeResponseSchema, bciTranscribeClientParamsSchema, bciTranscribeStreamResponseSchema } from '@qvac/inference/surface';
|
|
2
|
-
import { stream, duplex } from '
|
|
2
|
+
import { stream, duplex } from '../../client/rpc/rpc-client.js';
|
|
3
3
|
import { getClientLogger } from '../../logging/index.js';
|
|
4
4
|
import { TranscriptionFailedError } from '../../utils/errors-client.js';
|
|
5
5
|
import { decoratePromise } from '../../utils/decorate-promise.js';
|
|
6
|
-
import { parseClientInput } from '
|
|
7
|
-
import { generateClientRequestId } from '
|
|
6
|
+
import { parseClientInput } from '../../client/parse-input.js';
|
|
7
|
+
import { generateClientRequestId } from '../../client/api/client-request-id.js';
|
|
8
8
|
const logger = getClientLogger();
|
|
9
9
|
function buildBciTranscribeRequest(params, requestId) {
|
|
10
10
|
return {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { classifyResponseSchema } from '@qvac/inference/surface';
|
|
2
|
-
import { stream as streamRpc } from '
|
|
2
|
+
import { stream as streamRpc } from '../../client/rpc/rpc-client.js';
|
|
3
3
|
import { encodeBase64 } from '../../utils/encoding.js';
|
|
4
4
|
/**
|
|
5
5
|
* Classifies an image using a loaded classification model.
|
|
@@ -28,7 +28,7 @@ type CompletionParams = Omit<CompletionClientParams, 'tools'> & {
|
|
|
28
28
|
* @param params.mcp - Optional array of MCP client inputs for tool integration
|
|
29
29
|
* @param params.captureThinking - Best-effort parsing of `<think>` blocks into `thinkingDelta` events; `final.raw.fullText` always preserves the original output
|
|
30
30
|
* @param params.emitRawDeltas - When true, every raw model token is also emitted as a `rawDelta` event
|
|
31
|
-
* @param params.toolDialect - Override the SDK's name
|
|
31
|
+
* @param params.toolDialect - Override the SDK's dialect detection, which uses the model name, then the GGUF `general.architecture`, then `"hermes"`. Supported values: `"hermes"`, `"pythonic"`, `"json"`, `"harmony"`, `"qwen35"` (Qwen3.5/3.6/3.8), `"gemma4"`, `"dsml"` (DeepSeek V3.2/V4). Use when detection picks the wrong dialect for your model. Drives both streaming frame detection and finalization parsing.
|
|
32
32
|
* Common override case: Llama 3.x tool-calling fine-tunes that emit the native pythonic header (`<|start_header_id|>tool_call<|end_header_id|>...<|eot_id|>`).
|
|
33
33
|
* @param params.responseFormat - Optional structured-output constraint applied to the model's output:
|
|
34
34
|
* - `{ type: "text" }` — no constraint (default behavior)
|
|
@@ -45,6 +45,7 @@ type CompletionParams = Omit<CompletionClientParams, 'tools'> & {
|
|
|
45
45
|
* validation must encode it explicitly in `schema`.
|
|
46
46
|
*
|
|
47
47
|
* Cannot be combined with `tools` (tools already constrain output via their parameter schema).
|
|
48
|
+
* @param params.prefill - Evaluate the prompt and tools without generating an answer. Requires an enabled kvCache; cannot force tool_choice. Await final before sending the question with the same prefix.
|
|
48
49
|
* @param params.kvCache - Optional KV cache configuration. Cache files are organized hierarchically:
|
|
49
50
|
* - Structure: `{kvCacheKey}/{modelId}/{configHash}.bin`
|
|
50
51
|
* - The configHash includes model config + system prompt to ensure cache isolation
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { stream as streamRpc } from '
|
|
1
|
+
import { stream as streamRpc } from '../../client/rpc/rpc-client.js';
|
|
2
2
|
import { getClientLogger } from '../../logging/index.js';
|
|
3
3
|
import { completionStreamResponseSchema } from '@qvac/inference/surface';
|
|
4
4
|
import { CompletionFailedError, InferenceCancelledError } from '../../utils/errors-server.js';
|
|
5
5
|
import { getMcpToolsWithHandlers } from '../../utils/mcp-adapter.js';
|
|
6
6
|
import { validateTools } from '../../utils/tool-helpers.js';
|
|
7
7
|
import { buildFinalFromEvents } from '../../utils/aggregate-events.js';
|
|
8
|
-
import { generateClientRequestId } from '
|
|
8
|
+
import { generateClientRequestId } from '../../client/api/client-request-id.js';
|
|
9
9
|
const logger = getClientLogger();
|
|
10
10
|
/**
|
|
11
11
|
* Generates completion from a language model based on conversation history.
|
|
@@ -28,7 +28,7 @@ const logger = getClientLogger();
|
|
|
28
28
|
* @param params.mcp - Optional array of MCP client inputs for tool integration
|
|
29
29
|
* @param params.captureThinking - Best-effort parsing of `<think>` blocks into `thinkingDelta` events; `final.raw.fullText` always preserves the original output
|
|
30
30
|
* @param params.emitRawDeltas - When true, every raw model token is also emitted as a `rawDelta` event
|
|
31
|
-
* @param params.toolDialect - Override the SDK's name
|
|
31
|
+
* @param params.toolDialect - Override the SDK's dialect detection, which uses the model name, then the GGUF `general.architecture`, then `"hermes"`. Supported values: `"hermes"`, `"pythonic"`, `"json"`, `"harmony"`, `"qwen35"` (Qwen3.5/3.6/3.8), `"gemma4"`, `"dsml"` (DeepSeek V3.2/V4). Use when detection picks the wrong dialect for your model. Drives both streaming frame detection and finalization parsing.
|
|
32
32
|
* Common override case: Llama 3.x tool-calling fine-tunes that emit the native pythonic header (`<|start_header_id|>tool_call<|end_header_id|>...<|eot_id|>`).
|
|
33
33
|
* @param params.responseFormat - Optional structured-output constraint applied to the model's output:
|
|
34
34
|
* - `{ type: "text" }` — no constraint (default behavior)
|
|
@@ -45,6 +45,7 @@ const logger = getClientLogger();
|
|
|
45
45
|
* validation must encode it explicitly in `schema`.
|
|
46
46
|
*
|
|
47
47
|
* Cannot be combined with `tools` (tools already constrain output via their parameter schema).
|
|
48
|
+
* @param params.prefill - Evaluate the prompt and tools without generating an answer. Requires an enabled kvCache; cannot force tool_choice. Await final before sending the question with the same prefix.
|
|
48
49
|
* @param params.kvCache - Optional KV cache configuration. Cache files are organized hierarchically:
|
|
49
50
|
* - Structure: `{kvCacheKey}/{modelId}/{configHash}.bin`
|
|
50
51
|
* - The configHash includes model config + system prompt to ensure cache isolation
|
|
@@ -183,6 +184,7 @@ export function completion(params) {
|
|
|
183
184
|
modelId: params.modelId,
|
|
184
185
|
history: params.history.map((message) => ({ ...message, content: message.content ?? '' })),
|
|
185
186
|
kvCache: params.kvCache,
|
|
187
|
+
prefill: params.prefill,
|
|
186
188
|
tools: allTools.length > 0 ? allTools : undefined,
|
|
187
189
|
stream: params.stream ?? true,
|
|
188
190
|
generationParams: params.generationParams,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { send } from '
|
|
1
|
+
import { send } from '../../client/rpc/rpc-client.js';
|
|
2
2
|
import { type DecideParams, type DecisionResult, type DecisionResponse, type RPCOptions } from '@qvac/inference/surface';
|
|
3
3
|
/**
|
|
4
4
|
* Answers typed decision questions about one state or a batch of states.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { parseClientInput } from '
|
|
2
|
-
import { send } from '
|
|
1
|
+
import { parseClientInput } from '../../client/parse-input.js';
|
|
2
|
+
import { send } from '../../client/rpc/rpc-client.js';
|
|
3
3
|
import { decideParamsSchema, decideResponseSchema } from '@qvac/inference/surface';
|
|
4
4
|
import { InvalidResponseError } from '../../utils/errors-client.js';
|
|
5
5
|
import { decoratePromise } from '../../utils/decorate-promise.js';
|
|
6
|
-
import { generateClientRequestId } from '
|
|
6
|
+
import { generateClientRequestId } from '../../client/api/client-request-id.js';
|
|
7
7
|
export function decide(params, options) {
|
|
8
8
|
return createDecisionCall(params, options);
|
|
9
9
|
}
|
|
@@ -14,8 +14,11 @@ interface DiffusionResult {
|
|
|
14
14
|
*
|
|
15
15
|
* @param params - Diffusion request parameters (model, prompt, dimensions, sampler, seed, etc.).
|
|
16
16
|
* @returns A result object exposing `progressStream` (async iterator of `{ step, totalSteps, elapsedMs }`), `outputs` (promise of the generated image buffers), and `stats` (promise of generation statistics).
|
|
17
|
+
* @throws {InferenceCancelledError} The run's promises reject and progress stream throws when an active generation is cancelled.
|
|
18
|
+
* @throws {RequestRejectedByPolicyError} The run rejects when another image or video generation owns the model.
|
|
17
19
|
*
|
|
18
|
-
* Supports
|
|
20
|
+
* Supports txt2img without input images, img2img via `init_image`,
|
|
21
|
+
* and ordered multi-reference editing via `init_images` on supported models.
|
|
19
22
|
*
|
|
20
23
|
* @example
|
|
21
24
|
* ```typescript
|
|
@@ -49,6 +52,20 @@ interface DiffusionResult {
|
|
|
49
52
|
* height: 768,
|
|
50
53
|
* });
|
|
51
54
|
*
|
|
55
|
+
* // Qwen-Image-2.1 reference editing. Load the matching Qwen3-VL encoder,
|
|
56
|
+
* // vision projector, and 2.1 VAE from your local files first.
|
|
57
|
+
* const { outputs: edited } = diffusion({
|
|
58
|
+
* modelId,
|
|
59
|
+
* prompt: "Place the two referenced people together in one office.",
|
|
60
|
+
* init_images: [refA, refB],
|
|
61
|
+
* width: 512,
|
|
62
|
+
* height: 512,
|
|
63
|
+
* steps: 30,
|
|
64
|
+
* cfg_scale: 6,
|
|
65
|
+
* sampling_method: "euler",
|
|
66
|
+
* seed: 42,
|
|
67
|
+
* });
|
|
68
|
+
*
|
|
52
69
|
* // LoRA adapter for this generation (absolute path required).
|
|
53
70
|
* // Persistence across subsequent diffusion() calls is controlled at
|
|
54
71
|
* // loadModel time via `modelConfig.lora_apply_mode`.
|