@trymirai/uzu 0.1.20 → 0.1.22
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 +21 -0
- package/README.md +103 -136
- package/bridging/classificationFeature.d.mts +9 -0
- package/bridging/classificationFeature.d.mts.map +1 -0
- package/bridging/classificationFeature.d.ts +9 -0
- package/bridging/classificationFeature.d.ts.map +1 -0
- package/bridging/classificationFeature.js +18 -0
- package/bridging/classificationFeature.js.map +1 -0
- package/bridging/classificationFeature.mjs +14 -0
- package/bridging/classificationFeature.mjs.map +1 -0
- package/bridging/config.d.mts +20 -0
- package/bridging/config.d.mts.map +1 -0
- package/bridging/config.d.ts +20 -0
- package/bridging/config.d.ts.map +1 -0
- package/bridging/config.js +41 -0
- package/bridging/config.js.map +1 -0
- package/bridging/config.mjs +37 -0
- package/bridging/config.mjs.map +1 -0
- package/bridging/contextLength.d.mts +11 -0
- package/bridging/contextLength.d.mts.map +1 -0
- package/bridging/contextLength.d.ts +11 -0
- package/bridging/contextLength.d.ts.map +1 -0
- package/bridging/contextLength.js +25 -0
- package/bridging/contextLength.js.map +1 -0
- package/bridging/contextLength.mjs +21 -0
- package/bridging/contextLength.mjs.map +1 -0
- package/bridging/downloadHandle.d.mts +14 -0
- package/bridging/downloadHandle.d.mts.map +1 -0
- package/bridging/downloadHandle.d.ts +14 -0
- package/bridging/downloadHandle.d.ts.map +1 -0
- package/bridging/downloadHandle.js +36 -0
- package/bridging/downloadHandle.js.map +1 -0
- package/bridging/downloadHandle.mjs +32 -0
- package/bridging/downloadHandle.mjs.map +1 -0
- package/bridging/downloadProgressUpdate.d.mts +9 -0
- package/bridging/downloadProgressUpdate.d.mts.map +1 -0
- package/bridging/downloadProgressUpdate.d.ts +9 -0
- package/bridging/downloadProgressUpdate.d.ts.map +1 -0
- package/bridging/downloadProgressUpdate.js +15 -0
- package/bridging/downloadProgressUpdate.js.map +1 -0
- package/bridging/downloadProgressUpdate.mjs +11 -0
- package/bridging/downloadProgressUpdate.mjs.map +1 -0
- package/bridging/downloadState.d.mts +18 -0
- package/bridging/downloadState.d.mts.map +1 -0
- package/bridging/downloadState.d.ts +18 -0
- package/bridging/downloadState.d.ts.map +1 -0
- package/bridging/downloadState.js +42 -0
- package/bridging/downloadState.js.map +1 -0
- package/bridging/downloadState.mjs +38 -0
- package/bridging/downloadState.mjs.map +1 -0
- package/bridging/engine.d.mts +17 -0
- package/bridging/engine.d.mts.map +1 -0
- package/bridging/engine.d.ts +17 -0
- package/bridging/engine.d.ts.map +1 -0
- package/bridging/engine.js +84 -0
- package/bridging/engine.js.map +1 -0
- package/bridging/engine.mjs +80 -0
- package/bridging/engine.mjs.map +1 -0
- package/bridging/finishReason.d.mts +7 -0
- package/bridging/finishReason.d.mts.map +1 -0
- package/bridging/finishReason.d.ts +7 -0
- package/bridging/finishReason.d.ts.map +1 -0
- package/bridging/finishReason.js +11 -0
- package/bridging/finishReason.js.map +1 -0
- package/bridging/finishReason.mjs +8 -0
- package/bridging/finishReason.mjs.map +1 -0
- package/bridging/input.d.mts +11 -0
- package/bridging/input.d.mts.map +1 -0
- package/bridging/input.d.ts +11 -0
- package/bridging/input.d.ts.map +1 -0
- package/bridging/input.js +25 -0
- package/bridging/input.js.map +1 -0
- package/bridging/input.mjs +21 -0
- package/bridging/input.mjs.map +1 -0
- package/bridging/licenseStatus.d.mts +14 -0
- package/bridging/licenseStatus.d.mts.map +1 -0
- package/bridging/licenseStatus.d.ts +14 -0
- package/bridging/licenseStatus.d.ts.map +1 -0
- package/bridging/licenseStatus.js +42 -0
- package/bridging/licenseStatus.js.map +1 -0
- package/bridging/licenseStatus.mjs +38 -0
- package/bridging/licenseStatus.mjs.map +1 -0
- package/bridging/message.d.mts +15 -0
- package/bridging/message.d.mts.map +1 -0
- package/bridging/message.d.ts +15 -0
- package/bridging/message.d.ts.map +1 -0
- package/bridging/message.js +43 -0
- package/bridging/message.js.map +1 -0
- package/bridging/message.mjs +39 -0
- package/bridging/message.mjs.map +1 -0
- package/bridging/model.d.mts +18 -0
- package/bridging/model.d.mts.map +1 -0
- package/bridging/model.d.ts +18 -0
- package/bridging/model.d.ts.map +1 -0
- package/bridging/model.js +28 -0
- package/bridging/model.js.map +1 -0
- package/bridging/model.mjs +24 -0
- package/bridging/model.mjs.map +1 -0
- package/bridging/napi.d.mts +4 -0
- package/bridging/napi.d.mts.map +1 -0
- package/bridging/napi.d.ts +4 -0
- package/bridging/napi.d.ts.map +1 -0
- package/bridging/napi.js +3 -0
- package/bridging/napi.js.map +1 -0
- package/bridging/napi.mjs +2 -0
- package/bridging/napi.mjs.map +1 -0
- package/bridging/output.d.mts +13 -0
- package/bridging/output.d.mts.map +1 -0
- package/bridging/output.d.ts +13 -0
- package/bridging/output.d.ts.map +1 -0
- package/bridging/output.js +36 -0
- package/bridging/output.js.map +1 -0
- package/bridging/output.mjs +32 -0
- package/bridging/output.mjs.map +1 -0
- package/bridging/parsedText.d.mts +8 -0
- package/bridging/parsedText.d.mts.map +1 -0
- package/bridging/parsedText.d.ts +8 -0
- package/bridging/parsedText.d.ts.map +1 -0
- package/bridging/parsedText.js +16 -0
- package/bridging/parsedText.js.map +1 -0
- package/bridging/parsedText.mjs +12 -0
- package/bridging/parsedText.mjs.map +1 -0
- package/bridging/prefillStepSize.d.mts +11 -0
- package/bridging/prefillStepSize.d.mts.map +1 -0
- package/bridging/prefillStepSize.d.ts +11 -0
- package/bridging/prefillStepSize.d.ts.map +1 -0
- package/bridging/prefillStepSize.js +28 -0
- package/bridging/prefillStepSize.js.map +1 -0
- package/bridging/prefillStepSize.mjs +24 -0
- package/bridging/prefillStepSize.mjs.map +1 -0
- package/bridging/preset.d.mts +12 -0
- package/bridging/preset.d.mts.map +1 -0
- package/bridging/preset.d.ts +12 -0
- package/bridging/preset.d.ts.map +1 -0
- package/bridging/preset.js +29 -0
- package/bridging/preset.js.map +1 -0
- package/bridging/preset.mjs +25 -0
- package/bridging/preset.mjs.map +1 -0
- package/bridging/role.d.mts +6 -0
- package/bridging/role.d.mts.map +1 -0
- package/bridging/role.d.ts +6 -0
- package/bridging/role.d.ts.map +1 -0
- package/bridging/role.js +10 -0
- package/bridging/role.js.map +1 -0
- package/bridging/role.mjs +7 -0
- package/bridging/role.mjs.map +1 -0
- package/bridging/runConfig.d.mts +15 -0
- package/bridging/runConfig.d.mts.map +1 -0
- package/bridging/runConfig.d.ts +15 -0
- package/bridging/runConfig.d.ts.map +1 -0
- package/bridging/runConfig.js +34 -0
- package/bridging/runConfig.js.map +1 -0
- package/bridging/runConfig.mjs +30 -0
- package/bridging/runConfig.mjs.map +1 -0
- package/bridging/runStats.d.mts +8 -0
- package/bridging/runStats.d.mts.map +1 -0
- package/bridging/runStats.d.ts +8 -0
- package/bridging/runStats.d.ts.map +1 -0
- package/bridging/runStats.js +16 -0
- package/bridging/runStats.js.map +1 -0
- package/bridging/runStats.mjs +12 -0
- package/bridging/runStats.mjs.map +1 -0
- package/bridging/samplingMethod.d.mts +11 -0
- package/bridging/samplingMethod.d.mts.map +1 -0
- package/bridging/samplingMethod.d.ts +11 -0
- package/bridging/samplingMethod.d.ts.map +1 -0
- package/bridging/samplingMethod.js +28 -0
- package/bridging/samplingMethod.js.map +1 -0
- package/bridging/samplingMethod.mjs +24 -0
- package/bridging/samplingMethod.mjs.map +1 -0
- package/bridging/samplingPolicy.d.mts +11 -0
- package/bridging/samplingPolicy.d.mts.map +1 -0
- package/bridging/samplingPolicy.d.ts +11 -0
- package/bridging/samplingPolicy.d.ts.map +1 -0
- package/bridging/samplingPolicy.js +25 -0
- package/bridging/samplingPolicy.js.map +1 -0
- package/bridging/samplingPolicy.mjs +21 -0
- package/bridging/samplingPolicy.mjs.map +1 -0
- package/bridging/samplingSeed.d.mts +10 -0
- package/bridging/samplingSeed.d.mts.map +1 -0
- package/bridging/samplingSeed.d.ts +10 -0
- package/bridging/samplingSeed.d.ts.map +1 -0
- package/bridging/samplingSeed.js +21 -0
- package/bridging/samplingSeed.js.map +1 -0
- package/bridging/samplingSeed.mjs +17 -0
- package/bridging/samplingSeed.mjs.map +1 -0
- package/bridging/session.d.mts +10 -0
- package/bridging/session.d.mts.map +1 -0
- package/bridging/session.d.ts +10 -0
- package/bridging/session.d.ts.map +1 -0
- package/bridging/session.js +19 -0
- package/bridging/session.js.map +1 -0
- package/bridging/session.mjs +15 -0
- package/bridging/session.mjs.map +1 -0
- package/bridging/stats.d.mts +11 -0
- package/bridging/stats.d.mts.map +1 -0
- package/bridging/stats.d.ts +11 -0
- package/bridging/stats.d.ts.map +1 -0
- package/bridging/stats.js +20 -0
- package/bridging/stats.js.map +1 -0
- package/bridging/stats.mjs +16 -0
- package/bridging/stats.mjs.map +1 -0
- package/bridging/stepStats.d.mts +13 -0
- package/bridging/stepStats.d.mts.map +1 -0
- package/bridging/stepStats.d.ts +13 -0
- package/bridging/stepStats.d.ts.map +1 -0
- package/bridging/stepStats.js +25 -0
- package/bridging/stepStats.js.map +1 -0
- package/bridging/stepStats.mjs +21 -0
- package/bridging/stepStats.mjs.map +1 -0
- package/bridging/text.d.mts +9 -0
- package/bridging/text.d.mts.map +1 -0
- package/bridging/text.d.ts +9 -0
- package/bridging/text.d.ts.map +1 -0
- package/bridging/text.js +17 -0
- package/bridging/text.js.map +1 -0
- package/bridging/text.mjs +13 -0
- package/bridging/text.mjs.map +1 -0
- package/bridging/totalStats.d.mts +9 -0
- package/bridging/totalStats.d.mts.map +1 -0
- package/bridging/totalStats.d.ts +9 -0
- package/bridging/totalStats.d.ts.map +1 -0
- package/bridging/totalStats.js +18 -0
- package/bridging/totalStats.js.map +1 -0
- package/bridging/totalStats.mjs +14 -0
- package/bridging/totalStats.mjs.map +1 -0
- package/error.d.mts +16 -0
- package/error.d.mts.map +1 -0
- package/error.d.ts +16 -0
- package/error.d.ts.map +1 -0
- package/error.js +42 -0
- package/error.js.map +1 -0
- package/error.mjs +37 -0
- package/error.mjs.map +1 -0
- package/index.d.mts +33 -0
- package/index.d.mts.map +1 -0
- package/index.d.ts +33 -0
- package/index.d.ts.map +1 -0
- package/index.js +74 -0
- package/index.js.map +1 -0
- package/index.mjs +33 -0
- package/index.mjs.map +1 -0
- package/interactors/downloadInteractor.d.mts +16 -0
- package/interactors/downloadInteractor.d.mts.map +1 -0
- package/interactors/downloadInteractor.d.ts +16 -0
- package/interactors/downloadInteractor.d.ts.map +1 -0
- package/interactors/downloadInteractor.js +38 -0
- package/interactors/downloadInteractor.js.map +1 -0
- package/interactors/downloadInteractor.mjs +34 -0
- package/interactors/downloadInteractor.mjs.map +1 -0
- package/interactors/engineInteractor.d.mts +17 -0
- package/interactors/engineInteractor.d.mts.map +1 -0
- package/interactors/engineInteractor.d.ts +17 -0
- package/interactors/engineInteractor.d.ts.map +1 -0
- package/interactors/engineInteractor.js +34 -0
- package/interactors/engineInteractor.js.map +1 -0
- package/interactors/engineInteractor.mjs +30 -0
- package/interactors/engineInteractor.mjs.map +1 -0
- package/interactors/interactor.d.mts +6 -0
- package/interactors/interactor.d.mts.map +1 -0
- package/interactors/interactor.d.ts +6 -0
- package/interactors/interactor.d.ts.map +1 -0
- package/interactors/interactor.js +3 -0
- package/interactors/interactor.js.map +1 -0
- package/interactors/interactor.mjs +2 -0
- package/interactors/interactor.mjs.map +1 -0
- package/interactors/modelInteractor.d.mts +30 -0
- package/interactors/modelInteractor.d.mts.map +1 -0
- package/interactors/modelInteractor.d.ts +30 -0
- package/interactors/modelInteractor.d.ts.map +1 -0
- package/interactors/modelInteractor.js +85 -0
- package/interactors/modelInteractor.js.map +1 -0
- package/interactors/modelInteractor.mjs +81 -0
- package/interactors/modelInteractor.mjs.map +1 -0
- package/interactors/modelsInteractor.d.mts +12 -0
- package/interactors/modelsInteractor.d.mts.map +1 -0
- package/interactors/modelsInteractor.d.ts +12 -0
- package/interactors/modelsInteractor.d.ts.map +1 -0
- package/interactors/modelsInteractor.js +25 -0
- package/interactors/modelsInteractor.js.map +1 -0
- package/interactors/modelsInteractor.mjs +21 -0
- package/interactors/modelsInteractor.mjs.map +1 -0
- package/interactors/sessionInteractor.d.mts +24 -0
- package/interactors/sessionInteractor.d.mts.map +1 -0
- package/interactors/sessionInteractor.d.ts +24 -0
- package/interactors/sessionInteractor.d.ts.map +1 -0
- package/interactors/sessionInteractor.js +50 -0
- package/interactors/sessionInteractor.js.map +1 -0
- package/interactors/sessionInteractor.mjs +46 -0
- package/interactors/sessionInteractor.mjs.map +1 -0
- package/internal/tslib.js +2 -0
- package/internal/tslib.mjs +1 -0
- package/{uzu.d.ts → napi/uzu.d.ts} +38 -37
- package/napi/uzu.js +95 -0
- package/napi/uzu.mjs +61 -0
- package/{uzu.node → napi/uzu.node} +0 -0
- package/package.json +96 -35
- package/src/bridging/classificationFeature.ts +20 -0
- package/src/bridging/config.ts +60 -0
- package/src/bridging/contextLength.ts +29 -0
- package/src/bridging/downloadHandle.ts +41 -0
- package/src/bridging/downloadProgressUpdate.ts +21 -0
- package/src/bridging/downloadState.ts +59 -0
- package/src/bridging/engine.ts +97 -0
- package/src/bridging/finishReason.ts +6 -0
- package/src/bridging/input.ts +29 -0
- package/src/bridging/licenseStatus.ts +39 -0
- package/src/bridging/message.ts +50 -0
- package/src/bridging/model.ts +32 -0
- package/src/bridging/napi.ts +3 -0
- package/src/bridging/output.ts +40 -0
- package/src/bridging/parsedText.ts +17 -0
- package/src/bridging/prefillStepSize.ts +32 -0
- package/src/bridging/preset.ts +34 -0
- package/src/bridging/role.ts +5 -0
- package/src/bridging/runConfig.ts +41 -0
- package/src/bridging/runStats.ts +17 -0
- package/src/bridging/samplingMethod.ts +32 -0
- package/src/bridging/samplingPolicy.ts +29 -0
- package/src/bridging/samplingSeed.ts +24 -0
- package/src/bridging/session.ts +24 -0
- package/src/bridging/stats.ts +22 -0
- package/src/bridging/stepStats.ts +37 -0
- package/src/bridging/text.ts +18 -0
- package/src/bridging/totalStats.ts +20 -0
- package/src/error.ts +38 -0
- package/src/index.ts +32 -0
- package/src/interactors/downloadInteractor.ts +47 -0
- package/src/interactors/engineInteractor.ts +48 -0
- package/src/interactors/interactor.ts +7 -0
- package/src/interactors/modelInteractor.ts +113 -0
- package/src/interactors/modelsInteractor.ts +29 -0
- package/src/interactors/sessionInteractor.ts +70 -0
- package/src/napi/uzu.d.ts +230 -0
- package/src/napi/uzu.js +95 -0
- package/src/napi/uzu.mjs +61 -0
- package/src/napi/uzu.node +0 -0
- package/src/tsconfig.json +11 -0
- package/src/utilities/env.ts +9 -0
- package/src/version.ts +1 -0
- package/utilities/env.d.mts +2 -0
- package/utilities/env.d.mts.map +1 -0
- package/utilities/env.d.ts +2 -0
- package/utilities/env.d.ts.map +1 -0
- package/utilities/env.js +14 -0
- package/utilities/env.js.map +1 -0
- package/utilities/env.mjs +10 -0
- package/utilities/env.mjs.map +1 -0
- package/version.d.mts +2 -0
- package/version.d.mts.map +1 -0
- package/version.d.ts +2 -0
- package/version.d.ts.map +1 -0
- package/version.js +5 -0
- package/version.js.map +1 -0
- package/version.mjs +2 -0
- package/version.mjs.map +1 -0
- package/README.orig.md +0 -213
- package/README.src.md +0 -124
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Mirai Tech Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -18,185 +18,152 @@ Node package for [uzu](https://github.com/trymirai/uzu), a **high-performance**
|
|
|
18
18
|
- Simple, high-level API
|
|
19
19
|
- Specialized configurations with significant performance boosts for common use cases like classification and summarization
|
|
20
20
|
- [Broad model support](https://trymirai.com/models)
|
|
21
|
-
- Observable model manager
|
|
22
21
|
|
|
23
|
-
##
|
|
22
|
+
## Quick Start
|
|
24
23
|
|
|
25
24
|
Add the `uzu` dependency to your project's `package.json`:
|
|
26
25
|
|
|
27
26
|
```json
|
|
28
27
|
"dependencies": {
|
|
29
|
-
"@trymirai/uzu": "0.1.
|
|
28
|
+
"@trymirai/uzu": "0.1.22"
|
|
30
29
|
}
|
|
31
30
|
```
|
|
32
31
|
|
|
33
|
-
|
|
32
|
+
Set up your project through [Platform](https://platform.trymirai.com) and obtain an `API_KEY`. Then, choose the model you want from the [library](https://platform.trymirai.com/models) and run it with the following snippet using the corresponding identifier:
|
|
34
33
|
|
|
35
34
|
```ts
|
|
36
|
-
const
|
|
37
|
-
|
|
35
|
+
const output = await Engine
|
|
36
|
+
.create('API_KEY')
|
|
37
|
+
.model('Alibaba-Qwen3-0.6B')
|
|
38
|
+
.reply('Tell me a short, funny story about a robot');
|
|
38
39
|
```
|
|
39
40
|
|
|
40
|
-
|
|
41
|
+
Everything from model downloading to inference configuration is handled automatically. Refer to the [documentation](https://docs.trymirai.com) for details on how to customize each step of the process.
|
|
41
42
|
|
|
42
|
-
|
|
43
|
-
const localModels: LocalModel[] = await engine.updateRegistry()
|
|
44
|
-
const localModelId = 'Meta-Llama-3.2-1B-Instruct'
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
### Download with progress handle
|
|
48
|
-
|
|
49
|
-
```ts
|
|
50
|
-
const donwloadHandle = engine.downloadHandle(localModelId)
|
|
51
|
-
donwloadHandle.start()
|
|
52
|
-
|
|
53
|
-
for await (const donwloadProgress of donwloadHandle.progress()) {
|
|
54
|
-
// Implement a custom download progress handler
|
|
55
|
-
handleProgress(donwloadProgress)
|
|
56
|
-
}
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
Alternatively, you may use engine to control and observe model download:
|
|
43
|
+
## Examples
|
|
60
44
|
|
|
61
|
-
|
|
62
|
-
const modelState: ModelDownloadState = engine.getState(localModelId)
|
|
45
|
+
Place the `API_KEY` you obtained earlier in the corresponding example file, and then run it using one of the following commands:
|
|
63
46
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
// engine.delete(localModelId)
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
### Session
|
|
72
|
-
|
|
73
|
-
`Session` is the core entity used to communicate with the model:
|
|
74
|
-
|
|
75
|
-
```ts
|
|
76
|
-
const modelId: ModelID = { type: 'Local', id: localModelId }
|
|
77
|
-
const config: Config = {
|
|
78
|
-
preset: { type: 'General' },
|
|
79
|
-
prefillStepSize: { type: 'Default' },
|
|
80
|
-
contextLength: { type: 'Default' },
|
|
81
|
-
samplingSeed: { type: 'Default' },
|
|
82
|
-
}
|
|
83
|
-
const session: Session = engine.createSession(modelId, config)
|
|
47
|
+
```bash
|
|
48
|
+
pnpm run tsn examples/chat.ts
|
|
49
|
+
pnpm run tsn examples/summarization.ts
|
|
50
|
+
pnpm run tsn examples/classification.ts
|
|
84
51
|
```
|
|
85
52
|
|
|
86
53
|
### Chat
|
|
87
54
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
```ts
|
|
91
|
-
const input: Input = {
|
|
92
|
-
type: 'Messages',
|
|
93
|
-
messages: [
|
|
94
|
-
{
|
|
95
|
-
role: Role.System,
|
|
96
|
-
content: 'You are a helpful assistant.'
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
role: Role.User,
|
|
100
|
-
content: 'Tell me a short, funny story about a robot.'
|
|
101
|
-
},
|
|
102
|
-
],
|
|
103
|
-
}
|
|
104
|
-
```
|
|
55
|
+
In this example, we will download a model and get a reply to a specific list of messages:
|
|
105
56
|
|
|
106
57
|
```ts
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
58
|
+
import Engine, { Message } from '@trymirai/uzu';
|
|
59
|
+
|
|
60
|
+
async function main() {
|
|
61
|
+
const output = await Engine.create('API_KEY')
|
|
62
|
+
.model('Alibaba-Qwen3-0.6B')
|
|
63
|
+
.download((update) => {
|
|
64
|
+
console.log('Progress:', update.progress);
|
|
65
|
+
})
|
|
66
|
+
.replyToMessages(
|
|
67
|
+
[
|
|
68
|
+
Message.system('You are a helpful assistant'),
|
|
69
|
+
Message.user('Tell me a short, funny story about a robot')
|
|
70
|
+
],
|
|
71
|
+
(partialOutput) => {
|
|
72
|
+
return true;
|
|
73
|
+
},
|
|
74
|
+
);
|
|
75
|
+
console.log(output.text.original);
|
|
111
76
|
}
|
|
112
77
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
})
|
|
78
|
+
main().catch((error) => {
|
|
79
|
+
console.error(error);
|
|
80
|
+
});
|
|
117
81
|
```
|
|
118
82
|
|
|
119
83
|
### Summarization
|
|
120
84
|
|
|
121
|
-
In this example, we will
|
|
85
|
+
In this example, we will use the `summarization` preset to generate a summary of the input text:
|
|
122
86
|
|
|
123
87
|
```ts
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
88
|
+
import Engine, { Preset, SamplingMethod } from '@trymirai/uzu';
|
|
89
|
+
|
|
90
|
+
async function main() {
|
|
91
|
+
const textToSummarize =
|
|
92
|
+
"A Large Language Model (LLM) is a type of artificial intelligence that processes and generates human-like text. It is trained on vast datasets containing books, articles, and web content, allowing it to understand and predict language patterns. LLMs use deep learning, particularly transformer-based architectures, to analyze text, recognize context, and generate coherent responses. These models have a wide range of applications, including chatbots, content creation, translation, and code generation. One of the key strengths of LLMs is their ability to generate contextually relevant text based on prompts. They utilize self-attention mechanisms to weigh the importance of words within a sentence, improving accuracy and fluency. Examples of popular LLMs include OpenAI's GPT series, Google's BERT, and Meta's LLaMA. As these models grow in size and sophistication, they continue to enhance human-computer interactions, making AI-powered communication more natural and effective.";
|
|
93
|
+
const prompt = `Text is: "${textToSummarize}". Write only summary itself.`;
|
|
94
|
+
|
|
95
|
+
const output = await Engine.create('API_KEY')
|
|
96
|
+
.model('Alibaba-Qwen3-0.6B')
|
|
97
|
+
.download((update) => {
|
|
98
|
+
console.log('Progress:', update.progress);
|
|
99
|
+
})
|
|
100
|
+
.preset(Preset.summarization())
|
|
101
|
+
.session()
|
|
102
|
+
.tokensLimit(256)
|
|
103
|
+
.enableThinking(false)
|
|
104
|
+
.samplingMethod(SamplingMethod.greedy())
|
|
105
|
+
.reply(prompt);
|
|
106
|
+
|
|
107
|
+
console.log('Summary:', output.text.original);
|
|
108
|
+
console.log(
|
|
109
|
+
'Model runs:',
|
|
110
|
+
output.stats.prefillStats.modelRun.count + (output.stats.generateStats?.modelRun.count ?? 0),
|
|
111
|
+
);
|
|
112
|
+
console.log('Tokens count:', output.stats.totalStats.tokensCountOutput);
|
|
130
113
|
}
|
|
131
|
-
const session = engine.createSession(modelId, config)
|
|
132
|
-
```
|
|
133
114
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
const input: Input = {
|
|
138
|
-
type: 'Text',
|
|
139
|
-
text: `Text is: "${textToSummarize}". Write only summary itself.`,
|
|
140
|
-
}
|
|
115
|
+
main().catch((error) => {
|
|
116
|
+
console.error(error);
|
|
117
|
+
});
|
|
141
118
|
```
|
|
142
119
|
|
|
143
|
-
|
|
144
|
-
const runConfig: RunConfig = {
|
|
145
|
-
tokensLimit: 256,
|
|
146
|
-
enableThinking: true,
|
|
147
|
-
samplingPolicy: { type: 'Custom', value: { type: 'Greedy' } },
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
const output = session.run(input, runConfig, (partialOutput) => {
|
|
151
|
-
// Implement a custom partial output handler
|
|
152
|
-
return handlePartialOutput(partialOutput)
|
|
153
|
-
})
|
|
154
|
-
```
|
|
120
|
+
You will notice that the model’s run count is lower than the actual number of generated tokens due to speculative decoding, which significantly improves generation speed.
|
|
155
121
|
|
|
156
122
|
### Classification
|
|
157
123
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
```ts
|
|
161
|
-
const feature: ClassificationFeature = {
|
|
162
|
-
name: 'sentiment',
|
|
163
|
-
values: ['Happy', 'Sad', 'Angry', 'Fearful', 'Surprised', 'Disgusted'],
|
|
164
|
-
}
|
|
165
|
-
const config: Config = {
|
|
166
|
-
preset: { type: 'Classification', feature },
|
|
167
|
-
prefillStepSize: { type: 'Default' },
|
|
168
|
-
contextLength: { type: 'Default' },
|
|
169
|
-
samplingSeed: { type: 'Default' },
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
const modelId: ModelID = { type: 'Local', id: localModelId }
|
|
173
|
-
const session = engine.createSession(modelId, config)
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
```ts
|
|
177
|
-
const textToDetectFeature =
|
|
178
|
-
"Today's been awesome! Everything just feels right, and I can't stop smiling."
|
|
179
|
-
const classificationPrompt =
|
|
180
|
-
`Text is: "${textToDetectFeature}". Choose ${feature.name} from the list: ${feature.values.join(', ')}. ` +
|
|
181
|
-
"Answer with one word. Don't add a dot at the end."
|
|
182
|
-
const input: Input = { type: 'Text', text: classificationPrompt }
|
|
183
|
-
```
|
|
124
|
+
In this example, we will use the `classification` preset to determine the sentiment of the user's input:
|
|
184
125
|
|
|
185
126
|
```ts
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
127
|
+
import Engine, { ClassificationFeature, Preset, SamplingMethod } from '@trymirai/uzu';
|
|
128
|
+
|
|
129
|
+
async function main() {
|
|
130
|
+
const feature = new ClassificationFeature('sentiment', [
|
|
131
|
+
'Happy',
|
|
132
|
+
'Sad',
|
|
133
|
+
'Angry',
|
|
134
|
+
'Fearful',
|
|
135
|
+
'Surprised',
|
|
136
|
+
'Disgusted',
|
|
137
|
+
]);
|
|
138
|
+
const textToDetectFeature =
|
|
139
|
+
"Today's been awesome! Everything just feels right, and I can't stop smiling.";
|
|
140
|
+
const prompt =
|
|
141
|
+
`Text is: "${textToDetectFeature}". Choose ${feature.name} from the list: ${feature.values.join(', ')}. ` +
|
|
142
|
+
"Answer with one word. Don't add a dot at the end.";
|
|
143
|
+
|
|
144
|
+
const output = await Engine.create('API_KEY')
|
|
145
|
+
.model('Alibaba-Qwen3-0.6B')
|
|
146
|
+
.download((update) => {
|
|
147
|
+
console.log('Progress:', update.progress);
|
|
148
|
+
})
|
|
149
|
+
.preset(Preset.classification(feature))
|
|
150
|
+
.session()
|
|
151
|
+
.tokensLimit(32)
|
|
152
|
+
.enableThinking(false)
|
|
153
|
+
.samplingMethod(SamplingMethod.greedy())
|
|
154
|
+
.reply(prompt);
|
|
155
|
+
|
|
156
|
+
console.log('Prediction:', output.text.original);
|
|
157
|
+
console.log('Stats:', output.stats);
|
|
190
158
|
}
|
|
191
159
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
})
|
|
160
|
+
main().catch((error) => {
|
|
161
|
+
console.error(error);
|
|
162
|
+
});
|
|
196
163
|
```
|
|
197
164
|
|
|
198
|
-
|
|
165
|
+
You can view the stats to see that the answer will be ready immediately after the prefill step, and actual generation won’t even start due to speculative decoding, which significantly improves generation speed.
|
|
199
166
|
|
|
200
167
|
## License
|
|
201
168
|
|
|
202
|
-
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
|
169
|
+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ClassificationFeature as NapiClassificationFeature } from "../napi/uzu.mjs";
|
|
2
|
+
import { ToNapi } from "./napi.mjs";
|
|
3
|
+
export declare class ClassificationFeature implements ToNapi<NapiClassificationFeature> {
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly values: string[];
|
|
6
|
+
constructor(name: string, values: string[]);
|
|
7
|
+
toNapi(): NapiClassificationFeature;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=classificationFeature.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classificationFeature.d.mts","sourceRoot":"","sources":["../src/bridging/classificationFeature.ts"],"names":[],"mappings":"OAAO,EAAE,qBAAqB,IAAI,yBAAyB,EAAE;OACtD,EAAE,MAAM,EAAE;AAEjB,qBAAa,qBAAsB,YAAW,MAAM,CAAC,yBAAyB,CAAC;IAC3E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;gBAEd,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE;IAK1C,MAAM,IAAI,yBAAyB;CAOtC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ClassificationFeature as NapiClassificationFeature } from "../napi/uzu.js";
|
|
2
|
+
import { ToNapi } from "./napi.js";
|
|
3
|
+
export declare class ClassificationFeature implements ToNapi<NapiClassificationFeature> {
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly values: string[];
|
|
6
|
+
constructor(name: string, values: string[]);
|
|
7
|
+
toNapi(): NapiClassificationFeature;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=classificationFeature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classificationFeature.d.ts","sourceRoot":"","sources":["../src/bridging/classificationFeature.ts"],"names":[],"mappings":"OAAO,EAAE,qBAAqB,IAAI,yBAAyB,EAAE;OACtD,EAAE,MAAM,EAAE;AAEjB,qBAAa,qBAAsB,YAAW,MAAM,CAAC,yBAAyB,CAAC;IAC3E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;gBAEd,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE;IAK1C,MAAM,IAAI,yBAAyB;CAOtC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClassificationFeature = void 0;
|
|
4
|
+
class ClassificationFeature {
|
|
5
|
+
constructor(name, values) {
|
|
6
|
+
this.name = name;
|
|
7
|
+
this.values = values;
|
|
8
|
+
}
|
|
9
|
+
toNapi() {
|
|
10
|
+
const result = {
|
|
11
|
+
name: this.name,
|
|
12
|
+
values: this.values,
|
|
13
|
+
};
|
|
14
|
+
return result;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.ClassificationFeature = ClassificationFeature;
|
|
18
|
+
//# sourceMappingURL=classificationFeature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classificationFeature.js","sourceRoot":"","sources":["../src/bridging/classificationFeature.ts"],"names":[],"mappings":";;;AAGA,MAAa,qBAAqB;IAI9B,YAAY,IAAY,EAAE,MAAgB;QACtC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAED,MAAM;QACF,MAAM,MAAM,GAA8B;YACtC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,MAAM,EAAE,IAAI,CAAC,MAAM;SACtB,CAAC;QACF,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AAhBD,sDAgBC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export class ClassificationFeature {
|
|
2
|
+
constructor(name, values) {
|
|
3
|
+
this.name = name;
|
|
4
|
+
this.values = values;
|
|
5
|
+
}
|
|
6
|
+
toNapi() {
|
|
7
|
+
const result = {
|
|
8
|
+
name: this.name,
|
|
9
|
+
values: this.values,
|
|
10
|
+
};
|
|
11
|
+
return result;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=classificationFeature.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classificationFeature.mjs","sourceRoot":"","sources":["../src/bridging/classificationFeature.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,qBAAqB;IAI9B,YAAY,IAAY,EAAE,MAAgB;QACtC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAED,MAAM;QACF,MAAM,MAAM,GAA8B;YACtC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,MAAM,EAAE,IAAI,CAAC,MAAM;SACtB,CAAC;QACF,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Config as NapiConfig } from "../napi/uzu.mjs";
|
|
2
|
+
import { ContextLength } from "./contextLength.mjs";
|
|
3
|
+
import { ToNapi } from "./napi.mjs";
|
|
4
|
+
import { PrefillStepSize } from "./prefillStepSize.mjs";
|
|
5
|
+
import { Preset } from "./preset.mjs";
|
|
6
|
+
import { SamplingSeed } from "./samplingSeed.mjs";
|
|
7
|
+
export declare class Config implements ToNapi<NapiConfig> {
|
|
8
|
+
readonly preset: Preset;
|
|
9
|
+
readonly prefillStepSize: PrefillStepSize;
|
|
10
|
+
readonly contextLength: ContextLength;
|
|
11
|
+
readonly samplingSeed: SamplingSeed;
|
|
12
|
+
constructor(preset: Preset, prefillStepSize: PrefillStepSize, contextLength: ContextLength, samplingSeed: SamplingSeed);
|
|
13
|
+
static default(): Config;
|
|
14
|
+
withPreset(preset: Preset): Config;
|
|
15
|
+
withPrefillStepSize(prefillStepSize: PrefillStepSize): Config;
|
|
16
|
+
withContextLength(contextLength: ContextLength): Config;
|
|
17
|
+
withSamplingSeed(samplingSeed: SamplingSeed): Config;
|
|
18
|
+
toNapi(): NapiConfig;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=config.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.mts","sourceRoot":"","sources":["../src/bridging/config.ts"],"names":[],"mappings":"OAAO,EAAE,MAAM,IAAI,UAAU,EAAE;OACxB,EAAE,aAAa,EAAE;OACjB,EAAE,MAAM,EAAE;OACV,EAAE,eAAe,EAAE;OACnB,EAAE,MAAM,EAAE;OACV,EAAE,YAAY,EAAE;AAEvB,qBAAa,MAAO,YAAW,MAAM,CAAC,UAAU,CAAC;IAC7C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;IAC1C,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;IACtC,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;gBAGhC,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,eAAe,EAChC,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,YAAY;IAQ9B,MAAM,CAAC,OAAO,IAAI,MAAM;IASxB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAIlC,mBAAmB,CAAC,eAAe,EAAE,eAAe,GAAG,MAAM;IAI7D,iBAAiB,CAAC,aAAa,EAAE,aAAa,GAAG,MAAM;IAIvD,gBAAgB,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM;IAIpD,MAAM,IAAI,UAAU;CASvB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Config as NapiConfig } from "../napi/uzu.js";
|
|
2
|
+
import { ContextLength } from "./contextLength.js";
|
|
3
|
+
import { ToNapi } from "./napi.js";
|
|
4
|
+
import { PrefillStepSize } from "./prefillStepSize.js";
|
|
5
|
+
import { Preset } from "./preset.js";
|
|
6
|
+
import { SamplingSeed } from "./samplingSeed.js";
|
|
7
|
+
export declare class Config implements ToNapi<NapiConfig> {
|
|
8
|
+
readonly preset: Preset;
|
|
9
|
+
readonly prefillStepSize: PrefillStepSize;
|
|
10
|
+
readonly contextLength: ContextLength;
|
|
11
|
+
readonly samplingSeed: SamplingSeed;
|
|
12
|
+
constructor(preset: Preset, prefillStepSize: PrefillStepSize, contextLength: ContextLength, samplingSeed: SamplingSeed);
|
|
13
|
+
static default(): Config;
|
|
14
|
+
withPreset(preset: Preset): Config;
|
|
15
|
+
withPrefillStepSize(prefillStepSize: PrefillStepSize): Config;
|
|
16
|
+
withContextLength(contextLength: ContextLength): Config;
|
|
17
|
+
withSamplingSeed(samplingSeed: SamplingSeed): Config;
|
|
18
|
+
toNapi(): NapiConfig;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/bridging/config.ts"],"names":[],"mappings":"OAAO,EAAE,MAAM,IAAI,UAAU,EAAE;OACxB,EAAE,aAAa,EAAE;OACjB,EAAE,MAAM,EAAE;OACV,EAAE,eAAe,EAAE;OACnB,EAAE,MAAM,EAAE;OACV,EAAE,YAAY,EAAE;AAEvB,qBAAa,MAAO,YAAW,MAAM,CAAC,UAAU,CAAC;IAC7C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;IAC1C,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;IACtC,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;gBAGhC,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,eAAe,EAChC,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,YAAY;IAQ9B,MAAM,CAAC,OAAO,IAAI,MAAM;IASxB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAIlC,mBAAmB,CAAC,eAAe,EAAE,eAAe,GAAG,MAAM;IAI7D,iBAAiB,CAAC,aAAa,EAAE,aAAa,GAAG,MAAM;IAIvD,gBAAgB,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM;IAIpD,MAAM,IAAI,UAAU;CASvB"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Config = void 0;
|
|
4
|
+
const contextLength_1 = require("./contextLength.js");
|
|
5
|
+
const prefillStepSize_1 = require("./prefillStepSize.js");
|
|
6
|
+
const preset_1 = require("./preset.js");
|
|
7
|
+
const samplingSeed_1 = require("./samplingSeed.js");
|
|
8
|
+
class Config {
|
|
9
|
+
constructor(preset, prefillStepSize, contextLength, samplingSeed) {
|
|
10
|
+
this.preset = preset;
|
|
11
|
+
this.prefillStepSize = prefillStepSize;
|
|
12
|
+
this.contextLength = contextLength;
|
|
13
|
+
this.samplingSeed = samplingSeed;
|
|
14
|
+
}
|
|
15
|
+
static default() {
|
|
16
|
+
return new Config(preset_1.Preset.general(), prefillStepSize_1.PrefillStepSize.default(), contextLength_1.ContextLength.default(), samplingSeed_1.SamplingSeed.default());
|
|
17
|
+
}
|
|
18
|
+
withPreset(preset) {
|
|
19
|
+
return new Config(preset, this.prefillStepSize, this.contextLength, this.samplingSeed);
|
|
20
|
+
}
|
|
21
|
+
withPrefillStepSize(prefillStepSize) {
|
|
22
|
+
return new Config(this.preset, prefillStepSize, this.contextLength, this.samplingSeed);
|
|
23
|
+
}
|
|
24
|
+
withContextLength(contextLength) {
|
|
25
|
+
return new Config(this.preset, this.prefillStepSize, contextLength, this.samplingSeed);
|
|
26
|
+
}
|
|
27
|
+
withSamplingSeed(samplingSeed) {
|
|
28
|
+
return new Config(this.preset, this.prefillStepSize, this.contextLength, samplingSeed);
|
|
29
|
+
}
|
|
30
|
+
toNapi() {
|
|
31
|
+
const napiConfig = {
|
|
32
|
+
preset: this.preset.toNapi(),
|
|
33
|
+
prefillStepSize: this.prefillStepSize.toNapi(),
|
|
34
|
+
contextLength: this.contextLength.toNapi(),
|
|
35
|
+
samplingSeed: this.samplingSeed.toNapi(),
|
|
36
|
+
};
|
|
37
|
+
return napiConfig;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.Config = Config;
|
|
41
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/bridging/config.ts"],"names":[],"mappings":";;;AACA,sDAAgD;AAEhD,0DAAoD;AACpD,wCAAkC;AAClC,oDAA8C;AAE9C,MAAa,MAAM;IAMf,YACI,MAAc,EACd,eAAgC,EAChC,aAA4B,EAC5B,YAA0B;QAE1B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACrC,CAAC;IAED,MAAM,CAAC,OAAO;QACV,OAAO,IAAI,MAAM,CACb,eAAM,CAAC,OAAO,EAAE,EAChB,iCAAe,CAAC,OAAO,EAAE,EACzB,6BAAa,CAAC,OAAO,EAAE,EACvB,2BAAY,CAAC,OAAO,EAAE,CACzB,CAAC;IACN,CAAC;IAED,UAAU,CAAC,MAAc;QACrB,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IAC3F,CAAC;IAED,mBAAmB,CAAC,eAAgC;QAChD,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IAC3F,CAAC;IAED,iBAAiB,CAAC,aAA4B;QAC1C,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,aAAa,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IAC3F,CAAC;IAED,gBAAgB,CAAC,YAA0B;QACvC,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;IAC3F,CAAC;IAED,MAAM;QACF,MAAM,UAAU,GAAe;YAC3B,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;YAC5B,eAAe,EAAE,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE;YAC9C,aAAa,EAAE,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE;YAC1C,YAAY,EAAE,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;SAC3C,CAAC;QACF,OAAO,UAAU,CAAC;IACtB,CAAC;CACJ;AApDD,wBAoDC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ContextLength } from "./contextLength.mjs";
|
|
2
|
+
import { PrefillStepSize } from "./prefillStepSize.mjs";
|
|
3
|
+
import { Preset } from "./preset.mjs";
|
|
4
|
+
import { SamplingSeed } from "./samplingSeed.mjs";
|
|
5
|
+
export class Config {
|
|
6
|
+
constructor(preset, prefillStepSize, contextLength, samplingSeed) {
|
|
7
|
+
this.preset = preset;
|
|
8
|
+
this.prefillStepSize = prefillStepSize;
|
|
9
|
+
this.contextLength = contextLength;
|
|
10
|
+
this.samplingSeed = samplingSeed;
|
|
11
|
+
}
|
|
12
|
+
static default() {
|
|
13
|
+
return new Config(Preset.general(), PrefillStepSize.default(), ContextLength.default(), SamplingSeed.default());
|
|
14
|
+
}
|
|
15
|
+
withPreset(preset) {
|
|
16
|
+
return new Config(preset, this.prefillStepSize, this.contextLength, this.samplingSeed);
|
|
17
|
+
}
|
|
18
|
+
withPrefillStepSize(prefillStepSize) {
|
|
19
|
+
return new Config(this.preset, prefillStepSize, this.contextLength, this.samplingSeed);
|
|
20
|
+
}
|
|
21
|
+
withContextLength(contextLength) {
|
|
22
|
+
return new Config(this.preset, this.prefillStepSize, contextLength, this.samplingSeed);
|
|
23
|
+
}
|
|
24
|
+
withSamplingSeed(samplingSeed) {
|
|
25
|
+
return new Config(this.preset, this.prefillStepSize, this.contextLength, samplingSeed);
|
|
26
|
+
}
|
|
27
|
+
toNapi() {
|
|
28
|
+
const napiConfig = {
|
|
29
|
+
preset: this.preset.toNapi(),
|
|
30
|
+
prefillStepSize: this.prefillStepSize.toNapi(),
|
|
31
|
+
contextLength: this.contextLength.toNapi(),
|
|
32
|
+
samplingSeed: this.samplingSeed.toNapi(),
|
|
33
|
+
};
|
|
34
|
+
return napiConfig;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=config.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.mjs","sourceRoot":"","sources":["../src/bridging/config.ts"],"names":[],"mappings":"OACO,EAAE,aAAa,EAAE;OAEjB,EAAE,eAAe,EAAE;OACnB,EAAE,MAAM,EAAE;OACV,EAAE,YAAY,EAAE;AAEvB,MAAM,OAAO,MAAM;IAMf,YACI,MAAc,EACd,eAAgC,EAChC,aAA4B,EAC5B,YAA0B;QAE1B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACrC,CAAC;IAED,MAAM,CAAC,OAAO;QACV,OAAO,IAAI,MAAM,CACb,MAAM,CAAC,OAAO,EAAE,EAChB,eAAe,CAAC,OAAO,EAAE,EACzB,aAAa,CAAC,OAAO,EAAE,EACvB,YAAY,CAAC,OAAO,EAAE,CACzB,CAAC;IACN,CAAC;IAED,UAAU,CAAC,MAAc;QACrB,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IAC3F,CAAC;IAED,mBAAmB,CAAC,eAAgC;QAChD,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IAC3F,CAAC;IAED,iBAAiB,CAAC,aAA4B;QAC1C,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,aAAa,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IAC3F,CAAC;IAED,gBAAgB,CAAC,YAA0B;QACvC,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;IAC3F,CAAC;IAED,MAAM;QACF,MAAM,UAAU,GAAe;YAC3B,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;YAC5B,eAAe,EAAE,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE;YAC9C,aAAa,EAAE,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE;YAC1C,YAAY,EAAE,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;SAC3C,CAAC;QACF,OAAO,UAAU,CAAC;IACtB,CAAC;CACJ"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ContextLength as NapiContextLength } from "../napi/uzu.mjs";
|
|
2
|
+
import { ToNapi } from "./napi.mjs";
|
|
3
|
+
export declare class ContextLength implements ToNapi<NapiContextLength> {
|
|
4
|
+
private readonly napiContextLength;
|
|
5
|
+
private constructor();
|
|
6
|
+
static default(): ContextLength;
|
|
7
|
+
static maximal(): ContextLength;
|
|
8
|
+
static custom(length: number): ContextLength;
|
|
9
|
+
toNapi(): NapiContextLength;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=contextLength.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contextLength.d.mts","sourceRoot":"","sources":["../src/bridging/contextLength.ts"],"names":[],"mappings":"OAAO,EAAE,aAAa,IAAI,iBAAiB,EAAE;OACtC,EAAE,MAAM,EAAE;AAEjB,qBAAa,aAAc,YAAW,MAAM,CAAC,iBAAiB,CAAC;IAC3D,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAoB;IAEtD,OAAO;IAIP,MAAM,CAAC,OAAO,IAAI,aAAa;IAK/B,MAAM,CAAC,OAAO,IAAI,aAAa;IAK/B,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa;IAK5C,MAAM,IAAI,iBAAiB;CAG9B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ContextLength as NapiContextLength } from "../napi/uzu.js";
|
|
2
|
+
import { ToNapi } from "./napi.js";
|
|
3
|
+
export declare class ContextLength implements ToNapi<NapiContextLength> {
|
|
4
|
+
private readonly napiContextLength;
|
|
5
|
+
private constructor();
|
|
6
|
+
static default(): ContextLength;
|
|
7
|
+
static maximal(): ContextLength;
|
|
8
|
+
static custom(length: number): ContextLength;
|
|
9
|
+
toNapi(): NapiContextLength;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=contextLength.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contextLength.d.ts","sourceRoot":"","sources":["../src/bridging/contextLength.ts"],"names":[],"mappings":"OAAO,EAAE,aAAa,IAAI,iBAAiB,EAAE;OACtC,EAAE,MAAM,EAAE;AAEjB,qBAAa,aAAc,YAAW,MAAM,CAAC,iBAAiB,CAAC;IAC3D,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAoB;IAEtD,OAAO;IAIP,MAAM,CAAC,OAAO,IAAI,aAAa;IAK/B,MAAM,CAAC,OAAO,IAAI,aAAa;IAK/B,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa;IAK5C,MAAM,IAAI,iBAAiB;CAG9B"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ContextLength = void 0;
|
|
4
|
+
class ContextLength {
|
|
5
|
+
constructor(napiContextLength) {
|
|
6
|
+
this.napiContextLength = napiContextLength;
|
|
7
|
+
}
|
|
8
|
+
static default() {
|
|
9
|
+
const napiContextLength = { type: 'Default' };
|
|
10
|
+
return new ContextLength(napiContextLength);
|
|
11
|
+
}
|
|
12
|
+
static maximal() {
|
|
13
|
+
const napiContextLength = { type: 'Maximal' };
|
|
14
|
+
return new ContextLength(napiContextLength);
|
|
15
|
+
}
|
|
16
|
+
static custom(length) {
|
|
17
|
+
const napiContextLength = { type: 'Custom', length };
|
|
18
|
+
return new ContextLength(napiContextLength);
|
|
19
|
+
}
|
|
20
|
+
toNapi() {
|
|
21
|
+
return this.napiContextLength;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.ContextLength = ContextLength;
|
|
25
|
+
//# sourceMappingURL=contextLength.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contextLength.js","sourceRoot":"","sources":["../src/bridging/contextLength.ts"],"names":[],"mappings":";;;AAGA,MAAa,aAAa;IAGtB,YAAoB,iBAAoC;QACpD,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;IAC/C,CAAC;IAED,MAAM,CAAC,OAAO;QACV,MAAM,iBAAiB,GAAsB,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QACjE,OAAO,IAAI,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAChD,CAAC;IAED,MAAM,CAAC,OAAO;QACV,MAAM,iBAAiB,GAAsB,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QACjE,OAAO,IAAI,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAChD,CAAC;IAED,MAAM,CAAC,MAAM,CAAC,MAAc;QACxB,MAAM,iBAAiB,GAAsB,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;QACxE,OAAO,IAAI,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAChD,CAAC;IAED,MAAM;QACF,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAClC,CAAC;CACJ;AAzBD,sCAyBC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export class ContextLength {
|
|
2
|
+
constructor(napiContextLength) {
|
|
3
|
+
this.napiContextLength = napiContextLength;
|
|
4
|
+
}
|
|
5
|
+
static default() {
|
|
6
|
+
const napiContextLength = { type: 'Default' };
|
|
7
|
+
return new ContextLength(napiContextLength);
|
|
8
|
+
}
|
|
9
|
+
static maximal() {
|
|
10
|
+
const napiContextLength = { type: 'Maximal' };
|
|
11
|
+
return new ContextLength(napiContextLength);
|
|
12
|
+
}
|
|
13
|
+
static custom(length) {
|
|
14
|
+
const napiContextLength = { type: 'Custom', length };
|
|
15
|
+
return new ContextLength(napiContextLength);
|
|
16
|
+
}
|
|
17
|
+
toNapi() {
|
|
18
|
+
return this.napiContextLength;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=contextLength.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contextLength.mjs","sourceRoot":"","sources":["../src/bridging/contextLength.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,aAAa;IAGtB,YAAoB,iBAAoC;QACpD,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;IAC/C,CAAC;IAED,MAAM,CAAC,OAAO;QACV,MAAM,iBAAiB,GAAsB,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QACjE,OAAO,IAAI,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAChD,CAAC;IAED,MAAM,CAAC,OAAO;QACV,MAAM,iBAAiB,GAAsB,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QACjE,OAAO,IAAI,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAChD,CAAC;IAED,MAAM,CAAC,MAAM,CAAC,MAAc;QACxB,MAAM,iBAAiB,GAAsB,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;QACxE,OAAO,IAAI,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAChD,CAAC;IAED,MAAM;QACF,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAClC,CAAC;CACJ"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ModelDownloadHandle as NapiModelDownloadHandle } from "../napi/uzu.mjs";
|
|
2
|
+
import { DownloadProgressUpdate } from "./downloadProgressUpdate.mjs";
|
|
3
|
+
import { DownloadState } from "./downloadState.mjs";
|
|
4
|
+
export declare class DownloadHandle {
|
|
5
|
+
private readonly napiDownloadHandle;
|
|
6
|
+
constructor(napiDownloadHandle: NapiModelDownloadHandle);
|
|
7
|
+
identifier(): string;
|
|
8
|
+
state(): Promise<DownloadState>;
|
|
9
|
+
download(): Promise<void>;
|
|
10
|
+
pause(): Promise<void>;
|
|
11
|
+
delete(): Promise<void>;
|
|
12
|
+
progressUpdate(): AsyncIterable<DownloadProgressUpdate>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=downloadHandle.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"downloadHandle.d.mts","sourceRoot":"","sources":["../src/bridging/downloadHandle.ts"],"names":[],"mappings":"OAAO,EAAE,mBAAmB,IAAI,uBAAuB,EAAE;OAClD,EAAE,sBAAsB,EAAE;OAC1B,EAAE,aAAa,EAAE;AAExB,qBAAa,cAAc;IACvB,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAA0B;gBAEjD,kBAAkB,EAAE,uBAAuB;IAIvD,UAAU,IAAI,MAAM;IAId,KAAK,IAAI,OAAO,CAAC,aAAa,CAAC;IAK/B,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAIzB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAItB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAI7B,cAAc,IAAI,aAAa,CAAC,sBAAsB,CAAC;CAQ1D"}
|