@qvac/sdk 0.2.0-dev.1760804157.f3c48d2 ā 0.2.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/README.md +4 -3
- package/dist/client/rpc/bare-client.js +37 -1
- package/dist/examples/download-with-cancel.js +3 -3
- package/dist/examples/llamacpp-multimodal.js +3 -3
- package/dist/examples/rag/rag-hyperdb-workspaces.js +2 -1
- package/dist/models/hyperdrive/models.d.ts +49 -1
- package/dist/models/hyperdrive/models.js +105 -54
- package/dist/models/hyperdrive/validation.d.ts +6 -0
- package/dist/models/hyperdrive/validation.js +12 -0
- package/dist/schemas/common.d.ts +4 -0
- package/dist/schemas/llamacpp-config.d.ts +1 -0
- package/dist/schemas/llamacpp-config.js +4 -1
- package/dist/schemas/load-model.d.ts +10 -0
- package/dist/schemas/rag.d.ts +3 -0
- package/dist/schemas/rag.js +3 -1
- package/dist/server/bare/addons/llamacpp/handlers/completion-stream.js +28 -2
- package/dist/server/bare/registry/model-registry.d.ts +1 -0
- package/dist/server/bare/utilities/audio/decoder.d.ts +4 -0
- package/dist/server/bare/utilities/audio/decoder.js +38 -0
- package/dist/server/bare/utilities/index.d.ts +2 -0
- package/dist/server/bare/utilities/index.js +1 -0
- package/dist/server/rpc/handlers/completion-stream.js +31 -45
- package/dist/server/rpc/handlers/index.d.ts +4 -0
- package/dist/server/rpc/handlers/index.js +4 -0
- package/dist/server/rpc/handlers/load-model/cache.d.ts +2 -0
- package/dist/server/rpc/handlers/load-model/cache.js +15 -0
- package/dist/server/rpc/handlers/load-model/download-manager.d.ts +0 -19
- package/dist/server/rpc/handlers/load-model/download-manager.js +10 -25
- package/dist/server/rpc/handlers/load-model/hyperdrive.js +121 -80
- package/dist/server/rpc/handlers/load-model/resolve.js +8 -55
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -79,7 +79,7 @@ npm i expo-file-system react-native-bare-kit
|
|
|
79
79
|
```js
|
|
80
80
|
export default {
|
|
81
81
|
expo: {
|
|
82
|
-
plugins: ["qvac
|
|
82
|
+
plugins: ["@qvac/sdk/expo-plugin"],
|
|
83
83
|
},
|
|
84
84
|
};
|
|
85
85
|
```
|
|
@@ -141,6 +141,7 @@ const cachedResponse = completion({
|
|
|
141
141
|
|
|
142
142
|
// Unload model to free up system resources
|
|
143
143
|
await unloadModel({ modelId });
|
|
144
|
+
process.exit();
|
|
144
145
|
```
|
|
145
146
|
|
|
146
147
|
**For more on how to use QVAC SDK, see [SDK at QVAC documentation](https://tether-2.gitbook.io/qvac-by-tether-or-reference/y2AsIh94H9DJ1pIBCNj9/sdk)**.
|
|
@@ -161,10 +162,10 @@ bun run build # or `watch` for hotreload
|
|
|
161
162
|
bun run build:pack
|
|
162
163
|
```
|
|
163
164
|
|
|
164
|
-
This outputs a tarball under `dist/
|
|
165
|
+
This outputs a tarball under `dist/qvac-sdk-{version}.tgz` that you can install in your project, e.g.:
|
|
165
166
|
|
|
166
167
|
```bash
|
|
167
|
-
npm i path/to/
|
|
168
|
+
npm i path/to/qvac-sdk-0.1.0.tgz
|
|
168
169
|
```
|
|
169
170
|
|
|
170
171
|
## Examples
|
|
@@ -45,8 +45,44 @@ export async function* stream(request) {
|
|
|
45
45
|
}
|
|
46
46
|
yield* streamWithProgress();
|
|
47
47
|
}
|
|
48
|
+
else if (request.type === "downloadAsset" &&
|
|
49
|
+
"withProgress" in request &&
|
|
50
|
+
request.withProgress) {
|
|
51
|
+
async function* streamWithProgress() {
|
|
52
|
+
const queue = [];
|
|
53
|
+
let done = false;
|
|
54
|
+
const downloadAssetHandler = handler;
|
|
55
|
+
downloadAssetHandler(request, (update) => queue.push(update))
|
|
56
|
+
.then((final) => {
|
|
57
|
+
queue.push(final);
|
|
58
|
+
done = true;
|
|
59
|
+
})
|
|
60
|
+
.catch((error) => {
|
|
61
|
+
done = true;
|
|
62
|
+
throw error;
|
|
63
|
+
});
|
|
64
|
+
while (!done || queue.length > 0) {
|
|
65
|
+
if (queue.length > 0) {
|
|
66
|
+
yield queue.shift();
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
yield* streamWithProgress();
|
|
74
|
+
}
|
|
48
75
|
else {
|
|
49
|
-
|
|
76
|
+
const result = handler(request);
|
|
77
|
+
// Check if the handler returns a Promise or AsyncGenerator
|
|
78
|
+
if (Symbol.asyncIterator in result) {
|
|
79
|
+
// It's an AsyncGenerator
|
|
80
|
+
yield* result;
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
// It's a Promise, await and yield the single result
|
|
84
|
+
yield await result;
|
|
85
|
+
}
|
|
50
86
|
}
|
|
51
87
|
}
|
|
52
88
|
const createMockRPCRequest = () => {
|
|
@@ -12,9 +12,9 @@ try {
|
|
|
12
12
|
const totalMB = (progress.total / 1024 / 1024).toFixed(2);
|
|
13
13
|
const percentage = progress.percentage.toFixed(1);
|
|
14
14
|
console.log(`š Progress: ${percentage}% (${downloadedMB}MB / ${totalMB}MB)`);
|
|
15
|
-
// Example: Stops at
|
|
16
|
-
if (parseFloat(percentage) >=
|
|
17
|
-
console.log("\nš« Auto-cancelling at
|
|
15
|
+
// Example: Stops at 10% (or use Ctrl+C for manual stop)
|
|
16
|
+
if (parseFloat(percentage) >= 10 && !cancelled) {
|
|
17
|
+
console.log("\nš« Auto-cancelling at 10% for demo purposes...,");
|
|
18
18
|
console.log(`š Progress: ${percentage}% (${downloadedMB}MB / ${totalMB}MB)`);
|
|
19
19
|
console.log(progress);
|
|
20
20
|
cancelled = true;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { completion, loadModel, unloadModel } from "@qvac/sdk";
|
|
1
|
+
import { completion, loadModel, SMOLVLM2_2_500M_MULTIMODAL_Q8_0, MMPROJ_SMOLVLM2_2_500M_MULTIMODAL_Q8_0, unloadModel, } from "@qvac/sdk";
|
|
2
2
|
if (process.argv.length < 3) {
|
|
3
3
|
console.error(`Specify an image file path as the first argument and a second image file path as the second (optional) argument`);
|
|
4
4
|
process.exit(1);
|
|
@@ -8,9 +8,9 @@ try {
|
|
|
8
8
|
const imageFilePath = process.argv[2];
|
|
9
9
|
// Load the main model with projection in a single step
|
|
10
10
|
const modelId = await loadModel({
|
|
11
|
-
modelSrc:
|
|
11
|
+
modelSrc: SMOLVLM2_2_500M_MULTIMODAL_Q8_0,
|
|
12
12
|
modelType: "llm",
|
|
13
|
-
projectionModelSrc:
|
|
13
|
+
projectionModelSrc: MMPROJ_SMOLVLM2_2_500M_MULTIMODAL_Q8_0,
|
|
14
14
|
modelConfig: {
|
|
15
15
|
ctx_size: 1024,
|
|
16
16
|
},
|
|
@@ -41,9 +41,10 @@ try {
|
|
|
41
41
|
documents: medicalArticle,
|
|
42
42
|
chunk: true,
|
|
43
43
|
chunkOpts: {
|
|
44
|
-
chunkSize:
|
|
44
|
+
chunkSize: 100,
|
|
45
45
|
chunkOverlap: 10,
|
|
46
46
|
chunkStrategy: "paragraph",
|
|
47
|
+
splitStrategy: "token",
|
|
47
48
|
},
|
|
48
49
|
});
|
|
49
50
|
console.log(`ā
Created ${medicalResult.processed.length} chunks from medical article`);
|
|
@@ -62,6 +62,20 @@ export declare const models: readonly [{
|
|
|
62
62
|
readonly addon: "llm";
|
|
63
63
|
readonly expectedSize: 1056782912;
|
|
64
64
|
readonly sha256Checksum: "c876f159707a4e4f70e045106c69db15bfc935a4981706fd4f65c6e7ea1e81c5";
|
|
65
|
+
}, {
|
|
66
|
+
readonly hyperdriveKey: "583f04c31d151b29e02aaf98f80d16aff585714ef9e2806a5067651c0f64ae31";
|
|
67
|
+
readonly hyperbeeKey: "generation:qwen2.5-omni:multimodal::3B::1.0.0";
|
|
68
|
+
readonly modelId: "Qwen2.5-Omni-3B-Q4_K_M.gguf";
|
|
69
|
+
readonly addon: "llm";
|
|
70
|
+
readonly expectedSize: 2104931648;
|
|
71
|
+
readonly sha256Checksum: "4b0bd358c1e9ec55dd3055ef6d71c958c821533d85916a10cfa89c4552a86e29";
|
|
72
|
+
}, {
|
|
73
|
+
readonly hyperdriveKey: "583f04c31d151b29e02aaf98f80d16aff585714ef9e2806a5067651c0f64ae31";
|
|
74
|
+
readonly hyperbeeKey: "generation:qwen2.5-omni:multimodal::3B::1.0.0";
|
|
75
|
+
readonly modelId: "mmproj-Qwen2.5-Omni-3B-Q8_0.gguf";
|
|
76
|
+
readonly addon: "llm";
|
|
77
|
+
readonly expectedSize: 1538031328;
|
|
78
|
+
readonly sha256Checksum: "4e6c816cd33f7298d07cb780c136a396631e50e62f6501660271f8c6e302e565";
|
|
65
79
|
}, {
|
|
66
80
|
readonly hyperdriveKey: "d331ed49c444f90b3b2a70aa5b820752685142bf2d769a0592ed666140477578";
|
|
67
81
|
readonly hyperbeeKey: "generation:qwen3:instruct::0.6B::1.0.0";
|
|
@@ -97,6 +111,34 @@ export declare const models: readonly [{
|
|
|
97
111
|
readonly addon: "llm";
|
|
98
112
|
readonly expectedSize: 2401075552;
|
|
99
113
|
readonly sha256Checksum: "9cfebb63cd7e6b6d1755ea8ef001fcdadfa17831da1db96eafe3fc554913d5e1";
|
|
114
|
+
}, {
|
|
115
|
+
readonly hyperdriveKey: "b99c6f5dcadaad827cdcb1a129a3b34aff6ad28056738e0bd559c7ffb807e30f";
|
|
116
|
+
readonly hyperbeeKey: "generation:smolVLM2:multimodal:2:500M:f16:1.0.0:video-instruct";
|
|
117
|
+
readonly modelId: "SmolVLM2-500M-Video-Instruct-f16.gguf";
|
|
118
|
+
readonly addon: "llm";
|
|
119
|
+
readonly expectedSize: 820424704;
|
|
120
|
+
readonly sha256Checksum: "80f7e3f04bc2d3324ac1a9f52f5776fe13a69912adf74f8e7edacf773d140d77";
|
|
121
|
+
}, {
|
|
122
|
+
readonly hyperdriveKey: "b99c6f5dcadaad827cdcb1a129a3b34aff6ad28056738e0bd559c7ffb807e30f";
|
|
123
|
+
readonly hyperbeeKey: "generation:smolVLM2:multimodal:2:500M:f16:1.0.0:video-instruct";
|
|
124
|
+
readonly modelId: "mmproj-SmolVLM2-500M-Video-Instruct-f16.gguf";
|
|
125
|
+
readonly addon: "llm";
|
|
126
|
+
readonly expectedSize: 199470624;
|
|
127
|
+
readonly sha256Checksum: "b5dc8ebe7cbeab66a5369693960a52515d7824f13d4063ceca78431f2a6b59b0";
|
|
128
|
+
}, {
|
|
129
|
+
readonly hyperdriveKey: "73b1bc01d01e25fa27be7d7f434337d14f054b0315e8463766ca31e778ac6576";
|
|
130
|
+
readonly hyperbeeKey: "generation:smolVLM2:multimodal:2:500M:q8_0:1.0.0:video-instruct";
|
|
131
|
+
readonly modelId: "SmolVLM2-500M-Video-Instruct-Q8_0.gguf";
|
|
132
|
+
readonly addon: "llm";
|
|
133
|
+
readonly expectedSize: 436808704;
|
|
134
|
+
readonly sha256Checksum: "6f67b8036b2469fcd71728702720c6b51aebd759b78137a8120733b4d66438bc";
|
|
135
|
+
}, {
|
|
136
|
+
readonly hyperdriveKey: "73b1bc01d01e25fa27be7d7f434337d14f054b0315e8463766ca31e778ac6576";
|
|
137
|
+
readonly hyperbeeKey: "generation:smolVLM2:multimodal:2:500M:q8_0:1.0.0:video-instruct";
|
|
138
|
+
readonly modelId: "mmproj-SmolVLM2-500M-Video-Instruct-Q8_0.gguf";
|
|
139
|
+
readonly addon: "llm";
|
|
140
|
+
readonly expectedSize: 108785184;
|
|
141
|
+
readonly sha256Checksum: "921dc7e259f308e5b027111fa185efcbf33db13f6e35749ddf7f5cdb60ef520b";
|
|
100
142
|
}, {
|
|
101
143
|
readonly hyperdriveKey: "268c2e9b2a3420632e4b6649e32822f42d5dfbda4c7e96daec5b629ed20f99f7";
|
|
102
144
|
readonly hyperbeeKey: "translation:ggml-indictrans:dist:2:200M:q0f32:1.0.0:en-hi";
|
|
@@ -421,11 +463,17 @@ export declare const GTE_LARGE_FP16: "pear://d1896d9259692818df95bd2480e90c2d057
|
|
|
421
463
|
export declare const LASER_DOLPHIN_2_6_2X7B_INST_Q2_K: "pear://bd40e4bfae48b5bf436d1b0b447ae26e4c384aebe101a5e7df6ae71c919dadf1/dolphin-mixtral-2x7b-dop-Q2_K.gguf";
|
|
422
464
|
export declare const LLAMA_3_2_1B_INST_Q4_0: "pear://afa79ee07c0a138bb9f11bfaee771fb1bdfca8c82d961cff0474e49827bd1de3/Llama-3.2-1B-Instruct-Q4_0.gguf";
|
|
423
465
|
export declare const QWEN_3_1_7B_INST_Q4: "pear://05d3d7ad9cd650f53c28f85e312ef09a645dd487845897958b3be8a19cb3aab9/Qwen3-1.7B-Q4_0.gguf";
|
|
466
|
+
export declare const QWEN2_5_OMNI_3B_MULTIMODAL: "pear://583f04c31d151b29e02aaf98f80d16aff585714ef9e2806a5067651c0f64ae31/Qwen2.5-Omni-3B-Q4_K_M.gguf";
|
|
467
|
+
export declare const MMPROJ_QWEN2_5_OMNI_3B_MULTIMODAL: "pear://583f04c31d151b29e02aaf98f80d16aff585714ef9e2806a5067651c0f64ae31/mmproj-Qwen2.5-Omni-3B-Q8_0.gguf";
|
|
424
468
|
export declare const QWEN3_0_6B_INST: "pear://d331ed49c444f90b3b2a70aa5b820752685142bf2d769a0592ed666140477578/Qwen3-0.6B-UD-IQ1_S.gguf";
|
|
425
469
|
export declare const QWEN3_4B_INST_Q4: "pear://19ffb75463149955ee24d786dfddd84d41fc872ea813cd4465f5f7299d165adc/model.gguf";
|
|
426
470
|
export declare const QWEN3_600M_INST_Q4: "pear://211874c9885f6b88b9926904420e365f5e74e1b6ac47207b7536408539bef4b7/Qwen3-0.6B-Q4_0.gguf";
|
|
427
471
|
export declare const SALAMANDRATA_2B_INST_Q4: "pear://1610d81772a9e7c37660666dbdfdcef915b6b83c522ea1ad31c19cab0075811d/salamandrata_2b_inst_q4.gguf";
|
|
428
472
|
export declare const SALAMANDRATA_2B_INST_Q8: "pear://96860337b0bdffdbb8ef0df4c8b2c3ab5e78568f5f7e15815a0a6b392512c9b5/salamandrata_2b_inst_q8.gguf";
|
|
473
|
+
export declare const SMOLVLM2_2_500M_MULTIMODAL_F16: "pear://b99c6f5dcadaad827cdcb1a129a3b34aff6ad28056738e0bd559c7ffb807e30f/SmolVLM2-500M-Video-Instruct-f16.gguf";
|
|
474
|
+
export declare const MMPROJ_SMOLVLM2_2_500M_MULTIMODAL_F16: "pear://b99c6f5dcadaad827cdcb1a129a3b34aff6ad28056738e0bd559c7ffb807e30f/mmproj-SmolVLM2-500M-Video-Instruct-f16.gguf";
|
|
475
|
+
export declare const SMOLVLM2_2_500M_MULTIMODAL_Q8_0: "pear://73b1bc01d01e25fa27be7d7f434337d14f054b0315e8463766ca31e778ac6576/SmolVLM2-500M-Video-Instruct-Q8_0.gguf";
|
|
476
|
+
export declare const MMPROJ_SMOLVLM2_2_500M_MULTIMODAL_Q8_0: "pear://73b1bc01d01e25fa27be7d7f434337d14f054b0315e8463766ca31e778ac6576/mmproj-SmolVLM2-500M-Video-Instruct-Q8_0.gguf";
|
|
429
477
|
export declare const MARIAN_EN_HI_INDIC_200M_Q0F32: "pear://268c2e9b2a3420632e4b6649e32822f42d5dfbda4c7e96daec5b629ed20f99f7/ggml-indictrans2-en-indic-dist-200M.bin";
|
|
430
478
|
export declare const MARIAN_HI_EN_INDIC_200M_Q0F32: "pear://dfea395ffe1cb6d259029e5c81c290f8828981987855e23e7b66fd7c705901eb/ggml-indictrans2-indic-en-dist-200M.bin";
|
|
431
479
|
export declare const MARIAN_HI_HI_INDIC_320M_Q0F32: "pear://9a66da960931c449b41e3315d9aea4d3925f2cda024e8a4c139b64d0a539ed41/ggml-indictrans2-indic-indic-dist-320M.bin";
|
|
@@ -471,5 +519,5 @@ export declare const WHISPER_LARGE_3: "pear://76fb36d7f16a430618962d3e78b0e22e61
|
|
|
471
519
|
export declare const WHISPER_SMALL: "pear://c6a987fbb4ad8fba1526e446501f88ee45dfafbf1685410a7aeadb589fe18608/ggml-small.en-q8_0.bin";
|
|
472
520
|
export declare const WHISPER_TINY: "pear://9281d61503593fdf3eaa9d5e5d44746c271ef930aed3b7f8ee9ce153c76399d6/ggml-tiny.bin";
|
|
473
521
|
export declare const WHISPER_TINY_SILERO: "pear://ebfb94b378276da139554668f1ff737644eadff529c2ea0f2662d7df61fd86ca/ggml-tiny.bin";
|
|
474
|
-
export declare function getModelBySrc(modelId: string, hyperdriveKey
|
|
522
|
+
export declare function getModelBySrc(modelId: string, hyperdriveKey: string): HyperdriveItem | undefined;
|
|
475
523
|
//# sourceMappingURL=models.d.ts.map
|
|
@@ -65,6 +65,22 @@ export const models = [
|
|
|
65
65
|
expectedSize: 1056782912,
|
|
66
66
|
sha256Checksum: "c876f159707a4e4f70e045106c69db15bfc935a4981706fd4f65c6e7ea1e81c5",
|
|
67
67
|
},
|
|
68
|
+
{
|
|
69
|
+
hyperdriveKey: "583f04c31d151b29e02aaf98f80d16aff585714ef9e2806a5067651c0f64ae31",
|
|
70
|
+
hyperbeeKey: "generation:qwen2.5-omni:multimodal::3B::1.0.0",
|
|
71
|
+
modelId: "Qwen2.5-Omni-3B-Q4_K_M.gguf",
|
|
72
|
+
addon: "llm",
|
|
73
|
+
expectedSize: 2104931648,
|
|
74
|
+
sha256Checksum: "4b0bd358c1e9ec55dd3055ef6d71c958c821533d85916a10cfa89c4552a86e29",
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
hyperdriveKey: "583f04c31d151b29e02aaf98f80d16aff585714ef9e2806a5067651c0f64ae31",
|
|
78
|
+
hyperbeeKey: "generation:qwen2.5-omni:multimodal::3B::1.0.0",
|
|
79
|
+
modelId: "mmproj-Qwen2.5-Omni-3B-Q8_0.gguf",
|
|
80
|
+
addon: "llm",
|
|
81
|
+
expectedSize: 1538031328,
|
|
82
|
+
sha256Checksum: "4e6c816cd33f7298d07cb780c136a396631e50e62f6501660271f8c6e302e565",
|
|
83
|
+
},
|
|
68
84
|
{
|
|
69
85
|
hyperdriveKey: "d331ed49c444f90b3b2a70aa5b820752685142bf2d769a0592ed666140477578",
|
|
70
86
|
hyperbeeKey: "generation:qwen3:instruct::0.6B::1.0.0",
|
|
@@ -105,6 +121,38 @@ export const models = [
|
|
|
105
121
|
expectedSize: 2401075552,
|
|
106
122
|
sha256Checksum: "9cfebb63cd7e6b6d1755ea8ef001fcdadfa17831da1db96eafe3fc554913d5e1",
|
|
107
123
|
},
|
|
124
|
+
{
|
|
125
|
+
hyperdriveKey: "b99c6f5dcadaad827cdcb1a129a3b34aff6ad28056738e0bd559c7ffb807e30f",
|
|
126
|
+
hyperbeeKey: "generation:smolVLM2:multimodal:2:500M:f16:1.0.0:video-instruct",
|
|
127
|
+
modelId: "SmolVLM2-500M-Video-Instruct-f16.gguf",
|
|
128
|
+
addon: "llm",
|
|
129
|
+
expectedSize: 820424704,
|
|
130
|
+
sha256Checksum: "80f7e3f04bc2d3324ac1a9f52f5776fe13a69912adf74f8e7edacf773d140d77",
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
hyperdriveKey: "b99c6f5dcadaad827cdcb1a129a3b34aff6ad28056738e0bd559c7ffb807e30f",
|
|
134
|
+
hyperbeeKey: "generation:smolVLM2:multimodal:2:500M:f16:1.0.0:video-instruct",
|
|
135
|
+
modelId: "mmproj-SmolVLM2-500M-Video-Instruct-f16.gguf",
|
|
136
|
+
addon: "llm",
|
|
137
|
+
expectedSize: 199470624,
|
|
138
|
+
sha256Checksum: "b5dc8ebe7cbeab66a5369693960a52515d7824f13d4063ceca78431f2a6b59b0",
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
hyperdriveKey: "73b1bc01d01e25fa27be7d7f434337d14f054b0315e8463766ca31e778ac6576",
|
|
142
|
+
hyperbeeKey: "generation:smolVLM2:multimodal:2:500M:q8_0:1.0.0:video-instruct",
|
|
143
|
+
modelId: "SmolVLM2-500M-Video-Instruct-Q8_0.gguf",
|
|
144
|
+
addon: "llm",
|
|
145
|
+
expectedSize: 436808704,
|
|
146
|
+
sha256Checksum: "6f67b8036b2469fcd71728702720c6b51aebd759b78137a8120733b4d66438bc",
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
hyperdriveKey: "73b1bc01d01e25fa27be7d7f434337d14f054b0315e8463766ca31e778ac6576",
|
|
150
|
+
hyperbeeKey: "generation:smolVLM2:multimodal:2:500M:q8_0:1.0.0:video-instruct",
|
|
151
|
+
modelId: "mmproj-SmolVLM2-500M-Video-Instruct-Q8_0.gguf",
|
|
152
|
+
addon: "llm",
|
|
153
|
+
expectedSize: 108785184,
|
|
154
|
+
sha256Checksum: "921dc7e259f308e5b027111fa185efcbf33db13f6e35749ddf7f5cdb60ef520b",
|
|
155
|
+
},
|
|
108
156
|
{
|
|
109
157
|
hyperdriveKey: "268c2e9b2a3420632e4b6649e32822f42d5dfbda4c7e96daec5b629ed20f99f7",
|
|
110
158
|
hyperbeeKey: "translation:ggml-indictrans:dist:2:200M:q0f32:1.0.0:en-hi",
|
|
@@ -475,60 +523,63 @@ export const GTE_LARGE_FP16 = `pear://${models[4].hyperdriveKey}/${models[4].mod
|
|
|
475
523
|
export const LASER_DOLPHIN_2_6_2X7B_INST_Q2_K = `pear://${models[5].hyperdriveKey}/${models[5].modelId}`;
|
|
476
524
|
export const LLAMA_3_2_1B_INST_Q4_0 = `pear://${models[6].hyperdriveKey}/${models[6].modelId}`;
|
|
477
525
|
export const QWEN_3_1_7B_INST_Q4 = `pear://${models[7].hyperdriveKey}/${models[7].modelId}`;
|
|
478
|
-
export const
|
|
479
|
-
export const
|
|
480
|
-
export const
|
|
481
|
-
export const
|
|
482
|
-
export const
|
|
483
|
-
export const
|
|
484
|
-
export const
|
|
485
|
-
export const
|
|
486
|
-
export const
|
|
487
|
-
export const
|
|
488
|
-
export const
|
|
489
|
-
export const
|
|
490
|
-
export const
|
|
491
|
-
export const
|
|
492
|
-
export const
|
|
493
|
-
export const
|
|
494
|
-
export const
|
|
495
|
-
export const
|
|
496
|
-
export const
|
|
497
|
-
export const
|
|
498
|
-
export const
|
|
499
|
-
export const
|
|
500
|
-
export const
|
|
501
|
-
export const
|
|
502
|
-
export const
|
|
503
|
-
export const
|
|
504
|
-
export const
|
|
505
|
-
export const
|
|
506
|
-
export const
|
|
507
|
-
export const
|
|
508
|
-
export const
|
|
509
|
-
export const
|
|
510
|
-
export const
|
|
511
|
-
export const
|
|
512
|
-
export const
|
|
513
|
-
export const
|
|
514
|
-
export const
|
|
515
|
-
export const
|
|
516
|
-
export const
|
|
517
|
-
export const
|
|
518
|
-
export const
|
|
519
|
-
export const
|
|
520
|
-
export const
|
|
521
|
-
export const
|
|
522
|
-
export const
|
|
523
|
-
export const
|
|
524
|
-
export const
|
|
525
|
-
export const
|
|
526
|
-
export const
|
|
527
|
-
export const
|
|
526
|
+
export const QWEN2_5_OMNI_3B_MULTIMODAL = `pear://${models[8].hyperdriveKey}/${models[8].modelId}`;
|
|
527
|
+
export const MMPROJ_QWEN2_5_OMNI_3B_MULTIMODAL = `pear://${models[9].hyperdriveKey}/${models[9].modelId}`;
|
|
528
|
+
export const QWEN3_0_6B_INST = `pear://${models[10].hyperdriveKey}/${models[10].modelId}`;
|
|
529
|
+
export const QWEN3_4B_INST_Q4 = `pear://${models[11].hyperdriveKey}/${models[11].modelId}`;
|
|
530
|
+
export const QWEN3_600M_INST_Q4 = `pear://${models[12].hyperdriveKey}/${models[12].modelId}`;
|
|
531
|
+
export const SALAMANDRATA_2B_INST_Q4 = `pear://${models[13].hyperdriveKey}/${models[13].modelId}`;
|
|
532
|
+
export const SALAMANDRATA_2B_INST_Q8 = `pear://${models[14].hyperdriveKey}/${models[14].modelId}`;
|
|
533
|
+
export const SMOLVLM2_2_500M_MULTIMODAL_F16 = `pear://${models[15].hyperdriveKey}/${models[15].modelId}`;
|
|
534
|
+
export const MMPROJ_SMOLVLM2_2_500M_MULTIMODAL_F16 = `pear://${models[16].hyperdriveKey}/${models[16].modelId}`;
|
|
535
|
+
export const SMOLVLM2_2_500M_MULTIMODAL_Q8_0 = `pear://${models[17].hyperdriveKey}/${models[17].modelId}`;
|
|
536
|
+
export const MMPROJ_SMOLVLM2_2_500M_MULTIMODAL_Q8_0 = `pear://${models[18].hyperdriveKey}/${models[18].modelId}`;
|
|
537
|
+
export const MARIAN_EN_HI_INDIC_200M_Q0F32 = `pear://${models[19].hyperdriveKey}/${models[19].modelId}`;
|
|
538
|
+
export const MARIAN_HI_EN_INDIC_200M_Q0F32 = `pear://${models[20].hyperdriveKey}/${models[20].modelId}`;
|
|
539
|
+
export const MARIAN_HI_HI_INDIC_320M_Q0F32 = `pear://${models[21].hyperdriveKey}/${models[21].modelId}`;
|
|
540
|
+
export const MARIAN_EN_HI_INDIC_1B_Q0F16 = `pear://${models[22].hyperdriveKey}/${models[22].modelId}`;
|
|
541
|
+
export const MARIAN_HI_EN_INDIC_1B_Q0F16 = `pear://${models[23].hyperdriveKey}/${models[23].modelId}`;
|
|
542
|
+
export const MARIAN_HI_HI_INDIC_1B_Q0F16 = `pear://${models[24].hyperdriveKey}/${models[24].modelId}`;
|
|
543
|
+
export const MARIAN_EN_HI_INDIC_1B_Q0F32 = `pear://${models[25].hyperdriveKey}/${models[25].modelId}`;
|
|
544
|
+
export const MARIAN_HI_EN_INDIC_1B_Q0F32 = `pear://${models[26].hyperdriveKey}/${models[26].modelId}`;
|
|
545
|
+
export const MARIAN_HI_HI_INDIC_1B_Q0F32 = `pear://${models[27].hyperdriveKey}/${models[27].modelId}`;
|
|
546
|
+
export const MARIAN_EN_HI_INDIC_1B_Q4_0 = `pear://${models[28].hyperdriveKey}/${models[28].modelId}`;
|
|
547
|
+
export const MARIAN_HI_EN_INDIC_1B_Q4_0 = `pear://${models[29].hyperdriveKey}/${models[29].modelId}`;
|
|
548
|
+
export const MARIAN_HI_HI_INDIC_1B_Q4_0 = `pear://${models[30].hyperdriveKey}/${models[30].modelId}`;
|
|
549
|
+
export const MARIAN_EN_HI_INDIC_200M_Q0F16 = `pear://${models[31].hyperdriveKey}/${models[31].modelId}`;
|
|
550
|
+
export const MARIAN_HI_EN_INDIC_200M_Q0F16 = `pear://${models[32].hyperdriveKey}/${models[32].modelId}`;
|
|
551
|
+
export const MARIAN_EN_HI_INDIC_200M_Q4_0 = `pear://${models[33].hyperdriveKey}/${models[33].modelId}`;
|
|
552
|
+
export const MARIAN_HI_EN_INDIC_200M_Q4_0 = `pear://${models[34].hyperdriveKey}/${models[34].modelId}`;
|
|
553
|
+
export const MARIAN_HI_HI_INDIC_320M_Q0F16 = `pear://${models[35].hyperdriveKey}/${models[35].modelId}`;
|
|
554
|
+
export const MARIAN_HI_HI_INDIC_320M_Q4_0 = `pear://${models[36].hyperdriveKey}/${models[36].modelId}`;
|
|
555
|
+
export const MARIAN_OPUS_EN_IT = `pear://${models[37].hyperdriveKey}/${models[37].modelId}`;
|
|
556
|
+
export const MARIAN_OPUS_IT_EN = `pear://${models[38].hyperdriveKey}/${models[38].modelId}`;
|
|
557
|
+
export const MARIAN_OPUS_DE_EN_Q0F32 = `pear://${models[39].hyperdriveKey}/${models[39].modelId}`;
|
|
558
|
+
export const MARIAN_OPUS_DE_ES_Q0F32 = `pear://${models[40].hyperdriveKey}/${models[40].modelId}`;
|
|
559
|
+
export const MARIAN_OPUS_DE_IT_Q0F32 = `pear://${models[41].hyperdriveKey}/${models[41].modelId}`;
|
|
560
|
+
export const MARIAN_OPUS_EN_DE_Q0F32 = `pear://${models[42].hyperdriveKey}/${models[42].modelId}`;
|
|
561
|
+
export const MARIAN_OPUS_EN_ES_Q0F32 = `pear://${models[43].hyperdriveKey}/${models[43].modelId}`;
|
|
562
|
+
export const MARIAN_OPUS_EN_IT_Q0F32 = `pear://${models[44].hyperdriveKey}/${models[44].modelId}`;
|
|
563
|
+
export const MARIAN_OPUS_ES_DE_Q0F32 = `pear://${models[45].hyperdriveKey}/${models[45].modelId}`;
|
|
564
|
+
export const MARIAN_OPUS_ES_EN_Q0F32 = `pear://${models[46].hyperdriveKey}/${models[46].modelId}`;
|
|
565
|
+
export const MARIAN_OPUS_ES_IT_Q0F32 = `pear://${models[47].hyperdriveKey}/${models[47].modelId}`;
|
|
566
|
+
export const MARIAN_OPUS_IT_DE_Q0F32 = `pear://${models[48].hyperdriveKey}/${models[48].modelId}`;
|
|
567
|
+
export const MARIAN_OPUS_IT_EN_Q0F32 = `pear://${models[49].hyperdriveKey}/${models[49].modelId}`;
|
|
568
|
+
export const MARIAN_OPUS_IT_ES_Q0F32 = `pear://${models[50].hyperdriveKey}/${models[50].modelId}`;
|
|
569
|
+
export const MARIAN_OPUS_EN_RU_Q0F16 = `pear://${models[51].hyperdriveKey}/${models[51].modelId}`;
|
|
570
|
+
export const MARIAN_OPUS_RU_EN_Q0F16 = `pear://${models[52].hyperdriveKey}/${models[52].modelId}`;
|
|
571
|
+
export const MARIAN_OPUS_EN_RU_Q0F32 = `pear://${models[53].hyperdriveKey}/${models[53].modelId}`;
|
|
572
|
+
export const MARIAN_OPUS_RU_EN_Q0F32 = `pear://${models[54].hyperdriveKey}/${models[54].modelId}`;
|
|
573
|
+
export const MARIAN_OPUS_EN_RU_Q4_0 = `pear://${models[55].hyperdriveKey}/${models[55].modelId}`;
|
|
574
|
+
export const MARIAN_OPUS_RU_EN_Q4_0 = `pear://${models[56].hyperdriveKey}/${models[56].modelId}`;
|
|
575
|
+
export const MARIAN_OPUS_EN_JA_Q4F16_1 = `pear://${models[57].hyperdriveKey}/${models[57].modelId}`;
|
|
576
|
+
export const MARIAN_OPUS_JA_EN_Q4F16_1 = `pear://${models[58].hyperdriveKey}/${models[58].modelId}`;
|
|
577
|
+
export const VAD_SILERO_5_1_2 = `pear://${models[59].hyperdriveKey}/${models[59].modelId}`;
|
|
578
|
+
export const WHISPER_LARGE_3 = `pear://${models[60].hyperdriveKey}/${models[60].modelId}`;
|
|
579
|
+
export const WHISPER_SMALL = `pear://${models[61].hyperdriveKey}/${models[61].modelId}`;
|
|
580
|
+
export const WHISPER_TINY = `pear://${models[62].hyperdriveKey}/${models[62].modelId}`;
|
|
581
|
+
export const WHISPER_TINY_SILERO = `pear://${models[63].hyperdriveKey}/${models[63].modelId}`;
|
|
528
582
|
// Helper function for our curated model list
|
|
529
583
|
export function getModelBySrc(modelId, hyperdriveKey) {
|
|
530
|
-
|
|
531
|
-
return models.find((model) => model.modelId === modelId && model.hyperdriveKey === hyperdriveKey);
|
|
532
|
-
}
|
|
533
|
-
return models.find((model) => model.modelId === modelId);
|
|
584
|
+
return models.find((model) => model.modelId === modelId && model.hyperdriveKey === hyperdriveKey);
|
|
534
585
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Parse hyperdrive URLs: pear://key/path/to/model.gguf
|
|
2
|
+
export function parseHyperdriveUrl(url) {
|
|
3
|
+
const match = url.match(/^pear:\/\/([0-9a-fA-F]{64})\/(.+)$/);
|
|
4
|
+
if (!match || !match[1] || !match[2]) {
|
|
5
|
+
throw new Error(`Invalid hyperdrive URL: "${url}". Expected format: pear://64-char-hex-key/path/to/model.gguf`);
|
|
6
|
+
}
|
|
7
|
+
return { key: match[1], path: match[2] };
|
|
8
|
+
}
|
|
9
|
+
// Hyperdrive key validation (32 bytes = 64 hex chars)
|
|
10
|
+
export function isValidHyperdriveKey(key) {
|
|
11
|
+
return /^[0-9a-fA-F]{64}$/.test(key);
|
|
12
|
+
}
|
package/dist/schemas/common.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export declare const requestSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
32
32
|
frequency_penalty: z.ZodOptional<z.ZodNumber>;
|
|
33
33
|
repeat_penalty: z.ZodOptional<z.ZodNumber>;
|
|
34
34
|
reverse_prompt: z.ZodOptional<z.ZodString>;
|
|
35
|
+
n_discarded: z.ZodOptional<z.ZodNumber>;
|
|
35
36
|
}, z.core.$strip>;
|
|
36
37
|
}, z.core.$strip>, z.ZodObject<{
|
|
37
38
|
type: z.ZodLiteral<"loadModel">;
|
|
@@ -199,6 +200,7 @@ export declare const requestSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
199
200
|
frequency_penalty?: number | undefined;
|
|
200
201
|
repeat_penalty?: number | undefined;
|
|
201
202
|
reverse_prompt?: string | undefined;
|
|
203
|
+
n_discarded?: number | undefined;
|
|
202
204
|
};
|
|
203
205
|
projectionModelSrc?: string | undefined;
|
|
204
206
|
vadModelSrc?: string | undefined;
|
|
@@ -296,6 +298,7 @@ export declare const requestSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
296
298
|
frequency_penalty?: number | undefined;
|
|
297
299
|
repeat_penalty?: number | undefined;
|
|
298
300
|
reverse_prompt?: string | undefined;
|
|
301
|
+
n_discarded?: number | undefined;
|
|
299
302
|
};
|
|
300
303
|
projectionModelSrc?: string | undefined;
|
|
301
304
|
vadModelSrc?: string | undefined;
|
|
@@ -483,6 +486,7 @@ export declare const requestSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
483
486
|
paragraph: "paragraph";
|
|
484
487
|
}>>;
|
|
485
488
|
splitStrategy: z.ZodOptional<z.ZodEnum<{
|
|
489
|
+
token: "token";
|
|
486
490
|
character: "character";
|
|
487
491
|
word: "word";
|
|
488
492
|
sentence: "sentence";
|
|
@@ -21,6 +21,7 @@ export declare const llmConfigSchema: z.ZodObject<{
|
|
|
21
21
|
frequency_penalty: z.ZodOptional<z.ZodNumber>;
|
|
22
22
|
repeat_penalty: z.ZodOptional<z.ZodNumber>;
|
|
23
23
|
reverse_prompt: z.ZodOptional<z.ZodString>;
|
|
24
|
+
n_discarded: z.ZodOptional<z.ZodNumber>;
|
|
24
25
|
}, z.core.$strip>;
|
|
25
26
|
export declare const embedConfigSchema: z.ZodObject<{
|
|
26
27
|
config: z.ZodDefault<z.ZodString>;
|
|
@@ -32,8 +32,11 @@ export const llmConfigSchema = z.object({
|
|
|
32
32
|
frequency_penalty: z.number().optional(),
|
|
33
33
|
repeat_penalty: z.number().optional(),
|
|
34
34
|
reverse_prompt: z.string().optional(),
|
|
35
|
+
n_discarded: z.number().optional(),
|
|
35
36
|
});
|
|
36
37
|
export const embedConfigSchema = z.object({
|
|
37
38
|
// https://github.com/tetherto/qvac-lib-infer-llamacpp-embed/tree/main?tab=readme-ov-file#4-create-config
|
|
38
|
-
config: z
|
|
39
|
+
config: z
|
|
40
|
+
.string()
|
|
41
|
+
.default("-ngl\t99\n-dev\tgpu\n--embd-separator\tāŖĀ§Ā§Ā§EMBED_SEP§§§ā«\n-c\t512"),
|
|
39
42
|
});
|
|
@@ -19,6 +19,7 @@ export declare const loadModelOptionsSchema: z.ZodPipe<z.ZodUnion<readonly [z.Zo
|
|
|
19
19
|
frequency_penalty: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
20
20
|
repeat_penalty: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
21
21
|
reverse_prompt: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
22
|
+
n_discarded: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
22
23
|
}, z.core.$strict>>;
|
|
23
24
|
seed: z.ZodOptional<z.ZodBoolean>;
|
|
24
25
|
projectionModelSrc: z.ZodOptional<z.ZodString>;
|
|
@@ -187,6 +188,7 @@ export declare const loadModelOptionsSchema: z.ZodPipe<z.ZodUnion<readonly [z.Zo
|
|
|
187
188
|
frequency_penalty?: number | undefined;
|
|
188
189
|
repeat_penalty?: number | undefined;
|
|
189
190
|
reverse_prompt?: string | undefined;
|
|
191
|
+
n_discarded?: number | undefined;
|
|
190
192
|
} | undefined;
|
|
191
193
|
projectionModelSrc?: string | undefined;
|
|
192
194
|
delegate?: {
|
|
@@ -271,6 +273,7 @@ export declare const loadModelOptionsSchema: z.ZodPipe<z.ZodUnion<readonly [z.Zo
|
|
|
271
273
|
frequency_penalty?: number | undefined;
|
|
272
274
|
repeat_penalty?: number | undefined;
|
|
273
275
|
reverse_prompt?: string | undefined;
|
|
276
|
+
n_discarded?: number | undefined;
|
|
274
277
|
} | undefined;
|
|
275
278
|
seed?: boolean | undefined;
|
|
276
279
|
projectionModelSrc?: string | undefined;
|
|
@@ -370,6 +373,7 @@ export declare const loadLlmModelRequestSchema: z.ZodObject<{
|
|
|
370
373
|
frequency_penalty: z.ZodOptional<z.ZodNumber>;
|
|
371
374
|
repeat_penalty: z.ZodOptional<z.ZodNumber>;
|
|
372
375
|
reverse_prompt: z.ZodOptional<z.ZodString>;
|
|
376
|
+
n_discarded: z.ZodOptional<z.ZodNumber>;
|
|
373
377
|
}, z.core.$strip>;
|
|
374
378
|
}, z.core.$strip>;
|
|
375
379
|
export declare const loadWhisperModelRequestSchema: z.ZodObject<{
|
|
@@ -550,6 +554,7 @@ export declare const loadModelRequestSchema: z.ZodPipe<z.ZodDiscriminatedUnion<[
|
|
|
550
554
|
frequency_penalty: z.ZodOptional<z.ZodNumber>;
|
|
551
555
|
repeat_penalty: z.ZodOptional<z.ZodNumber>;
|
|
552
556
|
reverse_prompt: z.ZodOptional<z.ZodString>;
|
|
557
|
+
n_discarded: z.ZodOptional<z.ZodNumber>;
|
|
553
558
|
}, z.core.$strip>;
|
|
554
559
|
}, z.core.$strip>, z.ZodObject<{
|
|
555
560
|
type: z.ZodLiteral<"loadModel">;
|
|
@@ -717,6 +722,7 @@ export declare const loadModelRequestSchema: z.ZodPipe<z.ZodDiscriminatedUnion<[
|
|
|
717
722
|
frequency_penalty?: number | undefined;
|
|
718
723
|
repeat_penalty?: number | undefined;
|
|
719
724
|
reverse_prompt?: string | undefined;
|
|
725
|
+
n_discarded?: number | undefined;
|
|
720
726
|
};
|
|
721
727
|
projectionModelSrc?: string | undefined;
|
|
722
728
|
vadModelSrc?: string | undefined;
|
|
@@ -814,6 +820,7 @@ export declare const loadModelRequestSchema: z.ZodPipe<z.ZodDiscriminatedUnion<[
|
|
|
814
820
|
frequency_penalty?: number | undefined;
|
|
815
821
|
repeat_penalty?: number | undefined;
|
|
816
822
|
reverse_prompt?: string | undefined;
|
|
823
|
+
n_discarded?: number | undefined;
|
|
817
824
|
};
|
|
818
825
|
projectionModelSrc?: string | undefined;
|
|
819
826
|
vadModelSrc?: string | undefined;
|
|
@@ -932,6 +939,7 @@ export declare const loadModelServerParamsSchema: z.ZodObject<{
|
|
|
932
939
|
frequency_penalty: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
933
940
|
repeat_penalty: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
934
941
|
reverse_prompt: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
942
|
+
n_discarded: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
935
943
|
}, z.core.$strict>>;
|
|
936
944
|
seed: z.ZodOptional<z.ZodBoolean>;
|
|
937
945
|
projectionModelSrc: z.ZodOptional<z.ZodString>;
|
|
@@ -1100,6 +1108,7 @@ export declare const loadModelServerParamsSchema: z.ZodObject<{
|
|
|
1100
1108
|
frequency_penalty?: number | undefined;
|
|
1101
1109
|
repeat_penalty?: number | undefined;
|
|
1102
1110
|
reverse_prompt?: string | undefined;
|
|
1111
|
+
n_discarded?: number | undefined;
|
|
1103
1112
|
} | undefined;
|
|
1104
1113
|
projectionModelSrc?: string | undefined;
|
|
1105
1114
|
delegate?: {
|
|
@@ -1184,6 +1193,7 @@ export declare const loadModelServerParamsSchema: z.ZodObject<{
|
|
|
1184
1193
|
frequency_penalty?: number | undefined;
|
|
1185
1194
|
repeat_penalty?: number | undefined;
|
|
1186
1195
|
reverse_prompt?: string | undefined;
|
|
1196
|
+
n_discarded?: number | undefined;
|
|
1187
1197
|
} | undefined;
|
|
1188
1198
|
seed?: boolean | undefined;
|
|
1189
1199
|
projectionModelSrc?: string | undefined;
|
package/dist/schemas/rag.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ declare const ragSaveEmbeddingsParamsSchema: z.ZodObject<{
|
|
|
25
25
|
paragraph: "paragraph";
|
|
26
26
|
}>>;
|
|
27
27
|
splitStrategy: z.ZodOptional<z.ZodEnum<{
|
|
28
|
+
token: "token";
|
|
28
29
|
character: "character";
|
|
29
30
|
word: "word";
|
|
30
31
|
sentence: "sentence";
|
|
@@ -45,6 +46,7 @@ export declare const ragSaveEmbeddingsOperationSchema: z.ZodObject<{
|
|
|
45
46
|
paragraph: "paragraph";
|
|
46
47
|
}>>;
|
|
47
48
|
splitStrategy: z.ZodOptional<z.ZodEnum<{
|
|
49
|
+
token: "token";
|
|
48
50
|
character: "character";
|
|
49
51
|
word: "word";
|
|
50
52
|
sentence: "sentence";
|
|
@@ -95,6 +97,7 @@ export declare const ragRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
95
97
|
paragraph: "paragraph";
|
|
96
98
|
}>>;
|
|
97
99
|
splitStrategy: z.ZodOptional<z.ZodEnum<{
|
|
100
|
+
token: "token";
|
|
98
101
|
character: "character";
|
|
99
102
|
word: "word";
|
|
100
103
|
sentence: "sentence";
|
package/dist/schemas/rag.js
CHANGED
|
@@ -4,7 +4,9 @@ const llmChunkOptsSchema = z.object({
|
|
|
4
4
|
chunkSize: z.number().optional(),
|
|
5
5
|
chunkOverlap: z.number().optional(),
|
|
6
6
|
chunkStrategy: z.enum(["character", "paragraph"]).optional(),
|
|
7
|
-
splitStrategy: z
|
|
7
|
+
splitStrategy: z
|
|
8
|
+
.enum(["character", "word", "token", "sentence", "line"])
|
|
9
|
+
.optional(),
|
|
8
10
|
});
|
|
9
11
|
const ragSaveEmbeddingsResultSchema = z.object({
|
|
10
12
|
status: z.enum(["fulfilled", "rejected"]),
|
|
@@ -54,8 +54,34 @@ function prepareMessagesForCache(cachePathToUse, cacheExists, history) {
|
|
|
54
54
|
}
|
|
55
55
|
async function* processModelResponse(model, messagesToSend, shouldSaveCache) {
|
|
56
56
|
const response = await model.run(messagesToSend);
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
// Create a promise that rejects when onError is triggered
|
|
58
|
+
let rejectOnError = null;
|
|
59
|
+
const errorPromise = new Promise((_, reject) => {
|
|
60
|
+
rejectOnError = reject;
|
|
61
|
+
});
|
|
62
|
+
response.onError((error) => {
|
|
63
|
+
if (rejectOnError) {
|
|
64
|
+
rejectOnError(error);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
const iterator = response.iterate();
|
|
68
|
+
try {
|
|
69
|
+
while (true) {
|
|
70
|
+
// Race between getting the next token and an error occurring
|
|
71
|
+
const result = await Promise.race([iterator.next(), errorPromise]);
|
|
72
|
+
if (result.done) {
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
yield result.value;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
if (error instanceof Error) {
|
|
80
|
+
throw error;
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
throw new Error(String(error));
|
|
84
|
+
}
|
|
59
85
|
}
|
|
60
86
|
if (shouldSaveCache) {
|
|
61
87
|
await model.run([{ role: "session", content: "save" }]);
|