@trymirai/uzu 0.1.21 → 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
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Engine } from '../bridging/engine';
|
|
2
|
+
import { ModelKind, ModelType } from '../bridging/model';
|
|
3
|
+
import { Interactor, InteractorEntity } from './interactor';
|
|
4
|
+
import { ModelInteractor } from './modelInteractor';
|
|
5
|
+
import { ModelsInteractor } from './modelsInteractor';
|
|
6
|
+
|
|
7
|
+
export class EngineInteractor implements Interactor<Engine> {
|
|
8
|
+
readonly entity: InteractorEntity<Engine>;
|
|
9
|
+
readonly modelTypeFilter: ModelType[] | null;
|
|
10
|
+
readonly modelKindFilter: ModelKind[] | null;
|
|
11
|
+
|
|
12
|
+
constructor(
|
|
13
|
+
engine: InteractorEntity<Engine>,
|
|
14
|
+
modelTypeFilter: ModelType[] | null = null,
|
|
15
|
+
modelKindFilter: ModelKind[] | null = null,
|
|
16
|
+
) {
|
|
17
|
+
this.entity = engine;
|
|
18
|
+
this.modelTypeFilter = modelTypeFilter;
|
|
19
|
+
this.modelKindFilter = modelKindFilter;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async finalize(): Promise<Engine> {
|
|
23
|
+
return await this.entity;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/* Models */
|
|
27
|
+
|
|
28
|
+
filterTypes(types: ModelType[] | null): EngineInteractor {
|
|
29
|
+
return new EngineInteractor(this.entity, types, this.modelKindFilter);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
filterKinds(kinds: ModelKind[] | null): EngineInteractor {
|
|
33
|
+
return new EngineInteractor(this.entity, this.modelTypeFilter, kinds);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
models(): ModelsInteractor {
|
|
37
|
+
const modelsPromise = (async () => {
|
|
38
|
+
const engine = await this.finalize();
|
|
39
|
+
return await engine.models(this.modelTypeFilter, this.modelKindFilter);
|
|
40
|
+
})();
|
|
41
|
+
return new ModelsInteractor(this, modelsPromise);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
model(repoId: string): ModelInteractor {
|
|
45
|
+
const models = this.models();
|
|
46
|
+
return models.get(repoId);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { Config } from '../bridging/config';
|
|
2
|
+
import { ContextLength } from '../bridging/contextLength';
|
|
3
|
+
import { DownloadProgressUpdate } from '../bridging/downloadProgressUpdate';
|
|
4
|
+
import { DownloadPhase } from '../bridging/downloadState';
|
|
5
|
+
import { Message } from '../bridging/message';
|
|
6
|
+
import { Model, ModelType } from '../bridging/model';
|
|
7
|
+
import { Output } from '../bridging/output';
|
|
8
|
+
import { PrefillStepSize } from '../bridging/prefillStepSize';
|
|
9
|
+
import { Preset } from '../bridging/preset';
|
|
10
|
+
import { RunConfig } from '../bridging/runConfig';
|
|
11
|
+
import { SamplingSeed } from '../bridging/samplingSeed';
|
|
12
|
+
import { DownloadInteractor } from './downloadInteractor';
|
|
13
|
+
import { Interactor, InteractorEntity } from './interactor';
|
|
14
|
+
import { ModelsInteractor } from './modelsInteractor';
|
|
15
|
+
import { SessionInteractor } from './sessionInteractor';
|
|
16
|
+
|
|
17
|
+
export class ModelInteractor implements Interactor<Model> {
|
|
18
|
+
readonly modelsInteractor: ModelsInteractor;
|
|
19
|
+
readonly entity: InteractorEntity<Model>;
|
|
20
|
+
readonly config: Config;
|
|
21
|
+
|
|
22
|
+
constructor(modelsInteractor: ModelsInteractor, model: InteractorEntity<Model>, config: Config) {
|
|
23
|
+
this.modelsInteractor = modelsInteractor;
|
|
24
|
+
this.entity = model;
|
|
25
|
+
this.config = config;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async finalize(): Promise<Model> {
|
|
29
|
+
return await this.entity;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/* Downloading */
|
|
33
|
+
|
|
34
|
+
downloading(): DownloadInteractor {
|
|
35
|
+
const handlePromise = (async () => {
|
|
36
|
+
const model = await this.finalize();
|
|
37
|
+
const engine = await this.modelsInteractor.engineInteractor.finalize();
|
|
38
|
+
const handle = engine.downloadHandle(model);
|
|
39
|
+
return handle;
|
|
40
|
+
})();
|
|
41
|
+
return new DownloadInteractor(this, handlePromise);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
download(callback?: (progressUpdate: DownloadProgressUpdate) => void): ModelInteractor {
|
|
45
|
+
const modelPromise = (async () => {
|
|
46
|
+
const downloadInteractor = this.downloading();
|
|
47
|
+
const handle = await downloadInteractor.finalize();
|
|
48
|
+
const state = await handle.state();
|
|
49
|
+
switch (state.phase) {
|
|
50
|
+
case DownloadPhase.Downloaded:
|
|
51
|
+
break;
|
|
52
|
+
default:
|
|
53
|
+
await downloadInteractor
|
|
54
|
+
.resume()
|
|
55
|
+
.onProgressUpdate(callback ?? (() => {}))
|
|
56
|
+
.finalize();
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
return this.finalize();
|
|
60
|
+
})();
|
|
61
|
+
return new ModelInteractor(this.modelsInteractor, modelPromise, this.config);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/* Config */
|
|
65
|
+
|
|
66
|
+
preset(preset: Preset): ModelInteractor {
|
|
67
|
+
const config = this.config.withPreset(preset);
|
|
68
|
+
return new ModelInteractor(this.modelsInteractor, this.entity, config);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
prefillStepSize(prefillStepSize: PrefillStepSize): ModelInteractor {
|
|
72
|
+
const config = this.config.withPrefillStepSize(prefillStepSize);
|
|
73
|
+
return new ModelInteractor(this.modelsInteractor, this.entity, config);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
contextLength(contextLength: ContextLength): ModelInteractor {
|
|
77
|
+
const config = this.config.withContextLength(contextLength);
|
|
78
|
+
return new ModelInteractor(this.modelsInteractor, this.entity, config);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
samplingSeed(samplingSeed: SamplingSeed): ModelInteractor {
|
|
82
|
+
const config = this.config.withSamplingSeed(samplingSeed);
|
|
83
|
+
return new ModelInteractor(this.modelsInteractor, this.entity, config);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/* Session */
|
|
87
|
+
|
|
88
|
+
session(): SessionInteractor {
|
|
89
|
+
const sessionPromise = (async () => {
|
|
90
|
+
const engine = await this.modelsInteractor.engineInteractor.finalize();
|
|
91
|
+
|
|
92
|
+
let model = await this.finalize();
|
|
93
|
+
if (model.type === ModelType.Local) {
|
|
94
|
+
model = await this.download().finalize();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const session = engine.session(model, this.config);
|
|
98
|
+
return session;
|
|
99
|
+
})();
|
|
100
|
+
return new SessionInteractor(this, sessionPromise, RunConfig.default());
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
async reply(text: string, progress: (partialOutput: Output) => boolean = () => true): Promise<Output> {
|
|
104
|
+
return await this.session().reply(text, progress);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async replyToMessages(
|
|
108
|
+
messages: Message[],
|
|
109
|
+
progress: (partialOutput: Output) => boolean = () => true,
|
|
110
|
+
): Promise<Output> {
|
|
111
|
+
return await this.session().replyToMessages(messages, progress);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Config } from '../bridging/config';
|
|
2
|
+
import { Model } from '../bridging/model';
|
|
3
|
+
import { EngineErrorCode, unwrapOrThrow } from '../error';
|
|
4
|
+
import { EngineInteractor } from './engineInteractor';
|
|
5
|
+
import { Interactor, InteractorEntity } from './interactor';
|
|
6
|
+
import { ModelInteractor } from './modelInteractor';
|
|
7
|
+
|
|
8
|
+
export class ModelsInteractor implements Interactor<Model[]> {
|
|
9
|
+
readonly engineInteractor: EngineInteractor;
|
|
10
|
+
readonly entity: InteractorEntity<Model[]>;
|
|
11
|
+
|
|
12
|
+
constructor(engineInteractor: EngineInteractor, models: InteractorEntity<Model[]>) {
|
|
13
|
+
this.engineInteractor = engineInteractor;
|
|
14
|
+
this.entity = models;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async finalize(): Promise<Model[]> {
|
|
18
|
+
return await this.entity;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
get(repoId: string): ModelInteractor {
|
|
22
|
+
const modelPromise = (async () => {
|
|
23
|
+
const models = await this.finalize();
|
|
24
|
+
const model = models.find((model) => model.repoId === repoId);
|
|
25
|
+
return unwrapOrThrow(model, EngineErrorCode.ModelNotFound);
|
|
26
|
+
})();
|
|
27
|
+
return new ModelInteractor(this, modelPromise, Config.default());
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Input } from '../bridging/input';
|
|
2
|
+
import { Message } from '../bridging/message';
|
|
3
|
+
import { Output } from '../bridging/output';
|
|
4
|
+
import { RunConfig } from '../bridging/runConfig';
|
|
5
|
+
import { SamplingMethod } from '../bridging/samplingMethod';
|
|
6
|
+
import { SamplingPolicy } from '../bridging/samplingPolicy';
|
|
7
|
+
import { Session } from '../bridging/session';
|
|
8
|
+
import { Interactor, InteractorEntity } from './interactor';
|
|
9
|
+
import { ModelInteractor } from './modelInteractor';
|
|
10
|
+
|
|
11
|
+
export class SessionInteractor implements Interactor<Session> {
|
|
12
|
+
readonly modelInteractor: ModelInteractor;
|
|
13
|
+
readonly entity: InteractorEntity<Session>;
|
|
14
|
+
readonly config: RunConfig;
|
|
15
|
+
|
|
16
|
+
constructor(modelInteractor: ModelInteractor, session: InteractorEntity<Session>, config: RunConfig) {
|
|
17
|
+
this.modelInteractor = modelInteractor;
|
|
18
|
+
this.entity = session;
|
|
19
|
+
this.config = config;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async finalize(): Promise<Session> {
|
|
23
|
+
return await this.entity;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/* Config */
|
|
27
|
+
|
|
28
|
+
tokensLimit(tokensLimit: number): SessionInteractor {
|
|
29
|
+
const config = this.config.withTokensLimit(tokensLimit);
|
|
30
|
+
return new SessionInteractor(this.modelInteractor, this.entity, config);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
enableThinking(enableThinking: boolean): SessionInteractor {
|
|
34
|
+
const config = this.config.withEnableThinking(enableThinking);
|
|
35
|
+
return new SessionInteractor(this.modelInteractor, this.entity, config);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
samplingPolicy(samplingPolicy: SamplingPolicy): SessionInteractor {
|
|
39
|
+
const config = this.config.withSamplingPolicy(samplingPolicy);
|
|
40
|
+
return new SessionInteractor(this.modelInteractor, this.entity, config);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
samplingMethod(samplingMethod: SamplingMethod): SessionInteractor {
|
|
44
|
+
const config = this.config.withSamplingPolicy(SamplingPolicy.custom(samplingMethod));
|
|
45
|
+
return new SessionInteractor(this.modelInteractor, this.entity, config);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/* Run */
|
|
49
|
+
|
|
50
|
+
async run(input: Input, progress: (partialOutput: Output) => boolean = () => true): Promise<Output> {
|
|
51
|
+
const outputPromise = (async () => {
|
|
52
|
+
const session = await this.finalize();
|
|
53
|
+
const output = session.run(input, this.config, progress);
|
|
54
|
+
return output;
|
|
55
|
+
})();
|
|
56
|
+
const output = await outputPromise;
|
|
57
|
+
return output;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async reply(text: string, progress: (partialOutput: Output) => boolean = () => true): Promise<Output> {
|
|
61
|
+
return await this.run(Input.text(text), progress);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async replyToMessages(
|
|
65
|
+
messages: Message[],
|
|
66
|
+
progress: (partialOutput: Output) => boolean = () => true,
|
|
67
|
+
): Promise<Output> {
|
|
68
|
+
return await this.run(Input.messages(messages), progress);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/* auto-generated by NAPI-RS */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/** Thin FFI wrapper around `ModelStorage`. */
|
|
4
|
+
export declare class Engine {
|
|
5
|
+
getCloudModels(): Promise<Array<CloudModel>>
|
|
6
|
+
fetchCloudModels(): Promise<Array<CloudModel>>
|
|
7
|
+
/** Returns a `DownloadHandle` for the given model identifier. */
|
|
8
|
+
downloadHandle(identifier: string): ModelDownloadHandle
|
|
9
|
+
getLocalModels(): Array<LocalModel>
|
|
10
|
+
getState(identifier: string): ModelDownloadState
|
|
11
|
+
activate(apiKey: string): Promise<LicenseStatus>
|
|
12
|
+
downloadModel(identifier: string): Promise<void>
|
|
13
|
+
pauseModel(identifier: string): Promise<void>
|
|
14
|
+
deleteModel(identifier: string): Promise<void>
|
|
15
|
+
constructor()
|
|
16
|
+
createSession(modelId: ModelID, config: Config): Session
|
|
17
|
+
}
|
|
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
|
+
|
|
28
|
+
export declare class ProgressStream {
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export declare class ProgressUpdate {
|
|
33
|
+
/** Bytes downloaded so far. */
|
|
34
|
+
completedBytes: number
|
|
35
|
+
/** Total bytes expected for the download; `None` while unknown. */
|
|
36
|
+
totalBytes?: number
|
|
37
|
+
/** Normalised progress between 0.0 and 1.0. */
|
|
38
|
+
progress: number
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export declare class Session {
|
|
42
|
+
run(input: Input, config: RunConfig, progress?: (arg: Output) => boolean | undefined | null): Output
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface ClassificationFeature {
|
|
46
|
+
name: string
|
|
47
|
+
values: Array<string>
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface CloudModel {
|
|
51
|
+
readonly repoId: string
|
|
52
|
+
readonly name: string
|
|
53
|
+
readonly vendor: string
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface Config {
|
|
57
|
+
preset: Preset
|
|
58
|
+
prefillStepSize: PrefillStepSize
|
|
59
|
+
contextLength: ContextLength
|
|
60
|
+
samplingSeed: SamplingSeed
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export type ContextLength =
|
|
64
|
+
| { type: 'Default' }
|
|
65
|
+
| { type: 'Maximal' }
|
|
66
|
+
| { type: 'Custom', length: number }
|
|
67
|
+
|
|
68
|
+
export declare const enum FinishReason {
|
|
69
|
+
Stop = 0,
|
|
70
|
+
Length = 1,
|
|
71
|
+
Cancelled = 2,
|
|
72
|
+
ContextLimitReached = 3
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export type Input =
|
|
76
|
+
| { type: 'Text', text: string }
|
|
77
|
+
| { type: 'Messages', messages: Array<Message> }
|
|
78
|
+
|
|
79
|
+
export type LicenseStatus =
|
|
80
|
+
| { type: 'NotActivated' }
|
|
81
|
+
| { type: 'PaymentRequired' }
|
|
82
|
+
| { type: 'GracePeriodActive' }
|
|
83
|
+
| { type: 'Activated' }
|
|
84
|
+
| { type: 'NetworkError' }
|
|
85
|
+
| { type: 'InvalidApiKey' }
|
|
86
|
+
| { type: 'SignatureMismatch' }
|
|
87
|
+
| { type: 'Timeout' }
|
|
88
|
+
| { type: 'HttpError', code: number }
|
|
89
|
+
|
|
90
|
+
export interface LocalModel {
|
|
91
|
+
/** Unique identifier of the model in the form `<vendor>-<name>-<precision>`. */
|
|
92
|
+
readonly identifier: string
|
|
93
|
+
/** Vendor/author of the model (e.g. "Alibaba", "Meta"). */
|
|
94
|
+
readonly vendor: string
|
|
95
|
+
/** Human-readable model name without vendor (e.g. "Qwen2.5-0.5B-Instruct"). */
|
|
96
|
+
readonly name: string
|
|
97
|
+
/** Precision of the model (e.g. "bfloat16", "float16"). */
|
|
98
|
+
readonly precision: string
|
|
99
|
+
/** Quantization type if the model is quantized (e.g. "uint4"). */
|
|
100
|
+
readonly quantization?: string
|
|
101
|
+
/** Optional regex to parse model output provided by the backend. */
|
|
102
|
+
readonly outputParserRegex?: string
|
|
103
|
+
/** Current download/installation state. */
|
|
104
|
+
readonly state: ModelDownloadState
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface Message {
|
|
108
|
+
role: Role
|
|
109
|
+
content: string
|
|
110
|
+
reasoningContent?: string
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export declare const enum ModelDownloadPhase {
|
|
114
|
+
NotDownloaded = 0,
|
|
115
|
+
Downloading = 1,
|
|
116
|
+
Paused = 2,
|
|
117
|
+
Downloaded = 3,
|
|
118
|
+
Error = 4
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface ModelDownloadState {
|
|
122
|
+
/** Total size of all model files in kilobytes. */
|
|
123
|
+
readonly totalKbytes: number
|
|
124
|
+
/** Bytes already downloaded (meaningful in Downloading / Paused). */
|
|
125
|
+
readonly downloadedKbytes: number
|
|
126
|
+
/** Current phase of the download. */
|
|
127
|
+
readonly phase: ModelDownloadPhase
|
|
128
|
+
/** Stringified error when `phase == ModelDownloadPhase::Error`. */
|
|
129
|
+
readonly error?: string
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export type ModelID =
|
|
133
|
+
| { type: 'Local', id: string }
|
|
134
|
+
| { type: 'Cloud', id: string }
|
|
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
|
+
|
|
146
|
+
export interface Output {
|
|
147
|
+
text: Text
|
|
148
|
+
stats: Stats
|
|
149
|
+
finishReason?: FinishReason
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export interface ParsedText {
|
|
153
|
+
chainOfThought?: string
|
|
154
|
+
response?: string
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export type PrefillStepSize =
|
|
158
|
+
| { type: 'Default' }
|
|
159
|
+
| { type: 'Maximal' }
|
|
160
|
+
| { type: 'Custom', length: number }
|
|
161
|
+
|
|
162
|
+
export type Preset =
|
|
163
|
+
| { type: 'General' }
|
|
164
|
+
| { type: 'Classification', feature: ClassificationFeature }
|
|
165
|
+
| { type: 'Summarization' }
|
|
166
|
+
|
|
167
|
+
export declare const enum Role {
|
|
168
|
+
System = 0,
|
|
169
|
+
User = 1,
|
|
170
|
+
Assistant = 2
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export interface RunConfig {
|
|
174
|
+
tokensLimit: number
|
|
175
|
+
enableThinking: boolean
|
|
176
|
+
samplingPolicy: SamplingPolicy
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export interface RunStats {
|
|
180
|
+
count: bigint
|
|
181
|
+
averageDuration: number
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export type SamplingMethod =
|
|
185
|
+
| { type: 'Greedy' }
|
|
186
|
+
| { type: 'Temperature', temperature: number }
|
|
187
|
+
| { type: 'TopP', topP: number }
|
|
188
|
+
|
|
189
|
+
export type SamplingPolicy =
|
|
190
|
+
| { type: 'Default' }
|
|
191
|
+
| { type: 'Custom', value: SamplingMethod }
|
|
192
|
+
|
|
193
|
+
export type SamplingSeed =
|
|
194
|
+
| { type: 'Default' }
|
|
195
|
+
| { type: 'Custom', seed: number }
|
|
196
|
+
|
|
197
|
+
export interface Stats {
|
|
198
|
+
prefillStats: StepStats
|
|
199
|
+
generateStats?: StepStats
|
|
200
|
+
totalStats: TotalStats
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export interface StepStats {
|
|
204
|
+
duration: number
|
|
205
|
+
suffixLength: bigint
|
|
206
|
+
tokensCount: bigint
|
|
207
|
+
tokensPerSecond: number
|
|
208
|
+
modelRun: RunStats
|
|
209
|
+
run?: RunStats
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export type StorageError =
|
|
213
|
+
| { type: 'ModelNotDownloaded' }
|
|
214
|
+
| { type: 'UnknownModel', identifier: string }
|
|
215
|
+
| { type: 'Storage', message: string }
|
|
216
|
+
| { type: 'MutexPoisoned', message: string }
|
|
217
|
+
| { type: 'LicenseNotActivated' }
|
|
218
|
+
|
|
219
|
+
export interface Text {
|
|
220
|
+
original: string
|
|
221
|
+
parsed: ParsedText
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export interface TotalStats {
|
|
225
|
+
duration: number
|
|
226
|
+
tokensCountInput: bigint
|
|
227
|
+
tokensCountOutput: bigint
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export declare function version(): string
|
package/src/napi/uzu.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// Auto-generated NAPI wrapper for uzu native module
|
|
2
|
+
// Currently supports only Apple Silicon (arm64) on macOS
|
|
3
|
+
// Other platforms may be added in future releases
|
|
4
|
+
|
|
5
|
+
const { createRequire } = require('module');
|
|
6
|
+
|
|
7
|
+
const require_ = createRequire(__filename);
|
|
8
|
+
|
|
9
|
+
// Check for Apple Silicon support only
|
|
10
|
+
if (process.platform !== 'darwin' || process.arch !== 'arm64') {
|
|
11
|
+
throw new Error(`This package only supports Apple Silicon (arm64) on macOS. Current platform: ${process.platform}-${process.arch}`);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
let nativeBinding = null;
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
nativeBinding = require_('./uzu.node');
|
|
18
|
+
} catch (e) {
|
|
19
|
+
throw new Error(`Failed to load native binding: ${e.message}`);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Re-export all runtime exports
|
|
23
|
+
const {
|
|
24
|
+
Engine,
|
|
25
|
+
ModelDownloadHandle,
|
|
26
|
+
ProgressStream,
|
|
27
|
+
ProgressUpdate,
|
|
28
|
+
Session,
|
|
29
|
+
FinishReason,
|
|
30
|
+
ModelDownloadPhase,
|
|
31
|
+
Role,
|
|
32
|
+
version,
|
|
33
|
+
ClassificationFeature,
|
|
34
|
+
CloudModel,
|
|
35
|
+
Config,
|
|
36
|
+
LocalModel,
|
|
37
|
+
Message,
|
|
38
|
+
ModelDownloadState,
|
|
39
|
+
Output,
|
|
40
|
+
ParsedText,
|
|
41
|
+
RunConfig,
|
|
42
|
+
RunStats,
|
|
43
|
+
Stats,
|
|
44
|
+
StepStats,
|
|
45
|
+
Text,
|
|
46
|
+
TotalStats,
|
|
47
|
+
ContextLength,
|
|
48
|
+
Input,
|
|
49
|
+
LicenseStatus,
|
|
50
|
+
ModelID,
|
|
51
|
+
ModelStorageError,
|
|
52
|
+
PrefillStepSize,
|
|
53
|
+
Preset,
|
|
54
|
+
SamplingMethod,
|
|
55
|
+
SamplingPolicy,
|
|
56
|
+
SamplingSeed,
|
|
57
|
+
StorageError
|
|
58
|
+
} = nativeBinding;
|
|
59
|
+
|
|
60
|
+
module.exports = {
|
|
61
|
+
Engine,
|
|
62
|
+
ModelDownloadHandle,
|
|
63
|
+
ProgressStream,
|
|
64
|
+
ProgressUpdate,
|
|
65
|
+
Session,
|
|
66
|
+
FinishReason,
|
|
67
|
+
ModelDownloadPhase,
|
|
68
|
+
Role,
|
|
69
|
+
version,
|
|
70
|
+
ClassificationFeature,
|
|
71
|
+
CloudModel,
|
|
72
|
+
Config,
|
|
73
|
+
LocalModel,
|
|
74
|
+
Message,
|
|
75
|
+
ModelDownloadState,
|
|
76
|
+
Output,
|
|
77
|
+
ParsedText,
|
|
78
|
+
RunConfig,
|
|
79
|
+
RunStats,
|
|
80
|
+
Stats,
|
|
81
|
+
StepStats,
|
|
82
|
+
Text,
|
|
83
|
+
TotalStats,
|
|
84
|
+
ContextLength,
|
|
85
|
+
Input,
|
|
86
|
+
LicenseStatus,
|
|
87
|
+
ModelID,
|
|
88
|
+
ModelStorageError,
|
|
89
|
+
PrefillStepSize,
|
|
90
|
+
Preset,
|
|
91
|
+
SamplingMethod,
|
|
92
|
+
SamplingPolicy,
|
|
93
|
+
SamplingSeed,
|
|
94
|
+
StorageError
|
|
95
|
+
};
|
package/src/napi/uzu.mjs
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// Auto-generated NAPI wrapper for uzu native module
|
|
2
|
+
// Currently supports only Apple Silicon (arm64) on macOS
|
|
3
|
+
// Other platforms may be added in future releases
|
|
4
|
+
|
|
5
|
+
import { createRequire } from 'module';
|
|
6
|
+
|
|
7
|
+
const require = createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// Check for Apple Silicon support only
|
|
10
|
+
if (process.platform !== 'darwin' || process.arch !== 'arm64') {
|
|
11
|
+
throw new Error(`This package only supports Apple Silicon (arm64) on macOS. Current platform: ${process.platform}-${process.arch}`);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
let nativeBinding = null;
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
nativeBinding = require('./uzu.node');
|
|
18
|
+
} catch (e) {
|
|
19
|
+
throw new Error(`Failed to load native binding: ${e.message}`);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Re-export all runtime exports as named exports
|
|
23
|
+
export const {
|
|
24
|
+
Engine,
|
|
25
|
+
ModelDownloadHandle,
|
|
26
|
+
ProgressStream,
|
|
27
|
+
ProgressUpdate,
|
|
28
|
+
Session,
|
|
29
|
+
FinishReason,
|
|
30
|
+
ModelDownloadPhase,
|
|
31
|
+
Role,
|
|
32
|
+
version,
|
|
33
|
+
ClassificationFeature,
|
|
34
|
+
CloudModel,
|
|
35
|
+
Config,
|
|
36
|
+
LocalModel,
|
|
37
|
+
Message,
|
|
38
|
+
ModelDownloadState,
|
|
39
|
+
Output,
|
|
40
|
+
ParsedText,
|
|
41
|
+
RunConfig,
|
|
42
|
+
RunStats,
|
|
43
|
+
Stats,
|
|
44
|
+
StepStats,
|
|
45
|
+
Text,
|
|
46
|
+
TotalStats,
|
|
47
|
+
ContextLength,
|
|
48
|
+
Input,
|
|
49
|
+
LicenseStatus,
|
|
50
|
+
ModelID,
|
|
51
|
+
ModelStorageError,
|
|
52
|
+
PrefillStepSize,
|
|
53
|
+
Preset,
|
|
54
|
+
SamplingMethod,
|
|
55
|
+
SamplingPolicy,
|
|
56
|
+
SamplingSeed,
|
|
57
|
+
StorageError
|
|
58
|
+
} = nativeBinding;
|
|
59
|
+
|
|
60
|
+
// Also provide default export
|
|
61
|
+
export default nativeBinding;
|
|
Binary file
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
// this config is included in the published src directory to prevent TS errors
|
|
3
|
+
// from appearing when users go to source, and VSCode opens the source .ts file
|
|
4
|
+
// via declaration maps
|
|
5
|
+
"include": ["index.ts"],
|
|
6
|
+
"compilerOptions": {
|
|
7
|
+
"target": "ES2015",
|
|
8
|
+
"lib": ["DOM", "DOM.Iterable", "ES2018"],
|
|
9
|
+
"moduleResolution": "node"
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const readEnv = (env: string): string | undefined => {
|
|
2
|
+
if (typeof (globalThis as any).process !== 'undefined') {
|
|
3
|
+
return (globalThis as any).process.env?.[env]?.trim() ?? undefined;
|
|
4
|
+
}
|
|
5
|
+
if (typeof (globalThis as any).Deno !== 'undefined') {
|
|
6
|
+
return (globalThis as any).Deno.env?.get?.(env)?.trim();
|
|
7
|
+
}
|
|
8
|
+
return undefined;
|
|
9
|
+
};
|
package/src/version.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const VERSION = '0.1.22';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.d.mts","sourceRoot":"","sources":["../src/utilities/env.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,GAAI,KAAK,MAAM,KAAG,MAAM,GAAG,SAQ9C,CAAC"}
|