@qvac/sdk 0.10.0 → 0.10.2

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 (28) hide show
  1. package/NOTICE +28 -28
  2. package/dist/examples/{llamacpp-native-tools.js → tools/llamacpp-native-tools.js} +4 -47
  3. package/dist/examples/tools/llamacpp-tools-harmony-multiturn.d.ts +2 -0
  4. package/dist/examples/tools/llamacpp-tools-harmony-multiturn.js +81 -0
  5. package/dist/examples/{llamacpp-tools-pythonic.js → tools/llamacpp-tools-pythonic.js} +1 -20
  6. package/dist/examples/tools/shared.d.ts +21 -0
  7. package/dist/examples/tools/shared.js +42 -0
  8. package/dist/models/registry/models.d.ts +312 -1231
  9. package/dist/models/registry/models.js +2081 -3025
  10. package/dist/models/update-models/registry.d.ts +1 -0
  11. package/dist/models/update-models/registry.js +19 -1
  12. package/dist/schemas/common.d.ts +1 -0
  13. package/dist/schemas/completion-stream.d.ts +4 -0
  14. package/dist/schemas/completion-stream.js +2 -1
  15. package/dist/server/bare/delegate-rpc-client.js +10 -8
  16. package/dist/server/bare/plugins/llamacpp-completion/plugin.d.ts +1 -0
  17. package/dist/server/bare/plugins/llamacpp-completion/plugin.js +3 -3
  18. package/dist/server/bare/plugins/nmtcpp-translation/plugin.js +1 -82
  19. package/dist/server/bare/plugins/nmtcpp-translation/resolve-vocab.d.ts +32 -0
  20. package/dist/server/bare/plugins/nmtcpp-translation/resolve-vocab.js +117 -0
  21. package/dist/server/utils/completion-normalizer.js +168 -56
  22. package/dist/server/utils/tools/dialect.js +2 -0
  23. package/dist/server/utils/tools/parser.js +6 -0
  24. package/dist/server/utils/tools/parsers/harmony.d.ts +4 -0
  25. package/dist/server/utils/tools/parsers/harmony.js +59 -0
  26. package/package.json +1 -1
  27. /package/dist/examples/{llamacpp-native-tools.d.ts → tools/llamacpp-native-tools.d.ts} +0 -0
  28. /package/dist/examples/{llamacpp-tools-pythonic.d.ts → tools/llamacpp-tools-pythonic.d.ts} +0 -0
package/NOTICE CHANGED
@@ -489,8 +489,6 @@ JavaScript Dependencies
489
489
 
490
490
  @hyperswarm/secret-stream@6.9.1
491
491
  https://github.com/holepunchto/hyperswarm-secret-stream
492
- @qvac/decoder-audio@0.3.6
493
- https://github.com/tetherto/qvac
494
492
  @qvac/decoder-audio@0.3.7
495
493
  https://github.com/tetherto/qvac
496
494
  @qvac/diagnostics@0.1.1
@@ -502,8 +500,6 @@ JavaScript Dependencies
502
500
  https://github.com/tetherto/qvac
503
501
  @qvac/error@0.1.1
504
502
  @qvac/infer-base@0.1.1
505
- @qvac/infer-base@0.4.0
506
- https://github.com/tetherto/qvac
507
503
  @qvac/infer-base@0.4.1
508
504
  https://github.com/tetherto/qvac
509
505
  @qvac/langdetect-text@0.1.2
@@ -521,9 +517,9 @@ JavaScript Dependencies
521
517
  https://github.com/tetherto/qvac
522
518
  @qvac/registry-schema@0.1.2
523
519
  @qvac/response@0.1.2
524
- @qvac/transcription-parakeet@0.3.1
520
+ @qvac/transcription-parakeet@0.3.2
525
521
  https://github.com/tetherto/qvac
526
- @qvac/transcription-whispercpp@0.6.1
522
+ @qvac/transcription-whispercpp@0.6.7
527
523
  https://github.com/tetherto/qvac
528
524
  @qvac/translation-nmtcpp@2.1.0
529
525
  https://github.com/tetherto/qvac
@@ -559,19 +555,19 @@ JavaScript Dependencies
559
555
  https://github.com/holepunchto/bare-events
560
556
  bare-events@2.8.2
561
557
  https://github.com/holepunchto/bare-events
562
- bare-fetch@2.8.1
558
+ bare-fetch@2.9.0
563
559
  https://github.com/holepunchto/bare-fetch
564
560
  bare-ffmpeg@1.2.2
565
561
  https://github.com/holepunchto/bare-ffmpeg
566
562
  bare-form-data@1.2.1
567
563
  https://github.com/holepunchto/bare-form-data
568
- bare-fs@4.6.0
564
+ bare-fs@4.7.1
569
565
  https://github.com/holepunchto/bare-fs
570
566
  bare-hrtime@2.1.1
571
567
  https://github.com/holepunchto/bare-hrtime
572
568
  bare-http-parser@1.1.3
573
569
  https://github.com/holepunchto/bare-http-parser
574
- bare-http1@4.5.5
570
+ bare-http1@4.5.6
575
571
  https://github.com/holepunchto/bare-http1
576
572
  bare-https@2.1.3
577
573
  https://github.com/holepunchto/bare-https
@@ -581,7 +577,9 @@ JavaScript Dependencies
581
577
  https://github.com/holepunchto/bare-lief
582
578
  bare-link@3.2.1
583
579
  https://github.com/holepunchto/bare-link
584
- bare-module@6.1.3
580
+ bare-mime@1.0.0
581
+ https://github.com/holepunchto/bare-mime
582
+ bare-module@6.2.0
585
583
  https://github.com/holepunchto/bare-module
586
584
  bare-module-lexer@1.4.7
587
585
  https://github.com/holepunchto/bare-module-lexer
@@ -595,7 +593,7 @@ JavaScript Dependencies
595
593
  https://github.com/holepunchto/bare-node
596
594
  bare-node-worker-threads@1.0.0
597
595
  https://github.com/holepunchto/bare-node
598
- bare-os@3.8.7
596
+ bare-os@3.9.0
599
597
  https://github.com/holepunchto/bare-os
600
598
  bare-path@3.0.0
601
599
  https://github.com/holepunchto/bare-path
@@ -605,39 +603,39 @@ JavaScript Dependencies
605
603
  https://github.com/holepunchto/bare-process
606
604
  bare-rpc@1.2.0
607
605
  https://github.com/holepunchto/bare-rpc
608
- bare-runtime@1.28.1
606
+ bare-runtime@1.28.4
609
607
  https://github.com/holepunchto/bare-runtime
610
- bare-runtime-darwin-arm64@1.28.1
608
+ bare-runtime-darwin-arm64@1.28.4
611
609
  https://github.com/holepunchto/bare-runtime
612
- bare-semver@1.0.2
610
+ bare-semver@1.0.3
613
611
  https://github.com/holepunchto/bare-semver
614
612
  bare-signals@4.2.0
615
613
  https://github.com/holepunchto/bare-signals
616
614
  bare-stdio@1.0.2
617
615
  https://github.com/holepunchto/bare-stdio
618
- bare-stream@2.12.0
616
+ bare-stream@2.13.1
619
617
  https://github.com/holepunchto/bare-stream
620
- bare-structured-clone@1.5.3
618
+ bare-structured-clone@1.5.4
621
619
  https://github.com/holepunchto/bare-structured-clone
622
620
  bare-subprocess@5.2.3
623
621
  https://github.com/holepunchto/bare-subprocess
624
- bare-tcp@2.2.7
622
+ bare-tcp@2.2.12
625
623
  https://github.com/holepunchto/bare-tcp
626
624
  bare-thread@1.2.0
627
625
  https://github.com/holepunchto/bare-thread
628
- bare-tls@2.2.1
626
+ bare-tls@2.2.3
629
627
  https://github.com/holepunchto/bare-tls
630
628
  bare-tty@5.1.0
631
629
  https://github.com/holepunchto/bare-tty
632
630
  bare-type@1.1.0
633
631
  https://github.com/holepunchto/bare-type
634
- bare-url@2.4.0
632
+ bare-url@2.4.2
635
633
  https://github.com/holepunchto/bare-url
636
634
  bare-worker@4.1.6
637
635
  https://github.com/holepunchto/bare-worker
638
- bare-zlib@1.3.1
636
+ bare-zlib@1.3.3
639
637
  https://github.com/holepunchto/bare-zlib
640
- blind-relay@1.4.0
638
+ blind-relay@1.5.0
641
639
  https://github.com/holepunchto/blind-relay
642
640
  compact-encoding@2.19.2
643
641
  https://github.com/holepunchto/compact-encoding
@@ -647,7 +645,7 @@ JavaScript Dependencies
647
645
  https://github.com/holepunchto/events-universal
648
646
  fd-lock@2.1.1
649
647
  https://github.com/holepunchto/fd-lock
650
- fs-native-extensions@1.4.5
648
+ fs-native-extensions@1.5.0
651
649
  https://github.com/holepunchto/fs-native-extensions
652
650
  hyperblobs@2.11.1
653
651
  https://github.com/holepunchto/hyperblobs
@@ -661,6 +659,8 @@ JavaScript Dependencies
661
659
  https://github.com/holepunchto/hypercore-storage
662
660
  hyperdb@4.22.3
663
661
  https://github.com/holepunchto/hyperdb
662
+ hyperdht-address@1.0.1
663
+ https://github.com/holepunchto/hyperdht-address
664
664
  hyperdht-stats@1.10.0
665
665
  https://github.com/holepunchto/hyperdht-stats
666
666
  hyperdispatch@1.5.1
@@ -673,7 +673,7 @@ JavaScript Dependencies
673
673
  https://github.com/holepunchto/hyperswarm-stats
674
674
  index-encoder@3.5.0
675
675
  https://github.com/holepunchto/index-encoder
676
- mirror-drive@1.14.1
676
+ mirror-drive@1.14.2
677
677
  https://github.com/holepunchto/mirror-drive
678
678
  noise-handshake@4.2.0
679
679
  https://github.com/holepunchto/noise-handshake
@@ -745,8 +745,8 @@ JavaScript Dependencies
745
745
  https://github.com/holepunchto/corestore
746
746
  debounceify@1.1.0
747
747
  https://github.com/mafintosh/debounceify
748
- dht-rpc@6.26.3
749
- https://github.com/mafintosh/dht-rpc
748
+ dht-rpc@6.26.4
749
+ https://github.com/holepunchto/dht-rpc
750
750
  events@3.3.0
751
751
  https://github.com/Gozala/events
752
752
  fast-fifo@1.3.2
@@ -765,7 +765,7 @@ JavaScript Dependencies
765
765
  https://github.com/holepunchto/hypercore
766
766
  hypercore-crypto@3.6.1
767
767
  https://github.com/mafintosh/hypercore-crypto
768
- hyperdht@6.29.6
768
+ hyperdht@6.30.0
769
769
  https://github.com/holepunchto/hyperdht
770
770
  hyperswarm@4.17.0
771
771
  https://github.com/holepunchto/hyperswarm
@@ -783,8 +783,8 @@ JavaScript Dependencies
783
783
  https://github.com/mafintosh/nat-sampler
784
784
  protocol-buffers-encodings@1.2.0
785
785
  https://github.com/mafintosh/protocol-buffers-encodings
786
- protomux@3.10.1
787
- https://github.com/mafintosh/protomux
786
+ protomux@3.10.3
787
+ https://github.com/holepunchto/protomux
788
788
  queue-tick@1.0.1
789
789
  https://github.com/mafintosh/queue-tick
790
790
  random-array-iterator@1.0.0
@@ -1,44 +1,16 @@
1
- import { z } from "zod";
2
- import { completion, loadModel, unloadModel, QWEN3_1_7B_INST_Q4, } from "../index.js";
3
- // Define Zod schemas for tool parameters
4
- const weatherSchema = z.object({
5
- city: z.string().describe("City name"),
6
- country: z.string().describe("Country code").optional(),
7
- });
8
- const horoscopeSchema = z.object({
9
- sign: z.string().describe("An astrological sign like Taurus or Aquarius"),
10
- });
11
- // Map tool names to their schemas for runtime validation
12
- const toolSchemas = {
13
- get_weather: weatherSchema,
14
- get_horoscope: horoscopeSchema,
15
- };
16
- // Simple tool definitions - just name, description, and Zod schema!
17
- const tools = [
18
- {
19
- name: "get_weather",
20
- description: "Get current weather for a city",
21
- parameters: weatherSchema,
22
- },
23
- {
24
- name: "get_horoscope",
25
- description: "Get today's horoscope for an astrological sign",
26
- parameters: horoscopeSchema,
27
- },
28
- ];
1
+ import { completion, loadModel, unloadModel, QWEN3_1_7B_INST_Q4, } from "@qvac/sdk";
2
+ import { tools, toolSchemas, mockExecute } from "./shared.js";
29
3
  try {
30
- // Load model from provided file path with tools support enabled
31
4
  const modelId = await loadModel({
32
5
  modelSrc: QWEN3_1_7B_INST_Q4,
33
6
  modelType: "llm",
34
7
  modelConfig: {
35
8
  ctx_size: 4096,
36
- tools: true, // Enable tools support
9
+ tools: true,
37
10
  },
38
11
  onProgress: (progress) => console.log(`Loading: ${progress.percentage.toFixed(1)}%`),
39
12
  });
40
13
  console.log(`✅ Model loaded successfully! Model ID: ${modelId}`);
41
- // Create conversation history
42
14
  const history = [
43
15
  {
44
16
  role: "system",
@@ -52,13 +24,11 @@ try {
52
24
  console.log("\n🤖 AI Response:");
53
25
  console.log("(Streaming with tool definitions in prompt)\n");
54
26
  const result = completion({ modelId, history, stream: true, tools });
55
- // Consume token stream
56
27
  const tokensTask = (async () => {
57
28
  for await (const token of result.tokenStream) {
58
29
  process.stdout.write(token);
59
30
  }
60
31
  })();
61
- // Consume tool call events
62
32
  const toolsTask = (async () => {
63
33
  for await (const evt of result.toolCallStream) {
64
34
  console.log(`\n\n→ Tool Call Detected: ${evt.call.name}(${JSON.stringify(evt.call.arguments)})`);
@@ -88,36 +58,23 @@ try {
88
58
  console.log(" No tool calls detected in response");
89
59
  }
90
60
  console.log("\n📊 Performance Stats:", stats);
91
- // Execute tool calls and send results back to the model
92
61
  if (toolCalls.length > 0) {
93
62
  console.log("\n\n🔧 Simulating Tool Execution...");
94
- // Simulate tool execution (in a real app, you'd call actual APIs)
95
63
  const toolResults = toolCalls.map((call) => {
96
- let result = "";
97
- if (call.name === "get_weather") {
98
- const args = call.arguments;
99
- result = `The weather in ${args.city} is sunny, 22°C with light clouds.`;
100
- }
101
- else if (call.name === "get_horoscope") {
102
- const args = call.arguments;
103
- result = `Horoscope for ${args.sign}: Today is a great day for new beginnings and creative endeavors!`;
104
- }
64
+ const result = mockExecute(call.name, call.arguments);
105
65
  console.log(` ✓ ${call.name}: ${result}`);
106
66
  return { toolCallId: call.id, result };
107
67
  });
108
- // Add tool results to conversation history
109
68
  history.push({
110
69
  role: "assistant",
111
70
  content: await result.text,
112
71
  });
113
- // Add tool results as tool messages
114
72
  for (const toolResult of toolResults) {
115
73
  history.push({
116
74
  role: "tool",
117
75
  content: toolResult.result,
118
76
  });
119
77
  }
120
- // Send follow-up question with tool results
121
78
  console.log("\n\n🤖 Follow-up Response with Tool Results:");
122
79
  const followUpResult = completion({
123
80
  modelId,
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=llamacpp-tools-harmony-multiturn.d.ts.map
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Multi-turn tool-calling example using the GPT-OSS model (Harmony dialect).
3
+ *
4
+ * GPT-OSS emits one tool call per generation, so multi-tool requests need
5
+ * a turn-by-turn loop: send prompt + tools → mock-execute the returned
6
+ * `ToolCall` → append the raw assistant frame + tool result to history →
7
+ * repeat until the model produces a final answer (no tool call).
8
+ *
9
+ */
10
+ import { completion, loadModel, unloadModel, GPT_OSS_20B_INST_Q4_K_M, } from "@qvac/sdk";
11
+ import { tools, mockExecute } from "./shared.js";
12
+ const MAX_TURNS = 5;
13
+ let modelId;
14
+ try {
15
+ modelId = await loadModel({
16
+ modelSrc: GPT_OSS_20B_INST_Q4_K_M,
17
+ modelConfig: { ctx_size: 4096, tools: true },
18
+ onProgress: (progress) => console.log(`Loading: ${progress.percentage.toFixed(1)}%`),
19
+ });
20
+ console.log(`✅ Model loaded: ${modelId}`);
21
+ const history = [
22
+ {
23
+ role: "system",
24
+ content: "You are a helpful assistant that can use tools to get the weather and horoscope.",
25
+ },
26
+ {
27
+ role: "user",
28
+ content: "What's the weather in Tokyo and my horoscope for Aquarius?",
29
+ },
30
+ ];
31
+ for (let turn = 1; turn <= MAX_TURNS; turn++) {
32
+ console.log(`\n========== TURN ${turn} ==========`);
33
+ const result = completion({ modelId, history, tools, stream: true });
34
+ for await (const token of result.tokenStream) {
35
+ process.stdout.write(token);
36
+ }
37
+ console.log();
38
+ const final = await result.final;
39
+ console.log(`\n--- TURN ${turn} SUMMARY ---`);
40
+ console.log(`[sdk toolCalls] ${final.toolCalls.length}`);
41
+ for (const call of final.toolCalls) {
42
+ console.log(` → ${call.name}(${JSON.stringify(call.arguments)})`);
43
+ }
44
+ if (final.toolCalls.length === 0) {
45
+ console.log(`\n🎉 Final response received — exiting loop.`);
46
+ break;
47
+ }
48
+ // Raw, not result.text — GPT-OSS needs its own framed output in history
49
+ // to anchor the next turn.
50
+ const assistantContent = final.raw.fullText;
51
+ history.push({ role: "assistant", content: assistantContent });
52
+ for (const call of final.toolCalls) {
53
+ const toolResult = mockExecute(call.name, call.arguments);
54
+ console.log(` ✓ mock-executed ${call.name}: ${toolResult}`);
55
+ history.push({ role: "tool", content: toolResult });
56
+ }
57
+ if (turn === MAX_TURNS) {
58
+ console.log(`\n⚠️ MAX_TURNS (${MAX_TURNS}) reached — stopping.`);
59
+ }
60
+ }
61
+ console.log(`\n========== HISTORY ==========`);
62
+ for (const msg of history) {
63
+ const preview = msg.content.slice(0, 120).replace(/\n/g, "\\n");
64
+ console.log(`[${msg.role}] ${preview}${msg.content.length > 120 ? "…" : ""}`);
65
+ }
66
+ }
67
+ catch (error) {
68
+ console.error("❌ Error:", error);
69
+ process.exit(1);
70
+ }
71
+ finally {
72
+ if (modelId) {
73
+ try {
74
+ await unloadModel({ modelId, clearStorage: false });
75
+ console.log(`\n[unload] done`);
76
+ }
77
+ catch (unloadError) {
78
+ console.error("[unload] failed:", unloadError);
79
+ }
80
+ }
81
+ }
@@ -1,25 +1,6 @@
1
- import { z } from "zod";
2
1
  import { completion, loadModel, unloadModel, } from "@qvac/sdk";
3
- // LFM2-1.2B-Tool emits Pythonic-style calls: [get_weather(city="Tokyo")].
2
+ import { tools } from "./shared.js";
4
3
  const LFM_TOOL_HF = "https://huggingface.co/LiquidAI/LFM2-1.2B-Tool-GGUF/resolve/main/LFM2-1.2B-Tool-Q4_K_M.gguf";
5
- const weatherSchema = z.object({
6
- city: z.string().describe("City name"),
7
- });
8
- const horoscopeSchema = z.object({
9
- sign: z.string().describe("An astrological sign like Taurus or Aquarius"),
10
- });
11
- const tools = [
12
- {
13
- name: "get_weather",
14
- description: "Get current weather for a city",
15
- parameters: weatherSchema,
16
- },
17
- {
18
- name: "get_horoscope",
19
- description: "Get today's horoscope for an astrological sign",
20
- parameters: horoscopeSchema,
21
- },
22
- ];
23
4
  try {
24
5
  const modelId = await loadModel({
25
6
  modelSrc: LFM_TOOL_HF,
@@ -0,0 +1,21 @@
1
+ import { z } from "zod";
2
+ import type { ToolInput } from "@qvac/sdk";
3
+ export declare const weatherSchema: z.ZodObject<{
4
+ city: z.ZodString;
5
+ country: z.ZodOptional<z.ZodString>;
6
+ }, z.core.$strip>;
7
+ export declare const horoscopeSchema: z.ZodObject<{
8
+ sign: z.ZodString;
9
+ }, z.core.$strip>;
10
+ export declare const toolSchemas: {
11
+ readonly get_weather: z.ZodObject<{
12
+ city: z.ZodString;
13
+ country: z.ZodOptional<z.ZodString>;
14
+ }, z.core.$strip>;
15
+ readonly get_horoscope: z.ZodObject<{
16
+ sign: z.ZodString;
17
+ }, z.core.$strip>;
18
+ };
19
+ export declare const tools: ToolInput[];
20
+ export declare function mockExecute(name: string, args: Record<string, unknown>): string;
21
+ //# sourceMappingURL=shared.d.ts.map
@@ -0,0 +1,42 @@
1
+ import { z } from "zod";
2
+ export const weatherSchema = z.object({
3
+ city: z.string().describe("City name"),
4
+ country: z.string().describe("Country code").optional(),
5
+ });
6
+ export const horoscopeSchema = z.object({
7
+ sign: z.string().describe("An astrological sign like Taurus or Aquarius"),
8
+ });
9
+ export const toolSchemas = {
10
+ get_weather: weatherSchema,
11
+ get_horoscope: horoscopeSchema,
12
+ };
13
+ export const tools = [
14
+ {
15
+ name: "get_weather",
16
+ description: "Get current weather for a city",
17
+ parameters: weatherSchema,
18
+ },
19
+ {
20
+ name: "get_horoscope",
21
+ description: "Get today's horoscope for an astrological sign",
22
+ parameters: horoscopeSchema,
23
+ },
24
+ ];
25
+ export function mockExecute(name, args) {
26
+ if (name === "get_weather") {
27
+ const a = args;
28
+ return JSON.stringify({
29
+ city: a.city,
30
+ country: a.country ?? "unknown",
31
+ temperature: "22°C",
32
+ condition: "Partly cloudy",
33
+ });
34
+ }
35
+ if (name === "get_horoscope") {
36
+ return JSON.stringify({
37
+ sign: args.sign,
38
+ horoscope: "Today is a great day for new beginnings.",
39
+ });
40
+ }
41
+ return JSON.stringify({ error: `Unknown tool: ${name}` });
42
+ }