@qvac/sdk 0.10.1 → 0.11.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 +92 -54
- package/dist/client/api/cancel.d.ts +24 -32
- package/dist/client/api/cancel.js +58 -31
- package/dist/client/api/client-request-id.d.ts +17 -0
- package/dist/client/api/client-request-id.js +27 -0
- package/dist/client/api/completion-stream.d.ts +1 -1
- package/dist/client/api/completion-stream.js +34 -3
- package/dist/client/api/diffusion.d.ts +46 -0
- package/dist/client/api/diffusion.js +50 -1
- package/dist/client/api/download-asset.d.ts +12 -2
- package/dist/client/api/download-asset.js +21 -3
- package/dist/client/api/embed.d.ts +8 -4
- package/dist/client/api/embed.js +14 -1
- package/dist/client/api/get-model-info.d.ts +1 -1
- package/dist/client/api/index.d.ts +1 -0
- package/dist/client/api/index.js +1 -0
- package/dist/client/api/load-model.d.ts +12 -4
- package/dist/client/api/load-model.js +25 -1
- package/dist/client/api/rag.d.ts +9 -3
- package/dist/client/api/rag.js +23 -3
- package/dist/client/api/transcribe.d.ts +20 -8
- package/dist/client/api/transcribe.js +58 -4
- package/dist/client/api/unload-model.d.ts +5 -2
- package/dist/client/api/unload-model.js +9 -4
- package/dist/client/api/upscale.d.ts +45 -0
- package/dist/client/api/upscale.js +99 -0
- package/dist/client/rpc/expo-rpc-client.js +2 -1
- package/dist/client/rpc/node-rpc-client.js +18 -7
- package/dist/client/rpc/rpc-client.d.ts +2 -2
- package/dist/client/rpc/rpc-client.js +10 -4
- package/dist/client/rpc/rpc-error.d.ts +9 -0
- package/dist/client/rpc/rpc-error.js +92 -0
- package/dist/examples/cancel-by-request-id.d.ts +38 -0
- package/dist/examples/cancel-by-request-id.js +103 -0
- package/dist/examples/diffusion-esrgan-upscale.d.ts +2 -0
- package/dist/examples/diffusion-esrgan-upscale.js +78 -0
- package/dist/examples/download-with-cancel.js +10 -10
- package/dist/examples/embed-multi-gpu.d.ts +2 -0
- package/dist/examples/embed-multi-gpu.js +46 -0
- package/dist/examples/llamacpp-multi-gpu.d.ts +2 -0
- package/dist/examples/llamacpp-multi-gpu.js +57 -0
- package/dist/examples/rag/rag-hyperdb/cancellation.js +20 -17
- package/dist/examples/tools/llamacpp-tools-gemma4.d.ts +2 -0
- package/dist/examples/tools/llamacpp-tools-gemma4.js +76 -0
- package/dist/examples/tools/llamacpp-tools-qwen35.d.ts +2 -0
- package/dist/examples/tools/llamacpp-tools-qwen35.js +70 -0
- package/dist/examples/transcription/whispercpp-microphone-conversation.d.ts +2 -0
- package/dist/examples/transcription/whispercpp-microphone-conversation.js +102 -0
- package/dist/examples/tts/supertonic.js +1 -1
- package/dist/expo/plugins/withMobileBundle.d.ts +20 -4
- package/dist/expo/plugins/withMobileBundle.js +44 -6
- package/dist/index.d.ts +5 -2
- package/dist/index.js +21 -1
- package/dist/models/registry/models.d.ts +186 -318
- package/dist/models/registry/models.js +1522 -1667
- package/dist/pear/pre.d.ts +3 -0
- package/dist/pear/pre.js +3 -0
- package/dist/schemas/cancel.d.ts +167 -28
- package/dist/schemas/cancel.js +119 -19
- package/dist/schemas/common.d.ts +427 -208
- package/dist/schemas/common.js +3 -1
- package/dist/schemas/completion-event.d.ts +14 -0
- package/dist/schemas/completion-event.js +11 -1
- package/dist/schemas/completion-stream.d.ts +15 -1
- package/dist/schemas/completion-stream.js +25 -7
- package/dist/schemas/download-asset.d.ts +15 -9
- package/dist/schemas/download-asset.js +17 -6
- package/dist/schemas/embed.d.ts +1 -0
- package/dist/schemas/embed.js +5 -0
- package/dist/schemas/error.d.ts +31 -0
- package/dist/schemas/error.js +29 -1
- package/dist/schemas/finetune.d.ts +2 -0
- package/dist/schemas/finetune.js +5 -0
- package/dist/schemas/get-model-info.d.ts +6 -6
- package/dist/schemas/llamacpp-config.d.ts +54 -8
- package/dist/schemas/llamacpp-config.js +12 -0
- package/dist/schemas/load-model.d.ts +1911 -1260
- package/dist/schemas/load-model.js +15 -0
- package/dist/schemas/model-src-utils.d.ts +14 -14
- package/dist/schemas/model-types.d.ts +10 -10
- package/dist/schemas/ocr.d.ts +3 -3
- package/dist/schemas/plugin.d.ts +40 -1
- package/dist/schemas/plugin.js +10 -1
- package/dist/schemas/rag.d.ts +9 -0
- package/dist/schemas/rag.js +17 -9
- package/dist/schemas/registry.d.ts +30 -30
- package/dist/schemas/reload-config.d.ts +14 -14
- package/dist/schemas/sdcpp-config.d.ts +131 -17
- package/dist/schemas/sdcpp-config.js +163 -1
- package/dist/schemas/sdk-config.d.ts +649 -271
- package/dist/schemas/sdk-errors-client.d.ts +1 -0
- package/dist/schemas/sdk-errors-client.js +5 -0
- package/dist/schemas/sdk-errors-server.d.ts +5 -0
- package/dist/schemas/sdk-errors-server.js +25 -0
- package/dist/schemas/text-to-speech.d.ts +78 -78
- package/dist/schemas/transcription-config.d.ts +24 -24
- package/dist/schemas/transcription.d.ts +56 -2
- package/dist/schemas/transcription.js +27 -0
- package/dist/schemas/translate.d.ts +2 -0
- package/dist/schemas/translate.js +13 -2
- package/dist/schemas/translation-config.d.ts +40 -40
- package/dist/schemas/unload-model.d.ts +2 -1
- package/dist/schemas/unload-model.js +4 -1
- package/dist/scripts/run-unit-tests.js +15 -2
- package/dist/server/bare/delegate-rpc-client.js +10 -8
- package/dist/server/bare/ops/cancel.d.ts +27 -1
- package/dist/server/bare/ops/cancel.js +36 -10
- package/dist/server/bare/ops/embed.d.ts +3 -3
- package/dist/server/bare/ops/embed.js +144 -28
- package/dist/server/bare/ops/kv-cache-utils.d.ts +0 -7
- package/dist/server/bare/ops/kv-cache-utils.js +8 -47
- package/dist/server/bare/ops/transcribe.d.ts +10 -5
- package/dist/server/bare/ops/transcribe.js +196 -41
- package/dist/server/bare/ops/translate.d.ts +1 -1
- package/dist/server/bare/ops/translate.js +197 -88
- package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stream.d.ts +12 -3
- package/dist/server/bare/plugins/llamacpp-completion/ops/completion-stream.js +170 -172
- package/dist/server/bare/plugins/llamacpp-completion/ops/finetune.js +125 -21
- package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-session.d.ts +154 -0
- package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-session.js +448 -0
- package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-state.d.ts +21 -73
- package/dist/server/bare/plugins/llamacpp-completion/ops/kv-cache-state.js +18 -101
- package/dist/server/bare/plugins/llamacpp-completion/plugin.d.ts +30 -3
- package/dist/server/bare/plugins/llamacpp-completion/plugin.js +157 -85
- package/dist/server/bare/plugins/llamacpp-completion/transform.d.ts +10 -0
- package/dist/server/bare/plugins/llamacpp-completion/transform.js +34 -0
- package/dist/server/bare/plugins/llamacpp-embedding/plugin.d.ts +7 -0
- package/dist/server/bare/plugins/llamacpp-embedding/plugin.js +10 -1
- package/dist/server/bare/plugins/nmtcpp-translation/plugin.d.ts +17 -15
- package/dist/server/bare/plugins/nmtcpp-translation/plugin.js +5 -1
- package/dist/server/bare/plugins/onnx-ocr/plugin.d.ts +3 -3
- package/dist/server/bare/plugins/onnx-ocr/plugin.js +3 -0
- package/dist/server/bare/plugins/onnx-tts/plugin.d.ts +39 -39
- package/dist/server/bare/plugins/onnx-tts/plugin.js +6 -0
- package/dist/server/bare/plugins/parakeet-transcription/plugin.d.ts +29 -21
- package/dist/server/bare/plugins/parakeet-transcription/plugin.js +4 -1
- package/dist/server/bare/plugins/sdcpp-generation/ops/diffusion.js +8 -0
- package/dist/server/bare/plugins/sdcpp-generation/ops/upscale.d.ts +3 -0
- package/dist/server/bare/plugins/sdcpp-generation/ops/upscale.js +40 -0
- package/dist/server/bare/plugins/sdcpp-generation/plugin.d.ts +91 -16
- package/dist/server/bare/plugins/sdcpp-generation/plugin.js +97 -7
- package/dist/server/bare/plugins/whispercpp-transcription/plugin.d.ts +22 -3
- package/dist/server/bare/plugins/whispercpp-transcription/plugin.js +50 -14
- package/dist/server/bare/rag-hyperdb/index.d.ts +1 -1
- package/dist/server/bare/rag-hyperdb/index.js +1 -1
- package/dist/server/bare/rag-hyperdb/rag-operation-manager.d.ts +26 -4
- package/dist/server/bare/rag-hyperdb/rag-operation-manager.js +65 -28
- package/dist/server/bare/runtime/disposable-scope.d.ts +36 -0
- package/dist/server/bare/runtime/disposable-scope.js +69 -0
- package/dist/server/bare/runtime/index.d.ts +8 -0
- package/dist/server/bare/runtime/index.js +3 -0
- package/dist/server/bare/runtime/request-context.d.ts +49 -0
- package/dist/server/bare/runtime/request-context.js +1 -0
- package/dist/server/bare/runtime/request-id.d.ts +12 -0
- package/dist/server/bare/runtime/request-id.js +14 -0
- package/dist/server/bare/runtime/request-registry-singleton.d.ts +4 -0
- package/dist/server/bare/runtime/request-registry-singleton.js +27 -0
- package/dist/server/bare/runtime/request-registry.d.ts +136 -0
- package/dist/server/bare/runtime/request-registry.js +297 -0
- package/dist/server/bare/runtime/with-request-context.d.ts +22 -0
- package/dist/server/bare/runtime/with-request-context.js +53 -0
- package/dist/server/bare/types/addon-responses.d.ts +11 -1
- package/dist/server/rpc/handler-registry.js +26 -7
- package/dist/server/rpc/handlers/cancel-delegated.js +28 -31
- package/dist/server/rpc/handlers/cancelHandler.d.ts +30 -1
- package/dist/server/rpc/handlers/cancelHandler.js +54 -22
- package/dist/server/rpc/handlers/delete-cache.d.ts +9 -0
- package/dist/server/rpc/handlers/delete-cache.js +13 -15
- package/dist/server/rpc/handlers/download-asset.js +133 -40
- package/dist/server/rpc/handlers/index.d.ts +2 -0
- package/dist/server/rpc/handlers/index.js +2 -0
- package/dist/server/rpc/handlers/load-model/download-manager.d.ts +60 -2
- package/dist/server/rpc/handlers/load-model/download-manager.js +141 -8
- package/dist/server/rpc/handlers/load-model/handler.js +213 -98
- package/dist/server/rpc/handlers/load-model/http.js +3 -3
- package/dist/server/rpc/handlers/load-model/hyperdrive.js +1 -1
- package/dist/server/rpc/handlers/load-model/registry.js +1 -1
- package/dist/server/rpc/handlers/load-model/resolve-session.d.ts +20 -1
- package/dist/server/rpc/handlers/load-model/resolve-session.js +6 -5
- package/dist/server/rpc/handlers/load-model/resolve.d.ts +3 -2
- package/dist/server/rpc/handlers/load-model/resolve.js +9 -6
- package/dist/server/rpc/handlers/load-model/types.d.ts +24 -0
- package/dist/server/rpc/handlers/rag.js +133 -15
- package/dist/server/rpc/handlers/upscale-stream.d.ts +3 -0
- package/dist/server/rpc/handlers/upscale-stream.js +4 -0
- package/dist/server/utils/completion-normalizer.js +8 -0
- package/dist/server/utils/tools/dialect.js +4 -0
- package/dist/server/utils/tools/parser.js +16 -1
- package/dist/server/utils/tools/parsers/gemma4native.d.ts +4 -0
- package/dist/server/utils/tools/parsers/gemma4native.js +60 -0
- package/dist/server/utils/tools/parsers/qwen35.d.ts +4 -0
- package/dist/server/utils/tools/parsers/qwen35.js +120 -0
- package/dist/utils/aggregate-events.d.ts +9 -0
- package/dist/utils/aggregate-events.js +18 -3
- package/dist/utils/decorate-promise.d.ts +34 -0
- package/dist/utils/decorate-promise.js +35 -0
- package/dist/utils/errors-client.d.ts +3 -0
- package/dist/utils/errors-client.js +5 -0
- package/dist/utils/errors-server.d.ts +85 -0
- package/dist/utils/errors-server.js +97 -0
- package/package.json +20 -15
|
@@ -46,6 +46,9 @@ export declare const parakeetPlugin: {
|
|
|
46
46
|
sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
|
|
47
47
|
addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
48
48
|
embeddings: "embeddings";
|
|
49
|
+
diffusion: "diffusion";
|
|
50
|
+
tts: "tts";
|
|
51
|
+
ocr: "ocr";
|
|
49
52
|
"llamacpp-completion": "llamacpp-completion";
|
|
50
53
|
"whispercpp-transcription": "whispercpp-transcription";
|
|
51
54
|
"llamacpp-embedding": "llamacpp-embedding";
|
|
@@ -58,9 +61,6 @@ export declare const parakeetPlugin: {
|
|
|
58
61
|
whisper: "whisper";
|
|
59
62
|
nmt: "nmt";
|
|
60
63
|
parakeet: "parakeet";
|
|
61
|
-
tts: "tts";
|
|
62
|
-
ocr: "ocr";
|
|
63
|
-
diffusion: "diffusion";
|
|
64
64
|
}>, import("zod").ZodLiteral<"vad">]>>;
|
|
65
65
|
}, import("zod/v4/core").$strip>]>>;
|
|
66
66
|
parakeetDecoderSrc: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodObject<{
|
|
@@ -76,6 +76,9 @@ export declare const parakeetPlugin: {
|
|
|
76
76
|
sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
|
|
77
77
|
addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
78
78
|
embeddings: "embeddings";
|
|
79
|
+
diffusion: "diffusion";
|
|
80
|
+
tts: "tts";
|
|
81
|
+
ocr: "ocr";
|
|
79
82
|
"llamacpp-completion": "llamacpp-completion";
|
|
80
83
|
"whispercpp-transcription": "whispercpp-transcription";
|
|
81
84
|
"llamacpp-embedding": "llamacpp-embedding";
|
|
@@ -88,9 +91,6 @@ export declare const parakeetPlugin: {
|
|
|
88
91
|
whisper: "whisper";
|
|
89
92
|
nmt: "nmt";
|
|
90
93
|
parakeet: "parakeet";
|
|
91
|
-
tts: "tts";
|
|
92
|
-
ocr: "ocr";
|
|
93
|
-
diffusion: "diffusion";
|
|
94
94
|
}>, import("zod").ZodLiteral<"vad">]>>;
|
|
95
95
|
}, import("zod/v4/core").$strip>]>>;
|
|
96
96
|
parakeetVocabSrc: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodObject<{
|
|
@@ -106,6 +106,9 @@ export declare const parakeetPlugin: {
|
|
|
106
106
|
sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
|
|
107
107
|
addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
108
108
|
embeddings: "embeddings";
|
|
109
|
+
diffusion: "diffusion";
|
|
110
|
+
tts: "tts";
|
|
111
|
+
ocr: "ocr";
|
|
109
112
|
"llamacpp-completion": "llamacpp-completion";
|
|
110
113
|
"whispercpp-transcription": "whispercpp-transcription";
|
|
111
114
|
"llamacpp-embedding": "llamacpp-embedding";
|
|
@@ -118,9 +121,6 @@ export declare const parakeetPlugin: {
|
|
|
118
121
|
whisper: "whisper";
|
|
119
122
|
nmt: "nmt";
|
|
120
123
|
parakeet: "parakeet";
|
|
121
|
-
tts: "tts";
|
|
122
|
-
ocr: "ocr";
|
|
123
|
-
diffusion: "diffusion";
|
|
124
124
|
}>, import("zod").ZodLiteral<"vad">]>>;
|
|
125
125
|
}, import("zod/v4/core").$strip>]>>;
|
|
126
126
|
parakeetPreprocessorSrc: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodObject<{
|
|
@@ -136,6 +136,9 @@ export declare const parakeetPlugin: {
|
|
|
136
136
|
sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
|
|
137
137
|
addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
138
138
|
embeddings: "embeddings";
|
|
139
|
+
diffusion: "diffusion";
|
|
140
|
+
tts: "tts";
|
|
141
|
+
ocr: "ocr";
|
|
139
142
|
"llamacpp-completion": "llamacpp-completion";
|
|
140
143
|
"whispercpp-transcription": "whispercpp-transcription";
|
|
141
144
|
"llamacpp-embedding": "llamacpp-embedding";
|
|
@@ -148,9 +151,6 @@ export declare const parakeetPlugin: {
|
|
|
148
151
|
whisper: "whisper";
|
|
149
152
|
nmt: "nmt";
|
|
150
153
|
parakeet: "parakeet";
|
|
151
|
-
tts: "tts";
|
|
152
|
-
ocr: "ocr";
|
|
153
|
-
diffusion: "diffusion";
|
|
154
154
|
}>, import("zod").ZodLiteral<"vad">]>>;
|
|
155
155
|
}, import("zod/v4/core").$strip>]>>;
|
|
156
156
|
parakeetCtcModelSrc: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodObject<{
|
|
@@ -166,6 +166,9 @@ export declare const parakeetPlugin: {
|
|
|
166
166
|
sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
|
|
167
167
|
addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
168
168
|
embeddings: "embeddings";
|
|
169
|
+
diffusion: "diffusion";
|
|
170
|
+
tts: "tts";
|
|
171
|
+
ocr: "ocr";
|
|
169
172
|
"llamacpp-completion": "llamacpp-completion";
|
|
170
173
|
"whispercpp-transcription": "whispercpp-transcription";
|
|
171
174
|
"llamacpp-embedding": "llamacpp-embedding";
|
|
@@ -178,9 +181,6 @@ export declare const parakeetPlugin: {
|
|
|
178
181
|
whisper: "whisper";
|
|
179
182
|
nmt: "nmt";
|
|
180
183
|
parakeet: "parakeet";
|
|
181
|
-
tts: "tts";
|
|
182
|
-
ocr: "ocr";
|
|
183
|
-
diffusion: "diffusion";
|
|
184
184
|
}>, import("zod").ZodLiteral<"vad">]>>;
|
|
185
185
|
}, import("zod/v4/core").$strip>]>>;
|
|
186
186
|
parakeetTokenizerSrc: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodObject<{
|
|
@@ -196,6 +196,9 @@ export declare const parakeetPlugin: {
|
|
|
196
196
|
sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
|
|
197
197
|
addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
198
198
|
embeddings: "embeddings";
|
|
199
|
+
diffusion: "diffusion";
|
|
200
|
+
tts: "tts";
|
|
201
|
+
ocr: "ocr";
|
|
199
202
|
"llamacpp-completion": "llamacpp-completion";
|
|
200
203
|
"whispercpp-transcription": "whispercpp-transcription";
|
|
201
204
|
"llamacpp-embedding": "llamacpp-embedding";
|
|
@@ -208,9 +211,6 @@ export declare const parakeetPlugin: {
|
|
|
208
211
|
whisper: "whisper";
|
|
209
212
|
nmt: "nmt";
|
|
210
213
|
parakeet: "parakeet";
|
|
211
|
-
tts: "tts";
|
|
212
|
-
ocr: "ocr";
|
|
213
|
-
diffusion: "diffusion";
|
|
214
214
|
}>, import("zod").ZodLiteral<"vad">]>>;
|
|
215
215
|
}, import("zod/v4/core").$strip>]>>;
|
|
216
216
|
parakeetSortformerSrc: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodObject<{
|
|
@@ -226,6 +226,9 @@ export declare const parakeetPlugin: {
|
|
|
226
226
|
sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
|
|
227
227
|
addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
228
228
|
embeddings: "embeddings";
|
|
229
|
+
diffusion: "diffusion";
|
|
230
|
+
tts: "tts";
|
|
231
|
+
ocr: "ocr";
|
|
229
232
|
"llamacpp-completion": "llamacpp-completion";
|
|
230
233
|
"whispercpp-transcription": "whispercpp-transcription";
|
|
231
234
|
"llamacpp-embedding": "llamacpp-embedding";
|
|
@@ -238,9 +241,6 @@ export declare const parakeetPlugin: {
|
|
|
238
241
|
whisper: "whisper";
|
|
239
242
|
nmt: "nmt";
|
|
240
243
|
parakeet: "parakeet";
|
|
241
|
-
tts: "tts";
|
|
242
|
-
ocr: "ocr";
|
|
243
|
-
diffusion: "diffusion";
|
|
244
244
|
}>, import("zod").ZodLiteral<"vad">]>>;
|
|
245
245
|
}, import("zod/v4/core").$strip>]>>;
|
|
246
246
|
}, import("zod/v4/core").$strip>;
|
|
@@ -260,6 +260,7 @@ export declare const parakeetPlugin: {
|
|
|
260
260
|
value: import("zod").ZodString;
|
|
261
261
|
}, import("zod/v4/core").$strip>], "type">;
|
|
262
262
|
type: import("zod").ZodLiteral<"transcribe">;
|
|
263
|
+
requestId: import("zod").ZodOptional<import("zod").ZodString>;
|
|
263
264
|
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
264
265
|
text: import("zod").ZodOptional<import("zod").ZodString>;
|
|
265
266
|
done: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
@@ -283,6 +284,13 @@ export declare const parakeetPlugin: {
|
|
|
283
284
|
append: import("zod").ZodBoolean;
|
|
284
285
|
id: import("zod").ZodNumber;
|
|
285
286
|
}, import("zod/v4/core").$strip>>;
|
|
287
|
+
vad: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
288
|
+
speaking: import("zod").ZodBoolean;
|
|
289
|
+
probability: import("zod").ZodNumber;
|
|
290
|
+
}, import("zod/v4/core").$strip>>;
|
|
291
|
+
endOfTurn: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
292
|
+
silenceDurationMs: import("zod").ZodNumber;
|
|
293
|
+
}, import("zod/v4/core").$strip>>;
|
|
286
294
|
type: import("zod").ZodLiteral<"transcribe">;
|
|
287
295
|
}, import("zod/v4/core").$strip>>;
|
|
288
296
|
};
|
|
@@ -126,6 +126,9 @@ export const parakeetPlugin = definePlugin({
|
|
|
126
126
|
requestSchema: transcribeRequestSchema,
|
|
127
127
|
responseSchema: transcribeResponseSchema,
|
|
128
128
|
streaming: true,
|
|
129
|
+
// Parakeet addon exposes a model-wide hard cancel — compute is
|
|
130
|
+
// interrupted on the currently-running transcription.
|
|
131
|
+
cancel: { scope: "model", hard: true },
|
|
129
132
|
handler: async function* (request) {
|
|
130
133
|
if (request.metadata === true) {
|
|
131
134
|
throw new TranscriptionFailedError(`Parakeet transcription does not support metadata: true; only the whisper engine emits per-segment metadata. Use a whisper model to receive segments.`);
|
|
@@ -134,7 +137,7 @@ export const parakeetPlugin = definePlugin({
|
|
|
134
137
|
modelId: request.modelId,
|
|
135
138
|
audioChunk: request.audioChunk,
|
|
136
139
|
prompt: request.prompt,
|
|
137
|
-
});
|
|
140
|
+
}, request.requestId);
|
|
138
141
|
try {
|
|
139
142
|
let result = await stream.next();
|
|
140
143
|
while (!result.done) {
|
|
@@ -4,6 +4,9 @@ export async function* diffusion(request) {
|
|
|
4
4
|
const init_image = request.init_image
|
|
5
5
|
? Buffer.from(request.init_image, "base64")
|
|
6
6
|
: undefined;
|
|
7
|
+
const init_images = request.init_images
|
|
8
|
+
? request.init_images.map((b64) => Buffer.from(b64, "base64"))
|
|
9
|
+
: undefined;
|
|
7
10
|
const response = await model.run({
|
|
8
11
|
prompt: request.prompt,
|
|
9
12
|
negative_prompt: request.negative_prompt,
|
|
@@ -20,7 +23,12 @@ export async function* diffusion(request) {
|
|
|
20
23
|
vae_tiling: request.vae_tiling,
|
|
21
24
|
cache_preset: request.cache_preset,
|
|
22
25
|
init_image,
|
|
26
|
+
init_images,
|
|
27
|
+
increase_ref_index: request.increase_ref_index,
|
|
28
|
+
auto_resize_ref_image: request.auto_resize_ref_image,
|
|
23
29
|
strength: request.strength,
|
|
30
|
+
lora: request.lora,
|
|
31
|
+
upscale: request.upscale === false ? undefined : request.upscale,
|
|
24
32
|
});
|
|
25
33
|
let outputIndex = 0;
|
|
26
34
|
for await (const chunk of response.iterate()) {
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { EsrganUpscaler } from "@qvac/diffusion-cpp";
|
|
2
|
+
import { getModel, getModelEntry, } from "../../../registry/model-registry.js";
|
|
3
|
+
import { ModelOperationNotSupportedError } from "../../../../../utils/errors-server.js";
|
|
4
|
+
import { ModelType } from "../../../../../schemas/index.js";
|
|
5
|
+
// The diffusion plugin instantiates `EsrganUpscaler` when the model is loaded
|
|
6
|
+
// with `modelConfig.mode === "upscale"` and `ImgStableDiffusion` otherwise. The
|
|
7
|
+
// latter has no `.upscale()` method, so we refuse the call upfront with a
|
|
8
|
+
// structured error rather than letting a TypeError propagate.
|
|
9
|
+
function asUpscalerModel(model, modelId) {
|
|
10
|
+
if (model instanceof EsrganUpscaler) {
|
|
11
|
+
return model;
|
|
12
|
+
}
|
|
13
|
+
const entry = getModelEntry(modelId);
|
|
14
|
+
const modelType = entry && !entry.isDelegated ? entry.local.modelType : ModelType.sdcppGeneration;
|
|
15
|
+
throw new ModelOperationNotSupportedError(modelId, modelType, "upscale", ["diffusion"], []);
|
|
16
|
+
}
|
|
17
|
+
export async function* upscale(request) {
|
|
18
|
+
const model = asUpscalerModel(getModel(request.modelId), request.modelId);
|
|
19
|
+
const response = await model.upscale(Buffer.from(request.image, "base64"), request.repeats === undefined ? undefined : { repeats: request.repeats });
|
|
20
|
+
// The addon emits exactly one final PNG regardless of `repeats`, so
|
|
21
|
+
// this loop typically iterates once. `outputIndex` is still emitted for
|
|
22
|
+
// wire parity with diffusionStream and to leave headroom for future
|
|
23
|
+
// multi-output variants.
|
|
24
|
+
let outputIndex = 0;
|
|
25
|
+
for await (const chunk of response.iterate()) {
|
|
26
|
+
if (chunk instanceof Uint8Array) {
|
|
27
|
+
yield {
|
|
28
|
+
type: "upscaleStream",
|
|
29
|
+
data: Buffer.from(chunk).toString("base64"),
|
|
30
|
+
outputIndex: outputIndex++,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const responseWithStats = response;
|
|
35
|
+
yield {
|
|
36
|
+
type: "upscaleStream",
|
|
37
|
+
done: true,
|
|
38
|
+
stats: responseWithStats.stats ?? undefined,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { type CreateModelParams, type PluginModelResult, type ResolveContext, type ResolveResult, type SdcppConfig } from "../../../../schemas/index";
|
|
2
|
-
type DiffusionArtifactKey = "clipLModelPath" | "clipGModelPath" | "t5XxlModelPath" | "llmModelPath" | "vaeModelPath";
|
|
2
|
+
type DiffusionArtifactKey = "clipLModelPath" | "clipGModelPath" | "t5XxlModelPath" | "llmModelPath" | "vaeModelPath" | "esrganModelPath";
|
|
3
3
|
export declare const diffusionPlugin: {
|
|
4
4
|
modelType: "sdcpp-generation";
|
|
5
5
|
displayName: string;
|
|
6
6
|
addonPackage: "@qvac/diffusion-cpp";
|
|
7
7
|
loadConfigSchema: import("zod").ZodObject<{
|
|
8
|
+
mode: import("zod").ZodDefault<import("zod").ZodEnum<{
|
|
9
|
+
diffusion: "diffusion";
|
|
10
|
+
upscale: "upscale";
|
|
11
|
+
}>>;
|
|
8
12
|
threads: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
9
13
|
device: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
10
14
|
cpu: "cpu";
|
|
@@ -49,6 +53,11 @@ export declare const diffusionPlugin: {
|
|
|
49
53
|
vae_on_cpu: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
50
54
|
vae_tiling: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
51
55
|
flash_attn: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
56
|
+
lora_apply_mode: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
57
|
+
auto: "auto";
|
|
58
|
+
immediately: "immediately";
|
|
59
|
+
at_runtime: "at_runtime";
|
|
60
|
+
}>>;
|
|
52
61
|
verbosity: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
53
62
|
clipLModelSrc: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodObject<{
|
|
54
63
|
src: import("zod").ZodString;
|
|
@@ -63,6 +72,9 @@ export declare const diffusionPlugin: {
|
|
|
63
72
|
sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
|
|
64
73
|
addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
65
74
|
embeddings: "embeddings";
|
|
75
|
+
diffusion: "diffusion";
|
|
76
|
+
tts: "tts";
|
|
77
|
+
ocr: "ocr";
|
|
66
78
|
"llamacpp-completion": "llamacpp-completion";
|
|
67
79
|
"whispercpp-transcription": "whispercpp-transcription";
|
|
68
80
|
"llamacpp-embedding": "llamacpp-embedding";
|
|
@@ -75,9 +87,6 @@ export declare const diffusionPlugin: {
|
|
|
75
87
|
whisper: "whisper";
|
|
76
88
|
nmt: "nmt";
|
|
77
89
|
parakeet: "parakeet";
|
|
78
|
-
tts: "tts";
|
|
79
|
-
ocr: "ocr";
|
|
80
|
-
diffusion: "diffusion";
|
|
81
90
|
}>, import("zod").ZodLiteral<"vad">]>>;
|
|
82
91
|
}, import("zod/v4/core").$strip>]>>;
|
|
83
92
|
clipGModelSrc: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodObject<{
|
|
@@ -93,6 +102,9 @@ export declare const diffusionPlugin: {
|
|
|
93
102
|
sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
|
|
94
103
|
addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
95
104
|
embeddings: "embeddings";
|
|
105
|
+
diffusion: "diffusion";
|
|
106
|
+
tts: "tts";
|
|
107
|
+
ocr: "ocr";
|
|
96
108
|
"llamacpp-completion": "llamacpp-completion";
|
|
97
109
|
"whispercpp-transcription": "whispercpp-transcription";
|
|
98
110
|
"llamacpp-embedding": "llamacpp-embedding";
|
|
@@ -105,9 +117,6 @@ export declare const diffusionPlugin: {
|
|
|
105
117
|
whisper: "whisper";
|
|
106
118
|
nmt: "nmt";
|
|
107
119
|
parakeet: "parakeet";
|
|
108
|
-
tts: "tts";
|
|
109
|
-
ocr: "ocr";
|
|
110
|
-
diffusion: "diffusion";
|
|
111
120
|
}>, import("zod").ZodLiteral<"vad">]>>;
|
|
112
121
|
}, import("zod/v4/core").$strip>]>>;
|
|
113
122
|
t5XxlModelSrc: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodObject<{
|
|
@@ -123,6 +132,9 @@ export declare const diffusionPlugin: {
|
|
|
123
132
|
sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
|
|
124
133
|
addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
125
134
|
embeddings: "embeddings";
|
|
135
|
+
diffusion: "diffusion";
|
|
136
|
+
tts: "tts";
|
|
137
|
+
ocr: "ocr";
|
|
126
138
|
"llamacpp-completion": "llamacpp-completion";
|
|
127
139
|
"whispercpp-transcription": "whispercpp-transcription";
|
|
128
140
|
"llamacpp-embedding": "llamacpp-embedding";
|
|
@@ -135,9 +147,6 @@ export declare const diffusionPlugin: {
|
|
|
135
147
|
whisper: "whisper";
|
|
136
148
|
nmt: "nmt";
|
|
137
149
|
parakeet: "parakeet";
|
|
138
|
-
tts: "tts";
|
|
139
|
-
ocr: "ocr";
|
|
140
|
-
diffusion: "diffusion";
|
|
141
150
|
}>, import("zod").ZodLiteral<"vad">]>>;
|
|
142
151
|
}, import("zod/v4/core").$strip>]>>;
|
|
143
152
|
llmModelSrc: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodObject<{
|
|
@@ -153,6 +162,9 @@ export declare const diffusionPlugin: {
|
|
|
153
162
|
sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
|
|
154
163
|
addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
155
164
|
embeddings: "embeddings";
|
|
165
|
+
diffusion: "diffusion";
|
|
166
|
+
tts: "tts";
|
|
167
|
+
ocr: "ocr";
|
|
156
168
|
"llamacpp-completion": "llamacpp-completion";
|
|
157
169
|
"whispercpp-transcription": "whispercpp-transcription";
|
|
158
170
|
"llamacpp-embedding": "llamacpp-embedding";
|
|
@@ -165,9 +177,6 @@ export declare const diffusionPlugin: {
|
|
|
165
177
|
whisper: "whisper";
|
|
166
178
|
nmt: "nmt";
|
|
167
179
|
parakeet: "parakeet";
|
|
168
|
-
tts: "tts";
|
|
169
|
-
ocr: "ocr";
|
|
170
|
-
diffusion: "diffusion";
|
|
171
180
|
}>, import("zod").ZodLiteral<"vad">]>>;
|
|
172
181
|
}, import("zod/v4/core").$strip>]>>;
|
|
173
182
|
vaeModelSrc: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodObject<{
|
|
@@ -183,6 +192,9 @@ export declare const diffusionPlugin: {
|
|
|
183
192
|
sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
|
|
184
193
|
addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
185
194
|
embeddings: "embeddings";
|
|
195
|
+
diffusion: "diffusion";
|
|
196
|
+
tts: "tts";
|
|
197
|
+
ocr: "ocr";
|
|
186
198
|
"llamacpp-completion": "llamacpp-completion";
|
|
187
199
|
"whispercpp-transcription": "whispercpp-transcription";
|
|
188
200
|
"llamacpp-embedding": "llamacpp-embedding";
|
|
@@ -195,11 +207,45 @@ export declare const diffusionPlugin: {
|
|
|
195
207
|
whisper: "whisper";
|
|
196
208
|
nmt: "nmt";
|
|
197
209
|
parakeet: "parakeet";
|
|
198
|
-
tts: "tts";
|
|
199
|
-
ocr: "ocr";
|
|
200
|
-
diffusion: "diffusion";
|
|
201
210
|
}>, import("zod").ZodLiteral<"vad">]>>;
|
|
202
211
|
}, import("zod/v4/core").$strip>]>>;
|
|
212
|
+
upscaler: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
213
|
+
type: import("zod").ZodOptional<import("zod").ZodLiteral<"esrgan">>;
|
|
214
|
+
model_src: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodObject<{
|
|
215
|
+
src: import("zod").ZodString;
|
|
216
|
+
name: import("zod").ZodOptional<import("zod").ZodString>;
|
|
217
|
+
modelId: import("zod").ZodOptional<import("zod").ZodString>;
|
|
218
|
+
registryPath: import("zod").ZodOptional<import("zod").ZodString>;
|
|
219
|
+
registrySource: import("zod").ZodOptional<import("zod").ZodString>;
|
|
220
|
+
blobCoreKey: import("zod").ZodOptional<import("zod").ZodString>;
|
|
221
|
+
blobIndex: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
222
|
+
engine: import("zod").ZodOptional<import("zod").ZodString>;
|
|
223
|
+
expectedSize: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
224
|
+
sha256Checksum: import("zod").ZodOptional<import("zod").ZodString>;
|
|
225
|
+
addon: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodEnum<{
|
|
226
|
+
embeddings: "embeddings";
|
|
227
|
+
diffusion: "diffusion";
|
|
228
|
+
tts: "tts";
|
|
229
|
+
ocr: "ocr";
|
|
230
|
+
"llamacpp-completion": "llamacpp-completion";
|
|
231
|
+
"whispercpp-transcription": "whispercpp-transcription";
|
|
232
|
+
"llamacpp-embedding": "llamacpp-embedding";
|
|
233
|
+
"nmtcpp-translation": "nmtcpp-translation";
|
|
234
|
+
"onnx-tts": "onnx-tts";
|
|
235
|
+
"parakeet-transcription": "parakeet-transcription";
|
|
236
|
+
"onnx-ocr": "onnx-ocr";
|
|
237
|
+
"sdcpp-generation": "sdcpp-generation";
|
|
238
|
+
llm: "llm";
|
|
239
|
+
whisper: "whisper";
|
|
240
|
+
nmt: "nmt";
|
|
241
|
+
parakeet: "parakeet";
|
|
242
|
+
}>, import("zod").ZodLiteral<"vad">]>>;
|
|
243
|
+
}, import("zod/v4/core").$strip>]>>;
|
|
244
|
+
tile_size: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
245
|
+
direct: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
246
|
+
offload_params_to_cpu: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
247
|
+
threads: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodLiteral<-1>, import("zod").ZodNumber]>>;
|
|
248
|
+
}, import("zod/v4/core").$strict>>;
|
|
203
249
|
}, import("zod/v4/core").$strip>;
|
|
204
250
|
resolveConfig(cfg: SdcppConfig, ctx: ResolveContext): Promise<ResolveResult<SdcppConfig, DiffusionArtifactKey>>;
|
|
205
251
|
createModel(params: CreateModelParams): PluginModelResult;
|
|
@@ -248,7 +294,14 @@ export declare const diffusionPlugin: {
|
|
|
248
294
|
vae_tiling: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
249
295
|
cache_preset: import("zod").ZodOptional<import("zod").ZodString>;
|
|
250
296
|
init_image: import("zod").ZodOptional<import("zod").ZodString>;
|
|
297
|
+
init_images: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
298
|
+
increase_ref_index: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
299
|
+
auto_resize_ref_image: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
300
|
+
lora: import("zod").ZodOptional<import("zod").ZodString>;
|
|
251
301
|
strength: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
302
|
+
upscale: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodBoolean, import("zod").ZodObject<{
|
|
303
|
+
repeats: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
304
|
+
}, import("zod/v4/core").$strict>]>>;
|
|
252
305
|
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
253
306
|
type: import("zod").ZodLiteral<"diffusionStream">;
|
|
254
307
|
step: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
@@ -271,6 +324,28 @@ export declare const diffusionPlugin: {
|
|
|
271
324
|
seed: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
272
325
|
}, import("zod/v4/core").$strip>>;
|
|
273
326
|
}, import("zod/v4/core").$strip>>;
|
|
327
|
+
upscaleStream: import("../../../../schemas/index").PluginHandlerDefinition<import("zod").ZodObject<{
|
|
328
|
+
modelId: import("zod").ZodString;
|
|
329
|
+
image: import("zod").ZodString;
|
|
330
|
+
repeats: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
331
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodObject<{
|
|
332
|
+
type: import("zod").ZodLiteral<"upscaleStream">;
|
|
333
|
+
data: import("zod").ZodOptional<import("zod").ZodString>;
|
|
334
|
+
outputIndex: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
335
|
+
done: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
336
|
+
stats: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
337
|
+
modelLoadMs: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
338
|
+
upscaleMs: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
339
|
+
totalUpscaleMs: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
340
|
+
totalWallMs: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
341
|
+
totalUpscales: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
342
|
+
totalImages: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
343
|
+
totalPixels: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
344
|
+
width: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
345
|
+
height: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
346
|
+
repeats: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
347
|
+
}, import("zod/v4/core").$strip>>;
|
|
348
|
+
}, import("zod/v4/core").$strip>>;
|
|
274
349
|
};
|
|
275
350
|
logging: {
|
|
276
351
|
module: import("@qvac/diffusion-cpp/addonLogging").AddonLogging;
|
|
@@ -1,27 +1,72 @@
|
|
|
1
|
-
import ImgStableDiffusion, {} from "@qvac/diffusion-cpp";
|
|
1
|
+
import ImgStableDiffusion, { EsrganUpscaler, } from "@qvac/diffusion-cpp";
|
|
2
2
|
import addonLogging from "@qvac/diffusion-cpp/addonLogging.js";
|
|
3
|
-
import { definePlugin, defineHandler, sdcppConfigSchema, diffusionRequestSchema, diffusionStreamResponseSchema, ModelType, ADDON_DIFFUSION, } from "../../../../schemas/index.js";
|
|
3
|
+
import { definePlugin, defineHandler, sdcppConfigSchema, diffusionRequestSchema, diffusionStreamResponseSchema, upscaleRequestSchema, upscaleStreamResponseSchema, ModelType, ADDON_DIFFUSION, } from "../../../../schemas/index.js";
|
|
4
4
|
import { createStreamLogger, registerAddonLogger } from "../../../../logging/index.js";
|
|
5
|
+
import { ModelLoadFailedError } from "../../../../utils/errors-server.js";
|
|
5
6
|
import { diffusion } from "./ops/diffusion.js";
|
|
7
|
+
import { upscale } from "./ops/upscale.js";
|
|
8
|
+
// Single source of truth for `SdcppConfig.upscaler.*` → addon-config key
|
|
9
|
+
// mapping. Used by both the diffusion-mode (post-generation upscaler) and the
|
|
10
|
+
// standalone-upscale-mode branches; keeping the mapping in one place avoids
|
|
11
|
+
// drift if `@qvac/diffusion-cpp` ever adds or renames an `upscaler_*` key.
|
|
12
|
+
function flattenUpscalerKeys(upscaler) {
|
|
13
|
+
if (!upscaler)
|
|
14
|
+
return {};
|
|
15
|
+
return {
|
|
16
|
+
...(upscaler.tile_size !== undefined && {
|
|
17
|
+
upscaler_tile_size: upscaler.tile_size,
|
|
18
|
+
}),
|
|
19
|
+
...(upscaler.direct !== undefined && {
|
|
20
|
+
upscaler_direct: upscaler.direct,
|
|
21
|
+
}),
|
|
22
|
+
...(upscaler.offload_params_to_cpu !== undefined && {
|
|
23
|
+
upscaler_offload_params_to_cpu: upscaler.offload_params_to_cpu,
|
|
24
|
+
}),
|
|
25
|
+
...(upscaler.threads !== undefined && {
|
|
26
|
+
upscaler_threads: upscaler.threads,
|
|
27
|
+
}),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function toEsrganAddonConfig(config) {
|
|
31
|
+
return {
|
|
32
|
+
...flattenUpscalerKeys(config.upscaler),
|
|
33
|
+
...(config.verbosity !== undefined && { verbosity: config.verbosity }),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
6
36
|
export const diffusionPlugin = definePlugin({
|
|
7
37
|
modelType: ModelType.sdcppGeneration,
|
|
8
|
-
displayName: "Image Generation (stable-diffusion.cpp)",
|
|
38
|
+
displayName: "Image Generation & Upscaling (stable-diffusion.cpp)",
|
|
9
39
|
addonPackage: ADDON_DIFFUSION,
|
|
10
40
|
loadConfigSchema: sdcppConfigSchema,
|
|
11
41
|
async resolveConfig(cfg, ctx) {
|
|
12
|
-
|
|
13
|
-
|
|
42
|
+
// Standalone-upscaler mode never references auxiliary models: the primary
|
|
43
|
+
// modelSrc IS the ESRGAN file. Skip resolution to avoid downloading
|
|
44
|
+
// unused encoders/VAEs and to keep load fast.
|
|
45
|
+
if (cfg.mode === "upscale") {
|
|
46
|
+
return { config: cfg };
|
|
47
|
+
}
|
|
48
|
+
const { clipLModelSrc, clipGModelSrc, t5XxlModelSrc, llmModelSrc, vaeModelSrc, upscaler, ...rest } = cfg;
|
|
49
|
+
const { model_src: esrganModelSrc, ...upscalerRuntime } = upscaler ?? {};
|
|
50
|
+
const runtimeConfig = {
|
|
51
|
+
...rest,
|
|
52
|
+
...(upscaler && { upscaler: upscalerRuntime }),
|
|
53
|
+
};
|
|
54
|
+
const sources = {
|
|
55
|
+
clipLModelSrc, clipGModelSrc, t5XxlModelSrc,
|
|
56
|
+
llmModelSrc, vaeModelSrc, esrganModelSrc,
|
|
57
|
+
};
|
|
14
58
|
const hasSources = Object.values(sources).some(Boolean);
|
|
15
59
|
if (!hasSources) {
|
|
16
60
|
return { config: runtimeConfig };
|
|
17
61
|
}
|
|
18
62
|
const resolve = ctx.resolveModelPath;
|
|
19
|
-
const [clipLModelPath, clipGModelPath, t5XxlModelPath, llmModelPath, vaeModelPath] = await Promise.all([
|
|
63
|
+
const [clipLModelPath, clipGModelPath, t5XxlModelPath, llmModelPath, vaeModelPath, esrganModelPath,] = await Promise.all([
|
|
20
64
|
clipLModelSrc ? resolve(clipLModelSrc) : undefined,
|
|
21
65
|
clipGModelSrc ? resolve(clipGModelSrc) : undefined,
|
|
22
66
|
t5XxlModelSrc ? resolve(t5XxlModelSrc) : undefined,
|
|
23
67
|
llmModelSrc ? resolve(llmModelSrc) : undefined,
|
|
24
68
|
vaeModelSrc ? resolve(vaeModelSrc) : undefined,
|
|
69
|
+
esrganModelSrc ? resolve(esrganModelSrc) : undefined,
|
|
25
70
|
]);
|
|
26
71
|
return {
|
|
27
72
|
config: runtimeConfig,
|
|
@@ -31,14 +76,37 @@ export const diffusionPlugin = definePlugin({
|
|
|
31
76
|
...(t5XxlModelPath && { t5XxlModelPath }),
|
|
32
77
|
...(llmModelPath && { llmModelPath }),
|
|
33
78
|
...(vaeModelPath && { vaeModelPath }),
|
|
79
|
+
...(esrganModelPath && { esrganModelPath }),
|
|
34
80
|
},
|
|
35
81
|
};
|
|
36
82
|
},
|
|
37
83
|
createModel(params) {
|
|
38
84
|
const { modelId, modelPath, modelConfig, artifacts } = params;
|
|
39
85
|
const config = (modelConfig ?? {});
|
|
86
|
+
// In diffusion mode the ESRGAN file (when post-generation upscale is
|
|
87
|
+
// wanted) must come from upscaler.model_src — the primary modelPath is
|
|
88
|
+
// the main diffusion checkpoint. Reject early with a clear error
|
|
89
|
+
// instead of letting the native addon fail mid-load. Done before any
|
|
90
|
+
// logger / native side-effects so callers can recover cleanly.
|
|
91
|
+
if (config.mode !== "upscale" &&
|
|
92
|
+
config.upscaler !== undefined &&
|
|
93
|
+
!artifacts?.["esrganModelPath"]) {
|
|
94
|
+
throw new ModelLoadFailedError("modelConfig.upscaler.model_src is required when modelConfig.upscaler " +
|
|
95
|
+
"is set in diffusion mode. Provide the ESRGAN model, omit the " +
|
|
96
|
+
"upscaler block, or switch to modelConfig.mode = 'upscale' to load " +
|
|
97
|
+
"a standalone upscaler.");
|
|
98
|
+
}
|
|
40
99
|
const logger = createStreamLogger(modelId, ModelType.sdcppGeneration);
|
|
41
100
|
registerAddonLogger(modelId, ModelType.sdcppGeneration, logger);
|
|
101
|
+
if (config.mode === "upscale") {
|
|
102
|
+
const model = new EsrganUpscaler({
|
|
103
|
+
files: { esrgan: modelPath },
|
|
104
|
+
config: toEsrganAddonConfig(config),
|
|
105
|
+
logger,
|
|
106
|
+
opts: { stats: true },
|
|
107
|
+
});
|
|
108
|
+
return { model };
|
|
109
|
+
}
|
|
42
110
|
const files = {
|
|
43
111
|
model: modelPath,
|
|
44
112
|
...(artifacts?.["clipLModelPath"] && { clipL: artifacts["clipLModelPath"] }),
|
|
@@ -46,10 +114,20 @@ export const diffusionPlugin = definePlugin({
|
|
|
46
114
|
...(artifacts?.["t5XxlModelPath"] && { t5Xxl: artifacts["t5XxlModelPath"] }),
|
|
47
115
|
...(artifacts?.["llmModelPath"] && { llm: artifacts["llmModelPath"] }),
|
|
48
116
|
...(artifacts?.["vaeModelPath"] && { vae: artifacts["vaeModelPath"] }),
|
|
117
|
+
...(artifacts?.["esrganModelPath"] && { esrgan: artifacts["esrganModelPath"] }),
|
|
118
|
+
};
|
|
119
|
+
// `mode` is consumed by this plugin to select the model class above; the
|
|
120
|
+
// stable-diffusion.cpp native config does not understand it. Strip it
|
|
121
|
+
// before forwarding `rest` to the addon.
|
|
122
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
123
|
+
const { upscaler, mode, ...rest } = config;
|
|
124
|
+
const addonConfig = {
|
|
125
|
+
...rest,
|
|
126
|
+
...flattenUpscalerKeys(upscaler),
|
|
49
127
|
};
|
|
50
128
|
const model = new ImgStableDiffusion({
|
|
51
129
|
files,
|
|
52
|
-
config:
|
|
130
|
+
config: addonConfig,
|
|
53
131
|
logger,
|
|
54
132
|
opts: { stats: true },
|
|
55
133
|
});
|
|
@@ -60,8 +138,20 @@ export const diffusionPlugin = definePlugin({
|
|
|
60
138
|
requestSchema: diffusionRequestSchema,
|
|
61
139
|
responseSchema: diffusionStreamResponseSchema,
|
|
62
140
|
streaming: true,
|
|
141
|
+
// sdcpp diffusion exposes a model-wide hard cancel — compute
|
|
142
|
+
// is interrupted on the currently-running generation.
|
|
143
|
+
cancel: { scope: "model", hard: true },
|
|
63
144
|
handler: diffusion,
|
|
64
145
|
}),
|
|
146
|
+
upscaleStream: defineHandler({
|
|
147
|
+
requestSchema: upscaleRequestSchema,
|
|
148
|
+
responseSchema: upscaleStreamResponseSchema,
|
|
149
|
+
streaming: true,
|
|
150
|
+
// sdcpp upscale path has no cancel surface today — SDK falls
|
|
151
|
+
// back to soft-cancel.
|
|
152
|
+
cancel: { scope: "none" },
|
|
153
|
+
handler: upscale,
|
|
154
|
+
}),
|
|
65
155
|
},
|
|
66
156
|
logging: {
|
|
67
157
|
module: addonLogging,
|