@qvac/sdk 0.1.0-dev.1760648187.328e967 → 0.1.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/models/hyperdrive/validation.d.ts +6 -0
- package/dist/models/hyperdrive/validation.js +12 -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/load-model/cache.d.ts +2 -0
- package/dist/server/rpc/handlers/load-model/cache.js +15 -0
- package/package.json +2 -2
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
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import fs from "bare-fs";
|
|
2
|
+
import path from "bare-path";
|
|
3
|
+
import GSTDecoder from "@qvac/decoder-audio";
|
|
4
|
+
import { Readable } from "bare-stream";
|
|
5
|
+
import { FORMATS_NEEDING_DECODE } from "../../../../constants/audio.js";
|
|
6
|
+
export function needsDecoding(filePath) {
|
|
7
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
8
|
+
return FORMATS_NEEDING_DECODE.includes(ext);
|
|
9
|
+
}
|
|
10
|
+
export async function decodeAudioToStream(inputPath) {
|
|
11
|
+
const decoder = new GSTDecoder({
|
|
12
|
+
config: {
|
|
13
|
+
audioFormat: "encoded",
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
try {
|
|
17
|
+
await decoder.load();
|
|
18
|
+
const audioStream = fs.createReadStream(inputPath);
|
|
19
|
+
const response = await decoder.run(audioStream);
|
|
20
|
+
const decodedBuffers = [];
|
|
21
|
+
await response
|
|
22
|
+
.onUpdate((output) => {
|
|
23
|
+
const bytes = new Uint8Array(output.outputArray);
|
|
24
|
+
decodedBuffers.push(bytes);
|
|
25
|
+
})
|
|
26
|
+
.onFinish(() => {
|
|
27
|
+
console.log("Audio decoded to buffer");
|
|
28
|
+
})
|
|
29
|
+
.await();
|
|
30
|
+
// Create a stream from the decoded buffers
|
|
31
|
+
const combinedBuffer = Buffer.concat(decodedBuffers);
|
|
32
|
+
return Readable.from([combinedBuffer]);
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
console.error("Decoding failed:", error instanceof Error ? error.message : String(error));
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./audio/decoder.js";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import fs from "bare-fs";
|
|
2
|
+
import path from "bare-path";
|
|
3
|
+
import { getEnv } from "../../../worker.js";
|
|
4
|
+
export function getCacheDir() {
|
|
5
|
+
const homeDir = getEnv().HOME_DIR;
|
|
6
|
+
const cacheDir = path.join(homeDir, ".qvac", "models");
|
|
7
|
+
// Ensure cache directory exists
|
|
8
|
+
try {
|
|
9
|
+
fs.mkdirSync(cacheDir, { recursive: true });
|
|
10
|
+
}
|
|
11
|
+
catch (error) {
|
|
12
|
+
console.error("Error creating cache directory:", error instanceof Error ? error.message : String(error));
|
|
13
|
+
}
|
|
14
|
+
return cacheDir;
|
|
15
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qvac/sdk",
|
|
3
|
-
"version": "0.1.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"@qvac/langdetect-text": "^0.1.0",
|
|
61
61
|
"@qvac/logging": "^0.1.0",
|
|
62
62
|
"@qvac/rag": "^0.1.0",
|
|
63
|
-
"@qvac/transcription-whispercpp": "^0.1.
|
|
63
|
+
"@qvac/transcription-whispercpp": "^0.1.4",
|
|
64
64
|
"@qvac/translation-nmtcpp": "^0.1.0",
|
|
65
65
|
"fast-safe-stringify": "2.1.1",
|
|
66
66
|
"zod": "^4.0.17"
|