@qvac/sdk 0.21.1 → 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.
Files changed (249) hide show
  1. package/NOTICE +131 -62
  2. package/README.md +31 -326
  3. package/dist/examples/abot-world.js +1 -1
  4. package/dist/examples/advisory-model-fit.d.ts +0 -58
  5. package/dist/examples/advisory-model-fit.js +23 -150
  6. package/dist/examples/asr/moss-transcribe-filesystem.d.ts +2 -0
  7. package/dist/examples/asr/moss-transcribe-filesystem.js +84 -0
  8. package/dist/examples/asr/moss-transcribe-fit.d.ts +2 -0
  9. package/dist/examples/asr/moss-transcribe-fit.js +40 -0
  10. package/dist/examples/asr/nemotron-diarization-filesystem.d.ts +2 -0
  11. package/dist/examples/asr/nemotron-diarization-filesystem.js +64 -0
  12. package/dist/examples/asr/parakeet-ctc-filesystem.js +2 -2
  13. package/dist/examples/asr/parakeet-indic-conformer-filesystem.js +2 -2
  14. package/dist/examples/asr/parakeet-microphone-record.js +1 -1
  15. package/dist/examples/asr/parakeet-microphone-stream.js +1 -1
  16. package/dist/examples/asr/parakeet-nemotron-filesystem.js +3 -3
  17. package/dist/examples/asr/parakeet-sortformer-streaming.js +2 -2
  18. package/dist/examples/asr/parakeet-sortformer.js +1 -1
  19. package/dist/examples/asr/parakeet-tdt-filesystem-chunked.js +2 -2
  20. package/dist/examples/asr/parakeet-tdt-filesystem.js +2 -2
  21. package/dist/examples/asr/parakeet-transcribepsy-filesystem.d.ts +2 -0
  22. package/dist/examples/asr/parakeet-transcribepsy-filesystem.js +76 -0
  23. package/dist/examples/asr/parakeet-unified-coreml.js +2 -2
  24. package/dist/examples/asr/parakeet-unified-filesystem.js +2 -2
  25. package/dist/examples/asr/whispercpp-filesystem-streaming.js +1 -1
  26. package/dist/examples/asr/whispercpp-filesystem.js +1 -1
  27. package/dist/examples/asr/whispercpp-microphone-record.js +1 -1
  28. package/dist/examples/asr/whispercpp-prompt.js +1 -1
  29. package/dist/examples/assess-model-fit.js +3 -6
  30. package/dist/examples/audiogen/edit-music.js +2 -2
  31. package/dist/examples/audiogen/generate-cover.js +2 -2
  32. package/dist/examples/audiogen/generate-music-minimax.js +1 -1
  33. package/dist/examples/audiogen/generate-music.js +1 -1
  34. package/dist/examples/audiogen/understand-music.js +2 -2
  35. package/dist/examples/batch-completion.d.ts +1 -1
  36. package/dist/examples/batch-completion.js +1 -1
  37. package/dist/examples/bci/bci-filesystem-streaming.js +2 -2
  38. package/dist/examples/bci/bci-filesystem.js +2 -2
  39. package/dist/examples/concurrent-completion-collision.js +1 -1
  40. package/dist/examples/config-reload.js +1 -1
  41. package/dist/examples/decisions.d.ts +2 -0
  42. package/dist/examples/decisions.js +38 -0
  43. package/dist/examples/diffusion-esrgan-upscale.js +1 -1
  44. package/dist/examples/diffusion-flux2-klein-img2img.js +1 -1
  45. package/dist/examples/diffusion-img2img.js +1 -1
  46. package/dist/examples/diffusion-img2vid-ltx.js +8 -15
  47. package/dist/examples/diffusion-img2vid-minimax-h3.d.ts +2 -0
  48. package/dist/examples/diffusion-img2vid-minimax-h3.js +72 -0
  49. package/dist/examples/diffusion-img2vid.js +1 -1
  50. package/dist/examples/diffusion-qwen-image-21.d.ts +2 -0
  51. package/dist/examples/diffusion-qwen-image-21.js +104 -0
  52. package/dist/examples/diffusion-txt2vid-ltx.js +7 -14
  53. package/dist/examples/finetune/llamacpp-finetune.js +9 -4
  54. package/dist/examples/llamacpp-filesystem.js +1 -1
  55. package/dist/examples/llamacpp-multi-gpu.js +2 -2
  56. package/dist/examples/llamacpp-multimodal.js +3 -1
  57. package/dist/examples/llamacpp-structured-output.js +1 -1
  58. package/dist/examples/mcp-websearch.d.ts +2 -2
  59. package/dist/examples/mcp-websearch.js +4 -4
  60. package/dist/examples/model-fit-ui/server.d.ts +1 -1
  61. package/dist/examples/model-fit-ui/server.js +1 -1
  62. package/dist/examples/multi-job-completion.d.ts +1 -1
  63. package/dist/examples/multi-job-completion.js +1 -1
  64. package/dist/examples/ocr-fasttext.js +1 -1
  65. package/dist/examples/plugins.js +1 -1
  66. package/dist/examples/rerank.d.ts +2 -0
  67. package/dist/examples/rerank.js +33 -0
  68. package/dist/examples/tools/llamacpp-deferred-tools.js +5 -5
  69. package/dist/examples/tools/llamacpp-tools-auto-dialect.js +5 -4
  70. package/dist/examples/tools/llamacpp-tools-gemma4.js +4 -4
  71. package/dist/examples/tools/llamacpp-tools-qwen35.js +5 -4
  72. package/dist/examples/tts/llm-to-tts-streaming.d.ts +2 -2
  73. package/dist/examples/tts/llm-to-tts-streaming.js +2 -2
  74. package/dist/examples/tts/moss-sound-effect-controls.d.ts +2 -0
  75. package/dist/examples/tts/moss-sound-effect-controls.js +88 -0
  76. package/dist/examples/tts/moss-sound-effect.d.ts +2 -0
  77. package/dist/examples/tts/moss-sound-effect.js +86 -0
  78. package/dist/examples/tts/moss-speech-audio.d.ts +2 -0
  79. package/dist/examples/tts/moss-speech-audio.js +159 -0
  80. package/dist/examples/tts/moss-speech.d.ts +2 -0
  81. package/dist/examples/tts/moss-speech.js +70 -0
  82. package/dist/examples/vla-groot.js +2 -2
  83. package/dist/examples/vla-pi05.js +2 -2
  84. package/dist/examples/vla-smolvla.js +2 -2
  85. package/dist/examples/voice-assistant/voice-assistant.js +1 -1
  86. package/dist/scripts/contract/build-contract.d.ts +3 -1
  87. package/dist/scripts/contract/build-contract.js +40 -2
  88. package/dist/scripts/contract/build-model-type-maps.d.ts +6 -1
  89. package/dist/scripts/contract/build-model-type-maps.js +3 -2
  90. package/dist/scripts/contract/constants-registry.d.ts +6 -0
  91. package/dist/scripts/contract/constants-registry.js +4 -1
  92. package/dist/scripts/contract/method-shapes.d.ts +2 -0
  93. package/dist/scripts/contract/method-shapes.js +2 -0
  94. package/dist/scripts/export-contract.js +20 -7
  95. package/dist/scripts/run-unit-tests.js +10 -5
  96. package/dist/src/client/api/assess-model-fit.d.ts +5 -5
  97. package/dist/src/client/api/assess-model-fit.js +6 -7
  98. package/dist/src/client/api/audio-edit.d.ts +14 -2
  99. package/dist/src/client/api/audio-edit.js +16 -4
  100. package/dist/src/client/api/audio-gen-result.js +2 -2
  101. package/dist/src/client/api/audio-gen.d.ts +10 -2
  102. package/dist/src/client/api/audio-gen.js +12 -4
  103. package/dist/src/client/api/audio-understand.d.ts +1 -1
  104. package/dist/src/client/api/audio-understand.js +3 -3
  105. package/dist/src/client/api/batch-completion.js +3 -3
  106. package/dist/src/client/api/bci-transcribe.js +3 -3
  107. package/dist/src/client/api/cancel.js +1 -1
  108. package/dist/src/client/api/classify.js +1 -1
  109. package/dist/src/client/api/completion-stream.d.ts +2 -1
  110. package/dist/src/client/api/completion-stream.js +6 -4
  111. package/dist/src/client/api/decide.d.ts +31 -0
  112. package/dist/src/client/api/decide.js +29 -0
  113. package/dist/src/client/api/delete-cache.js +1 -1
  114. package/dist/src/client/api/diffusion.d.ts +18 -1
  115. package/dist/src/client/api/diffusion.js +19 -2
  116. package/dist/src/client/api/download-asset.js +3 -3
  117. package/dist/src/client/api/embed.js +2 -2
  118. package/dist/src/client/api/finetune.js +3 -3
  119. package/dist/src/client/api/get-loaded-model-info.js +1 -1
  120. package/dist/src/client/api/get-model-info.js +1 -1
  121. package/dist/src/client/api/get-system-resources.js +1 -1
  122. package/dist/src/client/api/heartbeat.js +1 -1
  123. package/dist/src/client/api/index.d.ts +5 -3
  124. package/dist/src/client/api/index.js +5 -3
  125. package/dist/src/client/api/invoke-plugin.js +1 -1
  126. package/dist/src/client/api/load-model.d.ts +1 -0
  127. package/dist/src/client/api/load-model.js +4 -4
  128. package/dist/src/client/api/logging-stream.d.ts +11 -2
  129. package/dist/src/client/api/logging-stream.js +12 -3
  130. package/dist/src/client/api/ocr.js +1 -1
  131. package/dist/src/client/api/rag.js +2 -2
  132. package/dist/src/client/api/registry.d.ts +2 -1
  133. package/dist/src/client/api/registry.js +6 -5
  134. package/dist/src/client/api/rerank.d.ts +22 -0
  135. package/dist/src/client/api/rerank.js +39 -0
  136. package/dist/src/client/api/resume.js +1 -1
  137. package/dist/src/client/api/rpc-server.js +2 -2
  138. package/dist/src/client/api/state.js +1 -1
  139. package/dist/src/client/api/subscribe-logs.js +3 -2
  140. package/dist/src/client/api/suspend.js +1 -1
  141. package/dist/src/client/api/text-to-speech.d.ts +1 -0
  142. package/dist/src/client/api/text-to-speech.js +18 -25
  143. package/dist/src/client/api/transcribe.d.ts +1 -1
  144. package/dist/src/client/api/transcribe.js +7 -4
  145. package/dist/src/client/api/translate.js +2 -2
  146. package/dist/src/client/api/unload-model.js +2 -2
  147. package/dist/src/client/api/upscale.js +1 -1
  148. package/dist/src/client/api/vector-index.d.ts +1 -1
  149. package/dist/src/client/api/vector-index.js +1 -1
  150. package/dist/src/client/api/video-request.d.ts +5 -5
  151. package/dist/src/client/api/video.d.ts +23 -3
  152. package/dist/src/client/api/video.js +26 -6
  153. package/dist/src/client/api/world-result.js +2 -2
  154. package/dist/src/client/api/world.d.ts +1 -1
  155. package/dist/src/client/api/world.js +2 -2
  156. package/dist/src/client/logging-stream-registry.js +9 -6
  157. package/dist/src/client/plugins-factory.d.ts +1 -1
  158. package/dist/src/client/plugins-factory.js +1 -1
  159. package/dist/src/client/rpc/expo-rpc-client.js +3 -3
  160. package/dist/src/client/rpc/ipc-socket-path.d.ts +11 -0
  161. package/dist/src/client/rpc/ipc-socket-path.js +30 -0
  162. package/dist/src/client/rpc/node-rpc-client.js +14 -25
  163. package/dist/src/client/rpc/rpc-client.d.ts +3 -2
  164. package/dist/src/client/rpc/rpc-client.js +46 -12
  165. package/dist/src/client/rpc/rpc-error.js +4 -1
  166. package/dist/src/commands/bundle/bare-pack.d.ts +8 -0
  167. package/dist/src/commands/bundle/bare-pack.js +28 -5
  168. package/dist/src/commands/bundle/constants.js +3 -0
  169. package/dist/src/commands/bundle/entry-gen.js +1 -1
  170. package/dist/src/commands/bundle/index.d.ts +8 -7
  171. package/dist/src/commands/bundle/index.js +135 -52
  172. package/dist/src/commands/bundle/manifest.d.ts +2 -0
  173. package/dist/src/commands/bundle/manifest.js +3 -2
  174. package/dist/src/commands/bundle/plugins.js +1 -1
  175. package/dist/src/commands/host-prebuilds/index.d.ts +18 -10
  176. package/dist/src/commands/host-prebuilds/index.js +39 -20
  177. package/dist/src/commands/index.d.ts +13 -13
  178. package/dist/src/commands/index.js +8 -8
  179. package/dist/src/commands/verify/abi.d.ts +1 -1
  180. package/dist/src/commands/verify/abi.js +1 -1
  181. package/dist/src/commands/verify/addon-source.d.ts +12 -0
  182. package/dist/src/commands/verify/addon-source.js +36 -3
  183. package/dist/src/commands/verify/bare-kit-runtime.d.ts +1 -1
  184. package/dist/src/commands/verify/bare-kit-runtime.js +1 -1
  185. package/dist/src/commands/verify/bare-kit-runtimes.js +2 -1
  186. package/dist/src/commands/verify/bundle-source.d.ts +1 -1
  187. package/dist/src/commands/verify/bundle-source.js +3 -3
  188. package/dist/src/commands/verify/engines-advice.d.ts +4 -4
  189. package/dist/src/commands/verify/engines-advice.js +4 -4
  190. package/dist/src/commands/verify/index.d.ts +5 -5
  191. package/dist/src/commands/verify/index.js +7 -7
  192. package/dist/src/commands/verify/node-modules-source.d.ts +1 -1
  193. package/dist/src/commands/verify/node-modules-source.js +11 -2
  194. package/dist/src/{expo/plugins/patches/qvac-platform-addons.d.ts → commands/verify/platform-addons.d.ts} +6 -10
  195. package/dist/src/{expo/plugins/patches/qvac-platform-addons.js → commands/verify/platform-addons.js} +2 -45
  196. package/dist/src/commands/verify/prebuilds.d.ts +8 -11
  197. package/dist/src/commands/verify/prebuilds.js +44 -35
  198. package/dist/src/commands/verify/resource-collectors.js +2 -2
  199. package/dist/src/expo/plugins/link-addons.d.ts +18 -0
  200. package/dist/src/expo/plugins/link-addons.js +65 -0
  201. package/dist/src/expo/plugins/withAndroidNdkVersion.js +16 -10
  202. package/dist/src/expo/plugins/withDeviceInfo.js +19 -5
  203. package/dist/src/expo/plugins/withMobileBundle.d.ts +13 -23
  204. package/dist/src/expo/plugins/withMobileBundle.js +27 -117
  205. package/dist/src/index.d.ts +4 -4
  206. package/dist/src/index.js +3 -3
  207. package/dist/src/logging/addon.d.ts +1 -1
  208. package/dist/src/pear/pre.js +4 -0
  209. package/dist/src/plugin-ids.d.ts +4 -1
  210. package/dist/src/plugin-ids.js +6 -0
  211. package/dist/src/schemas/public.d.ts +2 -1
  212. package/dist/src/schemas/public.js +2 -1
  213. package/dist/src/schemas/sdk-errors-client.d.ts +3 -0
  214. package/dist/src/schemas/sdk-errors-client.js +16 -0
  215. package/dist/src/schemas/sdk-errors-server.d.ts +2 -0
  216. package/dist/src/schemas/sdk-errors-server.js +11 -1
  217. package/dist/src/server/rpc/rpc-utils.d.ts +5 -0
  218. package/dist/src/server/rpc/rpc-utils.js +7 -0
  219. package/dist/src/server/utils/qvac-paths.js +1 -1
  220. package/dist/src/server/utils/worker-lock.js +1 -1
  221. package/dist/src/utils/aggregate-events.d.ts +1 -1
  222. package/dist/src/utils/aggregate-events.js +2 -2
  223. package/dist/src/utils/errors-client.d.ts +10 -0
  224. package/dist/src/utils/errors-client.js +18 -0
  225. package/dist/src/utils/errors-server.d.ts +6 -0
  226. package/dist/src/utils/errors-server.js +12 -0
  227. package/dist/src/utils/mcp-adapter.d.ts +1 -1
  228. package/dist/src/utils/mcp-adapter.js +13 -9
  229. package/dist/src/utils/tool-helpers.d.ts +1 -1
  230. package/dist/src/utils/tool-helpers.js +21 -53
  231. package/dist/src/worker/create-server.d.ts +1 -0
  232. package/dist/src/worker/create-server.js +5 -0
  233. package/dist/src/worker/handle-request.js +4 -2
  234. package/dist/src/worker/handler-utils.js +1 -1
  235. package/dist/src/worker/index.js +7 -1
  236. package/dist/src/worker/lifecycle.js +10 -2
  237. package/dist/src/worker/plugins/llamacpp-decision.d.ts +2 -0
  238. package/dist/src/worker/plugins/llamacpp-decision.js +1 -0
  239. package/dist/src/worker/plugins/llamacpp-rerank.d.ts +2 -0
  240. package/dist/src/worker/plugins/llamacpp-rerank.js +1 -0
  241. package/dist/src/worker/plugins/moss-transcribe.d.ts +2 -0
  242. package/dist/src/worker/plugins/moss-transcribe.js +1 -0
  243. package/package.json +63 -53
  244. package/src/electron-forge/index.cjs +12 -71
  245. package/dist/scripts/link-workspace-inference.d.ts +0 -2
  246. package/dist/scripts/link-workspace-inference.js +0 -31
  247. package/src/expo/plugins/patches/android-link.mjs +0 -67
  248. package/src/expo/plugins/patches/ios-link.mjs +0 -67
  249. package/src/expo/plugins/patches/qvac-platform-addons.ts +0 -124
@@ -5,12 +5,12 @@
5
5
  * (whisper.cpp) addon in one shot via `bciTranscribe`, and prints the
6
6
  * decoded transcript.
7
7
  *
8
- * Usage: bun run examples/bci/bci-filesystem.ts <neural-bin-file-path>
8
+ * Usage: npx tsx examples/bci/bci-filesystem.ts <neural-bin-file-path>
9
9
  */
10
10
  import { loadModel, unloadModel, bciTranscribe, BCI_WINDOWED } from '@qvac/sdk';
11
11
  const args = process.argv.slice(2);
12
12
  if (!args[0]) {
13
- console.error('Usage: bun run examples/bci/bci-filesystem.ts <neural-bin-file-path>');
13
+ console.error('Usage: npx tsx examples/bci/bci-filesystem.ts <neural-bin-file-path>');
14
14
  process.exit(1);
15
15
  }
16
16
  const neuralFilePath = args[0];
@@ -19,7 +19,7 @@
19
19
  * distinct models never block each other).
20
20
  *
21
21
  * Run from packages/sdk:
22
- * bun run examples/concurrent-completion-collision.ts
22
+ * npx tsx examples/concurrent-completion-collision.ts
23
23
  */
24
24
  import { completion, loadModel, unloadModel, QWEN3_1_7B_INST_Q4, LLAMA_3_2_1B_INST_Q4_0, RequestRejectedByPolicyError } from '@qvac/sdk';
25
25
  async function runCompletion(label, modelId, prompt) {
@@ -2,7 +2,7 @@ import { WHISPER_TINY, loadModel, transcribe, unloadModel } from '@qvac/sdk';
2
2
  // Parse command line arguments
3
3
  const args = process.argv.slice(2);
4
4
  if (!args[0]) {
5
- console.error('✖ Usage: bun run examples/config-reload.ts <audio-file-path>');
5
+ console.error('✖ Usage: npx tsx examples/config-reload.ts <audio-file-path>');
6
6
  process.exit(1);
7
7
  }
8
8
  const audioFilePath = args[0];
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=decisions.d.ts.map
@@ -0,0 +1,38 @@
1
+ import { loadModel, decide, unloadModel, close, LAYA_MULTILINGUAL_322M_Q8_0 } from '@qvac/sdk';
2
+ const modelSrc = process.argv[2] ?? LAYA_MULTILINGUAL_322M_Q8_0;
3
+ let modelId;
4
+ try {
5
+ console.error('▸ Loading decision model');
6
+ modelId = await loadModel({
7
+ modelSrc,
8
+ modelType: 'llamacpp-decision',
9
+ modelConfig: { device: 'cpu' }
10
+ });
11
+ const result = await decide({
12
+ modelId,
13
+ state: 'My payment failed twice and I was charged both times. Please refund the duplicate.',
14
+ questions: {
15
+ department: {
16
+ type: 'choice',
17
+ instructions: 'Which team should handle this ticket?',
18
+ criteria: ['billing', 'technical']
19
+ },
20
+ urgency: {
21
+ type: 'score',
22
+ instructions: 'How urgent is this?',
23
+ criteria: ['not urgent', 'somewhat urgent', 'very urgent']
24
+ },
25
+ refund: { type: 'noul', instructions: 'The customer asks for a refund.' }
26
+ }
27
+ });
28
+ console.log(JSON.stringify(result, null, 2));
29
+ }
30
+ catch (error) {
31
+ console.error('✖', error);
32
+ process.exitCode = 1;
33
+ }
34
+ finally {
35
+ if (modelId)
36
+ await unloadModel({ modelId });
37
+ await close();
38
+ }
@@ -4,7 +4,7 @@ import path from 'path';
4
4
  // ESRGAN upscale example.
5
5
  //
6
6
  // Usage:
7
- // bun run examples/diffusion-esrgan-upscale.ts [esrganSrc] [prompt] [outputDir]
7
+ // npx tsx examples/diffusion-esrgan-upscale.ts [esrganSrc] [prompt] [outputDir]
8
8
  const esrganArg = process.argv[2];
9
9
  const promptArg = process.argv[3];
10
10
  const outputDirArg = process.argv[4];
@@ -10,7 +10,7 @@ const llmModelSrc = process.argv[6] || QWEN3_4B_Q4_K_M;
10
10
  const vaeModelSrc = process.argv[7] || FLUX_2_KLEIN_4B_VAE;
11
11
  if (!inputPath) {
12
12
  console.error('✖ input image path is required');
13
- console.error('Usage: bun run bare:example dist/examples/diffusion-flux2-klein-img2img.js <inputImage> [prompt] [outputDir] [diffusionModelSrc] [llmModelSrc] [vaeModelSrc]');
13
+ console.error('Usage: node dist/examples/diffusion-flux2-klein-img2img.js <inputImage> [prompt] [outputDir] [diffusionModelSrc] [llmModelSrc] [vaeModelSrc]');
14
14
  process.exit(1);
15
15
  }
16
16
  try {
@@ -8,7 +8,7 @@ const outputDir = process.argv[4] || '.';
8
8
  const modelSrc = process.argv[5] || SD_V2_1_1B_Q8_0;
9
9
  if (!inputPath) {
10
10
  console.error('✖ input image path is required');
11
- console.error('Usage: bun run bare:example dist/examples/diffusion-img2img.js <inputImage> [prompt] [outputDir] [modelSrc]');
11
+ console.error('Usage: node dist/examples/diffusion-img2img.js <inputImage> [prompt] [outputDir] [modelSrc]');
12
12
  process.exit(1);
13
13
  }
14
14
  try {
@@ -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
  // Image-to-video (+ synchronized audio) with LTX-2. Unlike Wan I2V, LTX-2
@@ -9,25 +9,18 @@ import path from 'path';
9
9
  // This example needs powerful hardware: LTX-2.3 is a ~21B model, budget at
10
10
  // least 20+ GB of video / unified memory.
11
11
  //
12
- // No LTX-2 model constants ship in the SDK registry, so the model sources
13
- // default to public HuggingFace URLs (the SDK downloads http(s) sources
14
- // directly). Pass your own paths / URLs via argv to override.
15
- const HF = 'https://huggingface.co';
12
+ // Pass your own paths / URLs via argv to override any of the five sources.
16
13
  const initImagePath = process.argv[2];
17
14
  const prompt = process.argv[3] || 'the subject slowly turns and smiles, soft natural lighting, cinematic';
18
15
  const outputDir = process.argv[4] || '.';
19
- const diffusionModelSrc = process.argv[5] ||
20
- `${HF}/QuantStack/LTX-2.3-GGUF/resolve/main/LTX-2.3-distilled-1.1/LTX-2.3-22B-distilled-1.1-Q5_K_M.gguf`;
21
- const llmModelSrc = process.argv[6] || `${HF}/unsloth/gemma-3-12b-it-GGUF/resolve/main/gemma-3-12b-it-UD-Q4_K_XL.gguf`;
22
- const vaeModelSrc = process.argv[7] ||
23
- `${HF}/unsloth/LTX-2.3-GGUF/resolve/main/vae/ltx-2.3-22b-distilled_video_vae.safetensors`;
24
- const audioVaeModelSrc = process.argv[8] ||
25
- `${HF}/unsloth/LTX-2.3-GGUF/resolve/main/vae/ltx-2.3-22b-distilled_audio_vae.safetensors`;
26
- const embeddingsConnectorsModelSrc = process.argv[9] ||
27
- `${HF}/unsloth/LTX-2.3-GGUF/resolve/main/text_encoders/ltx-2.3-22b-distilled_embeddings_connectors.safetensors`;
16
+ const diffusionModelSrc = process.argv[5] || LTX_2_3_22B_Q5_K_M;
17
+ const llmModelSrc = process.argv[6] || GEMMA_3_12B_Q4_K_XL;
18
+ const vaeModelSrc = process.argv[7] || LTX_2_3_VIDEO_VAE;
19
+ const audioVaeModelSrc = process.argv[8] || LTX_2_3_AUDIO_VAE;
20
+ const embeddingsConnectorsModelSrc = process.argv[9] || LTX_2_3_22B_DISTILLED_EMBEDDINGS_CONNECTORS;
28
21
  if (!initImagePath) {
29
22
  console.error('✖ init image path is required');
30
- console.error('Usage: bun run bare:example dist/examples/diffusion-img2vid-ltx.js ' +
23
+ console.error('Usage: node dist/examples/diffusion-img2vid-ltx.js ' +
31
24
  '<initImagePath> [prompt] [outputDir] ' +
32
25
  '[diffusionModelSrc] [llmModelSrc] [vaeModelSrc] [audioVaeModelSrc] [embeddingsConnectorsModelSrc]');
33
26
  process.exit(1);
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=diffusion-img2vid-minimax-h3.d.ts.map
@@ -0,0 +1,72 @@
1
+ import { loadModel, unloadModel, video } from '@qvac/sdk';
2
+ import fs from 'fs';
3
+ import path from 'path';
4
+ const modelsDir = process.argv[2];
5
+ const initImagePath = process.argv[3];
6
+ if (!modelsDir || !initImagePath) {
7
+ console.error('✖ models directory and init image path are required');
8
+ console.error('Usage: bun run bare:example dist/examples/diffusion-img2vid-minimax-h3.js ' +
9
+ '<modelsDirectory> <initImagePath> [output.avi]');
10
+ process.exit(1);
11
+ }
12
+ const outputPath = process.argv[4] || 'minimax-h3-img2vid.avi';
13
+ const modelSrc = path.resolve(modelsDir, process.env['H3_MODEL'] || 'minimax_h3_fl2va_pruned-Q4_K.gguf');
14
+ const llmModelSrc = path.resolve(modelsDir, process.env['H3_LLM'] || 'qwen3vl_32b_minimax_h3-Q4_K_M.gguf');
15
+ const vaeModelSrc = path.resolve(modelsDir, 'vae/minimax_h3_video_vae_fp16.safetensors');
16
+ let modelId;
17
+ try {
18
+ for (const file of [modelSrc, llmModelSrc, vaeModelSrc, initImagePath])
19
+ fs.accessSync(file);
20
+ console.log('▸ Loading MiniMax-H3 model (diffusion + Qwen3-VL + video VAE)...');
21
+ modelId = await loadModel({
22
+ modelType: 'sdcpp-generation',
23
+ modelSrc,
24
+ modelConfig: {
25
+ mode: 'video',
26
+ llmModelSrc,
27
+ vaeModelSrc,
28
+ device: 'gpu',
29
+ diffusion_fa: true,
30
+ offload_to_cpu: process.env['H3_OFFLOAD_TO_CPU'] !== '0',
31
+ stream_layers: process.env['H3_STREAM_LAYERS'] === '1',
32
+ ...(process.env['H3_BACKEND'] && { backend: process.env['H3_BACKEND'] }),
33
+ ...(process.env['H3_PARAMS_BACKEND'] && { params_backend: process.env['H3_PARAMS_BACKEND'] }),
34
+ ...(process.env['H3_MAX_VRAM'] && { max_vram: process.env['H3_MAX_VRAM'] })
35
+ }
36
+ });
37
+ console.log(`▸ Model loaded: ${modelId}`);
38
+ const init_image = new Uint8Array(fs.readFileSync(initImagePath));
39
+ const prompt = process.env['PROMPT'] ||
40
+ 'The boat glides forward through the mist while the camera slowly pulls back, cinematic natural motion.';
41
+ console.log(`▸ Generating video for: "${prompt}"`);
42
+ const { progressStream, outputs, stats } = video({
43
+ modelId,
44
+ mode: 'img2vid',
45
+ prompt,
46
+ init_image,
47
+ width: 864,
48
+ height: 480,
49
+ // H3 uses 17*k+5 frames and requires 24 FPS.
50
+ video_frames: Number(process.env['FRAMES'] || 124),
51
+ fps: 24,
52
+ steps: 8,
53
+ cfg_scale: 1,
54
+ seed: 11
55
+ });
56
+ for await (const { step, totalSteps } of progressStream) {
57
+ console.log(`▸ step ${step}/${totalSteps}`);
58
+ }
59
+ const buffers = await outputs;
60
+ if (!buffers[0])
61
+ throw new Error('Generation finished without an AVI result');
62
+ fs.writeFileSync(outputPath, buffers[0]);
63
+ console.log(`▸ Saved ${outputPath}`, await stats);
64
+ }
65
+ catch (error) {
66
+ console.error('✖', error);
67
+ process.exitCode = 1;
68
+ }
69
+ finally {
70
+ if (modelId)
71
+ await unloadModel({ modelId, clearStorage: false });
72
+ }
@@ -14,7 +14,7 @@ const vaeModelSrc = process.argv[7] || WAN_2_1_COMFYUI_REPACKAGED_VAE;
14
14
  const clipVisionModelSrc = process.argv[8] || CLIP_VISION_H;
15
15
  if (!initImagePath) {
16
16
  console.error('✖ init image path is required');
17
- console.error('Usage: bun run bare:example dist/examples/diffusion-img2vid.js ' +
17
+ console.error('Usage: node dist/examples/diffusion-img2vid.js ' +
18
18
  '<initImagePath> [prompt] [outputDir] ' +
19
19
  '[i2vModelSrc] [t5XxlModelSrc] [vaeModelSrc] [clipVisionModelSrc]');
20
20
  process.exit(1);
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=diffusion-qwen-image-21.d.ts.map
@@ -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
- // No LTX-2 model constants ship in the SDK registry, so the model sources
14
- // default to public HuggingFace URLs (the SDK downloads http(s) sources
15
- // directly). Pass your own paths / URLs via argv to override.
16
- const HF = 'https://huggingface.co';
17
- const diffusionModelSrc = process.argv[2] ||
18
- `${HF}/QuantStack/LTX-2.3-GGUF/resolve/main/LTX-2.3-distilled-1.1/LTX-2.3-22B-distilled-1.1-Q5_K_M.gguf`;
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: './examples/finetune/input/small_train_HF.jsonl',
30
+ trainDatasetDir: path.join(datasetDir, 'train.jsonl'),
26
31
  validation: {
27
32
  type: 'dataset',
28
- path: './examples/finetune/input/small_eval_HF.jsonl'
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: './examples/finetune/results/checkpoints',
37
- outputParametersDir: './examples/finetune/results'
41
+ checkpointSaveDir: './finetune-output/checkpoints',
42
+ outputParametersDir: './finetune-output'
38
43
  }
39
44
  };
40
45
  const handle = finetune(finetuneParams);
@@ -3,7 +3,7 @@ import { completion, loadModel, unloadModel } from '@qvac/sdk';
3
3
  const ggufPath = process.argv[2];
4
4
  if (!ggufPath) {
5
5
  console.error('✖ Please provide the path to a GGUF file as the first argument');
6
- console.error('✖ Usage: bun run examples/llamacpp-filesystem.ts <path-to-gguf-file>');
6
+ console.error('✖ Usage: npx tsx examples/llamacpp-filesystem.ts <path-to-gguf-file>');
7
7
  process.exit(1);
8
8
  }
9
9
  console.log(`▸ Loading GGUF model from: ${ggufPath}`);
@@ -10,8 +10,8 @@ import { completion, loadModel, unloadModel, VERBOSITY, LLAMA_3_2_1B_INST_Q4_0 }
10
10
  // "1,1" distributes evenly across two GPUs; "3,1" assigns 75% to GPU 0.
11
11
  //
12
12
  // Usage:
13
- // bun run bare:example dist/examples/llamacpp-multi-gpu.js
14
- // bun run bare:example dist/examples/llamacpp-multi-gpu.js '<model-url>'
13
+ // node dist/examples/llamacpp-multi-gpu.js
14
+ // node dist/examples/llamacpp-multi-gpu.js '<model-url>'
15
15
  const modelSrc = process.argv[2] ?? LLAMA_3_2_1B_INST_Q4_0;
16
16
  try {
17
17
  const modelId = await loadModel({
@@ -10,7 +10,9 @@ try {
10
10
  const modelId = await loadModel({
11
11
  modelSrc: SMOLVLM2_500M_MULTIMODAL_Q8_0,
12
12
  modelConfig: {
13
- ctx_size: 1024,
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) => {
@@ -4,7 +4,7 @@ import { loadModel, completion, unloadModel, QWEN3_600M_INST_Q4 } from '@qvac/sd
4
4
  // difference between free-form text, free-form JSON, and a strict JSON Schema.
5
5
  //
6
6
  // Usage:
7
- // bun run examples/llamacpp-structured-output.ts
7
+ // npx tsx examples/llamacpp-structured-output.ts
8
8
  const PERSON_SCHEMA = {
9
9
  type: 'object',
10
10
  properties: {
@@ -5,9 +5,9 @@
5
5
  * The server provides tools to search the web and get answers.
6
6
  *
7
7
  * Prerequisites:
8
- * - Install MCP SDK: bun add @modelcontextprotocol/sdk
8
+ * - Install MCP SDK: npm install @modelcontextprotocol/sdk
9
9
  *
10
- * Run with: bun run examples/mcp-websearch.ts
10
+ * Run with: npx tsx examples/mcp-websearch.ts
11
11
  */
12
12
  export {};
13
13
  //# sourceMappingURL=mcp-websearch.d.ts.map
@@ -5,13 +5,13 @@
5
5
  * The server provides tools to search the web and get answers.
6
6
  *
7
7
  * Prerequisites:
8
- * - Install MCP SDK: bun add @modelcontextprotocol/sdk
8
+ * - Install MCP SDK: npm install @modelcontextprotocol/sdk
9
9
  *
10
- * Run with: bun run examples/mcp-websearch.ts
10
+ * Run with: npx tsx examples/mcp-websearch.ts
11
11
  */
12
- import { completion, loadModel, unloadModel, QWEN3_1_7B_INST_Q4 } from '../src/index.js';
12
+ import { completion, loadModel, unloadModel, QWEN3_1_7B_INST_Q4 } from '@qvac/sdk';
13
13
  // MCP SDK is a user-installed optional dependency
14
- // Install with: bun add @modelcontextprotocol/sdk
14
+ // Install with: npm install @modelcontextprotocol/sdk
15
15
  import { Client } from '@modelcontextprotocol/sdk/client/index.js';
16
16
  import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
17
17
  function parseSearchResults(mcpResult) {
@@ -17,7 +17,7 @@
17
17
  * machine is doing — fine for a demo, not a measurement.
18
18
  *
19
19
  * Run (Node or Bun, not Bare — this uses node:http):
20
- * bun run examples/model-fit-ui/server.ts
20
+ * npx tsx examples/model-fit-ui/server.ts
21
21
  * node dist/examples/model-fit-ui/server.js
22
22
  */
23
23
  export {};
@@ -17,7 +17,7 @@
17
17
  * machine is doing — fine for a demo, not a measurement.
18
18
  *
19
19
  * Run (Node or Bun, not Bare — this uses node:http):
20
- * bun run examples/model-fit-ui/server.ts
20
+ * npx tsx examples/model-fit-ui/server.ts
21
21
  * node dist/examples/model-fit-ui/server.js
22
22
  */
23
23
  import { createServer } from 'node:http';
@@ -21,7 +21,7 @@
21
21
  * `parallel` in flight, admitting one more waits FIFO until a slot frees.
22
22
  *
23
23
  * Run from packages/sdk:
24
- * bun run examples/multi-job-completion.ts
24
+ * npx tsx examples/multi-job-completion.ts
25
25
  */
26
26
  export {};
27
27
  //# sourceMappingURL=multi-job-completion.d.ts.map
@@ -21,7 +21,7 @@
21
21
  * `parallel` in flight, admitting one more waits FIFO until a slot frees.
22
22
  *
23
23
  * Run from packages/sdk:
24
- * bun run examples/multi-job-completion.ts
24
+ * npx tsx examples/multi-job-completion.ts
25
25
  */
26
26
  import { completion, cancel, loadModel, unloadModel, InferenceCancelledError, LLAMA_3_2_1B_INST_Q4_0 } from '@qvac/sdk';
27
27
  const PROMPTS = [
@@ -2,7 +2,7 @@
2
2
  * OCR example using the QVAC SDK.
3
3
  *
4
4
  * Usage:
5
- * bun examples/ocr-fasttext.ts [path-to-image]
5
+ * npx tsx examples/ocr-fasttext.ts [path-to-image]
6
6
  *
7
7
  * This example requires a test image (default: examples/image/basic_test.bmp).
8
8
  * Sample images are available in the QVAC source repository, but not included in the published npm package.
@@ -10,7 +10,7 @@
10
10
  * 3. Embeddings -> fails (plugin not selected)
11
11
  *
12
12
  */
13
- import { bundleSdk } from '../src/commands/index.js';
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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=rerank.d.ts.map
@@ -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; the deferred schemas arrive in the conversation when the
5
- // model searches for them.
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: appending it is what makes the definitions
56
- // callable on the next turn.
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 appended. Turn 2 — the model can now call them directly.\n');
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);