@qvac/inference 0.20.1 → 0.21.1
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 +102 -40
- package/README.md +8 -5
- package/dist/api/bci-transcribe.d.ts +4 -1
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.js +1 -0
- package/dist/api/rpc-server.d.ts +19 -0
- package/dist/api/rpc-server.js +44 -0
- package/dist/api/text-to-speech.d.ts +9 -0
- package/dist/api/text-to-speech.js +9 -0
- package/dist/api/transcribe.d.ts +11 -7
- package/dist/api/transcribe.js +47 -15
- package/dist/api/video-request.d.ts +5 -5
- package/dist/dispatch.js +39 -7
- package/dist/errors/index.d.ts +7 -0
- package/dist/errors/index.js +15 -0
- package/dist/handlers/assess-model-fit.d.ts +8 -20
- package/dist/handlers/assess-model-fit.js +195 -77
- package/dist/handlers/completion-orchestrate.js +17 -0
- package/dist/handlers/get-loaded-model-info.js +4 -1
- package/dist/handlers/get-model-info.js +29 -1
- package/dist/handlers/load-model/coreml-sidecars.d.ts +25 -0
- package/dist/handlers/load-model/coreml-sidecars.js +274 -0
- package/dist/handlers/load-model/hyperdrive.js +2 -2
- package/dist/handlers/load-model/registry.js +59 -0
- package/dist/handlers/rpc-server.d.ts +23 -0
- package/dist/handlers/rpc-server.js +141 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/models/registry/models.d.ts +7731 -5672
- package/dist/models/registry/models.js +4652 -2526
- package/dist/models/registry/resource-profiles.js +481 -94
- package/dist/plugins/builtin/audiogen-ggml/plugin.d.ts +8 -6
- package/dist/plugins/builtin/audiogen-ggml/plugin.js +2 -1
- package/dist/plugins/builtin/bci-whispercpp-transcription/plugin.d.ts +73 -1
- package/dist/plugins/builtin/bci-whispercpp-transcription/plugin.js +37 -19
- package/dist/plugins/builtin/ggml-vla/plugin.d.ts +1 -1
- package/dist/plugins/builtin/llamacpp-completion/ops/batch-completion-stream.js +9 -5
- package/dist/plugins/builtin/llamacpp-completion/ops/completion-stats.d.ts +1 -1
- package/dist/plugins/builtin/llamacpp-completion/ops/completion-stream.js +16 -7
- package/dist/plugins/builtin/llamacpp-completion/plugin.d.ts +22 -11
- package/dist/plugins/builtin/llamacpp-completion/plugin.js +9 -3
- package/dist/plugins/builtin/llamacpp-embedding/plugin.d.ts +5 -3
- package/dist/plugins/builtin/llamacpp-embedding/plugin.js +2 -1
- package/dist/plugins/builtin/parakeet-transcription/plugin.d.ts +121 -0
- package/dist/plugins/builtin/parakeet-transcription/plugin.js +56 -27
- package/dist/plugins/builtin/sdcpp-generation/plugin.d.ts +8 -2
- package/dist/plugins/builtin/sdcpp-generation/plugin.js +7 -2
- package/dist/plugins/builtin/tts-ggml/ops/parler-options.d.ts +2 -0
- package/dist/plugins/builtin/tts-ggml/ops/parler-options.js +5 -1
- package/dist/plugins/builtin/tts-ggml/ops/text-to-speech.js +27 -10
- package/dist/plugins/builtin/tts-ggml/plugin.d.ts +181 -0
- package/dist/plugins/builtin/tts-ggml/plugin.js +84 -2
- package/dist/plugins/builtin/whispercpp-transcription/plugin.d.ts +136 -0
- package/dist/plugins/builtin/whispercpp-transcription/plugin.js +18 -7
- package/dist/plugins/ops/bci-transcribe.d.ts +6 -2
- package/dist/plugins/ops/bci-transcribe.js +18 -13
- package/dist/plugins/ops/load-model.js +2 -2
- package/dist/plugins/ops/transcribe.d.ts +4 -2
- package/dist/plugins/ops/transcribe.js +39 -2
- package/dist/plugins/ops/translate-stats.d.ts +2 -1
- package/dist/plugins/ops/translate-stats.js +64 -7
- package/dist/plugins/ops/translate.js +20 -4
- package/dist/profiling/operation-metrics.js +56 -0
- package/dist/registry.js +4 -0
- package/dist/resources/model-fit/assess.d.ts +37 -2
- package/dist/resources/model-fit/assess.js +24 -3
- package/dist/resources/model-fit/estimators/llm.js +2 -2
- package/dist/resources/model-fit/estimators/whisper.js +3 -4
- package/dist/resources/model-fit/fit-stub/fetch-fit-stub.d.ts +20 -1
- package/dist/resources/model-fit/fit-stub/fetch-fit-stub.js +126 -47
- package/dist/resources/model-fit/fit-stub/project-fit-from-load.d.ts +27 -0
- package/dist/resources/model-fit/fit-stub/project-fit-from-load.js +31 -0
- package/dist/resources/model-fit/fit-stub/resolve-load-from-stubs.d.ts +38 -0
- package/dist/resources/model-fit/fit-stub/resolve-load-from-stubs.js +138 -0
- package/dist/resources/model-fit/floor.js +2 -2
- package/dist/resources/model-fit/native-probe/advisory-fit.d.ts +9 -6
- package/dist/resources/model-fit/native-probe/advisory-fit.js +129 -80
- package/dist/resources/model-fit/native-probe/child-engine-fit.d.ts +2 -0
- package/dist/resources/model-fit/native-probe/child-engine-fit.js +41 -0
- package/dist/resources/model-fit/native-probe/classify-fit.d.ts +6 -0
- package/dist/resources/model-fit/native-probe/classify-fit.js +135 -0
- package/dist/resources/model-fit/native-probe/create-fit-request.d.ts +28 -0
- package/dist/resources/model-fit/native-probe/create-fit-request.js +51 -0
- package/dist/resources/model-fit/native-probe/engine-fit.d.ts +59 -0
- package/dist/resources/model-fit/native-probe/engine-fit.js +13 -0
- package/dist/resources/model-fit/native-probe/engines/asr.d.ts +10 -0
- package/dist/resources/model-fit/native-probe/engines/asr.js +103 -0
- package/dist/resources/model-fit/native-probe/engines/audiogen.d.ts +8 -0
- package/dist/resources/model-fit/native-probe/engines/audiogen.js +35 -0
- package/dist/resources/model-fit/native-probe/engines/diffusion.d.ts +7 -0
- package/dist/resources/model-fit/native-probe/engines/diffusion.js +55 -0
- package/dist/resources/model-fit/native-probe/engines/gpu.d.ts +10 -0
- package/dist/resources/model-fit/native-probe/engines/gpu.js +21 -0
- package/dist/resources/model-fit/native-probe/engines/llama.d.ts +13 -0
- package/dist/resources/model-fit/native-probe/engines/llama.js +145 -0
- package/dist/resources/model-fit/native-probe/engines/tts.d.ts +8 -0
- package/dist/resources/model-fit/native-probe/engines/tts.js +106 -0
- package/dist/resources/model-fit/native-probe/fit-outcome.d.ts +16 -0
- package/dist/resources/model-fit/native-probe/fit-outcome.js +1 -0
- package/dist/resources/model-fit/native-probe/fit-process.d.ts +27 -0
- package/dist/resources/model-fit/native-probe/fit-process.js +55 -0
- package/dist/resources/model-fit/native-probe/fit-runner.d.ts +1 -0
- package/dist/resources/model-fit/native-probe/fit-runner.js +58 -0
- package/dist/resources/model-fit/native-probe/run-fit.d.ts +24 -0
- package/dist/resources/model-fit/native-probe/run-fit.js +20 -0
- package/dist/resources/model-fit/native-probe/run-in-process-fit.d.ts +14 -34
- package/dist/resources/model-fit/native-probe/run-in-process-fit.js +55 -139
- package/dist/resources/model-fit/native-probe/run-isolated-fit.d.ts +5 -12
- package/dist/resources/model-fit/native-probe/run-isolated-fit.js +13 -8
- package/dist/resources/model-fit/platform.d.ts +9 -0
- package/dist/resources/model-fit/platform.js +28 -0
- package/dist/rpc/device-map.d.ts +13 -0
- package/dist/rpc/device-map.js +22 -0
- package/dist/rpc/discovery.d.ts +12 -0
- package/dist/rpc/discovery.js +225 -0
- package/dist/rpc/ggml-provider.d.ts +4 -0
- package/dist/rpc/ggml-provider.js +25 -0
- package/dist/rpc/index.d.ts +2 -0
- package/dist/rpc/index.js +1 -0
- package/dist/rpc/instance.d.ts +6 -0
- package/dist/rpc/instance.js +21 -0
- package/dist/rpc/inventory.d.ts +5 -0
- package/dist/rpc/inventory.js +144 -0
- package/dist/rpc/manager.d.ts +14 -0
- package/dist/rpc/manager.js +174 -0
- package/dist/rpc/network.d.ts +11 -0
- package/dist/rpc/network.js +85 -0
- package/dist/rpc/provider.d.ts +6 -0
- package/dist/rpc/provider.js +24 -0
- package/dist/runtime/lifecycle.js +31 -13
- package/dist/runtime/request-context.d.ts +1 -1
- package/dist/runtime/state.js +5 -0
- package/dist/schemas/assess-model-fit.d.ts +269 -85
- package/dist/schemas/assess-model-fit.js +78 -54
- package/dist/schemas/audio-gen.d.ts +6 -6
- package/dist/schemas/audio-gen.js +2 -2
- package/dist/schemas/batch-completion-stream.d.ts +13 -5
- package/dist/schemas/batch-completion-stream.js +5 -3
- package/dist/schemas/bci-config.js +1 -1
- package/dist/schemas/bci.d.ts +86 -1
- package/dist/schemas/bci.js +21 -2
- package/dist/schemas/cancel.d.ts +10 -0
- package/dist/schemas/cancel.js +2 -0
- package/dist/schemas/common.d.ts +708 -66
- package/dist/schemas/common.js +7 -0
- package/dist/schemas/completion-event.d.ts +6 -6
- package/dist/schemas/completion-stream.d.ts +27 -8
- package/dist/schemas/completion-stream.js +41 -4
- package/dist/schemas/config.d.ts +104 -36
- package/dist/schemas/config.js +10 -0
- package/dist/schemas/embed.d.ts +2 -2
- package/dist/schemas/error.js +13 -0
- package/dist/schemas/errors.d.ts +1 -0
- package/dist/schemas/errors.js +5 -0
- package/dist/schemas/index.d.ts +1 -0
- package/dist/schemas/index.js +1 -0
- package/dist/schemas/llamacpp-config.d.ts +25 -18
- package/dist/schemas/llamacpp-config.js +26 -16
- package/dist/schemas/load-model.d.ts +2608 -469
- package/dist/schemas/load-model.js +2 -2
- package/dist/schemas/mcp-adapter.d.ts +4 -0
- package/dist/schemas/model-config-schemas.d.ts +183 -6
- package/dist/schemas/model-info.d.ts +56 -0
- package/dist/schemas/model-info.js +5 -1
- package/dist/schemas/plugin.d.ts +8 -2
- package/dist/schemas/profiling.d.ts +4 -4
- package/dist/schemas/reload-config.d.ts +30 -0
- package/dist/schemas/rpc-server.d.ts +101 -0
- package/dist/schemas/rpc-server.js +87 -0
- package/dist/schemas/sdcpp-config.d.ts +7 -3
- package/dist/schemas/sdcpp-config.js +37 -2
- package/dist/schemas/system-resources.d.ts +4 -4
- package/dist/schemas/text-to-speech.d.ts +529 -1
- package/dist/schemas/text-to-speech.js +122 -12
- package/dist/schemas/tools.d.ts +2 -0
- package/dist/schemas/tools.js +8 -0
- package/dist/schemas/transcription-config.d.ts +5 -0
- package/dist/schemas/transcription-config.js +20 -2
- package/dist/schemas/transcription.d.ts +164 -0
- package/dist/schemas/transcription.js +71 -4
- package/dist/schemas/vla.d.ts +1 -1
- package/dist/surface.d.ts +4 -1
- package/dist/surface.js +3 -1
- package/dist/utils/addon-responses.d.ts +5 -1
- package/dist/utils/archive.js +5 -1
- package/dist/utils/asr-diagnostics.d.ts +12 -0
- package/dist/utils/asr-diagnostics.js +42 -0
- package/dist/utils/asr-events.d.ts +1 -0
- package/dist/utils/asr-events.js +3 -2
- package/dist/utils/cache/paths.js +3 -2
- package/dist/utils/mcp-adapter.js +7 -1
- package/dist/utils/multi-gpu-mobile.d.ts +1 -1
- package/dist/utils/multi-gpu-mobile.js +8 -6
- package/dist/utils/path-security.d.ts +5 -0
- package/dist/utils/path-security.js +14 -0
- package/dist/utils/tool-helpers.d.ts +4 -0
- package/dist/utils/tool-helpers.js +2 -0
- package/dist/utils/tools/defer.d.ts +93 -0
- package/dist/utils/tools/defer.js +290 -0
- package/dist/utils/tools/index.d.ts +1 -0
- package/dist/utils/tools/index.js +1 -0
- package/dist/utils/transcribe-metadata.d.ts +21 -7
- package/dist/utils/transcribe-metadata.js +24 -8
- package/dist/utils/tts-stats.d.ts +6 -0
- package/dist/utils/tts-stats.js +14 -1
- package/package.json +43 -29
- package/dist/resources/model-fit/fit-stub/index.d.ts +0 -2
- package/dist/resources/model-fit/fit-stub/index.js +0 -2
- package/dist/resources/model-fit/fit-stub/project-fit-from-stub.d.ts +0 -31
- package/dist/resources/model-fit/fit-stub/project-fit-from-stub.js +0 -36
- package/dist/resources/model-fit/native-probe/create-llama-fit-request.d.ts +0 -26
- package/dist/resources/model-fit/native-probe/create-llama-fit-request.js +0 -191
package/dist/schemas/common.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { startRpcServerRequestSchema, startRpcServerResponseSchema, stopRpcServerRequestSchema, stopRpcServerResponseSchema, discoverRpcServersRequestSchema, discoverRpcServersResponseSchema } from './rpc-server.js';
|
|
1
2
|
import { z } from 'zod';
|
|
2
3
|
import { perCallProfilingSchema } from './profiling.js';
|
|
3
4
|
import { heartbeatRequestSchema, heartbeatResponseSchema } from './heartbeat.js';
|
|
@@ -31,6 +32,9 @@ export const requestSchema = z.union([
|
|
|
31
32
|
audioGenStreamRequestSchema,
|
|
32
33
|
audioEditStreamRequestSchema,
|
|
33
34
|
audioUnderstandRequestSchema,
|
|
35
|
+
startRpcServerRequestSchema,
|
|
36
|
+
stopRpcServerRequestSchema,
|
|
37
|
+
discoverRpcServersRequestSchema,
|
|
34
38
|
heartbeatRequestSchema,
|
|
35
39
|
loadModelRequestSchema,
|
|
36
40
|
downloadAssetRequestSchema,
|
|
@@ -76,6 +80,9 @@ export const responseSchema = z.discriminatedUnion('type', [
|
|
|
76
80
|
audioGenStreamResponseSchema,
|
|
77
81
|
audioEditStreamResponseSchema,
|
|
78
82
|
audioUnderstandResponseSchema,
|
|
83
|
+
startRpcServerResponseSchema,
|
|
84
|
+
stopRpcServerResponseSchema,
|
|
85
|
+
discoverRpcServersResponseSchema,
|
|
79
86
|
heartbeatResponseSchema,
|
|
80
87
|
loadModelResponseSchema,
|
|
81
88
|
downloadAssetResponseSchema,
|
|
@@ -12,8 +12,8 @@ export declare const completionStatsSchema: z.ZodObject<{
|
|
|
12
12
|
avgConcurrentSeq: z.ZodOptional<z.ZodNumber>;
|
|
13
13
|
toolDefinitionsDropped: z.ZodOptional<z.ZodNumber>;
|
|
14
14
|
backendDevice: z.ZodOptional<z.ZodEnum<{
|
|
15
|
-
gpu: "gpu";
|
|
16
15
|
cpu: "cpu";
|
|
16
|
+
gpu: "gpu";
|
|
17
17
|
}>>;
|
|
18
18
|
}, z.core.$strip>;
|
|
19
19
|
export type CompletionStats = z.infer<typeof completionStatsSchema>;
|
|
@@ -70,8 +70,8 @@ export declare const statsEventSchema: z.ZodObject<{
|
|
|
70
70
|
avgConcurrentSeq: z.ZodOptional<z.ZodNumber>;
|
|
71
71
|
toolDefinitionsDropped: z.ZodOptional<z.ZodNumber>;
|
|
72
72
|
backendDevice: z.ZodOptional<z.ZodEnum<{
|
|
73
|
-
gpu: "gpu";
|
|
74
73
|
cpu: "cpu";
|
|
74
|
+
gpu: "gpu";
|
|
75
75
|
}>>;
|
|
76
76
|
}, z.core.$strip>;
|
|
77
77
|
}, z.core.$strip>;
|
|
@@ -80,8 +80,8 @@ export declare const completionErrorSchema: z.ZodObject<{
|
|
|
80
80
|
}, z.core.$strip>;
|
|
81
81
|
declare const stopReasonEnum: z.ZodEnum<{
|
|
82
82
|
cancelled: "cancelled";
|
|
83
|
-
eos: "eos";
|
|
84
83
|
length: "length";
|
|
84
|
+
eos: "eos";
|
|
85
85
|
stopSequence: "stopSequence";
|
|
86
86
|
}>;
|
|
87
87
|
export declare const doneEventSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
@@ -99,8 +99,8 @@ export declare const doneEventSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
99
99
|
seq: z.ZodNumber;
|
|
100
100
|
stopReason: z.ZodOptional<z.ZodEnum<{
|
|
101
101
|
cancelled: "cancelled";
|
|
102
|
-
eos: "eos";
|
|
103
102
|
length: "length";
|
|
103
|
+
eos: "eos";
|
|
104
104
|
stopSequence: "stopSequence";
|
|
105
105
|
}>>;
|
|
106
106
|
raw: z.ZodOptional<z.ZodObject<{
|
|
@@ -154,8 +154,8 @@ export declare const completionEventSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
154
154
|
avgConcurrentSeq: z.ZodOptional<z.ZodNumber>;
|
|
155
155
|
toolDefinitionsDropped: z.ZodOptional<z.ZodNumber>;
|
|
156
156
|
backendDevice: z.ZodOptional<z.ZodEnum<{
|
|
157
|
-
gpu: "gpu";
|
|
158
157
|
cpu: "cpu";
|
|
158
|
+
gpu: "gpu";
|
|
159
159
|
}>>;
|
|
160
160
|
}, z.core.$strip>;
|
|
161
161
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -173,8 +173,8 @@ export declare const completionEventSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
173
173
|
seq: z.ZodNumber;
|
|
174
174
|
stopReason: z.ZodOptional<z.ZodEnum<{
|
|
175
175
|
cancelled: "cancelled";
|
|
176
|
-
eos: "eos";
|
|
177
176
|
length: "length";
|
|
177
|
+
eos: "eos";
|
|
178
178
|
stopSequence: "stopSequence";
|
|
179
179
|
}>>;
|
|
180
180
|
raw: z.ZodOptional<z.ZodObject<{
|
|
@@ -44,15 +44,28 @@ export declare const generationParamsSchema: z.ZodObject<{
|
|
|
44
44
|
* as opposed to `auto` / `none`, which only shape how the model may call one.
|
|
45
45
|
*/
|
|
46
46
|
export declare function toolChoiceDemandsCall(toolChoice: string | undefined): boolean;
|
|
47
|
+
type ToolChoiceTool = {
|
|
48
|
+
type: 'function';
|
|
49
|
+
name: string;
|
|
50
|
+
deferLoading?: boolean | undefined;
|
|
51
|
+
};
|
|
47
52
|
export declare function refineToolChoiceMatchesTools(data: {
|
|
48
|
-
tools?:
|
|
49
|
-
type: 'function';
|
|
50
|
-
name: string;
|
|
51
|
-
}[] | undefined;
|
|
53
|
+
tools?: ToolChoiceTool[] | undefined;
|
|
52
54
|
generationParams?: {
|
|
53
55
|
tool_choice?: string | undefined;
|
|
54
56
|
} | undefined;
|
|
55
57
|
}, ctx: z.RefinementCtx): void;
|
|
58
|
+
/**
|
|
59
|
+
* `tool_search` is synthesised only when something defers, and would then
|
|
60
|
+
* shadow a caller-declared tool of that name. Requests that defer nothing
|
|
61
|
+
* keep the name free.
|
|
62
|
+
*/
|
|
63
|
+
export declare function refineReservedToolNames(data: {
|
|
64
|
+
tools?: {
|
|
65
|
+
name: string;
|
|
66
|
+
deferLoading?: boolean | undefined;
|
|
67
|
+
}[] | undefined;
|
|
68
|
+
}, ctx: z.RefinementCtx): void;
|
|
56
69
|
export declare const responseFormatSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
57
70
|
type: z.ZodLiteral<"text">;
|
|
58
71
|
}, z.core.$strict>, z.ZodObject<{
|
|
@@ -90,6 +103,8 @@ export declare const completionClientParamsSchema: z.ZodObject<{
|
|
|
90
103
|
type: z.ZodLiteral<"function">;
|
|
91
104
|
name: z.ZodString;
|
|
92
105
|
description: z.ZodString;
|
|
106
|
+
deferLoading: z.ZodOptional<z.ZodBoolean>;
|
|
107
|
+
group: z.ZodOptional<z.ZodString>;
|
|
93
108
|
parameters: z.ZodObject<{
|
|
94
109
|
type: z.ZodLiteral<"object">;
|
|
95
110
|
properties: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
@@ -161,6 +176,8 @@ export declare const completionStreamRequestSchema: z.ZodObject<{
|
|
|
161
176
|
type: z.ZodLiteral<"function">;
|
|
162
177
|
name: z.ZodString;
|
|
163
178
|
description: z.ZodString;
|
|
179
|
+
deferLoading: z.ZodOptional<z.ZodBoolean>;
|
|
180
|
+
group: z.ZodOptional<z.ZodString>;
|
|
164
181
|
parameters: z.ZodObject<{
|
|
165
182
|
type: z.ZodLiteral<"object">;
|
|
166
183
|
properties: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
@@ -270,8 +287,8 @@ export declare const completionStreamResponseSchema: z.ZodObject<{
|
|
|
270
287
|
avgConcurrentSeq: z.ZodOptional<z.ZodNumber>;
|
|
271
288
|
toolDefinitionsDropped: z.ZodOptional<z.ZodNumber>;
|
|
272
289
|
backendDevice: z.ZodOptional<z.ZodEnum<{
|
|
273
|
-
gpu: "gpu";
|
|
274
290
|
cpu: "cpu";
|
|
291
|
+
gpu: "gpu";
|
|
275
292
|
}>>;
|
|
276
293
|
}, z.core.$strip>;
|
|
277
294
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -289,8 +306,8 @@ export declare const completionStreamResponseSchema: z.ZodObject<{
|
|
|
289
306
|
seq: z.ZodNumber;
|
|
290
307
|
stopReason: z.ZodOptional<z.ZodEnum<{
|
|
291
308
|
cancelled: "cancelled";
|
|
292
|
-
eos: "eos";
|
|
293
309
|
length: "length";
|
|
310
|
+
eos: "eos";
|
|
294
311
|
stopSequence: "stopSequence";
|
|
295
312
|
}>>;
|
|
296
313
|
raw: z.ZodOptional<z.ZodObject<{
|
|
@@ -311,6 +328,8 @@ export declare const completionOrchestrateRequestSchema: z.ZodObject<{
|
|
|
311
328
|
type: z.ZodLiteral<"function">;
|
|
312
329
|
name: z.ZodString;
|
|
313
330
|
description: z.ZodString;
|
|
331
|
+
deferLoading: z.ZodOptional<z.ZodBoolean>;
|
|
332
|
+
group: z.ZodOptional<z.ZodString>;
|
|
314
333
|
parameters: z.ZodObject<{
|
|
315
334
|
type: z.ZodLiteral<"object">;
|
|
316
335
|
properties: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
@@ -434,8 +453,8 @@ export declare const completionOrchestrateResponseSchema: z.ZodObject<{
|
|
|
434
453
|
avgConcurrentSeq: z.ZodOptional<z.ZodNumber>;
|
|
435
454
|
toolDefinitionsDropped: z.ZodOptional<z.ZodNumber>;
|
|
436
455
|
backendDevice: z.ZodOptional<z.ZodEnum<{
|
|
437
|
-
gpu: "gpu";
|
|
438
456
|
cpu: "cpu";
|
|
457
|
+
gpu: "gpu";
|
|
439
458
|
}>>;
|
|
440
459
|
}, z.core.$strip>;
|
|
441
460
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -453,8 +472,8 @@ export declare const completionOrchestrateResponseSchema: z.ZodObject<{
|
|
|
453
472
|
seq: z.ZodNumber;
|
|
454
473
|
stopReason: z.ZodOptional<z.ZodEnum<{
|
|
455
474
|
cancelled: "cancelled";
|
|
456
|
-
eos: "eos";
|
|
457
475
|
length: "length";
|
|
476
|
+
eos: "eos";
|
|
458
477
|
stopSequence: "stopSequence";
|
|
459
478
|
}>>;
|
|
460
479
|
raw: z.ZodOptional<z.ZodObject<{
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { toolSchema } from './tools.js';
|
|
3
|
+
import { TOOL_SEARCH_NAME } from '../utils/tools/defer.js';
|
|
3
4
|
import { completionEventSchema } from './completion-event.js';
|
|
4
5
|
import { REASONING_BUDGET_MAX } from './llamacpp-config.js';
|
|
5
6
|
export { completionStatsSchema } from './completion-event.js';
|
|
@@ -92,12 +93,45 @@ export function refineToolChoiceMatchesTools(data, ctx) {
|
|
|
92
93
|
}
|
|
93
94
|
return;
|
|
94
95
|
}
|
|
95
|
-
|
|
96
|
+
// `tool_search` is synthesised rather than declared, so naming it is only
|
|
97
|
+
// valid when something actually defers.
|
|
98
|
+
if (toolChoice === TOOL_SEARCH_NAME && data.tools?.some((tool) => tool.deferLoading === true)) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const named = data.tools?.find((tool) => tool.name === toolChoice);
|
|
102
|
+
if (!named) {
|
|
96
103
|
ctx.addIssue({
|
|
97
104
|
code: 'custom',
|
|
98
105
|
message: `generationParams.tool_choice names "${toolChoice}", which is not one of the declared tools.`,
|
|
99
106
|
path: ['generationParams', 'tool_choice']
|
|
100
107
|
});
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
// A deferred tool has no parameter schema in the prompt, so the addon has
|
|
111
|
+
// nothing to build a grammar from and could not honour the demand.
|
|
112
|
+
if (named.deferLoading === true) {
|
|
113
|
+
ctx.addIssue({
|
|
114
|
+
code: 'custom',
|
|
115
|
+
message: `generationParams.tool_choice names "${toolChoice}", which sets deferLoading. Force "${TOOL_SEARCH_NAME}" instead, or drop deferLoading from that tool.`,
|
|
116
|
+
path: ['generationParams', 'tool_choice']
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* `tool_search` is synthesised only when something defers, and would then
|
|
122
|
+
* shadow a caller-declared tool of that name. Requests that defer nothing
|
|
123
|
+
* keep the name free.
|
|
124
|
+
*/
|
|
125
|
+
export function refineReservedToolNames(data, ctx) {
|
|
126
|
+
if (!data.tools?.some((tool) => tool.deferLoading === true))
|
|
127
|
+
return;
|
|
128
|
+
const index = data.tools?.findIndex((tool) => tool.name === TOOL_SEARCH_NAME) ?? -1;
|
|
129
|
+
if (index >= 0) {
|
|
130
|
+
ctx.addIssue({
|
|
131
|
+
code: 'custom',
|
|
132
|
+
message: `"${TOOL_SEARCH_NAME}" is reserved for the built-in deferred-tool search and cannot be declared.`,
|
|
133
|
+
path: ['tools', index, 'name']
|
|
134
|
+
});
|
|
101
135
|
}
|
|
102
136
|
}
|
|
103
137
|
const jsonSchemaObjectSchema = z.record(z.string(), z.unknown());
|
|
@@ -189,13 +223,15 @@ function refineNoToolsWithStructuredOutput(data, ctx) {
|
|
|
189
223
|
}
|
|
190
224
|
export const completionClientParamsSchema = completionClientParamsBaseSchema
|
|
191
225
|
.superRefine(refineNoToolsWithStructuredOutput)
|
|
192
|
-
.superRefine(refineToolChoiceMatchesTools)
|
|
226
|
+
.superRefine(refineToolChoiceMatchesTools)
|
|
227
|
+
.superRefine(refineReservedToolNames);
|
|
193
228
|
export const completionStreamRequestSchema = completionClientParamsBaseSchema
|
|
194
229
|
.extend({
|
|
195
230
|
type: z.literal('completionStream')
|
|
196
231
|
})
|
|
197
232
|
.superRefine(refineNoToolsWithStructuredOutput)
|
|
198
|
-
.superRefine(refineToolChoiceMatchesTools)
|
|
233
|
+
.superRefine(refineToolChoiceMatchesTools)
|
|
234
|
+
.superRefine(refineReservedToolNames);
|
|
199
235
|
export const completionStreamResponseSchema = z
|
|
200
236
|
.object({
|
|
201
237
|
type: z.literal('completionStream'),
|
|
@@ -221,7 +257,8 @@ export const completionOrchestrateRequestSchema = completionClientParamsBaseSche
|
|
|
221
257
|
'the next turn. Defaults to 8.')
|
|
222
258
|
})
|
|
223
259
|
.superRefine(refineNoToolsWithStructuredOutput)
|
|
224
|
-
.superRefine(refineToolChoiceMatchesTools)
|
|
260
|
+
.superRefine(refineToolChoiceMatchesTools)
|
|
261
|
+
.superRefine(refineReservedToolNames);
|
|
225
262
|
/**
|
|
226
263
|
* Downstream frame of the orchestrated completion duplex stream. Exactly one
|
|
227
264
|
* payload field is set per frame:
|