@trymirai/uzu 0.1.21 → 0.1.23
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
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ModelInteractor = void 0;
|
|
4
|
+
const downloadState_1 = require("../bridging/downloadState.js");
|
|
5
|
+
const model_1 = require("../bridging/model.js");
|
|
6
|
+
const runConfig_1 = require("../bridging/runConfig.js");
|
|
7
|
+
const downloadInteractor_1 = require("./downloadInteractor.js");
|
|
8
|
+
const sessionInteractor_1 = require("./sessionInteractor.js");
|
|
9
|
+
class ModelInteractor {
|
|
10
|
+
constructor(modelsInteractor, model, config) {
|
|
11
|
+
this.modelsInteractor = modelsInteractor;
|
|
12
|
+
this.entity = model;
|
|
13
|
+
this.config = config;
|
|
14
|
+
}
|
|
15
|
+
async finalize() {
|
|
16
|
+
return await this.entity;
|
|
17
|
+
}
|
|
18
|
+
/* Downloading */
|
|
19
|
+
downloading() {
|
|
20
|
+
const handlePromise = (async () => {
|
|
21
|
+
const model = await this.finalize();
|
|
22
|
+
const engine = await this.modelsInteractor.engineInteractor.finalize();
|
|
23
|
+
const handle = engine.downloadHandle(model);
|
|
24
|
+
return handle;
|
|
25
|
+
})();
|
|
26
|
+
return new downloadInteractor_1.DownloadInteractor(this, handlePromise);
|
|
27
|
+
}
|
|
28
|
+
download(callback) {
|
|
29
|
+
const modelPromise = (async () => {
|
|
30
|
+
const downloadInteractor = this.downloading();
|
|
31
|
+
const handle = await downloadInteractor.finalize();
|
|
32
|
+
const state = await handle.state();
|
|
33
|
+
switch (state.phase) {
|
|
34
|
+
case downloadState_1.DownloadPhase.Downloaded:
|
|
35
|
+
break;
|
|
36
|
+
default:
|
|
37
|
+
await downloadInteractor
|
|
38
|
+
.resume()
|
|
39
|
+
.onProgressUpdate(callback ?? (() => { }))
|
|
40
|
+
.finalize();
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
return this.finalize();
|
|
44
|
+
})();
|
|
45
|
+
return new ModelInteractor(this.modelsInteractor, modelPromise, this.config);
|
|
46
|
+
}
|
|
47
|
+
/* Config */
|
|
48
|
+
preset(preset) {
|
|
49
|
+
const config = this.config.withPreset(preset);
|
|
50
|
+
return new ModelInteractor(this.modelsInteractor, this.entity, config);
|
|
51
|
+
}
|
|
52
|
+
prefillStepSize(prefillStepSize) {
|
|
53
|
+
const config = this.config.withPrefillStepSize(prefillStepSize);
|
|
54
|
+
return new ModelInteractor(this.modelsInteractor, this.entity, config);
|
|
55
|
+
}
|
|
56
|
+
contextLength(contextLength) {
|
|
57
|
+
const config = this.config.withContextLength(contextLength);
|
|
58
|
+
return new ModelInteractor(this.modelsInteractor, this.entity, config);
|
|
59
|
+
}
|
|
60
|
+
samplingSeed(samplingSeed) {
|
|
61
|
+
const config = this.config.withSamplingSeed(samplingSeed);
|
|
62
|
+
return new ModelInteractor(this.modelsInteractor, this.entity, config);
|
|
63
|
+
}
|
|
64
|
+
/* Session */
|
|
65
|
+
session() {
|
|
66
|
+
const sessionPromise = (async () => {
|
|
67
|
+
const engine = await this.modelsInteractor.engineInteractor.finalize();
|
|
68
|
+
let model = await this.finalize();
|
|
69
|
+
if (model.type === model_1.ModelType.Local) {
|
|
70
|
+
model = await this.download().finalize();
|
|
71
|
+
}
|
|
72
|
+
const session = engine.session(model, this.config);
|
|
73
|
+
return session;
|
|
74
|
+
})();
|
|
75
|
+
return new sessionInteractor_1.SessionInteractor(this, sessionPromise, runConfig_1.RunConfig.default());
|
|
76
|
+
}
|
|
77
|
+
async reply(text, progress = () => true) {
|
|
78
|
+
return await this.session().reply(text, progress);
|
|
79
|
+
}
|
|
80
|
+
async replyToMessages(messages, progress = () => true) {
|
|
81
|
+
return await this.session().replyToMessages(messages, progress);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.ModelInteractor = ModelInteractor;
|
|
85
|
+
//# sourceMappingURL=modelInteractor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modelInteractor.js","sourceRoot":"","sources":["../src/interactors/modelInteractor.ts"],"names":[],"mappings":";;;AAGA,gEAA0D;AAE1D,gDAAqD;AAIrD,wDAAkD;AAElD,gEAA0D;AAG1D,8DAAwD;AAExD,MAAa,eAAe;IAKxB,YAAY,gBAAkC,EAAE,KAA8B,EAAE,MAAc;QAC1F,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,QAAQ;QACV,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC;IAC7B,CAAC;IAED,iBAAiB;IAEjB,WAAW;QACP,MAAM,aAAa,GAAG,CAAC,KAAK,IAAI,EAAE;YAC9B,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;YACpC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,gB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,IAAY,EAAE,WAA+C,GAAG,EAAE,CAAC,IAAI;QAC/E,OAAO,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,eAAe,CACjB,QAAmB,EACnB,WAA+C,GAAG,EAAE,CAAC,IAAI;QAEzD,OAAO,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC,eAAe,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IACpE,CAAC;CACJ;AAhGD,0CAgGC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { DownloadPhase } from "../bridging/downloadState.mjs";
|
|
2
|
+
import { ModelType } from "../bridging/model.mjs";
|
|
3
|
+
import { RunConfig } from "../bridging/runConfig.mjs";
|
|
4
|
+
import { DownloadInteractor } from "./downloadInteractor.mjs";
|
|
5
|
+
import { SessionInteractor } from "./sessionInteractor.mjs";
|
|
6
|
+
export class ModelInteractor {
|
|
7
|
+
constructor(modelsInteractor, model, config) {
|
|
8
|
+
this.modelsInteractor = modelsInteractor;
|
|
9
|
+
this.entity = model;
|
|
10
|
+
this.config = config;
|
|
11
|
+
}
|
|
12
|
+
async finalize() {
|
|
13
|
+
return await this.entity;
|
|
14
|
+
}
|
|
15
|
+
/* Downloading */
|
|
16
|
+
downloading() {
|
|
17
|
+
const handlePromise = (async () => {
|
|
18
|
+
const model = await this.finalize();
|
|
19
|
+
const engine = await this.modelsInteractor.engineInteractor.finalize();
|
|
20
|
+
const handle = engine.downloadHandle(model);
|
|
21
|
+
return handle;
|
|
22
|
+
})();
|
|
23
|
+
return new DownloadInteractor(this, handlePromise);
|
|
24
|
+
}
|
|
25
|
+
download(callback) {
|
|
26
|
+
const modelPromise = (async () => {
|
|
27
|
+
const downloadInteractor = this.downloading();
|
|
28
|
+
const handle = await downloadInteractor.finalize();
|
|
29
|
+
const state = await handle.state();
|
|
30
|
+
switch (state.phase) {
|
|
31
|
+
case DownloadPhase.Downloaded:
|
|
32
|
+
break;
|
|
33
|
+
default:
|
|
34
|
+
await downloadInteractor
|
|
35
|
+
.resume()
|
|
36
|
+
.onProgressUpdate(callback ?? (() => { }))
|
|
37
|
+
.finalize();
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
return this.finalize();
|
|
41
|
+
})();
|
|
42
|
+
return new ModelInteractor(this.modelsInteractor, modelPromise, this.config);
|
|
43
|
+
}
|
|
44
|
+
/* Config */
|
|
45
|
+
preset(preset) {
|
|
46
|
+
const config = this.config.withPreset(preset);
|
|
47
|
+
return new ModelInteractor(this.modelsInteractor, this.entity, config);
|
|
48
|
+
}
|
|
49
|
+
prefillStepSize(prefillStepSize) {
|
|
50
|
+
const config = this.config.withPrefillStepSize(prefillStepSize);
|
|
51
|
+
return new ModelInteractor(this.modelsInteractor, this.entity, config);
|
|
52
|
+
}
|
|
53
|
+
contextLength(contextLength) {
|
|
54
|
+
const config = this.config.withContextLength(contextLength);
|
|
55
|
+
return new ModelInteractor(this.modelsInteractor, this.entity, config);
|
|
56
|
+
}
|
|
57
|
+
samplingSeed(samplingSeed) {
|
|
58
|
+
const config = this.config.withSamplingSeed(samplingSeed);
|
|
59
|
+
return new ModelInteractor(this.modelsInteractor, this.entity, config);
|
|
60
|
+
}
|
|
61
|
+
/* Session */
|
|
62
|
+
session() {
|
|
63
|
+
const sessionPromise = (async () => {
|
|
64
|
+
const engine = await this.modelsInteractor.engineInteractor.finalize();
|
|
65
|
+
let model = await this.finalize();
|
|
66
|
+
if (model.type === ModelType.Local) {
|
|
67
|
+
model = await this.download().finalize();
|
|
68
|
+
}
|
|
69
|
+
const session = engine.session(model, this.config);
|
|
70
|
+
return session;
|
|
71
|
+
})();
|
|
72
|
+
return new SessionInteractor(this, sessionPromise, RunConfig.default());
|
|
73
|
+
}
|
|
74
|
+
async reply(text, progress = () => true) {
|
|
75
|
+
return await this.session().reply(text, progress);
|
|
76
|
+
}
|
|
77
|
+
async replyToMessages(messages, progress = () => true) {
|
|
78
|
+
return await this.session().replyToMessages(messages, progress);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=modelInteractor.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modelInteractor.mjs","sourceRoot":"","sources":["../src/interactors/modelInteractor.ts"],"names":[],"mappings":"OAGO,EAAE,aAAa,EAAE;OAEjB,EAAS,SAAS,EAAE;OAIpB,EAAE,SAAS,EAAE;OAEb,EAAE,kBAAkB,EAAE;OAGtB,EAAE,iBAAiB,EAAE;AAE5B,MAAM,OAAO,eAAe;IAKxB,YAAY,gBAAkC,EAAE,KAA8B,EAAE,MAAc;QAC1F,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,QAAQ;QACV,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC;IAC7B,CAAC;IAED,iBAAiB;IAEjB,WAAW;QACP,MAAM,aAAa,GAAG,CAAC,KAAK,IAAI,EAAE;YAC9B,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;YACpC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAAC;YACvE,MAAM,MAAM,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;YAC5C,OAAO,MAAM,CAAC;QAClB,CAAC,CAAC,EAAE,CAAC;QACL,OAAO,IAAI,kBAAkB,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;IACvD,CAAC;IAED,QAAQ,CAAC,QAA2D;QAChE,MAAM,YAAY,GAAG,CAAC,KAAK,IAAI,EAAE;YAC7B,MAAM,kBAAkB,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;YAC9C,MAAM,MAAM,GAAG,MAAM,k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js";
|
|
2
|
+
import { EngineInteractor } from "./engineInteractor.mjs";
|
|
3
|
+
import { Interactor, InteractorEntity } from "./interactor.mjs";
|
|
4
|
+
import { ModelInteractor } from "./modelInteractor.mjs";
|
|
5
|
+
export declare class ModelsInteractor implements Interactor<Model[]> {
|
|
6
|
+
readonly engineInteractor: EngineInteractor;
|
|
7
|
+
readonly entity: InteractorEntity<Model[]>;
|
|
8
|
+
constructor(engineInteractor: EngineInteractor, models: InteractorEntity<Model[]>);
|
|
9
|
+
finalize(): Promise<Model[]>;
|
|
10
|
+
get(repoId: string): ModelInteractor;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=modelsInteractor.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modelsInteractor.d.mts","sourceRoot":"","sources":["../src/interactors/modelsInteractor.ts"],"names":[],"mappings":"OACO,EAAE,KAAK,EAAE;OAET,EAAE,gBAAgB,EAAE;OACpB,EAAE,UAAU,EAAE,gBAAgB,EAAE;OAChC,EAAE,eAAe,EAAE;AAE1B,qBAAa,gBAAiB,YAAW,UAAU,CAAC,KAAK,EAAE,CAAC;IACxD,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAC5C,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC,KAAK,EAAE,CAAC,CAAC;gBAE/B,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,EAAE,gBAAgB,CAAC,KAAK,EAAE,CAAC;IAK3E,QAAQ,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;IAIlC,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe;CAQvC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Model } from "../bridging/model.js";
|
|
2
|
+
import { EngineInteractor } from "./engineInteractor.js";
|
|
3
|
+
import { Interactor, InteractorEntity } from "./interactor.js";
|
|
4
|
+
import { ModelInteractor } from "./modelInteractor.js";
|
|
5
|
+
export declare class ModelsInteractor implements Interactor<Model[]> {
|
|
6
|
+
readonly engineInteractor: EngineInteractor;
|
|
7
|
+
readonly entity: InteractorEntity<Model[]>;
|
|
8
|
+
constructor(engineInteractor: EngineInteractor, models: InteractorEntity<Model[]>);
|
|
9
|
+
finalize(): Promise<Model[]>;
|
|
10
|
+
get(repoId: string): ModelInteractor;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=modelsInteractor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modelsInteractor.d.ts","sourceRoot":"","sources":["../src/interactors/modelsInteractor.ts"],"names":[],"mappings":"OACO,EAAE,KAAK,EAAE;OAET,EAAE,gBAAgB,EAAE;OACpB,EAAE,UAAU,EAAE,gBAAgB,EAAE;OAChC,EAAE,eAAe,EAAE;AAE1B,qBAAa,gBAAiB,YAAW,UAAU,CAAC,KAAK,EAAE,CAAC;IACxD,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAC5C,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC,KAAK,EAAE,CAAC,CAAC;gBAE/B,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,EAAE,gBAAgB,CAAC,KAAK,EAAE,CAAC;IAK3E,QAAQ,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;IAIlC,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe;CAQvC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ModelsInteractor = void 0;
|
|
4
|
+
const config_1 = require("../bridging/config.js");
|
|
5
|
+
const error_1 = require("../error.js");
|
|
6
|
+
const modelInteractor_1 = require("./modelInteractor.js");
|
|
7
|
+
class ModelsInteractor {
|
|
8
|
+
constructor(engineInteractor, models) {
|
|
9
|
+
this.engineInteractor = engineInteractor;
|
|
10
|
+
this.entity = models;
|
|
11
|
+
}
|
|
12
|
+
async finalize() {
|
|
13
|
+
return await this.entity;
|
|
14
|
+
}
|
|
15
|
+
get(repoId) {
|
|
16
|
+
const modelPromise = (async () => {
|
|
17
|
+
const models = await this.finalize();
|
|
18
|
+
const model = models.find((model) => model.repoId === repoId);
|
|
19
|
+
return (0, error_1.unwrapOrThrow)(model, error_1.EngineErrorCode.ModelNotFound);
|
|
20
|
+
})();
|
|
21
|
+
return new modelInteractor_1.ModelInteractor(this, modelPromise, config_1.Config.default());
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.ModelsInteractor = ModelsInteractor;
|
|
25
|
+
//# sourceMappingURL=modelsInteractor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modelsInteractor.js","sourceRoot":"","sources":["../src/interactors/modelsInteractor.ts"],"names":[],"mappings":";;;AAAA,kDAA4C;AAE5C,uCAA0D;AAG1D,0DAAoD;AAEpD,MAAa,gBAAgB;IAIzB,YAAY,gBAAkC,EAAE,MAAiC;QAC7E,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,QAAQ;QACV,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC;IAC7B,CAAC;IAED,GAAG,CAAC,MAAc;QACd,MAAM,YAAY,GAAG,CAAC,KAAK,IAAI,EAAE;YAC7B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;YACrC,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC;YAC9D,OAAO,IAAA,qBAAa,EAAC,KAAK,EAAE,uBAAe,CAAC,aAAa,CAAC,CAAC;QAC/D,CAAC,CAAC,EAAE,CAAC;QACL,OAAO,IAAI,iCAAe,CAAC,IAAI,EAAE,YAAY,EAAE,eAAM,CAAC,OAAO,EAAE,CAAC,CAAC;IACrE,CAAC;CACJ;AArBD,4CAqBC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Config } from "../bridging/config.mjs";
|
|
2
|
+
import { EngineErrorCode, unwrapOrThrow } from "../error.mjs";
|
|
3
|
+
import { ModelInteractor } from "./modelInteractor.mjs";
|
|
4
|
+
export class ModelsInteractor {
|
|
5
|
+
constructor(engineInteractor, models) {
|
|
6
|
+
this.engineInteractor = engineInteractor;
|
|
7
|
+
this.entity = models;
|
|
8
|
+
}
|
|
9
|
+
async finalize() {
|
|
10
|
+
return await this.entity;
|
|
11
|
+
}
|
|
12
|
+
get(repoId) {
|
|
13
|
+
const modelPromise = (async () => {
|
|
14
|
+
const models = await this.finalize();
|
|
15
|
+
const model = models.find((model) => model.repoId === repoId);
|
|
16
|
+
return unwrapOrThrow(model, EngineErrorCode.ModelNotFound);
|
|
17
|
+
})();
|
|
18
|
+
return new ModelInteractor(this, modelPromise, Config.default());
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=modelsInteractor.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modelsInteractor.mjs","sourceRoot":"","sources":["../src/interactors/modelsInteractor.ts"],"names":[],"mappings":"OAAO,EAAE,MAAM,EAAE;OAEV,EAAE,eAAe,EAAE,aAAa,EAAE;OAGlC,EAAE,eAAe,EAAE;AAE1B,MAAM,OAAO,gBAAgB;IAIzB,YAAY,gBAAkC,EAAE,MAAiC;QAC7E,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,QAAQ;QACV,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC;IAC7B,CAAC;IAED,GAAG,CAAC,MAAc;QACd,MAAM,YAAY,GAAG,CAAC,KAAK,IAAI,EAAE;YAC7B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;YACrC,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC;YAC9D,OAAO,aAAa,CAAC,KAAK,EAAE,eAAe,CAAC,aAAa,CAAC,CAAC;QAC/D,CAAC,CAAC,EAAE,CAAC;QACL,OAAO,IAAI,eAAe,CAAC,IAAI,EAAE,YAAY,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;IACrE,CAAC;CACJ"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Input } from "../bridging/input.mjs";
|
|
2
|
+
import { Message } from "../bridging/message.mjs";
|
|
3
|
+
import { Output } from "../bridging/output.mjs";
|
|
4
|
+
import { RunConfig } from "../bridging/runConfig.mjs";
|
|
5
|
+
import { SamplingMethod } from "../bridging/samplingMethod.mjs";
|
|
6
|
+
import { SamplingPolicy } from "../bridging/samplingPolicy.mjs";
|
|
7
|
+
import { Session } from "../bridging/session.mjs";
|
|
8
|
+
import { Interactor, InteractorEntity } from "./interactor.mjs";
|
|
9
|
+
import { ModelInteractor } from "./modelInteractor.mjs";
|
|
10
|
+
export declare class SessionInteractor implements Interactor<Session> {
|
|
11
|
+
readonly modelInteractor: ModelInteractor;
|
|
12
|
+
readonly entity: InteractorEntity<Session>;
|
|
13
|
+
readonly config: RunConfig;
|
|
14
|
+
constructor(modelInteractor: ModelInteractor, session: InteractorEntity<Session>, config: RunConfig);
|
|
15
|
+
finalize(): Promise<Session>;
|
|
16
|
+
tokensLimit(tokensLimit: number): SessionInteractor;
|
|
17
|
+
enableThinking(enableThinking: boolean): SessionInteractor;
|
|
18
|
+
samplingPolicy(samplingPolicy: SamplingPolicy): SessionInteractor;
|
|
19
|
+
samplingMethod(samplingMethod: SamplingMethod): SessionInteractor;
|
|
20
|
+
run(input: Input, progress?: (partialOutput: Output) => boolean): Promise<Output>;
|
|
21
|
+
reply(text: string, progress?: (partialOutput: Output) => boolean): Promise<Output>;
|
|
22
|
+
replyToMessages(messages: Message[], progress?: (partialOutput: Output) => boolean): Promise<Output>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=sessionInteractor.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionInteractor.d.mts","sourceRoot":"","sources":["../src/interactors/sessionInteractor.ts"],"names":[],"mappings":"OAAO,EAAE,KAAK,EAAE;OACT,EAAE,OAAO,EAAE;OACX,EAAE,MAAM,EAAE;OACV,EAAE,SAAS,EAAE;OACb,EAAE,cAAc,EAAE;OAClB,EAAE,cAAc,EAAE;OAClB,EAAE,OAAO,EAAE;OACX,EAAE,UAAU,EAAE,gBAAgB,EAAE;OAChC,EAAE,eAAe,EAAE;AAE1B,qBAAa,iBAAkB,YAAW,UAAU,CAAC,OAAO,CAAC;IACzD,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;IAC1C,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAC3C,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;gBAEf,eAAe,EAAE,eAAe,EAAE,OAAO,EAAE,gBAAgB,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,SAAS;IAM7F,QAAQ,IAAI,OAAO,CAAC,OAAO,CAAC;IAMlC,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,iBAAiB;IAKnD,cAAc,CAAC,cAAc,EAAE,OAAO,GAAG,iBAAiB;IAK1D,cAAc,CAAC,cAAc,EAAE,cAAc,GAAG,iBAAiB;IAKjE,cAAc,CAAC,cAAc,EAAE,cAAc,GAAG,iBAAiB;IAO3D,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,GAAE,CAAC,aAAa,EAAE,MAAM,KAAK,OAAoB,GAAG,OAAO,CAAC,MAAM,CAAC;IAU7F,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,GAAE,CAAC,aAAa,EAAE,MAAM,KAAK,OAAoB,GAAG,OAAO,CAAC,MAAM,CAAC;IAI/F,eAAe,CACjB,QAAQ,EAAE,OAAO,EAAE,EACnB,QAAQ,GAAE,CAAC,aAAa,EAAE,MAAM,KAAK,OAAoB,GAC1D,OAAO,CAAC,MAAM,CAAC;CAGrB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Input } from "../bridging/input.js";
|
|
2
|
+
import { Message } from "../bridging/message.js";
|
|
3
|
+
import { Output } from "../bridging/output.js";
|
|
4
|
+
import { RunConfig } from "../bridging/runConfig.js";
|
|
5
|
+
import { SamplingMethod } from "../bridging/samplingMethod.js";
|
|
6
|
+
import { SamplingPolicy } from "../bridging/samplingPolicy.js";
|
|
7
|
+
import { Session } from "../bridging/session.js";
|
|
8
|
+
import { Interactor, InteractorEntity } from "./interactor.js";
|
|
9
|
+
import { ModelInteractor } from "./modelInteractor.js";
|
|
10
|
+
export declare class SessionInteractor implements Interactor<Session> {
|
|
11
|
+
readonly modelInteractor: ModelInteractor;
|
|
12
|
+
readonly entity: InteractorEntity<Session>;
|
|
13
|
+
readonly config: RunConfig;
|
|
14
|
+
constructor(modelInteractor: ModelInteractor, session: InteractorEntity<Session>, config: RunConfig);
|
|
15
|
+
finalize(): Promise<Session>;
|
|
16
|
+
tokensLimit(tokensLimit: number): SessionInteractor;
|
|
17
|
+
enableThinking(enableThinking: boolean): SessionInteractor;
|
|
18
|
+
samplingPolicy(samplingPolicy: SamplingPolicy): SessionInteractor;
|
|
19
|
+
samplingMethod(samplingMethod: SamplingMethod): SessionInteractor;
|
|
20
|
+
run(input: Input, progress?: (partialOutput: Output) => boolean): Promise<Output>;
|
|
21
|
+
reply(text: string, progress?: (partialOutput: Output) => boolean): Promise<Output>;
|
|
22
|
+
replyToMessages(messages: Message[], progress?: (partialOutput: Output) => boolean): Promise<Output>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=sessionInteractor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":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AGrB"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SessionInteractor = void 0;
|
|
4
|
+
const input_1 = require("../bridging/input.js");
|
|
5
|
+
const samplingPolicy_1 = require("../bridging/samplingPolicy.js");
|
|
6
|
+
class SessionInteractor {
|
|
7
|
+
constructor(modelInteractor, session, config) {
|
|
8
|
+
this.modelInteractor = modelInteractor;
|
|
9
|
+
this.entity = session;
|
|
10
|
+
this.config = config;
|
|
11
|
+
}
|
|
12
|
+
async finalize() {
|
|
13
|
+
return await this.entity;
|
|
14
|
+
}
|
|
15
|
+
/* Config */
|
|
16
|
+
tokensLimit(tokensLimit) {
|
|
17
|
+
const config = this.config.withTokensLimit(tokensLimit);
|
|
18
|
+
return new SessionInteractor(this.modelInteractor, this.entity, config);
|
|
19
|
+
}
|
|
20
|
+
enableThinking(enableThinking) {
|
|
21
|
+
const config = this.config.withEnableThinking(enableThinking);
|
|
22
|
+
return new SessionInteractor(this.modelInteractor, this.entity, config);
|
|
23
|
+
}
|
|
24
|
+
samplingPolicy(samplingPolicy) {
|
|
25
|
+
const config = this.config.withSamplingPolicy(samplingPolicy);
|
|
26
|
+
return new SessionInteractor(this.modelInteractor, this.entity, config);
|
|
27
|
+
}
|
|
28
|
+
samplingMethod(samplingMethod) {
|
|
29
|
+
const config = this.config.withSamplingPolicy(samplingPolicy_1.SamplingPolicy.custom(samplingMethod));
|
|
30
|
+
return new SessionInteractor(this.modelInteractor, this.entity, config);
|
|
31
|
+
}
|
|
32
|
+
/* Run */
|
|
33
|
+
async run(input, progress = () => true) {
|
|
34
|
+
const outputPromise = (async () => {
|
|
35
|
+
const session = await this.finalize();
|
|
36
|
+
const output = session.run(input, this.config, progress);
|
|
37
|
+
return output;
|
|
38
|
+
})();
|
|
39
|
+
const output = await outputPromise;
|
|
40
|
+
return output;
|
|
41
|
+
}
|
|
42
|
+
async reply(text, progress = () => true) {
|
|
43
|
+
return await this.run(input_1.Input.text(text), progress);
|
|
44
|
+
}
|
|
45
|
+
async replyToMessages(messages, progress = () => true) {
|
|
46
|
+
return await this.run(input_1.Input.messages(messages), progress);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.SessionInteractor = SessionInteractor;
|
|
50
|
+
//# sourceMappingURL=sessionInteractor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionInteractor.js","sourceRoot":"","sources":["../src/interactors/sessionInteractor.ts"],"names":[],"mappings":";;;AAAA,gDAA0C;AAK1C,kEAA4D;AAK5D,MAAa,iBAAiB;IAK1B,YAAY,eAAgC,EAAE,OAAkC,EAAE,MAAiB;QAC/F,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC;QACtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,QAAQ;QACV,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC;IAC7B,CAAC;IAED,YAAY;IAEZ,WAAW,CAAC,WAAmB;QAC3B,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;QACxD,OAAO,IAAI,iBAAiB,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5E,CAAC;IAED,cAAc,CAAC,cAAuB;QAClC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAC;QAC9D,OAAO,IAAI,iBAAiB,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5E,CAAC;IAED,cAAc,CAAC,cAA8B;QACzC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAC;QAC9D,OAAO,IAA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/input.mjs";
|
|
2
|
+
import { SamplingPolicy } from "../bridging/samplingPolicy.mjs";
|
|
3
|
+
export class SessionInteractor {
|
|
4
|
+
constructor(modelInteractor, session, config) {
|
|
5
|
+
this.modelInteractor = modelInteractor;
|
|
6
|
+
this.entity = session;
|
|
7
|
+
this.config = config;
|
|
8
|
+
}
|
|
9
|
+
async finalize() {
|
|
10
|
+
return await this.entity;
|
|
11
|
+
}
|
|
12
|
+
/* Config */
|
|
13
|
+
tokensLimit(tokensLimit) {
|
|
14
|
+
const config = this.config.withTokensLimit(tokensLimit);
|
|
15
|
+
return new SessionInteractor(this.modelInteractor, this.entity, config);
|
|
16
|
+
}
|
|
17
|
+
enableThinking(enableThinking) {
|
|
18
|
+
const config = this.config.withEnableThinking(enableThinking);
|
|
19
|
+
return new SessionInteractor(this.modelInteractor, this.entity, config);
|
|
20
|
+
}
|
|
21
|
+
samplingPolicy(samplingPolicy) {
|
|
22
|
+
const config = this.config.withSamplingPolicy(samplingPolicy);
|
|
23
|
+
return new SessionInteractor(this.modelInteractor, this.entity, config);
|
|
24
|
+
}
|
|
25
|
+
samplingMethod(samplingMethod) {
|
|
26
|
+
const config = this.config.withSamplingPolicy(SamplingPolicy.custom(samplingMethod));
|
|
27
|
+
return new SessionInteractor(this.modelInteractor, this.entity, config);
|
|
28
|
+
}
|
|
29
|
+
/* Run */
|
|
30
|
+
async run(input, progress = () => true) {
|
|
31
|
+
const outputPromise = (async () => {
|
|
32
|
+
const session = await this.finalize();
|
|
33
|
+
const output = session.run(input, this.config, progress);
|
|
34
|
+
return output;
|
|
35
|
+
})();
|
|
36
|
+
const output = await outputPromise;
|
|
37
|
+
return output;
|
|
38
|
+
}
|
|
39
|
+
async reply(text, progress = () => true) {
|
|
40
|
+
return await this.run(Input.text(text), progress);
|
|
41
|
+
}
|
|
42
|
+
async replyToMessages(messages, progress = () => true) {
|
|
43
|
+
return await this.run(Input.messages(messages), progress);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=sessionInteractor.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionInteractor.mjs","sourceRoot":"","sources":["../src/interactors/sessionInteractor.ts"],"names":[],"mappings":"OAAO,EAAE,KAAK,EAAE;OAKT,EAAE,cAAc,EAAE;AAKzB,MAAM,OAAO,iBAAiB;IAK1B,YAAY,eAAgC,EAAE,OAAkC,EAAE,MAAiB;QAC/F,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC;QACtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,QAAQ;QACV,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC;IAC7B,CAAC;IAED,YAAY;IAEZ,WAAW,CAAC,WAAmB;QAC3B,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;QACxD,OAAO,IAAI,iBAAiB,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5E,CAAC;IAED,cAAc,CAAC,cAAuB;QAClC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAC;QAC9D,OAAO,IAAI,iBAAiB,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5E,CAAC;IAED,cAAc,CAAC,cAA8B;QACzC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAC;QAC9D,OAAO,IAAI,iBAAiB,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5E,CAAC;IAED,cAAc,CAAC,cAA8B;QACzC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,cAAc,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC;QACrF,OAAO,IAAI,iBAAiB,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5E,CAAC;IAED,SAAS;IAET,KAAK,CAAC,GAAG,CAAC,KAAY,EAAE,WAA+C,GAAG,EAAE,CAAC,IAAI;QAC7E,MAAM,aAAa,GAAG,CAAC,KAAK,IAAI,EAAE;YAC9B,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;YACtC,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;YACzD,OAAO,MAAM,CAAC;QAClB,CAAC,CAAC,EAAE,CAAC;QACL,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC;QACnC,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,IAAY,EAAE,WAA+C,GAAG,EAAE,CAAC,IAAI;QAC/E,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,eAAe,CACjB,QAAmB,EACnB,WAA+C,GAAG,EAAE,CAAC,IAAI;QAEzD,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC;IAC9D,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,35 +1,30 @@
|
|
|
1
1
|
/* auto-generated by NAPI-RS */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
-
export declare class DownloadHandle {
|
|
4
|
-
start(): void
|
|
5
|
-
pause(): void
|
|
6
|
-
resume(): void
|
|
7
|
-
stop(): void
|
|
8
|
-
delete(): void
|
|
9
|
-
state(): ModelDownloadState
|
|
10
|
-
identifier(): string
|
|
11
|
-
progress(): AsyncIterable<ProgressUpdate>
|
|
12
|
-
}
|
|
13
|
-
|
|
14
3
|
/** Thin FFI wrapper around `ModelStorage`. */
|
|
15
4
|
export declare class Engine {
|
|
16
5
|
getCloudModels(): Promise<Array<CloudModel>>
|
|
17
6
|
fetchCloudModels(): Promise<Array<CloudModel>>
|
|
18
7
|
/** Returns a `DownloadHandle` for the given model identifier. */
|
|
19
|
-
downloadHandle(identifier: string):
|
|
8
|
+
downloadHandle(identifier: string): ModelDownloadHandle
|
|
20
9
|
getLocalModels(): Array<LocalModel>
|
|
21
10
|
getState(identifier: string): ModelDownloadState
|
|
22
|
-
download(identifier: string): void
|
|
23
|
-
pause(identifier: string): void
|
|
24
|
-
resume(identifier: string): void
|
|
25
|
-
stop(identifier: string): void
|
|
26
|
-
delete(identifier: string): void
|
|
27
|
-
updateRegistry(): Promise<Array<LocalModel>>
|
|
28
11
|
activate(apiKey: string): Promise<LicenseStatus>
|
|
12
|
+
downloadModel(identifier: string): Promise<void>
|
|
13
|
+
pauseModel(identifier: string): Promise<void>
|
|
14
|
+
deleteModel(identifier: string): Promise<void>
|
|
29
15
|
constructor()
|
|
30
16
|
createSession(modelId: ModelID, config: Config): Session
|
|
31
17
|
}
|
|
32
18
|
|
|
19
|
+
export declare class ModelDownloadHandle {
|
|
20
|
+
identifier(): string
|
|
21
|
+
download(): Promise<void>
|
|
22
|
+
pause(): Promise<void>
|
|
23
|
+
delete(): Promise<void>
|
|
24
|
+
state(): Promise<ModelDownloadState>
|
|
25
|
+
progress(): AsyncIterable<ProgressUpdate>
|
|
26
|
+
}
|
|
27
|
+
|
|
33
28
|
export declare class ProgressStream {
|
|
34
29
|
|
|
35
30
|
}
|
|
@@ -70,12 +65,6 @@ export type ContextLength =
|
|
|
70
65
|
| { type: 'Maximal' }
|
|
71
66
|
| { type: 'Custom', length: number }
|
|
72
67
|
|
|
73
|
-
export type DownloaderError =
|
|
74
|
-
| { type: 'Http', message: string }
|
|
75
|
-
| { type: 'Io', message: string }
|
|
76
|
-
| { type: 'AlreadyExists', path: string }
|
|
77
|
-
| { type: 'Generic', message: string }
|
|
78
|
-
|
|
79
68
|
export declare const enum FinishReason {
|
|
80
69
|
Stop = 0,
|
|
81
70
|
Length = 1,
|
|
@@ -99,12 +88,14 @@ export type LicenseStatus =
|
|
|
99
88
|
| { type: 'HttpError', code: number }
|
|
100
89
|
|
|
101
90
|
export interface LocalModel {
|
|
102
|
-
/** Unique identifier of the model in the form `<vendor>-<name>`. */
|
|
91
|
+
/** Unique identifier of the model in the form `<vendor>-<name>-<precision>`. */
|
|
103
92
|
readonly identifier: string
|
|
104
|
-
/** Vendor/author of the model (e.g. "
|
|
93
|
+
/** Vendor/author of the model (e.g. "Alibaba", "Meta"). */
|
|
105
94
|
readonly vendor: string
|
|
106
|
-
/** Human-readable model name without vendor (e.g. "
|
|
95
|
+
/** Human-readable model name without vendor (e.g. "Qwen2.5-0.5B-Instruct"). */
|
|
107
96
|
readonly name: string
|
|
97
|
+
/** Precision of the model (e.g. "bfloat16", "float16"). */
|
|
98
|
+
readonly precision: string
|
|
108
99
|
/** Quantization type if the model is quantized (e.g. "uint4"). */
|
|
109
100
|
readonly quantization?: string
|
|
110
101
|
/** Optional regex to parse model output provided by the backend. */
|
|
@@ -119,14 +110,22 @@ export interface Message {
|
|
|
119
110
|
reasoningContent?: string
|
|
120
111
|
}
|
|
121
112
|
|
|
113
|
+
export declare const enum ModelDownloadPhase {
|
|
114
|
+
NotDownloaded = 0,
|
|
115
|
+
Downloading = 1,
|
|
116
|
+
Paused = 2,
|
|
117
|
+
Downloaded = 3,
|
|
118
|
+
Error = 4
|
|
119
|
+
}
|
|
120
|
+
|
|
122
121
|
export interface ModelDownloadState {
|
|
123
122
|
/** Total size of all model files in kilobytes. */
|
|
124
123
|
readonly totalKbytes: number
|
|
125
124
|
/** Bytes already downloaded (meaningful in Downloading / Paused). */
|
|
126
125
|
readonly downloadedKbytes: number
|
|
127
126
|
/** Current phase of the download. */
|
|
128
|
-
readonly phase:
|
|
129
|
-
/** Stringified error when `phase ==
|
|
127
|
+
readonly phase: ModelDownloadPhase
|
|
128
|
+
/** Stringified error when `phase == ModelDownloadPhase::Error`. */
|
|
130
129
|
readonly error?: string
|
|
131
130
|
}
|
|
132
131
|
|
|
@@ -134,6 +133,16 @@ export type ModelID =
|
|
|
134
133
|
| { type: 'Local', id: string }
|
|
135
134
|
| { type: 'Cloud', id: string }
|
|
136
135
|
|
|
136
|
+
export type ModelStorageError =
|
|
137
|
+
| { type: 'Io', message: string }
|
|
138
|
+
| { type: 'Network', message: string }
|
|
139
|
+
| { type: 'DownloadFailed', message: string }
|
|
140
|
+
| { type: 'Download', message: string }
|
|
141
|
+
| { type: 'InvalidPath', message: string }
|
|
142
|
+
| { type: 'ModelNotFound', identifier: string }
|
|
143
|
+
| { type: 'FileVerificationFailed', message: string }
|
|
144
|
+
| { type: 'Paused' }
|
|
145
|
+
|
|
137
146
|
export interface Output {
|
|
138
147
|
text: Text
|
|
139
148
|
stats: Stats
|
|
@@ -145,14 +154,6 @@ export interface ParsedText {
|
|
|
145
154
|
response?: string
|
|
146
155
|
}
|
|
147
156
|
|
|
148
|
-
export declare const enum Phase {
|
|
149
|
-
NotDownloaded = 0,
|
|
150
|
-
Downloading = 1,
|
|
151
|
-
Paused = 2,
|
|
152
|
-
Downloaded = 3,
|
|
153
|
-
Error = 4
|
|
154
|
-
}
|
|
155
|
-
|
|
156
157
|
export type PrefillStepSize =
|
|
157
158
|
| { type: 'Default' }
|
|
158
159
|
| { type: 'Maximal' }
|