@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/LICENSE
CHANGED
|
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -4,81 +4,60 @@
|
|
|
4
4
|
</picture>
|
|
5
5
|
</p>
|
|
6
6
|
|
|
7
|
-
<a href="https://discord.com/invite/trymirai"><img src="https://img.shields.io/discord/1377764166764462120?label=Discord" alt="Discord"></a>
|
|
8
|
-
<a href="mailto:contact@getmirai.co?subject=Interested%20in%20Mirai"><img src="https://img.shields.io/badge/Send-Email-green" alt="Contact us"></a>
|
|
9
|
-
<a href="https://docs.trymirai.com/app-integration/overview"><img src="https://img.shields.io/badge/Read-Docs-blue" alt="Read docs"></a>
|
|
10
|
-
[](https://www.npmjs.com/package/@trymirai/uzu)
|
|
11
|
-
[](LICENSE)
|
|
7
|
+
<a href="https://discord.com/invite/trymirai"><img src="https://img.shields.io/discord/1377764166764462120?label=Discord&color=brightgreen" alt="Discord"></a> <a href="mailto:contact@getmirai.co?subject=Interested%20in%20Mirai"><img src="https://img.shields.io/badge/Send-Email-brightgreen" alt="Contact us"></a> <a href="https://docs.trymirai.com"><img src="https://img.shields.io/badge/Read-Docs-brightgreen" alt="Read docs"></a> [](LICENSE) [](https://github.com/trymirai/uzu/actions) [](bindings/typescript) [](https://www.npmjs.com/package/@trymirai/uzu) [](https://www.npmjs.com/package/@trymirai/uzu)
|
|
12
8
|
|
|
13
|
-
# uzu
|
|
9
|
+
# uzu
|
|
14
10
|
|
|
15
|
-
|
|
11
|
+
A high-performance inference engine for AI models. It allows you to deploy AI directly in your app with **zero latency**, **full data privacy**, and **no inference costs**. Key features:
|
|
16
12
|
|
|
17
13
|
- Simple, high-level API
|
|
18
|
-
-
|
|
14
|
+
- Unified model configurations, making it easy to add support for new models
|
|
15
|
+
- Traceable computations to ensure correctness against the source-of-truth implementation
|
|
16
|
+
- Utilizes unified memory on Apple devices
|
|
19
17
|
- [Broad model support](https://trymirai.com/models)
|
|
20
18
|
|
|
21
19
|
## Quick Start
|
|
22
20
|
|
|
23
|
-
Add the `uzu` dependency to your project's `package.json`:
|
|
24
21
|
|
|
25
|
-
```json
|
|
26
|
-
"dependencies": {
|
|
27
|
-
"@trymirai/uzu": "0.3.1"
|
|
28
|
-
}
|
|
29
|
-
```
|
|
30
22
|
|
|
31
|
-
|
|
23
|
+
Add the dependency:
|
|
32
24
|
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
.create('API_KEY')
|
|
36
|
-
.chatModel('Qwen/Qwen3-0.6B')
|
|
37
|
-
.reply('Tell me a short, funny story about a robot');
|
|
25
|
+
```bash
|
|
26
|
+
pnpm add @trymirai/uzu@0.4.0
|
|
38
27
|
```
|
|
39
28
|
|
|
40
|
-
|
|
29
|
+
Run the code below:
|
|
41
30
|
|
|
42
|
-
|
|
31
|
+
```ts
|
|
32
|
+
import { ChatConfig, ChatMessage, ChatReplyConfig, Engine, EngineConfig } from '@trymirai/uzu';
|
|
43
33
|
|
|
44
|
-
|
|
34
|
+
async function main() {
|
|
35
|
+
let engineConfig = EngineConfig.create();
|
|
36
|
+
let engine = await Engine.create(engineConfig);
|
|
45
37
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
pnpm run tsn examples/chatStaticContext.ts
|
|
51
|
-
pnpm run tsn examples/summarization.ts
|
|
52
|
-
pnpm run tsn examples/classification.ts
|
|
53
|
-
pnpm run tsn examples/cloud.ts
|
|
54
|
-
pnpm run tsn examples/structuredOutput.ts
|
|
55
|
-
pnpm run tsn examples/classifier.ts
|
|
56
|
-
pnpm run tsn examples/textToSpeech.ts
|
|
57
|
-
```
|
|
38
|
+
let model = await engine.model('Qwen/Qwen3-0.6B');
|
|
39
|
+
if (!model) {
|
|
40
|
+
throw new Error('Model not found');
|
|
41
|
+
}
|
|
58
42
|
|
|
59
|
-
|
|
43
|
+
for await (const update of await engine.download(model)) {
|
|
44
|
+
console.log('Download progress:', update.progress);
|
|
45
|
+
}
|
|
60
46
|
|
|
61
|
-
|
|
47
|
+
let session = await engine.chat(model, ChatConfig.create());
|
|
62
48
|
|
|
63
|
-
|
|
64
|
-
|
|
49
|
+
let messages = [
|
|
50
|
+
ChatMessage.system().withText('You are a helpful assistant'),
|
|
51
|
+
ChatMessage.user().withText('Tell me a short, funny story about a robot')
|
|
52
|
+
];
|
|
65
53
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
[
|
|
74
|
-
Message.system('You are a helpful assistant'),
|
|
75
|
-
Message.user('Tell me a short, funny story about a robot')
|
|
76
|
-
],
|
|
77
|
-
(partialOutput) => {
|
|
78
|
-
return true;
|
|
79
|
-
},
|
|
80
|
-
);
|
|
81
|
-
console.log(output.text.original);
|
|
54
|
+
let reply = await session.reply(messages, ChatReplyConfig.create());
|
|
55
|
+
let message = reply[0]?.message;
|
|
56
|
+
|
|
57
|
+
if (message) {
|
|
58
|
+
console.log('Reasoning: ', message.reasoning);
|
|
59
|
+
console.log('Text: ', message.text);
|
|
60
|
+
}
|
|
82
61
|
}
|
|
83
62
|
|
|
84
63
|
main().catch((error) => {
|
|
@@ -86,44 +65,51 @@ main().catch((error) => {
|
|
|
86
65
|
});
|
|
87
66
|
```
|
|
88
67
|
|
|
89
|
-
### Speedup with speculative decoding
|
|
90
68
|
|
|
91
|
-
|
|
69
|
+
<br>
|
|
70
|
+
|
|
71
|
+
Everything from model downloading to inference configuration is handled automatically. Refer to the [documentation](https://docs.trymirai.com) for details on how to customize each step of the process.
|
|
72
|
+
|
|
73
|
+
## Examples
|
|
74
|
+
|
|
75
|
+
You can run any example via `cargo tools example` \<**typescript**\> \<**chat** | **chat-cloud** | **chat-speculation-classification** | **chat-speculation-summarization** | **chat-structured-output** | **classification** | **quick-start** | **text-to-speech**\>:
|
|
76
|
+
|
|
77
|
+
### Chat
|
|
78
|
+
|
|
79
|
+
In this example, we will download a model and get a reply to a specific list of messages:
|
|
92
80
|
|
|
93
81
|
```ts
|
|
94
|
-
import
|
|
82
|
+
import { ChatConfig, ChatMessage, ChatReplyConfig, ChatSessionStreamChunkError, ChatSessionStreamChunkReplies, Engine, EngineConfig } from '@trymirai/uzu';
|
|
95
83
|
|
|
96
84
|
async function main() {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
];
|
|
85
|
+
let engineConfig = EngineConfig.create();
|
|
86
|
+
let engine = await Engine.create(engineConfig);
|
|
87
|
+
|
|
88
|
+
let model = await engine.model('Qwen/Qwen3-0.6B');
|
|
89
|
+
if (!model) {
|
|
90
|
+
throw new Error('Model not found');
|
|
91
|
+
}
|
|
92
|
+
for await (const update of await engine.download(model)) {
|
|
93
|
+
console.log('Download progress:', update.progress);
|
|
94
|
+
}
|
|
108
95
|
|
|
109
|
-
|
|
110
|
-
.
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
console.log('Generation speed t/s (with chat speculator):', outputWithSpeculator.stats.generateStats?.tokensPerSecond ?? 0);
|
|
96
|
+
let messages = [
|
|
97
|
+
ChatMessage.system().withText('You are a helpful assistant'),
|
|
98
|
+
ChatMessage.user().withText('Tell me a short, funny story about a robot')
|
|
99
|
+
];
|
|
100
|
+
let session = await engine.chat(model, ChatConfig.create());
|
|
101
|
+
let stream = await session.replyWithStream(messages, ChatReplyConfig.create());
|
|
102
|
+
let message: ChatMessage | undefined;
|
|
103
|
+
for await (const chunk of stream) {
|
|
104
|
+
if (chunk instanceof ChatSessionStreamChunkReplies) {
|
|
105
|
+
message = chunk.replies[0]?.message;
|
|
106
|
+
console.log('Generated tokens: ', chunk.replies[0]?.stats.tokensCountOutput);
|
|
107
|
+
} else if (chunk instanceof ChatSessionStreamChunkError) {
|
|
108
|
+
console.error('Error: ', chunk.error);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
console.log('Reasoning: ', message?.reasoning);
|
|
112
|
+
console.log('Text: ', message?.text);
|
|
127
113
|
}
|
|
128
114
|
|
|
129
115
|
main().catch((error) => {
|
|
@@ -131,44 +117,35 @@ main().catch((error) => {
|
|
|
131
117
|
});
|
|
132
118
|
```
|
|
133
119
|
|
|
134
|
-
|
|
120
|
+
<br>Once loaded, the same `ChatSession` can be reused for multiple requests until you drop it. Each model may consume a significant amount of RAM, so it's important to keep only one session loaded at a time. For iOS apps, we recommend adding the [Increased Memory Capability](https://developer.apple.com/documentation/bundleresources/entitlements/com.apple.developer.kernel.increased-memory-limit) entitlement to ensure your app can allocate the required memory.
|
|
135
121
|
|
|
136
|
-
|
|
122
|
+
### Chat with the cloud model
|
|
123
|
+
|
|
124
|
+
In this example, we will get a reply to a specific list of messages from a cloud model:
|
|
137
125
|
|
|
138
126
|
```ts
|
|
139
|
-
import
|
|
127
|
+
import { ChatConfig, ChatMessage, ChatReplyConfig, Engine, EngineConfig, ReasoningEffort } from '@trymirai/uzu';
|
|
140
128
|
|
|
141
129
|
async function main() {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
await engine.
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
.
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
const requests = [
|
|
155
|
-
'Tell about London',
|
|
156
|
-
'Compare with New York',
|
|
157
|
-
'Compare the population of the two',
|
|
130
|
+
let engineConfig = EngineConfig.create().withOpenaiApiKey('OPENAI_API_KEY');
|
|
131
|
+
let engine = await Engine.create(engineConfig);
|
|
132
|
+
|
|
133
|
+
let model = await engine.model('gpt-5');
|
|
134
|
+
if (!model) {
|
|
135
|
+
throw new Error('Model not found');
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
let messages = [
|
|
139
|
+
ChatMessage.system().withReasoningEffort("Low" as ReasoningEffort),
|
|
140
|
+
ChatMessage.user().withText('How LLMs work')
|
|
158
141
|
];
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
return true;
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
console.log('Request:', request);
|
|
170
|
-
console.log('Response:', output.text.original.trim());
|
|
171
|
-
console.log('-------------------------');
|
|
142
|
+
|
|
143
|
+
let session = await engine.chat(model, ChatConfig.create());
|
|
144
|
+
let reply = await session.reply(messages, ChatReplyConfig.create());
|
|
145
|
+
let message = reply[0]?.message;
|
|
146
|
+
if (message) {
|
|
147
|
+
console.log('Reasoning: ', message.reasoning);
|
|
148
|
+
console.log('Text: ', message.text);
|
|
172
149
|
}
|
|
173
150
|
}
|
|
174
151
|
|
|
@@ -177,49 +154,52 @@ main().catch((error) => {
|
|
|
177
154
|
});
|
|
178
155
|
```
|
|
179
156
|
|
|
180
|
-
### Chat
|
|
157
|
+
### Chat using speculation preset for classification
|
|
181
158
|
|
|
182
|
-
In this example, we will use the
|
|
159
|
+
In this example, we will use the `classification` speculation preset to determine the sentiment of the user's input:
|
|
183
160
|
|
|
184
161
|
```ts
|
|
185
|
-
import
|
|
186
|
-
|
|
187
|
-
function listToString(list: string[]): string {
|
|
188
|
-
return "[" + list.map((item) => `"${item}"`).join(", ") + "]";
|
|
189
|
-
}
|
|
162
|
+
import { ChatConfig, ChatMessage, ChatReplyConfig, ChatSpeculationPresetClassification, Engine, EngineConfig, Feature, ReasoningEffort, SamplingMethodGreedy } from '@trymirai/uzu';
|
|
190
163
|
|
|
191
164
|
async function main() {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
await engine.
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
const
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
165
|
+
let engineConfig = EngineConfig.create();
|
|
166
|
+
let engine = await Engine.create(engineConfig);
|
|
167
|
+
|
|
168
|
+
let model = await engine.model('Qwen/Qwen3-0.6B');
|
|
169
|
+
if (!model) {
|
|
170
|
+
throw new Error('Model not found');
|
|
171
|
+
}
|
|
172
|
+
for await (const update of await engine.download(model)) {
|
|
173
|
+
console.log('Download progress:', update.progress);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const feature = new Feature('sentiment', [
|
|
177
|
+
'Happy',
|
|
178
|
+
'Sad',
|
|
179
|
+
'Angry',
|
|
180
|
+
'Fearful',
|
|
181
|
+
'Surprised',
|
|
182
|
+
'Disgusted',
|
|
183
|
+
]);
|
|
184
|
+
let chatConfig = ChatConfig.create().withSpeculationPreset(new ChatSpeculationPresetClassification(feature));
|
|
185
|
+
let session = await engine.chat(model, chatConfig);
|
|
186
|
+
|
|
187
|
+
const textToDetectFeature =
|
|
188
|
+
"Today's been awesome! Everything just feels right, and I can't stop smiling.";
|
|
189
|
+
const prompt =
|
|
190
|
+
`Text is: "${textToDetectFeature}". Choose ${feature.name} from the list: ${feature.values.join(', ')}. ` +
|
|
191
|
+
"Answer with one word. Don't add a dot at the end.";
|
|
192
|
+
let messages = [
|
|
193
|
+
ChatMessage.system().withReasoningEffort("Disabled" as ReasoningEffort),
|
|
194
|
+
ChatMessage.user().withText(prompt)
|
|
210
195
|
];
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
console.log('Request:', request);
|
|
221
|
-
console.log('Response:', output.text.original.trim());
|
|
222
|
-
console.log('-------------------------');
|
|
196
|
+
|
|
197
|
+
let chatReplyConfig = ChatReplyConfig.create().withTokenLimit(32).withSamplingMethod(new SamplingMethodGreedy());
|
|
198
|
+
let reply = (await session.reply(messages, chatReplyConfig))[0];
|
|
199
|
+
|
|
200
|
+
if (reply) {
|
|
201
|
+
console.log('Prediction: ', reply.message.text);
|
|
202
|
+
console.log('Generated tokens: ', reply.stats.tokensCountOutput);
|
|
223
203
|
}
|
|
224
204
|
}
|
|
225
205
|
|
|
@@ -228,36 +208,45 @@ main().catch((error) => {
|
|
|
228
208
|
});
|
|
229
209
|
```
|
|
230
210
|
|
|
231
|
-
|
|
211
|
+
<br>You can view the stats to see that the answer will be ready immediately after the prefill step, and actual generation won’t even start due to speculative decoding, which significantly improves generation speed.
|
|
232
212
|
|
|
233
|
-
|
|
213
|
+
### Chat using speculation preset for summarization
|
|
214
|
+
|
|
215
|
+
In this example, we will use the `summarization` speculation preset to generate a summary of the input text:
|
|
234
216
|
|
|
235
217
|
```ts
|
|
236
|
-
import Engine,
|
|
218
|
+
import { ChatConfig, ChatMessage, ChatReplyConfig, ChatSpeculationPresetSummarization, Engine, EngineConfig, ReasoningEffort, SamplingMethodGreedy } from '@trymirai/uzu';
|
|
237
219
|
|
|
238
220
|
async function main() {
|
|
221
|
+
let engineConfig = EngineConfig.create();
|
|
222
|
+
let engine = await Engine.create(engineConfig);
|
|
223
|
+
|
|
224
|
+
let model = await engine.model('Qwen/Qwen3-0.6B');
|
|
225
|
+
if (!model) {
|
|
226
|
+
throw new Error('Model not found');
|
|
227
|
+
}
|
|
228
|
+
for await (const update of await engine.download(model)) {
|
|
229
|
+
console.log('Download progress:', update.progress);
|
|
230
|
+
}
|
|
231
|
+
|
|
239
232
|
const textToSummarize =
|
|
240
233
|
"A Large Language Model (LLM) is a type of artificial intelligence that processes and generates human-like text. It is trained on vast datasets containing books, articles, and web content, allowing it to understand and predict language patterns. LLMs use deep learning, particularly transformer-based architectures, to analyze text, recognize context, and generate coherent responses. These models have a wide range of applications, including chatbots, content creation, translation, and code generation. One of the key strengths of LLMs is their ability to generate contextually relevant text based on prompts. They utilize self-attention mechanisms to weigh the importance of words within a sentence, improving accuracy and fluency. Examples of popular LLMs include OpenAI's GPT series, Google's BERT, and Meta's LLaMA. As these models grow in size and sophistication, they continue to enhance human-computer interactions, making AI-powered communication more natural and effective.";
|
|
241
234
|
const prompt = `Text is: "${textToSummarize}". Write only summary itself.`;
|
|
235
|
+
let messages = [
|
|
236
|
+
ChatMessage.system().withReasoningEffort("Disabled" as ReasoningEffort),
|
|
237
|
+
ChatMessage.user().withText(prompt)
|
|
238
|
+
];
|
|
239
|
+
|
|
240
|
+
let chatConfig = ChatConfig.create().withSpeculationPreset(new ChatSpeculationPresetSummarization);
|
|
241
|
+
let session = await engine.chat(model, chatConfig);
|
|
242
|
+
|
|
243
|
+
let chatReplyConfig = ChatReplyConfig.create().withTokenLimit(256).withSamplingMethod(new SamplingMethodGreedy());
|
|
244
|
+
let reply = (await session.reply(messages, chatReplyConfig))[0];
|
|
242
245
|
|
|
243
|
-
|
|
244
|
-
.
|
|
245
|
-
.
|
|
246
|
-
|
|
247
|
-
})
|
|
248
|
-
.preset(Preset.summarization())
|
|
249
|
-
.session()
|
|
250
|
-
.tokensLimit(256)
|
|
251
|
-
.enableThinking(false)
|
|
252
|
-
.samplingMethod(SamplingMethod.greedy())
|
|
253
|
-
.reply(prompt);
|
|
254
|
-
|
|
255
|
-
console.log('Summary:', output.text.original);
|
|
256
|
-
console.log(
|
|
257
|
-
'Model runs:',
|
|
258
|
-
output.stats.prefillStats.modelRun.count + (output.stats.generateStats?.modelRun.count ?? 0),
|
|
259
|
-
);
|
|
260
|
-
console.log('Tokens count:', output.stats.totalStats.tokensCountOutput);
|
|
246
|
+
if (reply) {
|
|
247
|
+
console.log('Summary: ', reply.message.text);
|
|
248
|
+
console.log('Generation t\\s: ', reply.stats.generateTokensPerSecond);
|
|
249
|
+
}
|
|
261
250
|
}
|
|
262
251
|
|
|
263
252
|
main().catch((error) => {
|
|
@@ -265,44 +254,55 @@ main().catch((error) => {
|
|
|
265
254
|
});
|
|
266
255
|
```
|
|
267
256
|
|
|
268
|
-
You will notice that the model’s run count is lower than the actual number of generated tokens due to speculative decoding, which significantly improves generation speed.
|
|
257
|
+
<br>You will notice that the model’s run count is lower than the actual number of generated tokens due to speculative decoding, which significantly improves generation speed.
|
|
269
258
|
|
|
270
|
-
###
|
|
259
|
+
### Chat with structured output
|
|
271
260
|
|
|
272
|
-
|
|
261
|
+
Sometimes you want the generated output to be valid JSON with predefined fields. You can use `Grammar` to manually specify a JSON schema for the response you want to receive:
|
|
273
262
|
|
|
274
263
|
```ts
|
|
275
|
-
import
|
|
264
|
+
import { ChatConfig, ChatMessage, ChatReplyConfig, Engine, EngineConfig, GrammarJsonSchema, ReasoningEffort } from '@trymirai/uzu';
|
|
265
|
+
import * as z from "zod";
|
|
266
|
+
|
|
267
|
+
const CountryType = z.object({
|
|
268
|
+
name: z.string(),
|
|
269
|
+
capital: z.string(),
|
|
270
|
+
});
|
|
271
|
+
const CountryListType = z.array(CountryType);
|
|
272
|
+
|
|
273
|
+
function structuredResponse<T extends z.ZodType>(response: string | null | undefined, type: T): z.infer<T> | undefined {
|
|
274
|
+
if (!response) {
|
|
275
|
+
return undefined;
|
|
276
|
+
}
|
|
277
|
+
const data = JSON.parse(response);
|
|
278
|
+
const result = type.parse(data);
|
|
279
|
+
return result;
|
|
280
|
+
}
|
|
276
281
|
|
|
277
282
|
async function main() {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
'
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
283
|
+
let engineConfig = EngineConfig.create();
|
|
284
|
+
let engine = await Engine.create(engineConfig);
|
|
285
|
+
|
|
286
|
+
let model = await engine.model('Qwen/Qwen3-0.6B');
|
|
287
|
+
if (!model) {
|
|
288
|
+
throw new Error('Model not found');
|
|
289
|
+
}
|
|
290
|
+
for await (const update of await engine.download(model)) {
|
|
291
|
+
console.log('Download progress:', update.progress);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
let schema = z.toJSONSchema(CountryListType);
|
|
295
|
+
let schemaString = JSON.stringify(schema);
|
|
296
|
+
let messages = [
|
|
297
|
+
ChatMessage.system().withReasoningEffort("Disabled" as ReasoningEffort),
|
|
298
|
+
ChatMessage.user().withText('Give me a JSON object containing a list of 3 countries, where each country has name and capital fields')
|
|
299
|
+
];
|
|
291
300
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
.preset(Preset.classification(feature))
|
|
298
|
-
.session()
|
|
299
|
-
.tokensLimit(32)
|
|
300
|
-
.enableThinking(false)
|
|
301
|
-
.samplingMethod(SamplingMethod.greedy())
|
|
302
|
-
.reply(prompt);
|
|
303
|
-
|
|
304
|
-
console.log('Prediction:', output.text.original);
|
|
305
|
-
console.log('Stats:', output.stats);
|
|
301
|
+
let session = await engine.chat(model, ChatConfig.create());
|
|
302
|
+
let reply = await session.reply(messages, ChatReplyConfig.create().withGrammar(new GrammarJsonSchema(schemaString)));
|
|
303
|
+
let message = reply[0]?.message;
|
|
304
|
+
let countries = structuredResponse(message?.text, CountryListType);
|
|
305
|
+
console.log(countries);
|
|
306
306
|
}
|
|
307
307
|
|
|
308
308
|
main().catch((error) => {
|
|
@@ -310,21 +310,32 @@ main().catch((error) => {
|
|
|
310
310
|
});
|
|
311
311
|
```
|
|
312
312
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
### Cloud
|
|
313
|
+
### Classification
|
|
316
314
|
|
|
317
|
-
|
|
315
|
+
In this example, we will use a classification model to determine whether the user's input is safe from a moderation perspective:
|
|
318
316
|
|
|
319
317
|
```ts
|
|
320
|
-
import Engine from '@trymirai/uzu';
|
|
318
|
+
import { ClassificationMessage, Engine, EngineConfig } from '@trymirai/uzu';
|
|
321
319
|
|
|
322
320
|
async function main() {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
321
|
+
let engineConfig = EngineConfig.create();
|
|
322
|
+
let engine = await Engine.create(engineConfig);
|
|
323
|
+
|
|
324
|
+
let model = await engine.model('trymirai/chat-moderation-router');
|
|
325
|
+
if (!model) {
|
|
326
|
+
throw new Error('Model not found');
|
|
327
|
+
}
|
|
328
|
+
for await (const update of await engine.download(model)) {
|
|
329
|
+
console.log('Download progress:', update.progress);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
let messages = [
|
|
333
|
+
ClassificationMessage.user('Hi')
|
|
334
|
+
];
|
|
335
|
+
|
|
336
|
+
let session = await engine.classification(model);
|
|
337
|
+
let output = await session.classify(messages);
|
|
338
|
+
console.log('Output: ', output.probabilities.values);
|
|
328
339
|
}
|
|
329
340
|
|
|
330
341
|
main().catch((error) => {
|
|
@@ -332,38 +343,33 @@ main().catch((error) => {
|
|
|
332
343
|
});
|
|
333
344
|
```
|
|
334
345
|
|
|
335
|
-
###
|
|
346
|
+
### Text to Speech
|
|
336
347
|
|
|
337
|
-
|
|
348
|
+
In this example, we will generate audio from text:
|
|
338
349
|
|
|
339
350
|
```ts
|
|
340
|
-
import Engine,
|
|
341
|
-
import
|
|
342
|
-
|
|
343
|
-
const CountryType = z.object({
|
|
344
|
-
name: z.string(),
|
|
345
|
-
capital: z.string(),
|
|
346
|
-
});
|
|
347
|
-
const CountryListType = z.array(CountryType);
|
|
351
|
+
import { Engine, EngineConfig } from '@trymirai/uzu';
|
|
352
|
+
import { homedir } from "os";
|
|
353
|
+
import { join } from "path";
|
|
348
354
|
|
|
349
355
|
async function main() {
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
.
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
console.log(
|
|
356
|
+
let engineConfig = EngineConfig.create();
|
|
357
|
+
let engine = await Engine.create(engineConfig);
|
|
358
|
+
|
|
359
|
+
let model = await engine.model('fishaudio/s1-mini');
|
|
360
|
+
if (!model) {
|
|
361
|
+
throw new Error('Model not found');
|
|
362
|
+
}
|
|
363
|
+
for await (const update of await engine.download(model)) {
|
|
364
|
+
console.log('Download progress:', update.progress);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
const text = "London is the capital of United Kingdom and one of the world’s most influential cities, known for its rich history, cultural diversity, and global significance in finance, politics, and the arts. Situated along the River Thames, the city blends historic landmarks like Tower of London and Buckingham Palace with modern architecture such as The Shard. London is also home to renowned institutions including the British Museum and vibrant areas like Covent Garden, offering a mix of history, entertainment, and innovation that attracts millions of visitors each year.";
|
|
368
|
+
const outputPath = join(homedir(), "Desktop", "output.wav");
|
|
369
|
+
let session = await engine.textToSpeech(model);
|
|
370
|
+
let pcmBatch = await session.synthesize(text);
|
|
371
|
+
pcmBatch.saveAsWav(outputPath);
|
|
372
|
+
console.log('Output saved to: ', outputPath);
|
|
367
373
|
}
|
|
368
374
|
|
|
369
375
|
main().catch((error) => {
|
|
@@ -371,6 +377,8 @@ main().catch((error) => {
|
|
|
371
377
|
});
|
|
372
378
|
```
|
|
373
379
|
|
|
380
|
+
|
|
381
|
+
|
|
374
382
|
## Troubleshooting
|
|
375
383
|
|
|
376
384
|
If you experience any problems, please contact us via [Discord](https://discord.com/invite/trymirai) or [email](mailto:contact@getmirai.co).
|