@qvac/sdk 0.8.1 → 0.8.3
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
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
[](https://qvac.tether.dev)
|
|
2
|
-
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
**QVAC** is an open-source, cross-platform **ecosystem** for local-first, peer-to-peer **AI**. QVAC runs on [**Bare**](https://bare.pears.com) by [Holepunch](https://holepunch.to), a lightweight, cross-platform JavaScript runtime.
|
|
6
|
-
|
|
7
1
|
# QVAC SDK
|
|
8
2
|
|
|
9
3
|
**QVAC SDK** is the canonical entry point to develop AI applications with QVAC.
|
|
@@ -11,140 +5,75 @@
|
|
|
11
5
|
> _Part of **QVAC** ecosystem_
|
|
12
6
|
> <br>
|
|
13
7
|
> <sup>
|
|
14
|
-
> <a href="https://qvac.tether.
|
|
15
|
-
> <a href="https://qvac.tether.
|
|
16
|
-
> <a href="https://
|
|
8
|
+
> <a href="https://qvac.tether.io/" >Home</a> •
|
|
9
|
+
> <a href="https://docs.qvac.tether.io/" >Docs</a> •
|
|
10
|
+
> <a href="https://discord.com/channels/1425125849346216029/1445400675189264516" >Support</a> •
|
|
17
11
|
> <a href="https://discord.com/invite/tetherdev" >Discord</a>
|
|
18
|
-
> </sup>
|
|
19
|
-
|
|
20
|
-
Written in TypeScript, it provides all QVAC capabilities through a unified interface while also abstracting away the complexity of running your application in a JS environment other than Bare.
|
|
21
12
|
|
|
22
|
-
|
|
13
|
+
**QVAC SDK** is the main entry point for developing applications with QVAC. It is type-safe and exposes all QVAC capabilities through a unified interface. It runs on Node.js, [Bare runtime](https://bare.pears.com), and [Expo](https://expo.dev).
|
|
23
14
|
|
|
24
|
-
|
|
15
|
+
See [https://docs.qvac.tether.io/sdk/getting-started](https://docs.qvac.tether.io/sdk/getting-started) for the comprehensive QVAC documentation.
|
|
25
16
|
|
|
26
|
-
|
|
17
|
+
For AI/LLM tools, use [https://docs.qvac.tether.io/llms-full.txt](https://docs.qvac.tether.io/llms-full.txt) as the consolidated plaintext documentation export.
|
|
27
18
|
|
|
28
|
-
##
|
|
19
|
+
## Supported environments and installation
|
|
29
20
|
|
|
30
|
-
|
|
31
|
-
npm install @qvac/sdk
|
|
32
|
-
```
|
|
21
|
+
See https://docs.qvac.tether.io/sdk/getting-started/installation
|
|
33
22
|
|
|
34
|
-
|
|
23
|
+
## Quickstart
|
|
35
24
|
|
|
36
|
-
|
|
25
|
+
1. Create the examples workspace:
|
|
37
26
|
|
|
38
27
|
```bash
|
|
39
|
-
|
|
28
|
+
mkdir qvac-examples
|
|
29
|
+
cd qvac-examples
|
|
30
|
+
npm init -y && npm pkg set type=module
|
|
40
31
|
```
|
|
41
32
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
1. Peer dependencies:
|
|
33
|
+
2. Install the SDK:
|
|
45
34
|
|
|
46
35
|
```bash
|
|
47
|
-
npm
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
2. On Android, bump `minSdkVersion` to 29, by adding `ext { minSdkVersion=29 }` to `android/build.gradle` or using `expo-build-properties`.
|
|
51
|
-
|
|
52
|
-
3. Add the QVAC Expo plugin to `app.json`:
|
|
53
|
-
|
|
54
|
-
```js
|
|
55
|
-
export default {
|
|
56
|
-
expo: {
|
|
57
|
-
plugins: ["@qvac/sdk/expo-plugin"],
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
4. Prebuild your project to generate the native files:
|
|
63
|
-
|
|
64
|
-
```bash
|
|
65
|
-
npx expo prebuild
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
5. Build and run it on a **physical device**:
|
|
69
|
-
|
|
70
|
-
```bash
|
|
71
|
-
npx expo run:ios --device
|
|
72
|
-
# or
|
|
73
|
-
npx expo run:android --device
|
|
36
|
+
npm install @qvac/sdk
|
|
74
37
|
```
|
|
75
38
|
|
|
76
|
-
|
|
77
|
-
> Due to limitations with `llamacpp`, QVAC currently does not run on emulators. You **must** use a physical device.
|
|
78
|
-
|
|
79
|
-
## Usage
|
|
39
|
+
3. Create the quickstart script:
|
|
80
40
|
|
|
81
41
|
```js
|
|
82
|
-
import {
|
|
83
|
-
completion,
|
|
84
|
-
LLAMA_3_2_1B_INST_Q4_0,
|
|
85
|
-
loadModel,
|
|
86
|
-
downloadAsset,
|
|
87
|
-
unloadModel,
|
|
88
|
-
VERBOSITY,
|
|
89
|
-
} from "@qvac/sdk";
|
|
42
|
+
import { loadModel, LLAMA_3_2_1B_INST_Q4_0, completion, unloadModel, } from "@qvac/sdk";
|
|
90
43
|
try {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
process.stdout.write(token);
|
|
117
|
-
}
|
|
118
|
-
const stats = await result.stats;
|
|
119
|
-
console.log("\n📊 Performance Stats:", stats);
|
|
120
|
-
// Change `clearStorage: true` to delete cached model files
|
|
121
|
-
await unloadModel({ modelId, clearStorage: false });
|
|
122
|
-
} catch (error) {
|
|
123
|
-
console.error("❌ Error:", error);
|
|
124
|
-
process.exit(1);
|
|
44
|
+
// Load a model into memory
|
|
45
|
+
const modelId = await loadModel({
|
|
46
|
+
modelSrc: LLAMA_3_2_1B_INST_Q4_0,
|
|
47
|
+
modelType: "llm",
|
|
48
|
+
onProgress: (progress) => {
|
|
49
|
+
console.log(progress);
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
// You can use the loaded model multiple times
|
|
53
|
+
const history = [
|
|
54
|
+
{
|
|
55
|
+
role: "user",
|
|
56
|
+
content: "Explain quantum computing in one sentence",
|
|
57
|
+
},
|
|
58
|
+
];
|
|
59
|
+
const result = completion({ modelId, history, stream: true });
|
|
60
|
+
for await (const token of result.tokenStream) {
|
|
61
|
+
process.stdout.write(token);
|
|
62
|
+
}
|
|
63
|
+
// Unload model to free up system resources
|
|
64
|
+
await unloadModel({ modelId });
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
console.error("❌ Error:", error);
|
|
68
|
+
process.exit(1);
|
|
125
69
|
}
|
|
126
70
|
```
|
|
127
71
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
### AI tasks
|
|
131
|
-
|
|
132
|
-
- Completion: LLM inference via [`llama.cpp`](https://github.com/ggml-org/llama.cpp).
|
|
133
|
-
- Transcription: speech-to-text (ASR) via [`whisper.cpp`](https://github.com/ggml-org/whisper.cpp).
|
|
134
|
-
- Text embeddings: via `llama.cpp`, for RAG.
|
|
135
|
-
- Translation: between different languages.
|
|
136
|
-
- Text-to-Speech: TTS via ONNX.
|
|
137
|
-
- Multimodal: via [`llama.cpp`] — i.e., process and understand multiple types of media within the same conversation context.
|
|
138
|
-
- RAG: retrieval-augmented generation with progress streaming, cancellation, and workspace management.
|
|
139
|
-
- Delegated inference: perform peer-to-peer edge inference via Holepunch stack.
|
|
72
|
+
4. Run the quickstart script:
|
|
140
73
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
- Logging: visibility into what's happening inside your models during loading, inference, and other operations.
|
|
145
|
-
- Download Lifecycle: pause and resume model downloads.
|
|
146
|
-
- Blind Relays: establish peer connections through NAT/firewalls by routing traffic through relay nodes.
|
|
147
|
-
- Sharded models: download a model that is sharded into multiple parts.
|
|
74
|
+
```bash
|
|
75
|
+
node quickstart.js
|
|
76
|
+
```
|
|
148
77
|
|
|
149
78
|
## Examples
|
|
150
79
|
|
|
@@ -164,161 +93,27 @@ node dist/examples/path/to/example.js
|
|
|
164
93
|
bun run examples/path/to/example.ts
|
|
165
94
|
```
|
|
166
95
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
- `llama.cpp` with local files: [`examples/llamacpp-filesystem.ts`](examples/llamacpp-filesystem.ts)
|
|
170
|
-
- `llama.cpp` with P2P registry: [`examples/llamacpp-p2p.ts`](examples/llamacpp-p2p.ts)
|
|
171
|
-
- `llama.cpp` with HTTP: [`examples/llamacpp-http.ts`](examples/llamacpp-http.ts)
|
|
172
|
-
- `llama.cpp` with tools/function calls: [`examples/llamacpp-native-tools.ts`](examples/llamacpp-native-tools.ts)
|
|
173
|
-
- `llama.cpp` with multimodal inference: [`examples/llamacpp-multimodal.ts`](examples/llamacpp-multimodal.ts)
|
|
174
|
-
- `llama.cpp` with KV cache: [`examples/kv-cache-example.ts`](examples/kv-cache-example.ts)
|
|
175
|
-
|
|
176
|
-
### Transcription
|
|
177
|
-
|
|
178
|
-
- `whisper.cpp` transcription: [`examples/whispercpp-filesystem.ts`](examples/whispercpp-filesystem.ts)
|
|
179
|
-
- Microphone recording: [`examples/whispercpp-microphone-record.ts`](examples/whispercpp-microphone-record.ts)
|
|
180
|
-
|
|
181
|
-
### Embeddings
|
|
182
|
-
|
|
183
|
-
- Single and batch embeddings: [`examples/embed-p2p.ts`](examples/embed-p2p.ts)
|
|
184
|
-
|
|
185
|
-
**RAG with HyperDB** (cross-platform):
|
|
186
|
-
|
|
187
|
-
- Ingest (full pipeline): [`examples/rag/rag-hyperdb/ingest.ts`](examples/rag/rag-hyperdb/ingest.ts)
|
|
188
|
-
- Segregated pipeline: [`examples/rag/rag-hyperdb/pipeline.ts`](examples/rag/rag-hyperdb/pipeline.ts) _(Segregated flow: chunk → embed → save)_
|
|
189
|
-
- Workspaces: [`examples/rag/rag-hyperdb/workspaces.ts`](examples/rag/rag-hyperdb/workspaces.ts) _(Workspace lifecycle: list, close, delete)_
|
|
190
|
-
- Cancellation: [`examples/rag/rag-hyperdb/cancellation.ts`](examples/rag/rag-hyperdb/cancellation.ts) _(progress + cancel)_
|
|
191
|
-
|
|
192
|
-
**RAG with other backends** (desktop only):
|
|
193
|
-
|
|
194
|
-
- LanceDB: [`examples/rag/rag-lancedb.ts`](examples/rag/rag-lancedb.ts)
|
|
195
|
-
- ChromaDB: [`examples/rag/rag-chromadb.ts`](examples/rag/rag-chromadb.ts) _(requires ChromaDB server)_
|
|
196
|
-
- SQLite-Vector: [`examples/rag/rag-sqlite.ts`](examples/rag/rag-sqlite.ts) _(SQLite-Vector WASM)_
|
|
197
|
-
|
|
198
|
-
### Translation
|
|
199
|
-
|
|
200
|
-
- Marian OPUS translation: [`examples/translation/translation-opus.ts`](examples/translation/translation-opus.ts)
|
|
201
|
-
- Indic language translation: [`examples/translation/translation-indic.ts`](examples/translation/translation-indic.ts)
|
|
202
|
-
- LLM-based translation: [`examples/translation/translation-llm.ts`](examples/translation/translation-llm.ts)
|
|
203
|
-
|
|
204
|
-
### Text-to-Speech
|
|
205
|
-
|
|
206
|
-
- TTS (Chatterbox): [`examples/tts/chatterbox.ts`](examples/tts/chatterbox.ts) _(voice cloning with reference audio)_
|
|
207
|
-
- TTS (Supertonic): [`examples/tts/supertonic.ts`](examples/tts/supertonic.ts) _(general-purpose, no voice cloning)_
|
|
208
|
-
|
|
209
|
-
### Multimodel
|
|
210
|
-
|
|
211
|
-
- Load multiple models simultaneously: [`examples/multi-model-demo.ts`](examples/multi-model-demo.ts)
|
|
212
|
-
|
|
213
|
-
### Delegated inference
|
|
214
|
-
|
|
215
|
-
- Provider: [`examples/delegated-inference/provider.ts`](examples/delegated-inference/provider.ts)
|
|
216
|
-
- Consumer: [`examples/delegated-inference/consumer.ts`](examples/delegated-inference/consumer.ts)
|
|
217
|
-
|
|
218
|
-
> [!TIP]
|
|
219
|
-
> Set `QVAC_HYPERSWARM_SEED` env var to ensure that the provider uses the same keypair (i.e., public key doesn't change on every run).
|
|
220
|
-
|
|
221
|
-
> [!NOTE]
|
|
222
|
-
> Consumer does not handle reconnection yet.
|
|
223
|
-
|
|
224
|
-
### Logging
|
|
225
|
-
|
|
226
|
-
Stream real-time logs from the SDK server and native addons:
|
|
227
|
-
|
|
228
|
-
```ts
|
|
229
|
-
import { loggingStream, SDK_LOG_ID } from "@qvac/sdk";
|
|
96
|
+
## Build
|
|
230
97
|
|
|
231
|
-
|
|
232
|
-
for await (const log of loggingStream({ id: SDK_LOG_ID })) {
|
|
233
|
-
console.log(`[${log.level}] ${log.namespace}: ${log.message}`);
|
|
234
|
-
}
|
|
98
|
+
Use the [Bun](https://bun.sh/) package manager:
|
|
235
99
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
console.log(`[${log.level}] ${log.namespace}: ${log.message}`);
|
|
239
|
-
}
|
|
100
|
+
```bash
|
|
101
|
+
bun i
|
|
240
102
|
```
|
|
241
103
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
### Configuration
|
|
246
|
-
|
|
247
|
-
Customize SDK behavior using a config file. The SDK auto-discovers `qvac.config.{json,js,ts}` in your project root, or you can specify a path via `QVAC_CONFIG_PATH` environment variable.
|
|
248
|
-
|
|
249
|
-
**Supported formats:**
|
|
250
|
-
|
|
251
|
-
- `qvac.config.json` - JSON format
|
|
252
|
-
- `qvac.config.js` - JavaScript with `export default`
|
|
253
|
-
- `qvac.config.ts` - TypeScript with `export default`
|
|
254
|
-
|
|
255
|
-
**Available options:**
|
|
256
|
-
|
|
257
|
-
| Option | Type | Default | Description |
|
|
258
|
-
| ------------------------- | ---------- | ---------------- | --------------------------------------------------- |
|
|
259
|
-
| `cacheDirectory` | `string` | `~/.qvac/models` | Where models and assets are stored |
|
|
260
|
-
| `swarmRelays` | `string[]` | `[]` | Hyperswarm relay public keys for P2P |
|
|
261
|
-
| `loggerLevel` | `string` | `"info"` | Log level: `"error"`, `"warn"`, `"info"`, `"debug"` |
|
|
262
|
-
| `loggerConsoleOutput` | `boolean` | `true` | Enable/disable console output |
|
|
263
|
-
| `httpDownloadConcurrency` | `number` | `3` | Max concurrent HTTP downloads for sharded models |
|
|
264
|
-
| `httpConnectionTimeoutMs` | `number` | `10000` | HTTP connection timeout in milliseconds |
|
|
265
|
-
|
|
266
|
-
- Config usage example: [`examples/default-config-usage.ts`](examples/default-config-usage.ts)
|
|
267
|
-
|
|
268
|
-
### Download Lifecycle
|
|
269
|
-
|
|
270
|
-
- Pause and resume download: [`examples/download-with-cancel.ts`](examples/download-with-cancel.ts)
|
|
271
|
-
|
|
272
|
-
### Blind Relays
|
|
273
|
-
|
|
274
|
-
Blind relays help establish peer connections through NAT/firewalls by routing traffic through relay nodes.
|
|
275
|
-
|
|
276
|
-
- Model downloads via Hyperdrive: [`examples/download-with-blind-relays.ts`](./examples/download-with-blind-relays.ts)
|
|
277
|
-
- Delegated inference: You can reuse the same pattern for delegated inference by adding `swarmRelays` to your config file before starting your provider/consumer.
|
|
278
|
-
|
|
279
|
-
> [!NOTE]
|
|
280
|
-
> The examples use mock relay keys. For real deployments, you **must** use your own relay servers or trusted public relays.
|
|
281
|
-
|
|
282
|
-
### Sharded Models
|
|
283
|
-
|
|
284
|
-
Sharded models are split into multiple files following the pattern: `<name>-00001-of-0000X.<ext>`. The SDK automatically downloads and loads all parts with detailed progress tracking.
|
|
285
|
-
|
|
286
|
-
**Supported formats:**
|
|
287
|
-
|
|
288
|
-
- Archives (`.tar`, `.tar.gz`, `.tgz`): HTTP or local with automatic extraction
|
|
289
|
-
- HTTP sharded URL: pass the download URL of any shard and the SDK will fetch the remaining shards
|
|
290
|
-
- Hyperdrive: use any sharded Hyperdrive model source
|
|
291
|
-
- Local shards: pass the path to any shard file. _(Note: All shards must be in the same directory)_
|
|
292
|
-
|
|
293
|
-
See: [`examples/llamacpp-sharded.ts`](examples/llamacpp-sharded.ts)
|
|
294
|
-
|
|
295
|
-
## Basic flow
|
|
296
|
-
|
|
297
|
-
```mermaid
|
|
298
|
-
sequenceDiagram
|
|
299
|
-
participant User as User
|
|
300
|
-
participant SDK as QVAC SDK
|
|
301
|
-
participant RPC as RPC Client (singleton)
|
|
302
|
-
participant Worker as Bare Worker (singleton)
|
|
303
|
-
|
|
304
|
-
User->>SDK: Call loadModel("llama-3", options)
|
|
305
|
-
SDK->>RPC: Create runtime-specific RPC client
|
|
306
|
-
RPC->>Worker: Spawn worker (if needed) and send loadModel request
|
|
307
|
-
Worker->>Worker: Download and load model into memory
|
|
308
|
-
Worker->>RPC: Return success response
|
|
309
|
-
RPC->>SDK: Model loaded successfully
|
|
310
|
-
SDK->>User: loadModel() resolves with modelId
|
|
104
|
+
```bash
|
|
105
|
+
bun run build # or `watch` for hotreload
|
|
311
106
|
```
|
|
312
107
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
Hot config reload allows you to update model configurations on-the-fly without unloading the model. Pass `modelId` (instead of `modelSrc`) to `loadModel` with the `modelType` and new `modelConfig` to apply changes instantly.
|
|
108
|
+
```bash
|
|
109
|
+
bun run build:pack
|
|
110
|
+
```
|
|
318
111
|
|
|
319
|
-
|
|
112
|
+
This outputs a tarball under `dist/sdk-{version}.tgz` that you can install in your project, e.g.:
|
|
320
113
|
|
|
321
|
-
|
|
114
|
+
```bash
|
|
115
|
+
npm i path/to/sdk-0.3.0.tgz
|
|
116
|
+
```
|
|
322
117
|
|
|
323
118
|
## Contributing
|
|
324
119
|
|
|
@@ -459,32 +254,3 @@ This will:
|
|
|
459
254
|
4. Generate `changelog/<version>/CHANGELOG.md`
|
|
460
255
|
5. Generate `changelog/<version>/breaking.md` for BC changes (with code examples)
|
|
461
256
|
6. Generate `changelog/<version>/api.md` for API changes (with code examples)
|
|
462
|
-
|
|
463
|
-
**Note:** Requires a GitHub token (`GITHUB_TOKEN` or `GH_TOKEN` environment variable) to fetch PR metadata.
|
|
464
|
-
|
|
465
|
-
## Build
|
|
466
|
-
|
|
467
|
-
Use the [Bun](https://bun.sh/) package manager:
|
|
468
|
-
|
|
469
|
-
```bash
|
|
470
|
-
bun i
|
|
471
|
-
```
|
|
472
|
-
|
|
473
|
-
```bash
|
|
474
|
-
bun run build # or `watch` for hotreload
|
|
475
|
-
```
|
|
476
|
-
|
|
477
|
-
```bash
|
|
478
|
-
bun run build:pack
|
|
479
|
-
```
|
|
480
|
-
|
|
481
|
-
This outputs a tarball under `dist/sdk-{version}.tgz` that you can install in your project, e.g.:
|
|
482
|
-
|
|
483
|
-
```bash
|
|
484
|
-
npm i path/to/sdk-0.3.0.tgz
|
|
485
|
-
```
|
|
486
|
-
|
|
487
|
-
## More Resources
|
|
488
|
-
|
|
489
|
-
- [Comprehensive documentation of this SDK](https://qvac.tether.dev/docs/sdk)
|
|
490
|
-
- [Package at NPM](https://www.npmjs.com/package/@qvac/sdk)
|
|
@@ -3,4 +3,5 @@ export declare function logCacheInit(cacheKey: string, systemPrompt: string, too
|
|
|
3
3
|
export declare function logMessagesToAddon(messages: unknown[], phase?: "CACHE_INIT" | "PROMPT_SEND" | "NO_CACHE"): void;
|
|
4
4
|
export declare function logCacheDisabled(): void;
|
|
5
5
|
export declare function logCacheSave(sessionPath: string): void;
|
|
6
|
+
export declare function logCacheSaveError(sessionPath: string, err: unknown): void;
|
|
6
7
|
//# sourceMappingURL=cache-logger.d.ts.map
|
|
@@ -32,3 +32,6 @@ export function logCacheDisabled() {
|
|
|
32
32
|
export function logCacheSave(sessionPath) {
|
|
33
33
|
logger.debug(`[kv-cache] Saving session: ...${sessionPath.slice(-20)}`);
|
|
34
34
|
}
|
|
35
|
+
export function logCacheSaveError(sessionPath, err) {
|
|
36
|
+
logger.warn(`[kv-cache] Failed to save session: ...${sessionPath.slice(-20)} — ${err instanceof Error ? err.message : String(err)}`);
|
|
37
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { logCacheDisabled, logCacheInit, logCacheSave, logCacheStatus, logMessagesToAddon, } from "./cache-logger.js";
|
|
1
|
+
import { logCacheDisabled, logCacheInit, logCacheSave, logCacheSaveError, logCacheStatus, logMessagesToAddon, } from "./cache-logger.js";
|
|
2
2
|
import { customCacheExists, extractSystemPrompt, findMatchingCache, generateConfigHash, getCacheFilePath, getCurrentCacheInfo, markCacheInitialized, renameCacheFile, } from "../../../ops/kv-cache-utils.js";
|
|
3
3
|
import { getModel, getModelConfig, } from "../../../registry/model-registry.js";
|
|
4
4
|
import { checkForToolEvents, insertToolsIntoHistory, setupToolGrammar, } from "../../../../utils/tool-integration.js";
|
|
@@ -104,8 +104,18 @@ async function* processModelResponse(model, messagesToSend, shouldSaveCache, too
|
|
|
104
104
|
const sessionMsg = messagesToSend.find((m) => m.role === "session");
|
|
105
105
|
if (sessionMsg?.content) {
|
|
106
106
|
logCacheSave(sessionMsg.content);
|
|
107
|
+
const cachePath = sessionMsg.content;
|
|
108
|
+
const saveResp = await model.run([
|
|
109
|
+
{ role: "session", content: cachePath },
|
|
110
|
+
{ role: "session", content: "save" },
|
|
111
|
+
]);
|
|
112
|
+
try {
|
|
113
|
+
await saveResp.await();
|
|
114
|
+
}
|
|
115
|
+
catch (err) {
|
|
116
|
+
logCacheSaveError(cachePath, err);
|
|
117
|
+
}
|
|
107
118
|
}
|
|
108
|
-
await model.run([{ role: "session", content: "save" }]);
|
|
109
119
|
}
|
|
110
120
|
const responseWithStats = response;
|
|
111
121
|
const stats = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qvac/sdk",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.3",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -9,6 +9,51 @@
|
|
|
9
9
|
},
|
|
10
10
|
"bugs": "https://github.com/tetherto/qvac/issues",
|
|
11
11
|
"homepage": "https://github.com/tetherto/qvac/tree/main/packages/sdk#readme",
|
|
12
|
+
"keywords": [
|
|
13
|
+
"ai",
|
|
14
|
+
"bare",
|
|
15
|
+
"cross-platform",
|
|
16
|
+
"deep-learning",
|
|
17
|
+
"diffusion",
|
|
18
|
+
"edge-ai",
|
|
19
|
+
"embeddings",
|
|
20
|
+
"expo",
|
|
21
|
+
"gguf",
|
|
22
|
+
"gpu",
|
|
23
|
+
"holepunch",
|
|
24
|
+
"hyperswarm",
|
|
25
|
+
"image-generation",
|
|
26
|
+
"inference",
|
|
27
|
+
"large-language-model",
|
|
28
|
+
"llama-cpp",
|
|
29
|
+
"llm",
|
|
30
|
+
"local",
|
|
31
|
+
"local-ai",
|
|
32
|
+
"machine-learning",
|
|
33
|
+
"ml",
|
|
34
|
+
"model-registry",
|
|
35
|
+
"node",
|
|
36
|
+
"ocr",
|
|
37
|
+
"offline",
|
|
38
|
+
"on-device",
|
|
39
|
+
"p2p",
|
|
40
|
+
"peer-to-peer",
|
|
41
|
+
"private-ai",
|
|
42
|
+
"qvac",
|
|
43
|
+
"rag",
|
|
44
|
+
"react-native",
|
|
45
|
+
"sdk",
|
|
46
|
+
"self-hosted",
|
|
47
|
+
"speech-to-text",
|
|
48
|
+
"stt",
|
|
49
|
+
"tether",
|
|
50
|
+
"text-to-speech",
|
|
51
|
+
"transcription",
|
|
52
|
+
"translation",
|
|
53
|
+
"tts",
|
|
54
|
+
"typescript",
|
|
55
|
+
"whisper"
|
|
56
|
+
],
|
|
12
57
|
"type": "module",
|
|
13
58
|
"main": "./dist/index.js",
|
|
14
59
|
"types": "./dist/index.d.ts",
|