@qvac/sdk 0.1.0-dev.1760648187.328e967
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/LICENSE +202 -0
- package/README.md +301 -0
- package/dist/client/api/cancel.d.ts +25 -0
- package/dist/client/api/cancel.js +37 -0
- package/dist/client/api/completion-stream.d.ts +50 -0
- package/dist/client/api/completion-stream.js +103 -0
- package/dist/client/api/download-asset.d.ts +39 -0
- package/dist/client/api/download-asset.js +72 -0
- package/dist/client/api/embed.d.ts +11 -0
- package/dist/client/api/embed.js +24 -0
- package/dist/client/api/index.d.ts +13 -0
- package/dist/client/api/index.js +12 -0
- package/dist/client/api/load-model.d.ts +98 -0
- package/dist/client/api/load-model.js +154 -0
- package/dist/client/api/logging-stream.d.ts +21 -0
- package/dist/client/api/logging-stream.js +32 -0
- package/dist/client/api/ping.d.ts +11 -0
- package/dist/client/api/ping.js +18 -0
- package/dist/client/api/provide.d.ts +18 -0
- package/dist/client/api/provide.js +27 -0
- package/dist/client/api/rag.d.ts +42 -0
- package/dist/client/api/rag.js +97 -0
- package/dist/client/api/transcribe.d.ts +24 -0
- package/dist/client/api/transcribe.js +52 -0
- package/dist/client/api/translate.d.ts +47 -0
- package/dist/client/api/translate.js +114 -0
- package/dist/client/api/unload-model.d.ts +11 -0
- package/dist/client/api/unload-model.js +26 -0
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.js +1 -0
- package/dist/client/logging-stream-registry.d.ts +5 -0
- package/dist/client/logging-stream-registry.js +60 -0
- package/dist/client/rpc/bare-client.d.ts +112 -0
- package/dist/client/rpc/bare-client.js +82 -0
- package/dist/client/rpc/bare-rpc-client.d.ts +4 -0
- package/dist/client/rpc/bare-rpc-client.js +87 -0
- package/dist/client/rpc/expo-rpc-client.d.ts +3 -0
- package/dist/client/rpc/expo-rpc-client.js +57 -0
- package/dist/client/rpc/node-rpc-client.d.ts +9 -0
- package/dist/client/rpc/node-rpc-client.js +99 -0
- package/dist/client/rpc/rpc-client.d.ts +5 -0
- package/dist/client/rpc/rpc-client.js +91 -0
- package/dist/client/rpc/rpc-error.d.ts +19 -0
- package/dist/client/rpc/rpc-error.js +39 -0
- package/dist/constants/audio.d.ts +3 -0
- package/dist/constants/audio.js +17 -0
- package/dist/constants/index.d.ts +2 -0
- package/dist/constants/index.js +1 -0
- package/dist/examples/delegated-inference/consumer.d.ts +2 -0
- package/dist/examples/delegated-inference/consumer.js +56 -0
- package/dist/examples/delegated-inference/provider.d.ts +2 -0
- package/dist/examples/delegated-inference/provider.js +57 -0
- package/dist/examples/download-with-cancel.d.ts +2 -0
- package/dist/examples/download-with-cancel.js +46 -0
- package/dist/examples/embed-hyperdrive.d.ts +2 -0
- package/dist/examples/embed-hyperdrive.js +19 -0
- package/dist/examples/kv-cache-example.d.ts +2 -0
- package/dist/examples/kv-cache-example.js +74 -0
- package/dist/examples/llamacpp-file-logging.d.ts +2 -0
- package/dist/examples/llamacpp-file-logging.js +62 -0
- package/dist/examples/llamacpp-filesystem.d.ts +2 -0
- package/dist/examples/llamacpp-filesystem.js +40 -0
- package/dist/examples/llamacpp-http.d.ts +2 -0
- package/dist/examples/llamacpp-http.js +41 -0
- package/dist/examples/llamacpp-hyperdrive.d.ts +2 -0
- package/dist/examples/llamacpp-hyperdrive.js +39 -0
- package/dist/examples/llamacpp-multimodal.d.ts +2 -0
- package/dist/examples/llamacpp-multimodal.js +62 -0
- package/dist/examples/llamacpp-native-tools.d.ts +2 -0
- package/dist/examples/llamacpp-native-tools.js +64 -0
- package/dist/examples/llamacpp-tools-routing.d.ts +2 -0
- package/dist/examples/llamacpp-tools-routing.js +364 -0
- package/dist/examples/llamacpp-tools.d.ts +2 -0
- package/dist/examples/llamacpp-tools.js +81 -0
- package/dist/examples/multi-model-demo.d.ts +2 -0
- package/dist/examples/multi-model-demo.js +75 -0
- package/dist/examples/parallel-download.d.ts +2 -0
- package/dist/examples/parallel-download.js +21 -0
- package/dist/examples/rag/rag-chromadb.d.ts +2 -0
- package/dist/examples/rag/rag-chromadb.js +130 -0
- package/dist/examples/rag/rag-hyperdb-workspaces.d.ts +2 -0
- package/dist/examples/rag/rag-hyperdb-workspaces.js +106 -0
- package/dist/examples/rag/rag-hyperdb.d.ts +2 -0
- package/dist/examples/rag/rag-hyperdb.js +50 -0
- package/dist/examples/rag/rag-lancedb.d.ts +2 -0
- package/dist/examples/rag/rag-lancedb.js +95 -0
- package/dist/examples/rag/rag-sqlite.d.ts +2 -0
- package/dist/examples/rag/rag-sqlite.js +107 -0
- package/dist/examples/seed-hyperdrive.d.ts +2 -0
- package/dist/examples/seed-hyperdrive.js +21 -0
- package/dist/examples/translation/translation-indic.d.ts +2 -0
- package/dist/examples/translation/translation-indic.js +30 -0
- package/dist/examples/translation/translation-llm-context.d.ts +2 -0
- package/dist/examples/translation/translation-llm-context.js +30 -0
- package/dist/examples/translation/translation-llm.d.ts +2 -0
- package/dist/examples/translation/translation-llm.js +38 -0
- package/dist/examples/translation/translation-opus.d.ts +2 -0
- package/dist/examples/translation/translation-opus.js +30 -0
- package/dist/examples/translation/translation-stream.d.ts +2 -0
- package/dist/examples/translation/translation-stream.js +35 -0
- package/dist/examples/whispercpp-filesystem.d.ts +2 -0
- package/dist/examples/whispercpp-filesystem.js +43 -0
- package/dist/examples/whispercpp-microphone-record.d.ts +2 -0
- package/dist/examples/whispercpp-microphone-record.js +311 -0
- package/dist/expo/plugins/index.d.ts +5 -0
- package/dist/expo/plugins/index.js +5 -0
- package/dist/expo/plugins/withMobileBundle.d.ts +8 -0
- package/dist/expo/plugins/withMobileBundle.js +60 -0
- package/dist/expo/plugins/withOpenCL.d.ts +9 -0
- package/dist/expo/plugins/withOpenCL.js +118 -0
- package/dist/expo/plugins/withQvacSDK.d.ts +9 -0
- package/dist/expo/plugins/withQvacSDK.js +13 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +8 -0
- package/dist/logging/base-logger.d.ts +7 -0
- package/dist/logging/base-logger.js +55 -0
- package/dist/logging/index.d.ts +4 -0
- package/dist/logging/index.js +2 -0
- package/dist/logging/logger.d.ts +5 -0
- package/dist/logging/logger.js +28 -0
- package/dist/logging/stream-logger.d.ts +3 -0
- package/dist/logging/stream-logger.js +9 -0
- package/dist/logging/transport.d.ts +3 -0
- package/dist/logging/transport.js +15 -0
- package/dist/logging/types.d.ts +18 -0
- package/dist/logging/types.js +1 -0
- package/dist/logging/utils.d.ts +4 -0
- package/dist/logging/utils.js +47 -0
- package/dist/models/hyperdrive/index.d.ts +2 -0
- package/dist/models/hyperdrive/index.js +2 -0
- package/dist/models/hyperdrive/models.d.ts +475 -0
- package/dist/models/hyperdrive/models.js +534 -0
- package/dist/schemas/cancel.d.ts +33 -0
- package/dist/schemas/cancel.js +25 -0
- package/dist/schemas/common.d.ts +626 -0
- package/dist/schemas/common.js +47 -0
- package/dist/schemas/completion-stream.d.ts +125 -0
- package/dist/schemas/completion-stream.js +53 -0
- package/dist/schemas/delegate.d.ts +9 -0
- package/dist/schemas/delegate.js +9 -0
- package/dist/schemas/download-asset.d.ts +75 -0
- package/dist/schemas/download-asset.js +43 -0
- package/dist/schemas/embed.d.ts +20 -0
- package/dist/schemas/embed.js +14 -0
- package/dist/schemas/error.d.ts +13 -0
- package/dist/schemas/error.js +35 -0
- package/dist/schemas/index.d.ts +19 -0
- package/dist/schemas/index.js +19 -0
- package/dist/schemas/llamacpp-config.d.ts +30 -0
- package/dist/schemas/llamacpp-config.js +39 -0
- package/dist/schemas/load-model.d.ts +1259 -0
- package/dist/schemas/load-model.js +108 -0
- package/dist/schemas/logging-stream.d.ts +27 -0
- package/dist/schemas/logging-stream.js +16 -0
- package/dist/schemas/ping.d.ts +11 -0
- package/dist/schemas/ping.js +8 -0
- package/dist/schemas/provide.d.ts +43 -0
- package/dist/schemas/provide.js +25 -0
- package/dist/schemas/rag.d.ts +159 -0
- package/dist/schemas/rag.js +78 -0
- package/dist/schemas/transcription.d.ts +24 -0
- package/dist/schemas/transcription.js +15 -0
- package/dist/schemas/translate.d.ts +82 -0
- package/dist/schemas/translate.js +42 -0
- package/dist/schemas/translation-config.d.ts +83 -0
- package/dist/schemas/translation-config.js +46 -0
- package/dist/schemas/unload-model.d.ts +19 -0
- package/dist/schemas/unload-model.js +13 -0
- package/dist/schemas/whispercpp-config.d.ts +25 -0
- package/dist/schemas/whispercpp-config.js +18 -0
- package/dist/server/bare/addons/cancel.d.ts +3 -0
- package/dist/server/bare/addons/cancel.js +12 -0
- package/dist/server/bare/addons/index.d.ts +4 -0
- package/dist/server/bare/addons/index.js +3 -0
- package/dist/server/bare/addons/llamacpp/create-model.d.ts +5 -0
- package/dist/server/bare/addons/llamacpp/create-model.js +57 -0
- package/dist/server/bare/addons/llamacpp/handlers/completion-stream.d.ts +3 -0
- package/dist/server/bare/addons/llamacpp/handlers/completion-stream.js +65 -0
- package/dist/server/bare/addons/llamacpp/handlers/embed.d.ts +4 -0
- package/dist/server/bare/addons/llamacpp/handlers/embed.js +40 -0
- package/dist/server/bare/addons/llamacpp/index.d.ts +4 -0
- package/dist/server/bare/addons/llamacpp/index.js +3 -0
- package/dist/server/bare/addons/llamacpp/kv-cache-utils.d.ts +19 -0
- package/dist/server/bare/addons/llamacpp/kv-cache-utils.js +46 -0
- package/dist/server/bare/addons/load-model.d.ts +3 -0
- package/dist/server/bare/addons/load-model.js +55 -0
- package/dist/server/bare/addons/translation/create-model.d.ts +4 -0
- package/dist/server/bare/addons/translation/create-model.js +45 -0
- package/dist/server/bare/addons/translation/handlers/translate.d.ts +3 -0
- package/dist/server/bare/addons/translation/handlers/translate.js +86 -0
- package/dist/server/bare/addons/translation/index.d.ts +3 -0
- package/dist/server/bare/addons/translation/index.js +2 -0
- package/dist/server/bare/addons/unload-model.d.ts +3 -0
- package/dist/server/bare/addons/unload-model.js +20 -0
- package/dist/server/bare/addons/whispercpp/create-model.d.ts +6 -0
- package/dist/server/bare/addons/whispercpp/create-model.js +55 -0
- package/dist/server/bare/addons/whispercpp/handlers/transcribe-stream.d.ts +3 -0
- package/dist/server/bare/addons/whispercpp/handlers/transcribe-stream.js +42 -0
- package/dist/server/bare/addons/whispercpp/index.d.ts +3 -0
- package/dist/server/bare/addons/whispercpp/index.js +2 -0
- package/dist/server/bare/delegate-rpc-client.d.ts +4 -0
- package/dist/server/bare/delegate-rpc-client.js +70 -0
- package/dist/server/bare/hyperswarm.d.ts +7 -0
- package/dist/server/bare/hyperswarm.js +62 -0
- package/dist/server/bare/rag-hyperdb/handlers/delete-embeddings.d.ts +3 -0
- package/dist/server/bare/rag-hyperdb/handlers/delete-embeddings.js +12 -0
- package/dist/server/bare/rag-hyperdb/handlers/save-embeddings.d.ts +6 -0
- package/dist/server/bare/rag-hyperdb/handlers/save-embeddings.js +16 -0
- package/dist/server/bare/rag-hyperdb/handlers/search.d.ts +3 -0
- package/dist/server/bare/rag-hyperdb/handlers/search.js +15 -0
- package/dist/server/bare/rag-hyperdb/index.d.ts +5 -0
- package/dist/server/bare/rag-hyperdb/index.js +4 -0
- package/dist/server/bare/rag-hyperdb/rag-manager.d.ts +5 -0
- package/dist/server/bare/rag-hyperdb/rag-manager.js +61 -0
- package/dist/server/bare/registry/logging-stream-registry.d.ts +12 -0
- package/dist/server/bare/registry/logging-stream-registry.js +46 -0
- package/dist/server/bare/registry/model-registry.d.ts +64 -0
- package/dist/server/bare/registry/model-registry.js +95 -0
- package/dist/server/error-handlers.d.ts +4 -0
- package/dist/server/error-handlers.js +27 -0
- package/dist/server/http-server.d.ts +2 -0
- package/dist/server/http-server.js +189 -0
- package/dist/server/rpc/create-server.d.ts +4 -0
- package/dist/server/rpc/create-server.js +19 -0
- package/dist/server/rpc/handle-request.d.ts +12 -0
- package/dist/server/rpc/handle-request.js +220 -0
- package/dist/server/rpc/handlers/cancelHandler.d.ts +3 -0
- package/dist/server/rpc/handlers/cancelHandler.js +27 -0
- package/dist/server/rpc/handlers/completion-stream-delegated.d.ts +3 -0
- package/dist/server/rpc/handlers/completion-stream-delegated.js +30 -0
- package/dist/server/rpc/handlers/completion-stream.d.ts +3 -0
- package/dist/server/rpc/handlers/completion-stream.js +52 -0
- package/dist/server/rpc/handlers/download-asset.d.ts +3 -0
- package/dist/server/rpc/handlers/download-asset.js +21 -0
- package/dist/server/rpc/handlers/embed.d.ts +3 -0
- package/dist/server/rpc/handlers/embed.js +21 -0
- package/dist/server/rpc/handlers/index.d.ts +23 -0
- package/dist/server/rpc/handlers/index.js +22 -0
- package/dist/server/rpc/handlers/load-model/download-manager.d.ts +31 -0
- package/dist/server/rpc/handlers/load-model/download-manager.js +88 -0
- package/dist/server/rpc/handlers/load-model/http.d.ts +3 -0
- package/dist/server/rpc/handlers/load-model/http.js +337 -0
- package/dist/server/rpc/handlers/load-model/hyperdrive.d.ts +4 -0
- package/dist/server/rpc/handlers/load-model/hyperdrive.js +332 -0
- package/dist/server/rpc/handlers/load-model/index.d.ts +4 -0
- package/dist/server/rpc/handlers/load-model/index.js +3 -0
- package/dist/server/rpc/handlers/load-model/resolve.d.ts +3 -0
- package/dist/server/rpc/handlers/load-model/resolve.js +121 -0
- package/dist/server/rpc/handlers/load-model-delegated.d.ts +3 -0
- package/dist/server/rpc/handlers/load-model-delegated.js +93 -0
- package/dist/server/rpc/handlers/load-model.d.ts +3 -0
- package/dist/server/rpc/handlers/load-model.js +41 -0
- package/dist/server/rpc/handlers/logging-stream.d.ts +3 -0
- package/dist/server/rpc/handlers/logging-stream.js +37 -0
- package/dist/server/rpc/handlers/provideHandler/connection.d.ts +3 -0
- package/dist/server/rpc/handlers/provideHandler/connection.js +25 -0
- package/dist/server/rpc/handlers/provideHandler/handler.d.ts +3 -0
- package/dist/server/rpc/handlers/provideHandler/handler.js +50 -0
- package/dist/server/rpc/handlers/provideHandler/proxy.d.ts +3 -0
- package/dist/server/rpc/handlers/provideHandler/proxy.js +22 -0
- package/dist/server/rpc/handlers/provideHandler.d.ts +2 -0
- package/dist/server/rpc/handlers/provideHandler.js +2 -0
- package/dist/server/rpc/handlers/rag.d.ts +3 -0
- package/dist/server/rpc/handlers/rag.js +67 -0
- package/dist/server/rpc/handlers/transcribe-stream.d.ts +3 -0
- package/dist/server/rpc/handlers/transcribe-stream.js +26 -0
- package/dist/server/rpc/handlers/translate.d.ts +3 -0
- package/dist/server/rpc/handlers/translate.js +51 -0
- package/dist/server/rpc/handlers/unload-model.d.ts +3 -0
- package/dist/server/rpc/handlers/unload-model.js +20 -0
- package/dist/server/rpc/index.d.ts +3 -0
- package/dist/server/rpc/index.js +2 -0
- package/dist/server/utils/audio/decoder.d.ts +4 -0
- package/dist/server/utils/audio/decoder.js +41 -0
- package/dist/server/utils/cache.d.ts +15 -0
- package/dist/server/utils/cache.js +32 -0
- package/dist/server/utils/hash.d.ts +5 -0
- package/dist/server/utils/hash.js +11 -0
- package/dist/server/utils/index.d.ts +5 -0
- package/dist/server/utils/index.js +4 -0
- package/dist/server/utils/model-path.d.ts +5 -0
- package/dist/server/utils/model-path.js +7 -0
- package/dist/server/worker.d.ts +6 -0
- package/dist/server/worker.js +77 -0
- package/dist/utils/withTimeout.d.ts +11 -0
- package/dist/utils/withTimeout.js +37 -0
- package/package.json +129 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
[](https://tether-2.gitbook.io/qvac-by-tether-or-reference/y2AsIh94H9DJ1pIBCNj9)
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
**QVAC** is an open-source, cross-platform system for building local-first, peer-to-peer **AI applications**. QVAC runs on [**Bare**](https://bare.pears.com) by [Holepunch](https://holepunch.to), a lightweight, cross-platform JavaScript runtime.
|
|
6
|
+
|
|
7
|
+
# QVAC SDK
|
|
8
|
+
|
|
9
|
+
**QVAC SDK** is the canonical entry point to QVAC. 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.
|
|
10
|
+
|
|
11
|
+
For the comprehensive reference, [see official QVAC documentation](https://tether-2.gitbook.io/qvac-by-tether-or-reference/y2AsIh94H9DJ1pIBCNj9).
|
|
12
|
+
|
|
13
|
+
## Requirements
|
|
14
|
+
|
|
15
|
+
Supported JS environments: Bare, Node.js, Expo and Bun.
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
### Steps
|
|
20
|
+
|
|
21
|
+
1. [Authenticate to Tether’s GitHub packages](#step-1-authenticate-to-tethers-github-packages)
|
|
22
|
+
2. [Install package and dependencies](#step-2-install-package-and-dependencies)
|
|
23
|
+
|
|
24
|
+
### Step 1: authenticate to Tether’s GitHub packages
|
|
25
|
+
|
|
26
|
+
1. [Create a GitHub personal access token (classic) with scope `read:packages`](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic).
|
|
27
|
+
|
|
28
|
+
2. Add the token to your environment variables. For example, on macOS/Linux:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
export NPM_TOKEN=<token_generated_in_previous_step>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
3. In the root of your project, create file `.npmrc` with the following content:
|
|
35
|
+
|
|
36
|
+
```ini
|
|
37
|
+
@qvac:registry=https://registry.npmjs.org
|
|
38
|
+
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
_Alternatively, you can create the `.npmrc` file in your home directory, for user-level (global) configuration._
|
|
42
|
+
|
|
43
|
+
4. Confirm authentication to Tether’s GitHub packages:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npm whoami --registry=https://npm.pkg.github.com
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
It should return your GitHub username.
|
|
50
|
+
|
|
51
|
+
### Step 2: Install package and dependencies
|
|
52
|
+
|
|
53
|
+
1. Install in your project using the package manager of your choice:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
npm i @qvac/sdk
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
> [!TIP]
|
|
60
|
+
> If you can't get the package via Tether's private GitHub package registry, see section [Build from source](#build-from-source).
|
|
61
|
+
|
|
62
|
+
#### On Linux
|
|
63
|
+
|
|
64
|
+
> [!IMPORTANT]
|
|
65
|
+
> If you're on Linux ensure that the Vulkan SDK is installed (e.g. `apt install vulkan-sdk` on Ubuntu)
|
|
66
|
+
|
|
67
|
+
#### On Expo
|
|
68
|
+
|
|
69
|
+
1. Install the peer dependencies for Expo/React Native support:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
npm i expo-file-system react-native-bare-kit
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
2. If you are on Android, bump your `minSdkVersion` to 29. You can do so by adding `ext { minSdkVersion=29 }` to your `android/build.gradle` or by using `expo-build-properties`.
|
|
76
|
+
|
|
77
|
+
3. Add the QVAC Expo plugin to your `app.json`:
|
|
78
|
+
|
|
79
|
+
```js
|
|
80
|
+
export default {
|
|
81
|
+
expo: {
|
|
82
|
+
plugins: ["qvac-sdk/expo-plugin"],
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
4. Prebuild your project to generate the native files:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
npx expo prebuild
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
5. Build and run it on a **physical device**:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
npx expo run:ios --device
|
|
97
|
+
# or
|
|
98
|
+
npx expo run:android --device
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
> [!IMPORTANT]
|
|
102
|
+
> Due to limitations with `llamacpp`, QVAC currently does not run on emulators. You **must** use a physical device.
|
|
103
|
+
|
|
104
|
+
## Quickstart
|
|
105
|
+
|
|
106
|
+
You can run the self-contained example below:
|
|
107
|
+
|
|
108
|
+
```js
|
|
109
|
+
import { loadModel, completion, unloadModel } from "@qvac/sdk";
|
|
110
|
+
|
|
111
|
+
// Load model into memory
|
|
112
|
+
const modelId = await loadModel(
|
|
113
|
+
"pear://afa79ee07c0a138bb9f11bfaee771fb1bdfca8c82d961cff0474e49827bd1de3/Llama-3.2-1B-Instruct-Q4_0.gguf",
|
|
114
|
+
{
|
|
115
|
+
modelType: "llm",
|
|
116
|
+
},
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
// Use the loaded model
|
|
120
|
+
const response = completion({
|
|
121
|
+
modelId,
|
|
122
|
+
history: [{ role: "user", content: "What is the capital of France?" }],
|
|
123
|
+
stream: false,
|
|
124
|
+
});
|
|
125
|
+
const text = await response.text;
|
|
126
|
+
console.log(text);
|
|
127
|
+
|
|
128
|
+
// Enable KV cache for faster subsequent completions
|
|
129
|
+
const cachedResponse = completion({
|
|
130
|
+
modelId,
|
|
131
|
+
history: [
|
|
132
|
+
{ role: "user", content: "What is the capital of France?" },
|
|
133
|
+
{ role: "assistant", content: "The capital of France is Paris." },
|
|
134
|
+
{ role: "user", content: "What about Germany?" },
|
|
135
|
+
],
|
|
136
|
+
stream: true,
|
|
137
|
+
kvCache: true, // enables caching for faster inference
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
// You can use the loaded model multiple times
|
|
141
|
+
|
|
142
|
+
// Unload model to free up system resources
|
|
143
|
+
await unloadModel({ modelId });
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
**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)**.
|
|
147
|
+
|
|
148
|
+
## Build from source
|
|
149
|
+
|
|
150
|
+
Use the [Bun](https://bun.sh/) package manager:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
bun i
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
bun run build # or `watch` for hotreload
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
bun run build:pack
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
This outputs a tarball under `dist/tetherto-qvac-sdk-{version}.tgz` that you can install in your project, e.g.:
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
npm i path/to/tetherto-qvac-sdk-0.0.1.tgz
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Examples
|
|
171
|
+
|
|
172
|
+
In the `./examples` subdirectory, you will find scripts demonstrating SDK usage. To try any of them:
|
|
173
|
+
|
|
174
|
+
1. Follow the steps in section [Build from source](#build-from-source).
|
|
175
|
+
2. Run using Bare, Node.js, or Bun as the runtime:
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
# With Bare
|
|
179
|
+
bun run bare:example dist/examples/path/to/example.js
|
|
180
|
+
|
|
181
|
+
# With Node
|
|
182
|
+
node dist/examples/path/to/example.js
|
|
183
|
+
|
|
184
|
+
# With bun, straight from source
|
|
185
|
+
bun run examples/path/to/example.ts
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## Logging
|
|
189
|
+
|
|
190
|
+
QVAC SDK includes built-in log propagation that streams model logs from the worker process to your client application in real-time. This gives you visibility into what's happening inside your models during loading, inference, and other operations.
|
|
191
|
+
|
|
192
|
+
### Usage
|
|
193
|
+
|
|
194
|
+
Simply pass a logger when loading your model:
|
|
195
|
+
|
|
196
|
+
```js
|
|
197
|
+
import { getLogger, loadModel, completion, unloadModel } from "@qvac/sdk";
|
|
198
|
+
|
|
199
|
+
// Create a logger for your application
|
|
200
|
+
const logger = getLogger("my-app", {
|
|
201
|
+
level: "debug", // Set log level
|
|
202
|
+
transports: [
|
|
203
|
+
// Optional: add custom log handlers
|
|
204
|
+
(level, namespace, message) => {
|
|
205
|
+
console.log(`[${level.toUpperCase()}] ${namespace}: ${message}`);
|
|
206
|
+
},
|
|
207
|
+
],
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
// Load model with logging - RPC stream starts automatically
|
|
211
|
+
const modelId = await loadModel(
|
|
212
|
+
"pear://afa79ee07c0a138bb9f11bfaee771fb1bdfca8c82d961cff0474e49827bd1de3/Llama-3.2-1B-Instruct-Q4_0.gguf",
|
|
213
|
+
{
|
|
214
|
+
modelType: "llm",
|
|
215
|
+
logger, // Enable log streaming
|
|
216
|
+
},
|
|
217
|
+
);
|
|
218
|
+
|
|
219
|
+
// Now you'll see model logs in your console as operations happen
|
|
220
|
+
for await (const token of completion({
|
|
221
|
+
modelId,
|
|
222
|
+
history: [{ role: "user", content: "Hello!" }],
|
|
223
|
+
}).tokenStream) {
|
|
224
|
+
process.stdout.write(token);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
await unloadModel({ modelId }); // Logging stream closes automatically
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### What You'll See
|
|
231
|
+
|
|
232
|
+
When logging is enabled, you'll see real-time logs from the underlying model libraries:
|
|
233
|
+
|
|
234
|
+
```
|
|
235
|
+
[DEBUG] llamacpp:llm: Loading model weights...
|
|
236
|
+
[INFO] llamacpp:llm: Model loaded successfully, vocab_size=32000
|
|
237
|
+
[DEBUG] llamacpp:llm: Starting inference...
|
|
238
|
+
[DEBUG] llamacpp:llm: Inference completed, tokens=12
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
This works for all model types (LLM, Whisper, NMT, Embeddings) and provides valuable insight into model performance and behavior.
|
|
242
|
+
|
|
243
|
+
### Completion
|
|
244
|
+
|
|
245
|
+
- `llama.cpp` with local files: [`examples/llamacpp-filesystem.ts`](examples/llamacpp-filesystem.ts)
|
|
246
|
+
- `llama.cpp` with Hyperdrive: [`examples/llamacpp-hyperdrive.ts`](examples/llamacpp-hyperdrive.ts)
|
|
247
|
+
- `llama.cpp` with HTTP: [`examples/llamacpp-http.ts`](examples/llamacpp-http.ts)
|
|
248
|
+
- `llama.cpp` with file logging: [`examples/llamacpp-file-logging.ts`](examples/llamacpp-file-logging.ts)
|
|
249
|
+
- `llama.cpp` with tools/function calls: [`examples/llamacpp-tools.ts`](examples/llamacpp-tools.ts)
|
|
250
|
+
- `llama.cpp` with tools and routing: [`examples/llamacpp-tools-routing.ts`](examples/llamacpp-tools-routing.ts)
|
|
251
|
+
- `llama.cpp` with multimodal inference: [`examples/llamacpp-multimodal.ts`](examples/llamacpp-multimodal.ts)
|
|
252
|
+
- `llama.cpp` with KV cache: [`examples/kv-cache-example.ts`](examples/kv-cache-example.ts)
|
|
253
|
+
|
|
254
|
+
### Transcription
|
|
255
|
+
|
|
256
|
+
- `whisper.cpp` transcription: [`examples/whispercpp-transcription.ts`](examples/whispercpp-transcription.ts)
|
|
257
|
+
- Microphone recording: [`examples/microphone-record-transcription.ts`](examples/microphone-record-transcription.ts)
|
|
258
|
+
|
|
259
|
+
### Embeddings
|
|
260
|
+
|
|
261
|
+
- Embedding with Hyperdrive: [`examples/embed-hyperdrive.ts`](examples/embed-hyperdrive.ts)
|
|
262
|
+
- RAG example with HyperDB: [`examples/rag-hyperdb.ts`](examples/rag-hyperdb.ts)
|
|
263
|
+
- RAG with workspaces: [`examples/rag-hyperdb-workspaces.ts`](examples/rag-hyperdb-workspaces.ts) _(Demonstrates workspace isolation and chunking)_
|
|
264
|
+
- RAG example with LanceDB (desktop only): [`examples/rag-lancedb.ts`](examples/rag-lancedb.ts)
|
|
265
|
+
- RAG example with ChromaDB (desktop only): [`examples/rag-chromadb.ts`](examples/rag-chromadb.ts) _(Note: Requires ChromaDB server running)_
|
|
266
|
+
- RAG example with SQLite-Vector (desktop only): [`examples/rag-sqlite.ts`](examples/rag-sqlite.ts) _(Note: Uses SQLite-Vector WASM)_
|
|
267
|
+
|
|
268
|
+
### Translation
|
|
269
|
+
|
|
270
|
+
- Marian OPUS translation: [`examples/translation-opus.ts`](examples/translation-opus.ts)
|
|
271
|
+
- Indic language translation: [`examples/translation-indic.ts`](examples/translation-indic.ts)
|
|
272
|
+
- LLM-based translation: [`examples/translation-llm.ts`](examples/translation-llm.ts)
|
|
273
|
+
|
|
274
|
+
### Multimodel
|
|
275
|
+
|
|
276
|
+
- Load multiple models simultaneously: [`examples/multi-model-demo.ts`](examples/multi-model-demo.ts)
|
|
277
|
+
|
|
278
|
+
### Delegated inference
|
|
279
|
+
|
|
280
|
+
- Provider example: [`examples/delegated-inference/provider.ts`](examples/delegated-inference/provider.ts)
|
|
281
|
+
- Consumer example: [`examples/delegated-inference/consumer.ts`](examples/delegated-inference/consumer.ts)
|
|
282
|
+
|
|
283
|
+
**Note**: Set the `QVAC_HYPERSWARM_SEED` env var to ensure that the provider's uses the same keypair (i.e. the public key doesn't change on every run).
|
|
284
|
+
**Note**: ⚠️ Consumer does not handle reconnection yet.
|
|
285
|
+
|
|
286
|
+
### Download Lifecycle
|
|
287
|
+
|
|
288
|
+
- Pause and resume download: [`examples/download-with-cancel.ts`](examples/download-with-cancel.ts)
|
|
289
|
+
|
|
290
|
+
## Known issues
|
|
291
|
+
|
|
292
|
+
- **One off scripts don't terminate / hang**
|
|
293
|
+
- Add a `process.exit()` call at the end, we're working on it.
|
|
294
|
+
|
|
295
|
+
- **I'm building my Expo app on iOS but I don't see logs from QVAC**
|
|
296
|
+
- `npx expo start`
|
|
297
|
+
- Open the `ios` folder in Xcode
|
|
298
|
+
- Start the app with the play ▶️ button
|
|
299
|
+
- View -> Debug area -> Activate console
|
|
300
|
+
- You should see the system logs on the right pane
|
|
301
|
+
- ⚠️ This only works when starting the app from Xcode
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type CancelParams } from "../../schemas/index";
|
|
2
|
+
/**
|
|
3
|
+
* Cancels an ongoing operation.
|
|
4
|
+
*
|
|
5
|
+
* @param params - The parameters for the cancellation
|
|
6
|
+
* @param params.operation - The type of operation to cancel ("inference" or "download")
|
|
7
|
+
* @param params.modelId - The model ID (required for inference cancellation)
|
|
8
|
+
* @param params.downloadKey - The download key (required for download cancellation)
|
|
9
|
+
* @param params.clearCache - If true, deletes the partial download file (default: false)
|
|
10
|
+
* @throws {Error} When the response type is invalid or when the cancellation fails
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* // Cancel inference
|
|
14
|
+
* await cancel({ operation: "inference", modelId: "model-123" });
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // Pause download (preserves partial file for automatic resume)
|
|
18
|
+
* await cancel({ operation: "download", downloadKey: "download-key" });
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* // Cancel download completely (deletes partial file)
|
|
22
|
+
* await cancel({ operation: "download", downloadKey: "download-key", clearCache: true });
|
|
23
|
+
*/
|
|
24
|
+
export declare function cancel(params: CancelParams): Promise<void>;
|
|
25
|
+
//# sourceMappingURL=cancel.d.ts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { send } from "../rpc/rpc-client.js";
|
|
2
|
+
import {} from "../../schemas/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Cancels an ongoing operation.
|
|
5
|
+
*
|
|
6
|
+
* @param params - The parameters for the cancellation
|
|
7
|
+
* @param params.operation - The type of operation to cancel ("inference" or "download")
|
|
8
|
+
* @param params.modelId - The model ID (required for inference cancellation)
|
|
9
|
+
* @param params.downloadKey - The download key (required for download cancellation)
|
|
10
|
+
* @param params.clearCache - If true, deletes the partial download file (default: false)
|
|
11
|
+
* @throws {Error} When the response type is invalid or when the cancellation fails
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* // Cancel inference
|
|
15
|
+
* await cancel({ operation: "inference", modelId: "model-123" });
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // Pause download (preserves partial file for automatic resume)
|
|
19
|
+
* await cancel({ operation: "download", downloadKey: "download-key" });
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* // Cancel download completely (deletes partial file)
|
|
23
|
+
* await cancel({ operation: "download", downloadKey: "download-key", clearCache: true });
|
|
24
|
+
*/
|
|
25
|
+
export async function cancel(params) {
|
|
26
|
+
const request = {
|
|
27
|
+
type: "cancel",
|
|
28
|
+
...params,
|
|
29
|
+
};
|
|
30
|
+
const response = await send(request);
|
|
31
|
+
if (response.type !== "cancel") {
|
|
32
|
+
throw new Error("Invalid response type");
|
|
33
|
+
}
|
|
34
|
+
if (!response.success) {
|
|
35
|
+
throw new Error(response.error ?? "Failed to cancel");
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type CompletionStats, type CompletionClientParams } from "../../schemas/index";
|
|
2
|
+
/**
|
|
3
|
+
* Generates completion from a language model based on conversation history.
|
|
4
|
+
*
|
|
5
|
+
* @param params - The completion parameters
|
|
6
|
+
* @param params.modelId - The identifier of the model to use for completion
|
|
7
|
+
* @param params.history - Array of conversation messages with role, content, and optional attachments
|
|
8
|
+
* @param params.stream - Whether to stream tokens (true) or return complete response (false). Defaults to true
|
|
9
|
+
* @param params.tools - Optional array of tools that can be used by the model
|
|
10
|
+
* @param params.kvCache - Optional boolean to enable KV cache for faster subsequent completions
|
|
11
|
+
* @returns Object with tokenStream generator, text promise, and stats promise
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* // Streaming mode
|
|
15
|
+
* const result = completion({
|
|
16
|
+
* modelId: "llama-2",
|
|
17
|
+
* history: [
|
|
18
|
+
* { role: "user", content: "Hello, how are you?" }
|
|
19
|
+
* ],
|
|
20
|
+
* stream: true,
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* for await (const token of result.tokenStream) {
|
|
24
|
+
* console.log(token);
|
|
25
|
+
* }
|
|
26
|
+
*
|
|
27
|
+
* const stats = await result.stats;
|
|
28
|
+
* console.log("Performance:", stats);
|
|
29
|
+
*
|
|
30
|
+
* // Non-streaming mode
|
|
31
|
+
* const response = completion({
|
|
32
|
+
* modelId: "llama-2",
|
|
33
|
+
* history: [
|
|
34
|
+
* { role: "user", content: "What is the capital of France?" }
|
|
35
|
+
* ],
|
|
36
|
+
* stream: false,
|
|
37
|
+
* });
|
|
38
|
+
*
|
|
39
|
+
* const text = await response.text;
|
|
40
|
+
* const stats = await response.stats;
|
|
41
|
+
* console.log(text);
|
|
42
|
+
* console.log(stats);
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare function completion(params: CompletionClientParams): {
|
|
46
|
+
tokenStream: AsyncGenerator<string>;
|
|
47
|
+
stats: Promise<CompletionStats | undefined>;
|
|
48
|
+
text: Promise<string>;
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=completion-stream.d.ts.map
|