@trymirai/uzu 0.3.1 → 0.4.0
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 +1 -1
- package/README.md +253 -245
- package/index.d.mts +1 -43
- package/index.d.mts.map +1 -1
- package/index.d.ts +1 -43
- package/index.d.ts.map +1 -1
- package/index.js +2 -88
- package/index.js.map +1 -1
- package/index.mjs +1 -43
- package/index.mjs.map +1 -1
- package/internal/tslib.js +6 -33
- package/napi/index.d.ts +975 -0
- package/napi/index.js +626 -0
- package/napi/index.mjs +3 -0
- package/napi/{uzu.node → uzu.darwin-arm64.node} +0 -0
- package/package.json +26 -63
- package/src/index.ts +1 -43
- package/src/napi/index.d.ts +975 -0
- package/src/napi/index.js +626 -0
- package/src/napi/index.mjs +3 -0
- package/src/napi/{uzu.node → uzu.darwin-arm64.node} +0 -0
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
- package/bridging/asyncBatchSize.d.mts +0 -10
- package/bridging/asyncBatchSize.d.mts.map +0 -1
- package/bridging/asyncBatchSize.d.ts +0 -10
- package/bridging/asyncBatchSize.d.ts.map +0 -1
- package/bridging/asyncBatchSize.js +0 -21
- package/bridging/asyncBatchSize.js.map +0 -1
- package/bridging/asyncBatchSize.mjs +0 -17
- package/bridging/asyncBatchSize.mjs.map +0 -1
- package/bridging/chatSession.d.mts +0 -11
- package/bridging/chatSession.d.mts.map +0 -1
- package/bridging/chatSession.d.ts +0 -11
- package/bridging/chatSession.d.ts.map +0 -1
- package/bridging/chatSession.js +0 -22
- package/bridging/chatSession.js.map +0 -1
- package/bridging/chatSession.mjs +0 -18
- package/bridging/chatSession.mjs.map +0 -1
- package/bridging/classificationFeature.d.mts +0 -9
- package/bridging/classificationFeature.d.mts.map +0 -1
- package/bridging/classificationFeature.d.ts +0 -9
- package/bridging/classificationFeature.d.ts.map +0 -1
- package/bridging/classificationFeature.js +0 -18
- package/bridging/classificationFeature.js.map +0 -1
- package/bridging/classificationFeature.mjs +0 -14
- package/bridging/classificationFeature.mjs.map +0 -1
- package/bridging/classificationLabel.d.mts +0 -12
- package/bridging/classificationLabel.d.mts.map +0 -1
- package/bridging/classificationLabel.d.ts +0 -12
- package/bridging/classificationLabel.d.ts.map +0 -1
- package/bridging/classificationLabel.js +0 -26
- package/bridging/classificationLabel.js.map +0 -1
- package/bridging/classificationLabel.mjs +0 -22
- package/bridging/classificationLabel.mjs.map +0 -1
- package/bridging/classificationOutput.d.mts +0 -10
- package/bridging/classificationOutput.d.mts.map +0 -1
- package/bridging/classificationOutput.d.ts +0 -10
- package/bridging/classificationOutput.d.ts.map +0 -1
- package/bridging/classificationOutput.js +0 -16
- package/bridging/classificationOutput.js.map +0 -1
- package/bridging/classificationOutput.mjs +0 -12
- package/bridging/classificationOutput.mjs.map +0 -1
- package/bridging/classificationSession.d.mts +0 -9
- package/bridging/classificationSession.d.mts.map +0 -1
- package/bridging/classificationSession.d.ts +0 -9
- package/bridging/classificationSession.d.ts.map +0 -1
- package/bridging/classificationSession.js +0 -16
- package/bridging/classificationSession.js.map +0 -1
- package/bridging/classificationSession.mjs +0 -12
- package/bridging/classificationSession.mjs.map +0 -1
- package/bridging/classificationStats.d.mts +0 -14
- package/bridging/classificationStats.d.mts.map +0 -1
- package/bridging/classificationStats.d.ts +0 -14
- package/bridging/classificationStats.d.ts.map +0 -1
- package/bridging/classificationStats.js +0 -20
- package/bridging/classificationStats.js.map +0 -1
- package/bridging/classificationStats.mjs +0 -16
- package/bridging/classificationStats.mjs.map +0 -1
- package/bridging/config.d.mts +0 -26
- package/bridging/config.d.mts.map +0 -1
- package/bridging/config.d.ts +0 -26
- package/bridging/config.d.ts.map +0 -1
- package/bridging/config.js +0 -53
- package/bridging/config.js.map +0 -1
- package/bridging/config.mjs +0 -49
- package/bridging/config.mjs.map +0 -1
- package/bridging/contextLength.d.mts +0 -11
- package/bridging/contextLength.d.mts.map +0 -1
- package/bridging/contextLength.d.ts +0 -11
- package/bridging/contextLength.d.ts.map +0 -1
- package/bridging/contextLength.js +0 -25
- package/bridging/contextLength.js.map +0 -1
- package/bridging/contextLength.mjs +0 -21
- package/bridging/contextLength.mjs.map +0 -1
- package/bridging/contextMode.d.mts +0 -12
- package/bridging/contextMode.d.mts.map +0 -1
- package/bridging/contextMode.d.ts +0 -12
- package/bridging/contextMode.d.ts.map +0 -1
- package/bridging/contextMode.js +0 -26
- package/bridging/contextMode.js.map +0 -1
- package/bridging/contextMode.mjs +0 -22
- package/bridging/contextMode.mjs.map +0 -1
- package/bridging/downloadHandle.d.mts +0 -14
- package/bridging/downloadHandle.d.mts.map +0 -1
- package/bridging/downloadHandle.d.ts +0 -14
- package/bridging/downloadHandle.d.ts.map +0 -1
- package/bridging/downloadHandle.js +0 -36
- package/bridging/downloadHandle.js.map +0 -1
- package/bridging/downloadHandle.mjs +0 -32
- package/bridging/downloadHandle.mjs.map +0 -1
- package/bridging/downloadProgressUpdate.d.mts +0 -9
- package/bridging/downloadProgressUpdate.d.mts.map +0 -1
- package/bridging/downloadProgressUpdate.d.ts +0 -9
- package/bridging/downloadProgressUpdate.d.ts.map +0 -1
- package/bridging/downloadProgressUpdate.js +0 -15
- package/bridging/downloadProgressUpdate.js.map +0 -1
- package/bridging/downloadProgressUpdate.mjs +0 -11
- package/bridging/downloadProgressUpdate.mjs.map +0 -1
- package/bridging/downloadState.d.mts +0 -19
- package/bridging/downloadState.d.mts.map +0 -1
- package/bridging/downloadState.d.ts +0 -19
- package/bridging/downloadState.d.ts.map +0 -1
- package/bridging/downloadState.js +0 -45
- package/bridging/downloadState.js.map +0 -1
- package/bridging/downloadState.mjs +0 -41
- package/bridging/downloadState.mjs.map +0 -1
- package/bridging/engine.d.mts +0 -29
- package/bridging/engine.d.mts.map +0 -1
- package/bridging/engine.d.ts +0 -29
- package/bridging/engine.d.ts.map +0 -1
- package/bridging/engine.js +0 -117
- package/bridging/engine.js.map +0 -1
- package/bridging/engine.mjs +0 -113
- package/bridging/engine.mjs.map +0 -1
- package/bridging/finishReason.d.mts +0 -7
- package/bridging/finishReason.d.mts.map +0 -1
- package/bridging/finishReason.d.ts +0 -7
- package/bridging/finishReason.d.ts.map +0 -1
- package/bridging/finishReason.js +0 -11
- package/bridging/finishReason.js.map +0 -1
- package/bridging/finishReason.mjs +0 -8
- package/bridging/finishReason.mjs.map +0 -1
- package/bridging/grammarConfig.d.mts +0 -13
- package/bridging/grammarConfig.d.mts.map +0 -1
- package/bridging/grammarConfig.d.ts +0 -13
- package/bridging/grammarConfig.d.ts.map +0 -1
- package/bridging/grammarConfig.js +0 -36
- package/bridging/grammarConfig.js.map +0 -1
- package/bridging/grammarConfig.mjs +0 -31
- package/bridging/grammarConfig.mjs.map +0 -1
- package/bridging/input.d.mts +0 -11
- package/bridging/input.d.mts.map +0 -1
- package/bridging/input.d.ts +0 -11
- package/bridging/input.d.ts.map +0 -1
- package/bridging/input.js +0 -25
- package/bridging/input.js.map +0 -1
- package/bridging/input.mjs +0 -21
- package/bridging/input.mjs.map +0 -1
- package/bridging/licenseStatus.d.mts +0 -14
- package/bridging/licenseStatus.d.mts.map +0 -1
- package/bridging/licenseStatus.d.ts +0 -14
- package/bridging/licenseStatus.d.ts.map +0 -1
- package/bridging/licenseStatus.js +0 -42
- package/bridging/licenseStatus.js.map +0 -1
- package/bridging/licenseStatus.mjs +0 -38
- package/bridging/licenseStatus.mjs.map +0 -1
- package/bridging/message.d.mts +0 -15
- package/bridging/message.d.mts.map +0 -1
- package/bridging/message.d.ts +0 -15
- package/bridging/message.d.ts.map +0 -1
- package/bridging/message.js +0 -43
- package/bridging/message.js.map +0 -1
- package/bridging/message.mjs +0 -39
- package/bridging/message.mjs.map +0 -1
- package/bridging/model.d.mts +0 -19
- package/bridging/model.d.mts.map +0 -1
- package/bridging/model.d.ts +0 -19
- package/bridging/model.d.ts.map +0 -1
- package/bridging/model.js +0 -39
- package/bridging/model.js.map +0 -1
- package/bridging/model.mjs +0 -35
- package/bridging/model.mjs.map +0 -1
- package/bridging/modelKind.d.mts +0 -8
- package/bridging/modelKind.d.mts.map +0 -1
- package/bridging/modelKind.d.ts +0 -8
- package/bridging/modelKind.d.ts.map +0 -1
- package/bridging/modelKind.js +0 -30
- package/bridging/modelKind.js.map +0 -1
- package/bridging/modelKind.mjs +0 -25
- package/bridging/modelKind.mjs.map +0 -1
- package/bridging/modelType.d.mts +0 -9
- package/bridging/modelType.d.mts.map +0 -1
- package/bridging/modelType.d.ts +0 -9
- package/bridging/modelType.d.ts.map +0 -1
- package/bridging/modelType.js +0 -35
- package/bridging/modelType.js.map +0 -1
- package/bridging/modelType.mjs +0 -30
- package/bridging/modelType.mjs.map +0 -1
- package/bridging/napi.d.mts +0 -4
- package/bridging/napi.d.mts.map +0 -1
- package/bridging/napi.d.ts +0 -4
- package/bridging/napi.d.ts.map +0 -1
- package/bridging/napi.js +0 -3
- package/bridging/napi.js.map +0 -1
- package/bridging/napi.mjs +0 -2
- package/bridging/napi.mjs.map +0 -1
- package/bridging/output.d.mts +0 -13
- package/bridging/output.d.mts.map +0 -1
- package/bridging/output.d.ts +0 -13
- package/bridging/output.d.ts.map +0 -1
- package/bridging/output.js +0 -36
- package/bridging/output.js.map +0 -1
- package/bridging/output.mjs +0 -32
- package/bridging/output.mjs.map +0 -1
- package/bridging/parsedText.d.mts +0 -10
- package/bridging/parsedText.d.mts.map +0 -1
- package/bridging/parsedText.d.ts +0 -10
- package/bridging/parsedText.d.ts.map +0 -1
- package/bridging/parsedText.js +0 -24
- package/bridging/parsedText.js.map +0 -1
- package/bridging/parsedText.mjs +0 -20
- package/bridging/parsedText.mjs.map +0 -1
- package/bridging/prefillStepSize.d.mts +0 -11
- package/bridging/prefillStepSize.d.mts.map +0 -1
- package/bridging/prefillStepSize.d.ts +0 -11
- package/bridging/prefillStepSize.d.ts.map +0 -1
- package/bridging/prefillStepSize.js +0 -28
- package/bridging/prefillStepSize.js.map +0 -1
- package/bridging/prefillStepSize.mjs +0 -24
- package/bridging/prefillStepSize.mjs.map +0 -1
- package/bridging/preset.d.mts +0 -14
- package/bridging/preset.d.mts.map +0 -1
- package/bridging/preset.d.ts +0 -14
- package/bridging/preset.d.ts.map +0 -1
- package/bridging/preset.js +0 -41
- package/bridging/preset.js.map +0 -1
- package/bridging/preset.mjs +0 -37
- package/bridging/preset.mjs.map +0 -1
- package/bridging/role.d.mts +0 -6
- package/bridging/role.d.mts.map +0 -1
- package/bridging/role.d.ts +0 -6
- package/bridging/role.d.ts.map +0 -1
- package/bridging/role.js +0 -10
- package/bridging/role.js.map +0 -1
- package/bridging/role.mjs +0 -7
- package/bridging/role.mjs.map +0 -1
- package/bridging/runConfig.d.mts +0 -18
- package/bridging/runConfig.d.mts.map +0 -1
- package/bridging/runConfig.d.ts +0 -18
- package/bridging/runConfig.d.ts.map +0 -1
- package/bridging/runConfig.js +0 -42
- package/bridging/runConfig.js.map +0 -1
- package/bridging/runConfig.mjs +0 -38
- package/bridging/runConfig.mjs.map +0 -1
- package/bridging/runStats.d.mts +0 -8
- package/bridging/runStats.d.mts.map +0 -1
- package/bridging/runStats.d.ts +0 -8
- package/bridging/runStats.d.ts.map +0 -1
- package/bridging/runStats.js +0 -16
- package/bridging/runStats.js.map +0 -1
- package/bridging/runStats.mjs +0 -12
- package/bridging/runStats.mjs.map +0 -1
- package/bridging/samplingMethod.d.mts +0 -11
- package/bridging/samplingMethod.d.mts.map +0 -1
- package/bridging/samplingMethod.d.ts +0 -11
- package/bridging/samplingMethod.d.ts.map +0 -1
- package/bridging/samplingMethod.js +0 -37
- package/bridging/samplingMethod.js.map +0 -1
- package/bridging/samplingMethod.mjs +0 -33
- package/bridging/samplingMethod.mjs.map +0 -1
- package/bridging/samplingPolicy.d.mts +0 -11
- package/bridging/samplingPolicy.d.mts.map +0 -1
- package/bridging/samplingPolicy.d.ts +0 -11
- package/bridging/samplingPolicy.d.ts.map +0 -1
- package/bridging/samplingPolicy.js +0 -25
- package/bridging/samplingPolicy.js.map +0 -1
- package/bridging/samplingPolicy.mjs +0 -21
- package/bridging/samplingPolicy.mjs.map +0 -1
- package/bridging/samplingProcessingOrder.d.mts +0 -8
- package/bridging/samplingProcessingOrder.d.mts.map +0 -1
- package/bridging/samplingProcessingOrder.d.ts +0 -8
- package/bridging/samplingProcessingOrder.d.ts.map +0 -1
- package/bridging/samplingProcessingOrder.js +0 -30
- package/bridging/samplingProcessingOrder.js.map +0 -1
- package/bridging/samplingProcessingOrder.mjs +0 -25
- package/bridging/samplingProcessingOrder.mjs.map +0 -1
- package/bridging/samplingSeed.d.mts +0 -10
- package/bridging/samplingSeed.d.mts.map +0 -1
- package/bridging/samplingSeed.d.ts +0 -10
- package/bridging/samplingSeed.d.ts.map +0 -1
- package/bridging/samplingSeed.js +0 -21
- package/bridging/samplingSeed.js.map +0 -1
- package/bridging/samplingSeed.mjs +0 -17
- package/bridging/samplingSeed.mjs.map +0 -1
- package/bridging/stats.d.mts +0 -11
- package/bridging/stats.d.mts.map +0 -1
- package/bridging/stats.d.ts +0 -11
- package/bridging/stats.d.ts.map +0 -1
- package/bridging/stats.js +0 -20
- package/bridging/stats.js.map +0 -1
- package/bridging/stats.mjs +0 -16
- package/bridging/stats.mjs.map +0 -1
- package/bridging/stepStats.d.mts +0 -14
- package/bridging/stepStats.d.mts.map +0 -1
- package/bridging/stepStats.d.ts +0 -14
- package/bridging/stepStats.d.ts.map +0 -1
- package/bridging/stepStats.js +0 -27
- package/bridging/stepStats.js.map +0 -1
- package/bridging/stepStats.mjs +0 -23
- package/bridging/stepStats.mjs.map +0 -1
- package/bridging/text.d.mts +0 -9
- package/bridging/text.d.mts.map +0 -1
- package/bridging/text.d.ts +0 -9
- package/bridging/text.d.ts.map +0 -1
- package/bridging/text.js +0 -17
- package/bridging/text.js.map +0 -1
- package/bridging/text.mjs +0 -13
- package/bridging/text.mjs.map +0 -1
- package/bridging/textToSpeechSession.d.mts +0 -8
- package/bridging/textToSpeechSession.d.mts.map +0 -1
- package/bridging/textToSpeechSession.d.ts +0 -8
- package/bridging/textToSpeechSession.d.ts.map +0 -1
- package/bridging/textToSpeechSession.js +0 -14
- package/bridging/textToSpeechSession.js.map +0 -1
- package/bridging/textToSpeechSession.mjs +0 -10
- package/bridging/textToSpeechSession.mjs.map +0 -1
- package/bridging/totalStats.d.mts +0 -9
- package/bridging/totalStats.d.mts.map +0 -1
- package/bridging/totalStats.d.ts +0 -9
- package/bridging/totalStats.d.ts.map +0 -1
- package/bridging/totalStats.js +0 -18
- package/bridging/totalStats.js.map +0 -1
- package/bridging/totalStats.mjs +0 -14
- package/bridging/totalStats.mjs.map +0 -1
- package/error.d.mts +0 -18
- package/error.d.mts.map +0 -1
- package/error.d.ts +0 -18
- package/error.d.ts.map +0 -1
- package/error.js +0 -46
- package/error.js.map +0 -1
- package/error.mjs +0 -41
- package/error.mjs.map +0 -1
- package/interactors/chatModelInteractor.d.mts +0 -34
- package/interactors/chatModelInteractor.d.mts.map +0 -1
- package/interactors/chatModelInteractor.d.ts +0 -34
- package/interactors/chatModelInteractor.d.ts.map +0 -1
- package/interactors/chatModelInteractor.js +0 -93
- package/interactors/chatModelInteractor.js.map +0 -1
- package/interactors/chatModelInteractor.mjs +0 -89
- package/interactors/chatModelInteractor.mjs.map +0 -1
- package/interactors/chatModelsInteractor.d.mts +0 -12
- package/interactors/chatModelsInteractor.d.mts.map +0 -1
- package/interactors/chatModelsInteractor.d.ts +0 -12
- package/interactors/chatModelsInteractor.d.ts.map +0 -1
- package/interactors/chatModelsInteractor.js +0 -25
- package/interactors/chatModelsInteractor.js.map +0 -1
- package/interactors/chatModelsInteractor.mjs +0 -21
- package/interactors/chatModelsInteractor.mjs.map +0 -1
- package/interactors/chatSessionInteractor.d.mts +0 -26
- package/interactors/chatSessionInteractor.d.mts.map +0 -1
- package/interactors/chatSessionInteractor.d.ts +0 -26
- package/interactors/chatSessionInteractor.d.ts.map +0 -1
- package/interactors/chatSessionInteractor.js +0 -54
- package/interactors/chatSessionInteractor.js.map +0 -1
- package/interactors/chatSessionInteractor.mjs +0 -50
- package/interactors/chatSessionInteractor.mjs.map +0 -1
- package/interactors/downloadInteractor.d.mts +0 -16
- package/interactors/downloadInteractor.d.mts.map +0 -1
- package/interactors/downloadInteractor.d.ts +0 -16
- package/interactors/downloadInteractor.d.ts.map +0 -1
- package/interactors/downloadInteractor.js +0 -38
- package/interactors/downloadInteractor.js.map +0 -1
- package/interactors/downloadInteractor.mjs +0 -34
- package/interactors/downloadInteractor.mjs.map +0 -1
- package/interactors/engineInteractor.d.mts +0 -15
- package/interactors/engineInteractor.d.mts.map +0 -1
- package/interactors/engineInteractor.d.ts +0 -15
- package/interactors/engineInteractor.d.ts.map +0 -1
- package/interactors/engineInteractor.js +0 -30
- package/interactors/engineInteractor.js.map +0 -1
- package/interactors/engineInteractor.mjs +0 -26
- package/interactors/engineInteractor.mjs.map +0 -1
- package/interactors/interactor.d.mts +0 -6
- package/interactors/interactor.d.mts.map +0 -1
- package/interactors/interactor.d.ts +0 -6
- package/interactors/interactor.d.ts.map +0 -1
- package/interactors/interactor.js +0 -3
- package/interactors/interactor.js.map +0 -1
- package/interactors/interactor.mjs +0 -2
- package/interactors/interactor.mjs.map +0 -1
- package/napi/uzu.d.ts +0 -325
- package/napi/uzu.js +0 -121
- package/napi/uzu.mjs +0 -74
- package/src/bridging/asyncBatchSize.ts +0 -24
- package/src/bridging/chatSession.ts +0 -28
- package/src/bridging/classificationFeature.ts +0 -20
- package/src/bridging/classificationLabel.ts +0 -43
- package/src/bridging/classificationOutput.ts +0 -22
- package/src/bridging/classificationSession.ts +0 -17
- package/src/bridging/classificationStats.ts +0 -45
- package/src/bridging/config.ts +0 -122
- package/src/bridging/contextLength.ts +0 -29
- package/src/bridging/contextMode.ts +0 -31
- package/src/bridging/downloadHandle.ts +0 -41
- package/src/bridging/downloadProgressUpdate.ts +0 -21
- package/src/bridging/downloadState.ts +0 -62
- package/src/bridging/engine.ts +0 -141
- package/src/bridging/finishReason.ts +0 -6
- package/src/bridging/grammarConfig.ts +0 -40
- package/src/bridging/input.ts +0 -29
- package/src/bridging/licenseStatus.ts +0 -39
- package/src/bridging/message.ts +0 -50
- package/src/bridging/model.ts +0 -68
- package/src/bridging/modelKind.ts +0 -27
- package/src/bridging/modelType.ts +0 -32
- package/src/bridging/napi.ts +0 -3
- package/src/bridging/output.ts +0 -40
- package/src/bridging/parsedText.ts +0 -27
- package/src/bridging/prefillStepSize.ts +0 -32
- package/src/bridging/preset.ts +0 -48
- package/src/bridging/role.ts +0 -5
- package/src/bridging/runConfig.ts +0 -57
- package/src/bridging/runStats.ts +0 -17
- package/src/bridging/samplingMethod.ts +0 -49
- package/src/bridging/samplingPolicy.ts +0 -29
- package/src/bridging/samplingProcessingOrder.ts +0 -31
- package/src/bridging/samplingSeed.ts +0 -24
- package/src/bridging/stats.ts +0 -22
- package/src/bridging/stepStats.ts +0 -49
- package/src/bridging/text.ts +0 -18
- package/src/bridging/textToSpeechSession.ts +0 -15
- package/src/bridging/totalStats.ts +0 -20
- package/src/error.ts +0 -42
- package/src/interactors/chatModelInteractor.ts +0 -126
- package/src/interactors/chatModelsInteractor.ts +0 -29
- package/src/interactors/chatSessionInteractor.ts +0 -80
- package/src/interactors/downloadInteractor.ts +0 -47
- package/src/interactors/engineInteractor.ts +0 -38
- package/src/interactors/interactor.ts +0 -7
- package/src/napi/uzu.d.ts +0 -325
- package/src/napi/uzu.js +0 -121
- package/src/napi/uzu.mjs +0 -74
- package/src/utilities/env.ts +0 -9
- package/utilities/env.d.mts +0 -2
- package/utilities/env.d.mts.map +0 -1
- package/utilities/env.d.ts +0 -2
- package/utilities/env.d.ts.map +0 -1
- package/utilities/env.js +0 -14
- package/utilities/env.js.map +0 -1
- package/utilities/env.mjs +0 -10
- package/utilities/env.mjs.map +0 -1
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { ClassificationStats as NapiClassificationStats } from '../napi/uzu';
|
|
2
|
-
|
|
3
|
-
export class ClassificationStats {
|
|
4
|
-
readonly preprocessingDuration: number;
|
|
5
|
-
readonly forwardPassDuration: number;
|
|
6
|
-
readonly postprocessingDuration: number;
|
|
7
|
-
readonly totalDuration: number;
|
|
8
|
-
readonly tokensCount: number;
|
|
9
|
-
readonly tokensPerSecond: number;
|
|
10
|
-
readonly predictedLabel: string;
|
|
11
|
-
readonly confidence: number;
|
|
12
|
-
|
|
13
|
-
constructor(
|
|
14
|
-
preprocessingDuration: number,
|
|
15
|
-
forwardPassDuration: number,
|
|
16
|
-
postprocessingDuration: number,
|
|
17
|
-
totalDuration: number,
|
|
18
|
-
tokensCount: number,
|
|
19
|
-
tokensPerSecond: number,
|
|
20
|
-
predictedLabel: string,
|
|
21
|
-
confidence: number,
|
|
22
|
-
) {
|
|
23
|
-
this.preprocessingDuration = preprocessingDuration;
|
|
24
|
-
this.forwardPassDuration = forwardPassDuration;
|
|
25
|
-
this.postprocessingDuration = postprocessingDuration;
|
|
26
|
-
this.totalDuration = totalDuration;
|
|
27
|
-
this.tokensCount = tokensCount;
|
|
28
|
-
this.tokensPerSecond = tokensPerSecond;
|
|
29
|
-
this.predictedLabel = predictedLabel;
|
|
30
|
-
this.confidence = confidence;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
static fromNapi(napiEntity: NapiClassificationStats): ClassificationStats {
|
|
34
|
-
return new ClassificationStats(
|
|
35
|
-
napiEntity.preprocessingDuration,
|
|
36
|
-
napiEntity.forwardPassDuration,
|
|
37
|
-
napiEntity.postprocessingDuration,
|
|
38
|
-
napiEntity.totalDuration,
|
|
39
|
-
napiEntity.tokensCount,
|
|
40
|
-
napiEntity.tokensPerSecond,
|
|
41
|
-
napiEntity.predictedLabel,
|
|
42
|
-
napiEntity.confidence,
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
}
|
package/src/bridging/config.ts
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { Config as NapiConfig } from '../napi/uzu';
|
|
2
|
-
import { AsyncBatchSize } from './asyncBatchSize';
|
|
3
|
-
import { ContextLength } from './contextLength';
|
|
4
|
-
import { ContextMode } from './contextMode';
|
|
5
|
-
import { ToNapi } from './napi';
|
|
6
|
-
import { PrefillStepSize } from './prefillStepSize';
|
|
7
|
-
import { Preset } from './preset';
|
|
8
|
-
import { SamplingSeed } from './samplingSeed';
|
|
9
|
-
|
|
10
|
-
export class Config implements ToNapi<NapiConfig> {
|
|
11
|
-
readonly preset: Preset;
|
|
12
|
-
readonly contextMode: ContextMode;
|
|
13
|
-
readonly contextLength: ContextLength;
|
|
14
|
-
readonly prefillStepSize: PrefillStepSize;
|
|
15
|
-
readonly samplingSeed: SamplingSeed;
|
|
16
|
-
readonly asyncBatchSize: AsyncBatchSize;
|
|
17
|
-
|
|
18
|
-
constructor(
|
|
19
|
-
preset: Preset,
|
|
20
|
-
contextMode: ContextMode,
|
|
21
|
-
contextLength: ContextLength,
|
|
22
|
-
prefillStepSize: PrefillStepSize,
|
|
23
|
-
samplingSeed: SamplingSeed,
|
|
24
|
-
asyncBatchSize: AsyncBatchSize,
|
|
25
|
-
) {
|
|
26
|
-
this.preset = preset;
|
|
27
|
-
this.contextMode = contextMode;
|
|
28
|
-
this.contextLength = contextLength;
|
|
29
|
-
this.prefillStepSize = prefillStepSize;
|
|
30
|
-
this.samplingSeed = samplingSeed;
|
|
31
|
-
this.asyncBatchSize = asyncBatchSize;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
static default(): Config {
|
|
35
|
-
return new Config(
|
|
36
|
-
Preset.general(),
|
|
37
|
-
ContextMode.none(),
|
|
38
|
-
ContextLength.default(),
|
|
39
|
-
PrefillStepSize.default(),
|
|
40
|
-
SamplingSeed.default(),
|
|
41
|
-
AsyncBatchSize.default(),
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
withPreset(preset: Preset): Config {
|
|
46
|
-
return new Config(
|
|
47
|
-
preset,
|
|
48
|
-
this.contextMode,
|
|
49
|
-
this.contextLength,
|
|
50
|
-
this.prefillStepSize,
|
|
51
|
-
this.samplingSeed,
|
|
52
|
-
this.asyncBatchSize,
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
withContextMode(contextMode: ContextMode): Config {
|
|
57
|
-
return new Config(
|
|
58
|
-
this.preset,
|
|
59
|
-
contextMode,
|
|
60
|
-
this.contextLength,
|
|
61
|
-
this.prefillStepSize,
|
|
62
|
-
this.samplingSeed,
|
|
63
|
-
this.asyncBatchSize,
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
withContextLength(contextLength: ContextLength): Config {
|
|
68
|
-
return new Config(
|
|
69
|
-
this.preset,
|
|
70
|
-
this.contextMode,
|
|
71
|
-
contextLength,
|
|
72
|
-
this.prefillStepSize,
|
|
73
|
-
this.samplingSeed,
|
|
74
|
-
this.asyncBatchSize,
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
withPrefillStepSize(prefillStepSize: PrefillStepSize): Config {
|
|
79
|
-
return new Config(
|
|
80
|
-
this.preset,
|
|
81
|
-
this.contextMode,
|
|
82
|
-
this.contextLength,
|
|
83
|
-
prefillStepSize,
|
|
84
|
-
this.samplingSeed,
|
|
85
|
-
this.asyncBatchSize,
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
withSamplingSeed(samplingSeed: SamplingSeed): Config {
|
|
90
|
-
return new Config(
|
|
91
|
-
this.preset,
|
|
92
|
-
this.contextMode,
|
|
93
|
-
this.contextLength,
|
|
94
|
-
this.prefillStepSize,
|
|
95
|
-
samplingSeed,
|
|
96
|
-
this.asyncBatchSize,
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
withAsyncBatchSize(asyncBatchSize: AsyncBatchSize): Config {
|
|
101
|
-
return new Config(
|
|
102
|
-
this.preset,
|
|
103
|
-
this.contextMode,
|
|
104
|
-
this.contextLength,
|
|
105
|
-
this.prefillStepSize,
|
|
106
|
-
this.samplingSeed,
|
|
107
|
-
asyncBatchSize,
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
toNapi(): NapiConfig {
|
|
112
|
-
const napiConfig: NapiConfig = {
|
|
113
|
-
preset: this.preset.toNapi(),
|
|
114
|
-
contextMode: this.contextMode.toNapi(),
|
|
115
|
-
contextLength: this.contextLength.toNapi(),
|
|
116
|
-
prefillStepSize: this.prefillStepSize.toNapi(),
|
|
117
|
-
samplingSeed: this.samplingSeed.toNapi(),
|
|
118
|
-
asyncBatchSize: this.asyncBatchSize.toNapi(),
|
|
119
|
-
};
|
|
120
|
-
return napiConfig;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { ContextLength as NapiContextLength } from '../napi/uzu';
|
|
2
|
-
import { ToNapi } from './napi';
|
|
3
|
-
|
|
4
|
-
export class ContextLength implements ToNapi<NapiContextLength> {
|
|
5
|
-
private readonly napiContextLength: NapiContextLength;
|
|
6
|
-
|
|
7
|
-
private constructor(napiContextLength: NapiContextLength) {
|
|
8
|
-
this.napiContextLength = napiContextLength;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
static default(): ContextLength {
|
|
12
|
-
const napiContextLength: NapiContextLength = { type: 'Default' };
|
|
13
|
-
return new ContextLength(napiContextLength);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
static maximal(): ContextLength {
|
|
17
|
-
const napiContextLength: NapiContextLength = { type: 'Maximal' };
|
|
18
|
-
return new ContextLength(napiContextLength);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
static custom(length: number): ContextLength {
|
|
22
|
-
const napiContextLength: NapiContextLength = { type: 'Custom', length };
|
|
23
|
-
return new ContextLength(napiContextLength);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
toNapi(): NapiContextLength {
|
|
27
|
-
return this.napiContextLength;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { ContextMode as NapiContextMode, Input as NapiInput } from '../napi/uzu';
|
|
2
|
-
import { Input } from './input';
|
|
3
|
-
import { ToNapi } from './napi';
|
|
4
|
-
|
|
5
|
-
export class ContextMode implements ToNapi<NapiContextMode> {
|
|
6
|
-
private readonly napiContextMode: NapiContextMode;
|
|
7
|
-
|
|
8
|
-
private constructor(napiContextMode: NapiContextMode) {
|
|
9
|
-
this.napiContextMode = napiContextMode;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
static none(): ContextMode {
|
|
13
|
-
const napiContextMode: NapiContextMode = { type: 'None' };
|
|
14
|
-
return new ContextMode(napiContextMode);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
static static(input: Input): ContextMode {
|
|
18
|
-
let napiInput: NapiInput = input.toNapi();
|
|
19
|
-
let napiContextMode: NapiContextMode = { type: 'Static', input: napiInput };
|
|
20
|
-
return new ContextMode(napiContextMode);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
static dynamic(): ContextMode {
|
|
24
|
-
const napiContextMode: NapiContextMode = { type: 'Dynamic' };
|
|
25
|
-
return new ContextMode(napiContextMode);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
toNapi(): NapiContextMode {
|
|
29
|
-
return this.napiContextMode;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { ModelDownloadHandle as NapiModelDownloadHandle } from '../napi/uzu';
|
|
2
|
-
import { DownloadProgressUpdate } from './downloadProgressUpdate';
|
|
3
|
-
import { DownloadState } from './downloadState';
|
|
4
|
-
|
|
5
|
-
export class DownloadHandle {
|
|
6
|
-
private readonly napiDownloadHandle: NapiModelDownloadHandle;
|
|
7
|
-
|
|
8
|
-
constructor(napiDownloadHandle: NapiModelDownloadHandle) {
|
|
9
|
-
this.napiDownloadHandle = napiDownloadHandle;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
identifier(): string {
|
|
13
|
-
return this.napiDownloadHandle.identifier();
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
async state(): Promise<DownloadState> {
|
|
17
|
-
const napiDownloadState = await this.napiDownloadHandle.state();
|
|
18
|
-
return DownloadState.fromNapi(napiDownloadState);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
async download(): Promise<void> {
|
|
22
|
-
await this.napiDownloadHandle.download();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
async pause(): Promise<void> {
|
|
26
|
-
await this.napiDownloadHandle.pause();
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
async delete(): Promise<void> {
|
|
30
|
-
await this.napiDownloadHandle.delete();
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
progressUpdate(): AsyncIterable<DownloadProgressUpdate> {
|
|
34
|
-
const source = this.napiDownloadHandle.progress();
|
|
35
|
-
return (async function* () {
|
|
36
|
-
for await (const update of source) {
|
|
37
|
-
yield DownloadProgressUpdate.fromNapi(update);
|
|
38
|
-
}
|
|
39
|
-
})();
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { ProgressUpdate as NapiProgressUpdate } from '../napi/uzu';
|
|
2
|
-
|
|
3
|
-
export class DownloadProgressUpdate {
|
|
4
|
-
readonly completedBytes: number;
|
|
5
|
-
readonly totalBytes: number | null;
|
|
6
|
-
readonly progress: number;
|
|
7
|
-
|
|
8
|
-
private constructor(completedBytes: number, totalBytes: number | null, progress: number) {
|
|
9
|
-
this.completedBytes = completedBytes;
|
|
10
|
-
this.totalBytes = totalBytes;
|
|
11
|
-
this.progress = progress;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
static fromNapi(napiDownloadProgress: NapiProgressUpdate): DownloadProgressUpdate {
|
|
15
|
-
return new DownloadProgressUpdate(
|
|
16
|
-
napiDownloadProgress.completedBytes,
|
|
17
|
-
napiDownloadProgress.totalBytes ?? null,
|
|
18
|
-
napiDownloadProgress.progress,
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { EngineError, EngineErrorCode } from '../error';
|
|
2
|
-
import {
|
|
3
|
-
ModelDownloadPhase as NapiModelDownloadPhase,
|
|
4
|
-
ModelDownloadState as NapiModelDownloadState,
|
|
5
|
-
} from '../napi/uzu';
|
|
6
|
-
|
|
7
|
-
export enum DownloadPhase {
|
|
8
|
-
NotDownloaded = 'NotDownloaded',
|
|
9
|
-
Downloading = 'Downloading',
|
|
10
|
-
Paused = 'Paused',
|
|
11
|
-
Downloaded = 'Downloaded',
|
|
12
|
-
Locked = 'Locked',
|
|
13
|
-
Error = 'Error',
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export class DownloadState {
|
|
17
|
-
readonly totalKbytes: number;
|
|
18
|
-
readonly downloadedKbytes: number;
|
|
19
|
-
readonly phase: DownloadPhase;
|
|
20
|
-
readonly error: string | null;
|
|
21
|
-
|
|
22
|
-
private constructor(
|
|
23
|
-
totalKbytes: number,
|
|
24
|
-
downloadedKbytes: number,
|
|
25
|
-
phase: DownloadPhase,
|
|
26
|
-
error: string | null,
|
|
27
|
-
) {
|
|
28
|
-
this.totalKbytes = totalKbytes;
|
|
29
|
-
this.downloadedKbytes = downloadedKbytes;
|
|
30
|
-
this.phase = phase;
|
|
31
|
-
this.error = error;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
private static napiPhaseToDownloadPhase(napiPhase: NapiModelDownloadPhase): DownloadPhase {
|
|
35
|
-
switch (napiPhase) {
|
|
36
|
-
case 0:
|
|
37
|
-
return DownloadPhase.NotDownloaded;
|
|
38
|
-
case 1:
|
|
39
|
-
return DownloadPhase.Downloading;
|
|
40
|
-
case 2:
|
|
41
|
-
return DownloadPhase.Paused;
|
|
42
|
-
case 3:
|
|
43
|
-
return DownloadPhase.Downloaded;
|
|
44
|
-
case 4:
|
|
45
|
-
return DownloadPhase.Locked;
|
|
46
|
-
case 5:
|
|
47
|
-
return DownloadPhase.Error;
|
|
48
|
-
default:
|
|
49
|
-
throw new EngineError(EngineErrorCode.UnexpectedDownloadPhase);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
static fromNapi(napiDownloadState: NapiModelDownloadState): DownloadState {
|
|
54
|
-
const phase = DownloadState.napiPhaseToDownloadPhase(napiDownloadState.phase);
|
|
55
|
-
return new DownloadState(
|
|
56
|
-
napiDownloadState.totalKbytes,
|
|
57
|
-
napiDownloadState.downloadedKbytes,
|
|
58
|
-
phase,
|
|
59
|
-
napiDownloadState.error ?? null,
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
}
|
package/src/bridging/engine.ts
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import { EngineError, EngineErrorCode, unwrapOrThrow } from '../error';
|
|
2
|
-
import { EngineInteractor } from '../interactors/engineInteractor';
|
|
3
|
-
import { Engine as NapiEngine } from '../napi/uzu';
|
|
4
|
-
import { readEnv } from '../utilities/env';
|
|
5
|
-
import { ChatSession } from './chatSession';
|
|
6
|
-
import { ClassificationSession } from './classificationSession';
|
|
7
|
-
import { Config } from './config';
|
|
8
|
-
import { DownloadHandle } from './downloadHandle';
|
|
9
|
-
import { DownloadProgressUpdate } from './downloadProgressUpdate';
|
|
10
|
-
import { DownloadPhase, DownloadState } from './downloadState';
|
|
11
|
-
import { LicenseStatus, licenseStatusFromNapiLicenseStatus } from './licenseStatus';
|
|
12
|
-
import { Model } from './model';
|
|
13
|
-
import { ModelKind, modelKindToNapiModelKind } from './modelKind';
|
|
14
|
-
import { TextToSpeechSession } from './textToSpeechSession';
|
|
15
|
-
|
|
16
|
-
export class Engine {
|
|
17
|
-
private readonly napiEngine: NapiEngine;
|
|
18
|
-
|
|
19
|
-
private constructor(napiEngine: NapiEngine) {
|
|
20
|
-
this.napiEngine = napiEngine;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
static async load(apiKey: string | undefined = undefined): Promise<Engine> {
|
|
24
|
-
const resolvedApiKey = unwrapOrThrow(
|
|
25
|
-
apiKey ?? readEnv('MIRAI_API_KEY'),
|
|
26
|
-
EngineErrorCode.APIKeyNotFound,
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
const napiEngine = new NapiEngine();
|
|
30
|
-
|
|
31
|
-
const napiLicenseStatus = await napiEngine.activate(resolvedApiKey);
|
|
32
|
-
const licenseStatus = licenseStatusFromNapiLicenseStatus(napiLicenseStatus);
|
|
33
|
-
switch (licenseStatus) {
|
|
34
|
-
case LicenseStatus.Activated:
|
|
35
|
-
case LicenseStatus.GracePeriodActive:
|
|
36
|
-
break;
|
|
37
|
-
default:
|
|
38
|
-
throw new EngineError(EngineErrorCode.LicenseNotActivated);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return new Engine(napiEngine);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
static create(apiKey: string | undefined = undefined): EngineInteractor {
|
|
45
|
-
const enginePromise = (async () => {
|
|
46
|
-
return await Engine.load(apiKey);
|
|
47
|
-
})();
|
|
48
|
-
return new EngineInteractor(enginePromise);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
getDownloadState(repoId: string): DownloadState {
|
|
52
|
-
let downloadState = this.napiEngine.getModelDownloadState(repoId);
|
|
53
|
-
return DownloadState.fromNapi(downloadState);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
downloadHandle(repoId: string): DownloadHandle {
|
|
57
|
-
return new DownloadHandle(this.napiEngine.createModelDownloadHandle(repoId));
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
async downloadModel(
|
|
61
|
-
model: Model,
|
|
62
|
-
progress: (progressUpdate: DownloadProgressUpdate) => void = () => {},
|
|
63
|
-
): Promise<DownloadState> {
|
|
64
|
-
switch (model.kind) {
|
|
65
|
-
case ModelKind.Local:
|
|
66
|
-
break;
|
|
67
|
-
case ModelKind.Cloud:
|
|
68
|
-
throw new EngineError(EngineErrorCode.UnexpectedModelKind);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const downloadHandle = this.downloadHandle(model.repoId);
|
|
72
|
-
const state = await downloadHandle.state();
|
|
73
|
-
switch (state.phase) {
|
|
74
|
-
case DownloadPhase.Downloaded:
|
|
75
|
-
break;
|
|
76
|
-
default:
|
|
77
|
-
await downloadHandle.download();
|
|
78
|
-
for await (const progressUpdate of downloadHandle.progressUpdate()) {
|
|
79
|
-
progress(progressUpdate);
|
|
80
|
-
}
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const finalState = await downloadHandle.state();
|
|
85
|
-
return finalState;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
async chatModels(kinds: ModelKind[] | null = null): Promise<Model[]> {
|
|
89
|
-
let kindsToFilter: ModelKind[] = kinds ?? [ModelKind.Local, ModelKind.Cloud];
|
|
90
|
-
let napiModelKinds = kindsToFilter.map(modelKindToNapiModelKind);
|
|
91
|
-
let napiChatModels = await this.napiEngine.getChatModels(napiModelKinds);
|
|
92
|
-
let results: Model[] = napiChatModels.map(Model.fromNapiModel);
|
|
93
|
-
return results;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
async chatModel(repoId: string, kinds: ModelKind[] | null = null): Promise<Model> {
|
|
97
|
-
const chatModels = await this.chatModels(kinds);
|
|
98
|
-
const chatModel = chatModels.find((model) => model.repoId === repoId);
|
|
99
|
-
return unwrapOrThrow(chatModel, EngineErrorCode.ModelNotFound);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
chatSession(model: Model, config: Config = Config.default()): ChatSession {
|
|
103
|
-
const napiModel = model.toNapi();
|
|
104
|
-
const napiConfig = config.toNapi();
|
|
105
|
-
return new ChatSession(this.napiEngine.createChatSession(napiModel, napiConfig));
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
async classificationModels(): Promise<Model[]> {
|
|
109
|
-
const napiClassificationModels = await this.napiEngine.getClassificationModels();
|
|
110
|
-
const results: Model[] = napiClassificationModels.map(Model.fromNapiModel);
|
|
111
|
-
return results;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
async classificationModel(repoId: string): Promise<Model> {
|
|
115
|
-
const classificationModels = await this.classificationModels();
|
|
116
|
-
const classificationModel = classificationModels.find((model) => model.repoId === repoId);
|
|
117
|
-
return unwrapOrThrow(classificationModel, EngineErrorCode.ModelNotFound);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
classificationSession(model: Model): ClassificationSession {
|
|
121
|
-
const napiModel = model.toNapi();
|
|
122
|
-
return new ClassificationSession(this.napiEngine.createClassificationSession(napiModel));
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
async textToSpeechModels(): Promise<Model[]> {
|
|
126
|
-
const napiTextToSpeechModels = await this.napiEngine.getTextToSpeechModels();
|
|
127
|
-
const results: Model[] = napiTextToSpeechModels.map(Model.fromNapiModel);
|
|
128
|
-
return results;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
async textToSpeechModel(repoId: string): Promise<Model> {
|
|
132
|
-
const textToSpeechModels = await this.textToSpeechModels();
|
|
133
|
-
const textToSpeechModel = textToSpeechModels.find((model) => model.repoId === repoId);
|
|
134
|
-
return unwrapOrThrow(textToSpeechModel, EngineErrorCode.ModelNotFound);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
textToSpeechSession(model: Model): TextToSpeechSession {
|
|
138
|
-
const napiModel = model.toNapi();
|
|
139
|
-
return new TextToSpeechSession(this.napiEngine.createTextToSpeechSession(napiModel));
|
|
140
|
-
}
|
|
141
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import * as z from 'zod';
|
|
2
|
-
import { GrammarConfig as NapiGrammarConfig } from '../napi/uzu';
|
|
3
|
-
import { ToNapi } from './napi';
|
|
4
|
-
|
|
5
|
-
export class GrammarConfig implements ToNapi<NapiGrammarConfig> {
|
|
6
|
-
private readonly napiGrammarConfig: NapiGrammarConfig;
|
|
7
|
-
|
|
8
|
-
private constructor(napiGrammarConfig: NapiGrammarConfig) {
|
|
9
|
-
this.napiGrammarConfig = napiGrammarConfig;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
static jsonSchema(schema: string): GrammarConfig {
|
|
13
|
-
let a = z.object({
|
|
14
|
-
name: z.string(),
|
|
15
|
-
age: z.number(),
|
|
16
|
-
});
|
|
17
|
-
const napiGrammarConfig: NapiGrammarConfig = { type: 'JsonSchema', schema: schema };
|
|
18
|
-
return new GrammarConfig(napiGrammarConfig);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
static regex(pattern: string): GrammarConfig {
|
|
22
|
-
const napiGrammarConfig: NapiGrammarConfig = { type: 'Regex', pattern: pattern };
|
|
23
|
-
return new GrammarConfig(napiGrammarConfig);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
static builtinJson(): GrammarConfig {
|
|
27
|
-
const napiGrammarConfig: NapiGrammarConfig = { type: 'BuiltinJson' };
|
|
28
|
-
return new GrammarConfig(napiGrammarConfig);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
static fromType(type: z.ZodType): GrammarConfig {
|
|
32
|
-
let schema = z.toJSONSchema(type);
|
|
33
|
-
let schemaString = JSON.stringify(schema);
|
|
34
|
-
return GrammarConfig.jsonSchema(schemaString);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
toNapi(): NapiGrammarConfig {
|
|
38
|
-
return this.napiGrammarConfig;
|
|
39
|
-
}
|
|
40
|
-
}
|
package/src/bridging/input.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Input as NapiInput, Message as NapiMessage } from '../napi/uzu';
|
|
2
|
-
import { Message } from './message';
|
|
3
|
-
import { ToNapi } from './napi';
|
|
4
|
-
|
|
5
|
-
export class Input implements ToNapi<NapiInput> {
|
|
6
|
-
private readonly napiInput: NapiInput;
|
|
7
|
-
|
|
8
|
-
private constructor(napiInput: NapiInput) {
|
|
9
|
-
this.napiInput = napiInput;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
static text(text: string): Input {
|
|
13
|
-
const napiInput: NapiInput = { type: 'Text', text };
|
|
14
|
-
return new Input(napiInput);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
static messages(messages: Message[]): Input {
|
|
18
|
-
const napiMessages: NapiMessage[] = messages.map((message) => message.toNapi());
|
|
19
|
-
const napiInput: NapiInput = {
|
|
20
|
-
type: 'Messages',
|
|
21
|
-
messages: napiMessages,
|
|
22
|
-
};
|
|
23
|
-
return new Input(napiInput);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
toNapi(): NapiInput {
|
|
27
|
-
return this.napiInput;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { EngineError, EngineErrorCode } from '../error';
|
|
2
|
-
import { LicenseStatus as NapiLicenseStatus } from '../napi/uzu';
|
|
3
|
-
|
|
4
|
-
export enum LicenseStatus {
|
|
5
|
-
NotActivated = 'NotActivated',
|
|
6
|
-
PaymentRequired = 'PaymentRequired',
|
|
7
|
-
GracePeriodActive = 'GracePeriodActive',
|
|
8
|
-
Activated = 'Activated',
|
|
9
|
-
NetworkError = 'NetworkError',
|
|
10
|
-
InvalidApiKey = 'InvalidApiKey',
|
|
11
|
-
SignatureMismatch = 'SignatureMismatch',
|
|
12
|
-
Timeout = 'Timeout',
|
|
13
|
-
HttpError = 'HttpError',
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function licenseStatusFromNapiLicenseStatus(napiLicenseStatus: NapiLicenseStatus): LicenseStatus {
|
|
17
|
-
switch (napiLicenseStatus.type) {
|
|
18
|
-
case 'NotActivated':
|
|
19
|
-
return LicenseStatus.NotActivated;
|
|
20
|
-
case 'PaymentRequired':
|
|
21
|
-
return LicenseStatus.PaymentRequired;
|
|
22
|
-
case 'GracePeriodActive':
|
|
23
|
-
return LicenseStatus.GracePeriodActive;
|
|
24
|
-
case 'Activated':
|
|
25
|
-
return LicenseStatus.Activated;
|
|
26
|
-
case 'NetworkError':
|
|
27
|
-
return LicenseStatus.NetworkError;
|
|
28
|
-
case 'InvalidApiKey':
|
|
29
|
-
return LicenseStatus.InvalidApiKey;
|
|
30
|
-
case 'SignatureMismatch':
|
|
31
|
-
return LicenseStatus.SignatureMismatch;
|
|
32
|
-
case 'Timeout':
|
|
33
|
-
return LicenseStatus.Timeout;
|
|
34
|
-
case 'HttpError':
|
|
35
|
-
return LicenseStatus.HttpError;
|
|
36
|
-
default:
|
|
37
|
-
throw new EngineError(EngineErrorCode.UnexpectedLicenseStatus);
|
|
38
|
-
}
|
|
39
|
-
}
|
package/src/bridging/message.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { Message as NapiMessage, Role as NapiRole } from '../napi/uzu';
|
|
2
|
-
import { ToNapi } from './napi';
|
|
3
|
-
import { Role } from './role';
|
|
4
|
-
|
|
5
|
-
export class Message implements ToNapi<NapiMessage> {
|
|
6
|
-
readonly role: Role;
|
|
7
|
-
readonly content: string;
|
|
8
|
-
readonly reasoningContent: string | null;
|
|
9
|
-
|
|
10
|
-
private constructor(role: Role, content: string, reasoningContent: string | null = null) {
|
|
11
|
-
this.role = role;
|
|
12
|
-
this.content = content;
|
|
13
|
-
this.reasoningContent = reasoningContent;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
static system(content: string): Message {
|
|
17
|
-
return new Message(Role.System, content);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
static user(content: string): Message {
|
|
21
|
-
return new Message(Role.User, content);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
static assistant(content: string, reasoningContent: string | null = null): Message {
|
|
25
|
-
return new Message(Role.Assistant, content, reasoningContent);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
private static roleToNapiRole(role: Role): NapiRole {
|
|
29
|
-
switch (role) {
|
|
30
|
-
case Role.System:
|
|
31
|
-
return 0;
|
|
32
|
-
case Role.User:
|
|
33
|
-
return 1;
|
|
34
|
-
case Role.Assistant:
|
|
35
|
-
return 2;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
toNapi(): NapiMessage {
|
|
40
|
-
const napiRole: NapiRole = Message.roleToNapiRole(this.role);
|
|
41
|
-
const napiMessage: NapiMessage = {
|
|
42
|
-
role: napiRole,
|
|
43
|
-
content: this.content,
|
|
44
|
-
};
|
|
45
|
-
if (this.reasoningContent) {
|
|
46
|
-
napiMessage.reasoningContent = this.reasoningContent;
|
|
47
|
-
}
|
|
48
|
-
return napiMessage;
|
|
49
|
-
}
|
|
50
|
-
}
|