@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
package/src/bridging/model.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { Model as NapiModel } from '../napi/uzu';
|
|
2
|
-
import { ClassificationLabel } from './classificationLabel';
|
|
3
|
-
import { ModelKind, modelKindFromNapiModelKind, modelKindToNapiModelKind } from './modelKind';
|
|
4
|
-
import { ModelType, modelTypeFromNapiModelType, modelTypeToNapiModelType } from './modelType';
|
|
5
|
-
|
|
6
|
-
export class Model {
|
|
7
|
-
readonly repoId: string;
|
|
8
|
-
readonly type: ModelType;
|
|
9
|
-
readonly kind: ModelKind;
|
|
10
|
-
readonly name: string;
|
|
11
|
-
readonly vendor: string;
|
|
12
|
-
readonly quantization: string | null;
|
|
13
|
-
readonly outputParserRegex: string | null;
|
|
14
|
-
readonly classificationLabels: ClassificationLabel[];
|
|
15
|
-
|
|
16
|
-
get isThinking(): boolean {
|
|
17
|
-
return this.outputParserRegex !== null;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
private constructor(
|
|
21
|
-
repoId: string,
|
|
22
|
-
type: ModelType,
|
|
23
|
-
kind: ModelKind,
|
|
24
|
-
name: string,
|
|
25
|
-
vendor: string,
|
|
26
|
-
quantization: string | null,
|
|
27
|
-
outputParserRegex: string | null,
|
|
28
|
-
classificationLabels: ClassificationLabel[],
|
|
29
|
-
) {
|
|
30
|
-
this.repoId = repoId;
|
|
31
|
-
this.type = type;
|
|
32
|
-
this.kind = kind;
|
|
33
|
-
this.name = name;
|
|
34
|
-
this.vendor = vendor;
|
|
35
|
-
this.quantization = quantization;
|
|
36
|
-
this.outputParserRegex = outputParserRegex;
|
|
37
|
-
this.classificationLabels = classificationLabels;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
static fromNapiModel(napiModel: NapiModel): Model {
|
|
41
|
-
return new Model(
|
|
42
|
-
napiModel.repoId,
|
|
43
|
-
modelTypeFromNapiModelType(napiModel.type),
|
|
44
|
-
modelKindFromNapiModelKind(napiModel.kind),
|
|
45
|
-
napiModel.name,
|
|
46
|
-
napiModel.vendor,
|
|
47
|
-
napiModel.quantization ?? null,
|
|
48
|
-
napiModel.outputParserRegex ?? null,
|
|
49
|
-
napiModel.classificationLabels.map(ClassificationLabel.fromNapi),
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
toNapi(): NapiModel {
|
|
54
|
-
const napiModel: NapiModel = {
|
|
55
|
-
repoId: this.repoId,
|
|
56
|
-
type: modelTypeToNapiModelType(this.type),
|
|
57
|
-
kind: modelKindToNapiModelKind(this.kind),
|
|
58
|
-
name: this.name,
|
|
59
|
-
vendor: this.vendor,
|
|
60
|
-
...(this.quantization !== null && { quantization: this.quantization }),
|
|
61
|
-
...(this.outputParserRegex !== null && { outputParserRegex: this.outputParserRegex }),
|
|
62
|
-
classificationLabels: this.classificationLabels.map((classificationLabel) =>
|
|
63
|
-
classificationLabel.toNapi(),
|
|
64
|
-
),
|
|
65
|
-
};
|
|
66
|
-
return napiModel;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { EngineError, EngineErrorCode } from '../error';
|
|
2
|
-
import { ModelKind as NapiModelKind } from '../napi/uzu';
|
|
3
|
-
|
|
4
|
-
export enum ModelKind {
|
|
5
|
-
Local = 'Local',
|
|
6
|
-
Cloud = 'Cloud',
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function modelKindFromNapiModelKind(napiModelKind: NapiModelKind): ModelKind {
|
|
10
|
-
switch (napiModelKind) {
|
|
11
|
-
case 0:
|
|
12
|
-
return ModelKind.Local;
|
|
13
|
-
case 1:
|
|
14
|
-
return ModelKind.Cloud;
|
|
15
|
-
default:
|
|
16
|
-
throw new EngineError(EngineErrorCode.UnexpectedModelKind);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function modelKindToNapiModelKind(modelKind: ModelKind): NapiModelKind {
|
|
21
|
-
switch (modelKind) {
|
|
22
|
-
case ModelKind.Local:
|
|
23
|
-
return 0;
|
|
24
|
-
case ModelKind.Cloud:
|
|
25
|
-
return 1;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { EngineError, EngineErrorCode } from '../error';
|
|
2
|
-
import { ModelType as NapiModelType } from '../napi/uzu';
|
|
3
|
-
|
|
4
|
-
export enum ModelType {
|
|
5
|
-
Chat = 'Chat',
|
|
6
|
-
Classification = 'Classification',
|
|
7
|
-
TTS = 'TTS',
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function modelTypeFromNapiModelType(napiModelType: NapiModelType): ModelType {
|
|
11
|
-
switch (napiModelType) {
|
|
12
|
-
case 0:
|
|
13
|
-
return ModelType.Chat;
|
|
14
|
-
case 1:
|
|
15
|
-
return ModelType.Classification;
|
|
16
|
-
case 2:
|
|
17
|
-
return ModelType.TTS;
|
|
18
|
-
default:
|
|
19
|
-
throw new EngineError(EngineErrorCode.UnexpectedModelType);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function modelTypeToNapiModelType(modelType: ModelType): NapiModelType {
|
|
24
|
-
switch (modelType) {
|
|
25
|
-
case ModelType.Chat:
|
|
26
|
-
return 0;
|
|
27
|
-
case ModelType.Classification:
|
|
28
|
-
return 1;
|
|
29
|
-
case ModelType.TTS:
|
|
30
|
-
return 2;
|
|
31
|
-
}
|
|
32
|
-
}
|
package/src/bridging/napi.ts
DELETED
package/src/bridging/output.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { EngineError, EngineErrorCode } from '../error';
|
|
2
|
-
import { FinishReason as NapiFinishReason, Output as NapiOutput } from '../napi/uzu';
|
|
3
|
-
import { FinishReason } from './finishReason';
|
|
4
|
-
import { Stats } from './stats';
|
|
5
|
-
import { Text } from './text';
|
|
6
|
-
|
|
7
|
-
export class Output {
|
|
8
|
-
readonly text: Text;
|
|
9
|
-
readonly stats: Stats;
|
|
10
|
-
readonly finishReason: FinishReason | null;
|
|
11
|
-
|
|
12
|
-
private constructor(text: Text, stats: Stats, finishReason: FinishReason | null) {
|
|
13
|
-
this.text = text;
|
|
14
|
-
this.stats = stats;
|
|
15
|
-
this.finishReason = finishReason;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
private static napiFinishReasonToFinishReason(napiFinishReason: NapiFinishReason): FinishReason {
|
|
19
|
-
switch (napiFinishReason) {
|
|
20
|
-
case 0:
|
|
21
|
-
return FinishReason.Stop;
|
|
22
|
-
case 1:
|
|
23
|
-
return FinishReason.Length;
|
|
24
|
-
case 2:
|
|
25
|
-
return FinishReason.Cancelled;
|
|
26
|
-
case 3:
|
|
27
|
-
return FinishReason.ContextLimitReached;
|
|
28
|
-
default:
|
|
29
|
-
throw new EngineError(EngineErrorCode.UnexpectedFinishReason);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
static fromNapi(napiEntity: NapiOutput): Output {
|
|
34
|
-
const text = Text.fromNapi(napiEntity.text);
|
|
35
|
-
const stats = Stats.fromNapi(napiEntity.stats);
|
|
36
|
-
const finishReason =
|
|
37
|
-
napiEntity.finishReason ? Output.napiFinishReasonToFinishReason(napiEntity.finishReason) : null;
|
|
38
|
-
return new Output(text, stats, finishReason);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import * as z from 'zod';
|
|
2
|
-
import { ParsedText as NapiParsedText } from '../napi/uzu';
|
|
3
|
-
|
|
4
|
-
export class ParsedText {
|
|
5
|
-
readonly chainOfThought: string | null;
|
|
6
|
-
readonly response: string | null;
|
|
7
|
-
|
|
8
|
-
private constructor(chainOfThought: string | null, response: string | null) {
|
|
9
|
-
this.chainOfThought = chainOfThought;
|
|
10
|
-
this.response = response;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
static fromNapi(napiEntity: NapiParsedText): ParsedText {
|
|
14
|
-
const chainOfThought = napiEntity.chainOfThought ?? null;
|
|
15
|
-
const response = napiEntity.response ?? null;
|
|
16
|
-
return new ParsedText(chainOfThought, response);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
structuredResponse<T extends z.ZodType>(type: T): z.infer<T> | null {
|
|
20
|
-
if (this.response === null) {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
const data = JSON.parse(this.response);
|
|
24
|
-
const result = type.parse(data);
|
|
25
|
-
return result;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { PrefillStepSize as NapiPrefillStepSize } from '../napi/uzu';
|
|
2
|
-
import { ToNapi } from './napi';
|
|
3
|
-
|
|
4
|
-
export class PrefillStepSize implements ToNapi<NapiPrefillStepSize> {
|
|
5
|
-
private readonly napiPrefillStepSize: NapiPrefillStepSize;
|
|
6
|
-
|
|
7
|
-
private constructor(napiPrefillStepSize: NapiPrefillStepSize) {
|
|
8
|
-
this.napiPrefillStepSize = napiPrefillStepSize;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
static default(): PrefillStepSize {
|
|
12
|
-
const napiPrefillStepSize: NapiPrefillStepSize = { type: 'Default' };
|
|
13
|
-
return new PrefillStepSize(napiPrefillStepSize);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
static maximal(): PrefillStepSize {
|
|
17
|
-
const napiPrefillStepSize: NapiPrefillStepSize = { type: 'Maximal' };
|
|
18
|
-
return new PrefillStepSize(napiPrefillStepSize);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
static custom(length: number): PrefillStepSize {
|
|
22
|
-
const napiPrefillStepSize: NapiPrefillStepSize = {
|
|
23
|
-
type: 'Custom',
|
|
24
|
-
length,
|
|
25
|
-
};
|
|
26
|
-
return new PrefillStepSize(napiPrefillStepSize);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
toNapi(): NapiPrefillStepSize {
|
|
30
|
-
return this.napiPrefillStepSize;
|
|
31
|
-
}
|
|
32
|
-
}
|
package/src/bridging/preset.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { Preset as NapiPreset } from '../napi/uzu';
|
|
2
|
-
import { ClassificationFeature } from './classificationFeature';
|
|
3
|
-
import { ToNapi } from './napi';
|
|
4
|
-
|
|
5
|
-
export class Preset implements ToNapi<NapiPreset> {
|
|
6
|
-
private readonly napiPreset: NapiPreset;
|
|
7
|
-
|
|
8
|
-
private constructor(napiPreset: NapiPreset) {
|
|
9
|
-
this.napiPreset = napiPreset;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
static general(): Preset {
|
|
13
|
-
const napiPreset: NapiPreset = { type: 'General' };
|
|
14
|
-
return new Preset(napiPreset);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
static classification(feature: ClassificationFeature): Preset {
|
|
18
|
-
const napiClassificationFeature = feature.toNapi();
|
|
19
|
-
const napiPreset: NapiPreset = {
|
|
20
|
-
type: 'Classification',
|
|
21
|
-
feature: napiClassificationFeature,
|
|
22
|
-
};
|
|
23
|
-
return new Preset(napiPreset);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
static summarization(): Preset {
|
|
27
|
-
const napiPreset: NapiPreset = { type: 'Summarization' };
|
|
28
|
-
return new Preset(napiPreset);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
static nGramSpeculator(useCase: string, numberOfSpeculatedTokens: number): Preset {
|
|
32
|
-
const napiPreset: NapiPreset = {
|
|
33
|
-
type: 'NGramSpeculator',
|
|
34
|
-
useCase,
|
|
35
|
-
numberOfSpeculatedTokens,
|
|
36
|
-
};
|
|
37
|
-
return new Preset(napiPreset);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
static chat(): Preset {
|
|
41
|
-
const napiPreset: NapiPreset = { type: 'Chat' };
|
|
42
|
-
return new Preset(napiPreset);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
toNapi(): NapiPreset {
|
|
46
|
-
return this.napiPreset;
|
|
47
|
-
}
|
|
48
|
-
}
|
package/src/bridging/role.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { RunConfig as NapiRunConfig } from '../napi/uzu';
|
|
2
|
-
import { GrammarConfig } from './grammarConfig';
|
|
3
|
-
import { ToNapi } from './napi';
|
|
4
|
-
import { SamplingPolicy } from './samplingPolicy';
|
|
5
|
-
|
|
6
|
-
export class RunConfig implements ToNapi<NapiRunConfig> {
|
|
7
|
-
readonly tokensLimit: number;
|
|
8
|
-
readonly enableThinking: boolean;
|
|
9
|
-
readonly samplingPolicy: SamplingPolicy;
|
|
10
|
-
readonly grammarConfig: GrammarConfig | null;
|
|
11
|
-
|
|
12
|
-
private constructor(
|
|
13
|
-
tokensLimit: number,
|
|
14
|
-
enableThinking: boolean,
|
|
15
|
-
samplingPolicy: SamplingPolicy,
|
|
16
|
-
grammarConfig: GrammarConfig | null,
|
|
17
|
-
) {
|
|
18
|
-
this.tokensLimit = tokensLimit;
|
|
19
|
-
this.enableThinking = enableThinking;
|
|
20
|
-
this.samplingPolicy = samplingPolicy;
|
|
21
|
-
this.grammarConfig = grammarConfig;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
static default(): RunConfig {
|
|
25
|
-
return new RunConfig(1024, true, SamplingPolicy.default(), null);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
withTokensLimit(tokensLimit: number): RunConfig {
|
|
29
|
-
return new RunConfig(tokensLimit, this.enableThinking, this.samplingPolicy, this.grammarConfig);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
withEnableThinking(enableThinking: boolean): RunConfig {
|
|
33
|
-
return new RunConfig(this.tokensLimit, enableThinking, this.samplingPolicy, this.grammarConfig);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
withSamplingPolicy(samplingPolicy: SamplingPolicy): RunConfig {
|
|
37
|
-
return new RunConfig(this.tokensLimit, this.enableThinking, samplingPolicy, this.grammarConfig);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
withGrammarConfig(grammarConfig: GrammarConfig | null): RunConfig {
|
|
41
|
-
return new RunConfig(this.tokensLimit, this.enableThinking, this.samplingPolicy, grammarConfig);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
toNapi(): NapiRunConfig {
|
|
45
|
-
const napiSamplingPolicy = this.samplingPolicy.toNapi();
|
|
46
|
-
let napiRunConfig: NapiRunConfig = {
|
|
47
|
-
tokensLimit: this.tokensLimit,
|
|
48
|
-
enableThinking: this.enableThinking,
|
|
49
|
-
samplingPolicy: napiSamplingPolicy,
|
|
50
|
-
};
|
|
51
|
-
if (this.grammarConfig !== null) {
|
|
52
|
-
let napiGrammarConfig = this.grammarConfig.toNapi();
|
|
53
|
-
napiRunConfig.grammarConfig = napiGrammarConfig;
|
|
54
|
-
}
|
|
55
|
-
return napiRunConfig;
|
|
56
|
-
}
|
|
57
|
-
}
|
package/src/bridging/runStats.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { RunStats as NapiRunStats } from '../napi/uzu';
|
|
2
|
-
|
|
3
|
-
export class RunStats {
|
|
4
|
-
readonly count: number;
|
|
5
|
-
readonly averageDuration: number;
|
|
6
|
-
|
|
7
|
-
private constructor(count: number, averageDuration: number) {
|
|
8
|
-
this.count = count;
|
|
9
|
-
this.averageDuration = averageDuration;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
static fromNapi(napiEntity: NapiRunStats): RunStats {
|
|
13
|
-
const count = Number(napiEntity.count);
|
|
14
|
-
const averageDuration = napiEntity.averageDuration;
|
|
15
|
-
return new RunStats(count, averageDuration);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { SamplingMethod as NapiSamplingMethod } from '../napi/uzu';
|
|
2
|
-
import { ToNapi } from './napi';
|
|
3
|
-
import {
|
|
4
|
-
SamplingProcessingOrder,
|
|
5
|
-
samplingProcessingOrderToNapiSamplingProcessingOrder,
|
|
6
|
-
} from './samplingProcessingOrder';
|
|
7
|
-
|
|
8
|
-
export class SamplingMethod implements ToNapi<NapiSamplingMethod> {
|
|
9
|
-
private readonly napiSamplingMethod: NapiSamplingMethod;
|
|
10
|
-
|
|
11
|
-
private constructor(napiSamplingMethod: NapiSamplingMethod) {
|
|
12
|
-
this.napiSamplingMethod = napiSamplingMethod;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
static greedy(): SamplingMethod {
|
|
16
|
-
const napiSamplingMethod: NapiSamplingMethod = { type: 'Greedy' };
|
|
17
|
-
return new SamplingMethod(napiSamplingMethod);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
static stochastic(
|
|
21
|
-
temperature: number | null,
|
|
22
|
-
topK: number | null,
|
|
23
|
-
topP: number | null,
|
|
24
|
-
minP: number | null,
|
|
25
|
-
processingOrder: SamplingProcessingOrder,
|
|
26
|
-
): SamplingMethod {
|
|
27
|
-
let napiSamplingMethod: NapiSamplingMethod = {
|
|
28
|
-
type: 'Stochastic',
|
|
29
|
-
processingOrder: samplingProcessingOrderToNapiSamplingProcessingOrder(processingOrder),
|
|
30
|
-
};
|
|
31
|
-
if (temperature !== null) {
|
|
32
|
-
napiSamplingMethod.temperature = temperature;
|
|
33
|
-
}
|
|
34
|
-
if (topK !== null) {
|
|
35
|
-
napiSamplingMethod.topK = topK;
|
|
36
|
-
}
|
|
37
|
-
if (topP !== null) {
|
|
38
|
-
napiSamplingMethod.topP = topP;
|
|
39
|
-
}
|
|
40
|
-
if (minP !== null) {
|
|
41
|
-
napiSamplingMethod.minP = minP;
|
|
42
|
-
}
|
|
43
|
-
return new SamplingMethod(napiSamplingMethod);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
toNapi(): NapiSamplingMethod {
|
|
47
|
-
return this.napiSamplingMethod;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { SamplingPolicy as NapiSamplingPolicy } from '../napi/uzu';
|
|
2
|
-
import { ToNapi } from './napi';
|
|
3
|
-
import { SamplingMethod } from './samplingMethod';
|
|
4
|
-
|
|
5
|
-
export class SamplingPolicy implements ToNapi<NapiSamplingPolicy> {
|
|
6
|
-
private readonly napiSamplingPolicy: NapiSamplingPolicy;
|
|
7
|
-
|
|
8
|
-
private constructor(napiSamplingPolicy: NapiSamplingPolicy) {
|
|
9
|
-
this.napiSamplingPolicy = napiSamplingPolicy;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
static default(): SamplingPolicy {
|
|
13
|
-
const napiSamplingPolicy: NapiSamplingPolicy = { type: 'Default' };
|
|
14
|
-
return new SamplingPolicy(napiSamplingPolicy);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
static custom(method: SamplingMethod): SamplingPolicy {
|
|
18
|
-
const napiSamplingMethod = method.toNapi();
|
|
19
|
-
const napiSamplingPolicy: NapiSamplingPolicy = {
|
|
20
|
-
type: 'Custom',
|
|
21
|
-
value: napiSamplingMethod,
|
|
22
|
-
};
|
|
23
|
-
return new SamplingPolicy(napiSamplingPolicy);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
toNapi(): NapiSamplingPolicy {
|
|
27
|
-
return this.napiSamplingPolicy;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { EngineError, EngineErrorCode } from '../error';
|
|
2
|
-
import { SamplingProcessingOrder as NapiSamplingProcessingOrder } from '../napi/uzu';
|
|
3
|
-
|
|
4
|
-
export enum SamplingProcessingOrder {
|
|
5
|
-
TemperatureThenFilters = 'TemperatureThenFilters',
|
|
6
|
-
FiltersThenTemperature = 'FiltersThenTemperature',
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function samplingProcessingOrderFromNapiSamplingProcessingOrder(
|
|
10
|
-
napiSamplingProcessingOrder: NapiSamplingProcessingOrder,
|
|
11
|
-
): SamplingProcessingOrder {
|
|
12
|
-
switch (napiSamplingProcessingOrder) {
|
|
13
|
-
case 0:
|
|
14
|
-
return SamplingProcessingOrder.TemperatureThenFilters;
|
|
15
|
-
case 1:
|
|
16
|
-
return SamplingProcessingOrder.FiltersThenTemperature;
|
|
17
|
-
default:
|
|
18
|
-
throw new EngineError(EngineErrorCode.UnexpectedSamplingProcessingOrder);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function samplingProcessingOrderToNapiSamplingProcessingOrder(
|
|
23
|
-
samplingProcessingOrder: SamplingProcessingOrder,
|
|
24
|
-
): NapiSamplingProcessingOrder {
|
|
25
|
-
switch (samplingProcessingOrder) {
|
|
26
|
-
case SamplingProcessingOrder.TemperatureThenFilters:
|
|
27
|
-
return 0;
|
|
28
|
-
case SamplingProcessingOrder.FiltersThenTemperature:
|
|
29
|
-
return 1;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { SamplingSeed as NapiSamplingSeed } from '../napi/uzu';
|
|
2
|
-
import { ToNapi } from './napi';
|
|
3
|
-
|
|
4
|
-
export class SamplingSeed implements ToNapi<NapiSamplingSeed> {
|
|
5
|
-
private readonly napiSamplingSeed: NapiSamplingSeed;
|
|
6
|
-
|
|
7
|
-
private constructor(napiSamplingSeed: NapiSamplingSeed) {
|
|
8
|
-
this.napiSamplingSeed = napiSamplingSeed;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
static default(): SamplingSeed {
|
|
12
|
-
const napiSamplingSeed: NapiSamplingSeed = { type: 'Default' };
|
|
13
|
-
return new SamplingSeed(napiSamplingSeed);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
static custom(seed: number): SamplingSeed {
|
|
17
|
-
const napiSamplingSeed: NapiSamplingSeed = { type: 'Custom', seed };
|
|
18
|
-
return new SamplingSeed(napiSamplingSeed);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
toNapi(): NapiSamplingSeed {
|
|
22
|
-
return this.napiSamplingSeed;
|
|
23
|
-
}
|
|
24
|
-
}
|
package/src/bridging/stats.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Stats as NapiStats } from '../napi/uzu';
|
|
2
|
-
import { StepStats } from './stepStats';
|
|
3
|
-
import { TotalStats } from './totalStats';
|
|
4
|
-
|
|
5
|
-
export class Stats {
|
|
6
|
-
readonly prefillStats: StepStats;
|
|
7
|
-
readonly generateStats: StepStats | null;
|
|
8
|
-
readonly totalStats: TotalStats;
|
|
9
|
-
|
|
10
|
-
private constructor(prefillStats: StepStats, generateStats: StepStats | null, totalStats: TotalStats) {
|
|
11
|
-
this.prefillStats = prefillStats;
|
|
12
|
-
this.generateStats = generateStats;
|
|
13
|
-
this.totalStats = totalStats;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
static fromNapi(napiEntity: NapiStats): Stats {
|
|
17
|
-
const prefillStats = StepStats.fromNapi(napiEntity.prefillStats);
|
|
18
|
-
const generateStats = napiEntity.generateStats ? StepStats.fromNapi(napiEntity.generateStats) : null;
|
|
19
|
-
const totalStats = TotalStats.fromNapi(napiEntity.totalStats);
|
|
20
|
-
return new Stats(prefillStats, generateStats, totalStats);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { StepStats as NapiStepStats } from '../napi/uzu';
|
|
2
|
-
import { RunStats } from './runStats';
|
|
3
|
-
|
|
4
|
-
export class StepStats {
|
|
5
|
-
readonly duration: number;
|
|
6
|
-
readonly suffixLength: number;
|
|
7
|
-
readonly tokensCount: number;
|
|
8
|
-
readonly tokensPerSecond: number;
|
|
9
|
-
readonly processedTokensPerSecond: number;
|
|
10
|
-
readonly modelRun: RunStats;
|
|
11
|
-
readonly run: RunStats | null;
|
|
12
|
-
|
|
13
|
-
private constructor(
|
|
14
|
-
duration: number,
|
|
15
|
-
suffixLength: number,
|
|
16
|
-
tokensCount: number,
|
|
17
|
-
tokensPerSecond: number,
|
|
18
|
-
processedTokensPerSecond: number,
|
|
19
|
-
modelRun: RunStats,
|
|
20
|
-
run: RunStats | null,
|
|
21
|
-
) {
|
|
22
|
-
this.duration = duration;
|
|
23
|
-
this.suffixLength = suffixLength;
|
|
24
|
-
this.tokensCount = tokensCount;
|
|
25
|
-
this.tokensPerSecond = tokensPerSecond;
|
|
26
|
-
this.processedTokensPerSecond = processedTokensPerSecond;
|
|
27
|
-
this.modelRun = modelRun;
|
|
28
|
-
this.run = run;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
static fromNapi(napiEntity: NapiStepStats): StepStats {
|
|
32
|
-
const duration = napiEntity.duration;
|
|
33
|
-
const suffixLength = Number(napiEntity.suffixLength);
|
|
34
|
-
const tokensCount = Number(napiEntity.tokensCount);
|
|
35
|
-
const tokensPerSecond = napiEntity.tokensPerSecond;
|
|
36
|
-
const processedTokensPerSecond = napiEntity.processedTokensPerSecond;
|
|
37
|
-
const modelRun = RunStats.fromNapi(napiEntity.modelRun);
|
|
38
|
-
const run = napiEntity.run ? RunStats.fromNapi(napiEntity.run) : null;
|
|
39
|
-
return new StepStats(
|
|
40
|
-
duration,
|
|
41
|
-
suffixLength,
|
|
42
|
-
tokensCount,
|
|
43
|
-
tokensPerSecond,
|
|
44
|
-
processedTokensPerSecond,
|
|
45
|
-
modelRun,
|
|
46
|
-
run,
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
}
|
package/src/bridging/text.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Text as NapiText } from '../napi/uzu';
|
|
2
|
-
import { ParsedText } from './parsedText';
|
|
3
|
-
|
|
4
|
-
export class Text {
|
|
5
|
-
readonly original: string;
|
|
6
|
-
readonly parsed: ParsedText;
|
|
7
|
-
|
|
8
|
-
private constructor(original: string, parsed: ParsedText) {
|
|
9
|
-
this.original = original;
|
|
10
|
-
this.parsed = parsed;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
static fromNapi(napiEntity: NapiText): Text {
|
|
14
|
-
const original = napiEntity.original;
|
|
15
|
-
const parsed = ParsedText.fromNapi(napiEntity.parsed);
|
|
16
|
-
return new Text(original, parsed);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { TextToSpeechSession as NapiTextToSpeechSession } from '../napi/uzu';
|
|
2
|
-
import { Input } from './input';
|
|
3
|
-
|
|
4
|
-
export class TextToSpeechSession {
|
|
5
|
-
private readonly napiTextToSpeechSession: NapiTextToSpeechSession;
|
|
6
|
-
|
|
7
|
-
constructor(napiTextToSpeechSession: NapiTextToSpeechSession) {
|
|
8
|
-
this.napiTextToSpeechSession = napiTextToSpeechSession;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
run(input: Input, outputPath: string): void {
|
|
12
|
-
const napiInput = input.toNapi();
|
|
13
|
-
this.napiTextToSpeechSession.run(napiInput, outputPath);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { TotalStats as NapiTotalStats } from '../napi/uzu';
|
|
2
|
-
|
|
3
|
-
export class TotalStats {
|
|
4
|
-
readonly duration: number;
|
|
5
|
-
readonly tokensCountInput: number;
|
|
6
|
-
readonly tokensCountOutput: number;
|
|
7
|
-
|
|
8
|
-
private constructor(duration: number, tokensCountInput: number, tokensCountOutput: number) {
|
|
9
|
-
this.duration = duration;
|
|
10
|
-
this.tokensCountInput = tokensCountInput;
|
|
11
|
-
this.tokensCountOutput = tokensCountOutput;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
static fromNapi(napiEntity: NapiTotalStats): TotalStats {
|
|
15
|
-
const duration = napiEntity.duration;
|
|
16
|
-
const tokensCountInput = Number(napiEntity.tokensCountInput);
|
|
17
|
-
const tokensCountOutput = Number(napiEntity.tokensCountOutput);
|
|
18
|
-
return new TotalStats(duration, tokensCountInput, tokensCountOutput);
|
|
19
|
-
}
|
|
20
|
-
}
|
package/src/error.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
export enum EngineErrorCode {
|
|
2
|
-
APIKeyNotFound = 'apiKeyNotFound',
|
|
3
|
-
ModelNotFound = 'modelNotFound',
|
|
4
|
-
ExpectedLocalModel = 'expectedLocalModel',
|
|
5
|
-
UnexpectedDownloadPhase = 'unexpectedDownloadPhase',
|
|
6
|
-
UnexpectedFinishReason = 'unexpectedFinishReason',
|
|
7
|
-
UnexpectedLicenseStatus = 'unexpectedLicenseStatus',
|
|
8
|
-
UnexpectedModelType = 'unexpectedModelType',
|
|
9
|
-
UnexpectedModelKind = 'unexpectedModelKind',
|
|
10
|
-
UnexpectedSamplingProcessingOrder = 'unexpectedSamplingProcessingOrder',
|
|
11
|
-
LicenseNotActivated = 'licenseNotActivated',
|
|
12
|
-
Unknown = 'unknown',
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const errorCodeToMessage = {
|
|
16
|
-
[EngineErrorCode.APIKeyNotFound]: 'API key not found',
|
|
17
|
-
[EngineErrorCode.ModelNotFound]: 'Model not found',
|
|
18
|
-
[EngineErrorCode.ExpectedLocalModel]: 'Expected local model',
|
|
19
|
-
[EngineErrorCode.UnexpectedDownloadPhase]: 'Unexpected download phase',
|
|
20
|
-
[EngineErrorCode.UnexpectedFinishReason]: 'Unexpected finish reason',
|
|
21
|
-
[EngineErrorCode.UnexpectedLicenseStatus]: 'Unexpected license status',
|
|
22
|
-
[EngineErrorCode.UnexpectedModelType]: 'Unexpected model type',
|
|
23
|
-
[EngineErrorCode.UnexpectedModelKind]: 'Unexpected model kind',
|
|
24
|
-
[EngineErrorCode.UnexpectedSamplingProcessingOrder]: 'Unexpected sampling processing order',
|
|
25
|
-
[EngineErrorCode.LicenseNotActivated]: 'License not activated',
|
|
26
|
-
[EngineErrorCode.Unknown]: 'Unknown error',
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export class EngineError extends Error {
|
|
30
|
-
constructor(code: EngineErrorCode) {
|
|
31
|
-
const message = errorCodeToMessage[code] ?? errorCodeToMessage[EngineErrorCode.Unknown];
|
|
32
|
-
super(message);
|
|
33
|
-
this.name = 'EngineError';
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function unwrapOrThrow<T>(value: T | null | undefined, errorCode: EngineErrorCode): T {
|
|
38
|
-
if (value === null || value === undefined) {
|
|
39
|
-
throw new EngineError(errorCode);
|
|
40
|
-
}
|
|
41
|
-
return value;
|
|
42
|
-
}
|