@trymirai/uzu 0.2.20 → 0.3.1

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.
Files changed (166) hide show
  1. package/README.md +6 -4
  2. package/bridging/classificationLabel.d.mts +12 -0
  3. package/bridging/classificationLabel.d.mts.map +1 -0
  4. package/bridging/classificationLabel.d.ts +12 -0
  5. package/bridging/classificationLabel.d.ts.map +1 -0
  6. package/bridging/classificationLabel.js +26 -0
  7. package/bridging/classificationLabel.js.map +1 -0
  8. package/bridging/classificationLabel.mjs +22 -0
  9. package/bridging/classificationLabel.mjs.map +1 -0
  10. package/bridging/classificationOutput.d.mts +10 -0
  11. package/bridging/classificationOutput.d.mts.map +1 -0
  12. package/bridging/classificationOutput.d.ts +10 -0
  13. package/bridging/classificationOutput.d.ts.map +1 -0
  14. package/bridging/classificationOutput.js +16 -0
  15. package/bridging/classificationOutput.js.map +1 -0
  16. package/bridging/classificationOutput.mjs +12 -0
  17. package/bridging/classificationOutput.mjs.map +1 -0
  18. package/bridging/classificationSession.d.mts +9 -0
  19. package/bridging/classificationSession.d.mts.map +1 -0
  20. package/bridging/classificationSession.d.ts +9 -0
  21. package/bridging/classificationSession.d.ts.map +1 -0
  22. package/bridging/classificationSession.js +16 -0
  23. package/bridging/classificationSession.js.map +1 -0
  24. package/bridging/classificationSession.mjs +12 -0
  25. package/bridging/classificationSession.mjs.map +1 -0
  26. package/bridging/classificationStats.d.mts +14 -0
  27. package/bridging/classificationStats.d.mts.map +1 -0
  28. package/bridging/classificationStats.d.ts +14 -0
  29. package/bridging/classificationStats.d.ts.map +1 -0
  30. package/bridging/classificationStats.js +20 -0
  31. package/bridging/classificationStats.js.map +1 -0
  32. package/bridging/classificationStats.mjs +16 -0
  33. package/bridging/classificationStats.mjs.map +1 -0
  34. package/bridging/engine.d.mts +14 -6
  35. package/bridging/engine.d.mts.map +1 -1
  36. package/bridging/engine.d.ts +14 -6
  37. package/bridging/engine.d.ts.map +1 -1
  38. package/bridging/engine.js +53 -23
  39. package/bridging/engine.js.map +1 -1
  40. package/bridging/engine.mjs +53 -23
  41. package/bridging/engine.mjs.map +1 -1
  42. package/bridging/model.d.mts +19 -0
  43. package/bridging/model.d.mts.map +1 -0
  44. package/bridging/model.d.ts +19 -0
  45. package/bridging/model.d.ts.map +1 -0
  46. package/bridging/model.js +39 -0
  47. package/bridging/model.js.map +1 -0
  48. package/bridging/model.mjs +35 -0
  49. package/bridging/model.mjs.map +1 -0
  50. package/bridging/modelKind.d.mts +8 -0
  51. package/bridging/modelKind.d.mts.map +1 -0
  52. package/bridging/modelKind.d.ts +8 -0
  53. package/bridging/modelKind.d.ts.map +1 -0
  54. package/bridging/modelKind.js +30 -0
  55. package/bridging/modelKind.js.map +1 -0
  56. package/bridging/modelKind.mjs +25 -0
  57. package/bridging/modelKind.mjs.map +1 -0
  58. package/bridging/modelType.d.mts +3 -2
  59. package/bridging/modelType.d.mts.map +1 -1
  60. package/bridging/modelType.d.ts +3 -2
  61. package/bridging/modelType.d.ts.map +1 -1
  62. package/bridging/modelType.js +11 -6
  63. package/bridging/modelType.js.map +1 -1
  64. package/bridging/modelType.mjs +11 -6
  65. package/bridging/modelType.mjs.map +1 -1
  66. package/bridging/samplingMethod.d.mts +2 -1
  67. package/bridging/samplingMethod.d.mts.map +1 -1
  68. package/bridging/samplingMethod.d.ts +2 -1
  69. package/bridging/samplingMethod.d.ts.map +1 -1
  70. package/bridging/samplingMethod.js +3 -1
  71. package/bridging/samplingMethod.js.map +1 -1
  72. package/bridging/samplingMethod.mjs +3 -1
  73. package/bridging/samplingMethod.mjs.map +1 -1
  74. package/bridging/samplingProcessingOrder.d.mts +8 -0
  75. package/bridging/samplingProcessingOrder.d.mts.map +1 -0
  76. package/bridging/samplingProcessingOrder.d.ts +8 -0
  77. package/bridging/samplingProcessingOrder.d.ts.map +1 -0
  78. package/bridging/samplingProcessingOrder.js +30 -0
  79. package/bridging/samplingProcessingOrder.js.map +1 -0
  80. package/bridging/samplingProcessingOrder.mjs +25 -0
  81. package/bridging/samplingProcessingOrder.mjs.map +1 -0
  82. package/bridging/textToSpeechSession.d.mts +8 -0
  83. package/bridging/textToSpeechSession.d.mts.map +1 -0
  84. package/bridging/textToSpeechSession.d.ts +8 -0
  85. package/bridging/textToSpeechSession.d.ts.map +1 -0
  86. package/bridging/textToSpeechSession.js +14 -0
  87. package/bridging/textToSpeechSession.js.map +1 -0
  88. package/bridging/textToSpeechSession.mjs +10 -0
  89. package/bridging/textToSpeechSession.mjs.map +1 -0
  90. package/error.d.mts +2 -0
  91. package/error.d.mts.map +1 -1
  92. package/error.d.ts +2 -0
  93. package/error.d.ts.map +1 -1
  94. package/error.js +4 -0
  95. package/error.js.map +1 -1
  96. package/error.mjs +4 -0
  97. package/error.mjs.map +1 -1
  98. package/index.d.mts +8 -1
  99. package/index.d.mts.map +1 -1
  100. package/index.d.ts +8 -1
  101. package/index.d.ts.map +1 -1
  102. package/index.js +17 -3
  103. package/index.js.map +1 -1
  104. package/index.mjs +8 -1
  105. package/index.mjs.map +1 -1
  106. package/interactors/chatModelInteractor.d.mts +5 -5
  107. package/interactors/chatModelInteractor.d.mts.map +1 -1
  108. package/interactors/chatModelInteractor.d.ts +5 -5
  109. package/interactors/chatModelInteractor.d.ts.map +1 -1
  110. package/interactors/chatModelInteractor.js +2 -2
  111. package/interactors/chatModelInteractor.js.map +1 -1
  112. package/interactors/chatModelInteractor.mjs +2 -2
  113. package/interactors/chatModelInteractor.mjs.map +1 -1
  114. package/interactors/chatModelsInteractor.d.mts +5 -5
  115. package/interactors/chatModelsInteractor.d.mts.map +1 -1
  116. package/interactors/chatModelsInteractor.d.ts +5 -5
  117. package/interactors/chatModelsInteractor.d.ts.map +1 -1
  118. package/interactors/chatModelsInteractor.js.map +1 -1
  119. package/interactors/chatModelsInteractor.mjs.map +1 -1
  120. package/interactors/engineInteractor.d.mts +4 -4
  121. package/interactors/engineInteractor.d.ts +4 -4
  122. package/interactors/engineInteractor.js +5 -5
  123. package/interactors/engineInteractor.mjs +5 -5
  124. package/napi/uzu.d.ts +67 -15
  125. package/napi/uzu.js +16 -2
  126. package/napi/uzu.mjs +8 -1
  127. package/napi/uzu.node +0 -0
  128. package/package.json +1 -1
  129. package/src/bridging/classificationLabel.ts +43 -0
  130. package/src/bridging/classificationOutput.ts +22 -0
  131. package/src/bridging/classificationSession.ts +17 -0
  132. package/src/bridging/classificationStats.ts +45 -0
  133. package/src/bridging/engine.ts +62 -26
  134. package/src/bridging/model.ts +68 -0
  135. package/src/bridging/modelKind.ts +27 -0
  136. package/src/bridging/modelType.ts +11 -6
  137. package/src/bridging/samplingMethod.ts +6 -0
  138. package/src/bridging/samplingProcessingOrder.ts +31 -0
  139. package/src/bridging/textToSpeechSession.ts +15 -0
  140. package/src/error.ts +4 -0
  141. package/src/index.ts +8 -1
  142. package/src/interactors/chatModelInteractor.ts +7 -7
  143. package/src/interactors/chatModelsInteractor.ts +5 -5
  144. package/src/interactors/engineInteractor.ts +7 -7
  145. package/src/napi/uzu.d.ts +67 -15
  146. package/src/napi/uzu.js +16 -2
  147. package/src/napi/uzu.mjs +8 -1
  148. package/src/napi/uzu.node +0 -0
  149. package/src/version.ts +1 -1
  150. package/version.d.mts +1 -1
  151. package/version.d.mts.map +1 -1
  152. package/version.d.ts +1 -1
  153. package/version.d.ts.map +1 -1
  154. package/version.js +1 -1
  155. package/version.js.map +1 -1
  156. package/version.mjs +1 -1
  157. package/version.mjs.map +1 -1
  158. package/bridging/chatModel.d.mts +0 -15
  159. package/bridging/chatModel.d.mts.map +0 -1
  160. package/bridging/chatModel.d.ts +0 -15
  161. package/bridging/chatModel.d.ts.map +0 -1
  162. package/bridging/chatModel.js +0 -33
  163. package/bridging/chatModel.js.map +0 -1
  164. package/bridging/chatModel.mjs +0 -29
  165. package/bridging/chatModel.mjs.map +0 -1
  166. package/src/bridging/chatModel.ts +0 -54
@@ -0,0 +1,68 @@
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
+ }
@@ -0,0 +1,27 @@
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
+ }
@@ -2,16 +2,19 @@ import { EngineError, EngineErrorCode } from '../error';
2
2
  import { ModelType as NapiModelType } from '../napi/uzu';
3
3
 
4
4
  export enum ModelType {
5
- Local = 'Local',
6
- Cloud = 'Cloud',
5
+ Chat = 'Chat',
6
+ Classification = 'Classification',
7
+ TTS = 'TTS',
7
8
  }
8
9
 
9
10
  export function modelTypeFromNapiModelType(napiModelType: NapiModelType): ModelType {
10
11
  switch (napiModelType) {
11
12
  case 0:
12
- return ModelType.Local;
13
+ return ModelType.Chat;
13
14
  case 1:
14
- return ModelType.Cloud;
15
+ return ModelType.Classification;
16
+ case 2:
17
+ return ModelType.TTS;
15
18
  default:
16
19
  throw new EngineError(EngineErrorCode.UnexpectedModelType);
17
20
  }
@@ -19,9 +22,11 @@ export function modelTypeFromNapiModelType(napiModelType: NapiModelType): ModelT
19
22
 
20
23
  export function modelTypeToNapiModelType(modelType: ModelType): NapiModelType {
21
24
  switch (modelType) {
22
- case ModelType.Local:
25
+ case ModelType.Chat:
23
26
  return 0;
24
- case ModelType.Cloud:
27
+ case ModelType.Classification:
25
28
  return 1;
29
+ case ModelType.TTS:
30
+ return 2;
26
31
  }
27
32
  }
@@ -1,5 +1,9 @@
1
1
  import { SamplingMethod as NapiSamplingMethod } from '../napi/uzu';
2
2
  import { ToNapi } from './napi';
3
+ import {
4
+ SamplingProcessingOrder,
5
+ samplingProcessingOrderToNapiSamplingProcessingOrder,
6
+ } from './samplingProcessingOrder';
3
7
 
4
8
  export class SamplingMethod implements ToNapi<NapiSamplingMethod> {
5
9
  private readonly napiSamplingMethod: NapiSamplingMethod;
@@ -18,9 +22,11 @@ export class SamplingMethod implements ToNapi<NapiSamplingMethod> {
18
22
  topK: number | null,
19
23
  topP: number | null,
20
24
  minP: number | null,
25
+ processingOrder: SamplingProcessingOrder,
21
26
  ): SamplingMethod {
22
27
  let napiSamplingMethod: NapiSamplingMethod = {
23
28
  type: 'Stochastic',
29
+ processingOrder: samplingProcessingOrderToNapiSamplingProcessingOrder(processingOrder),
24
30
  };
25
31
  if (temperature !== null) {
26
32
  napiSamplingMethod.temperature = temperature;
@@ -0,0 +1,31 @@
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
+ }
@@ -0,0 +1,15 @@
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
+ }
package/src/error.ts CHANGED
@@ -6,6 +6,8 @@ export enum EngineErrorCode {
6
6
  UnexpectedFinishReason = 'unexpectedFinishReason',
7
7
  UnexpectedLicenseStatus = 'unexpectedLicenseStatus',
8
8
  UnexpectedModelType = 'unexpectedModelType',
9
+ UnexpectedModelKind = 'unexpectedModelKind',
10
+ UnexpectedSamplingProcessingOrder = 'unexpectedSamplingProcessingOrder',
9
11
  LicenseNotActivated = 'licenseNotActivated',
10
12
  Unknown = 'unknown',
11
13
  }
@@ -18,6 +20,8 @@ const errorCodeToMessage = {
18
20
  [EngineErrorCode.UnexpectedFinishReason]: 'Unexpected finish reason',
19
21
  [EngineErrorCode.UnexpectedLicenseStatus]: 'Unexpected license status',
20
22
  [EngineErrorCode.UnexpectedModelType]: 'Unexpected model type',
23
+ [EngineErrorCode.UnexpectedModelKind]: 'Unexpected model kind',
24
+ [EngineErrorCode.UnexpectedSamplingProcessingOrder]: 'Unexpected sampling processing order',
21
25
  [EngineErrorCode.LicenseNotActivated]: 'License not activated',
22
26
  [EngineErrorCode.Unknown]: 'Unknown error',
23
27
  };
package/src/index.ts CHANGED
@@ -1,7 +1,10 @@
1
1
  export { AsyncBatchSize } from './bridging/asyncBatchSize';
2
- export { ChatModel } from './bridging/chatModel';
3
2
  export { ChatSession } from './bridging/chatSession';
4
3
  export { ClassificationFeature } from './bridging/classificationFeature';
4
+ export { ClassificationLabel } from './bridging/classificationLabel';
5
+ export { ClassificationOutput } from './bridging/classificationOutput';
6
+ export { ClassificationSession } from './bridging/classificationSession';
7
+ export { ClassificationStats } from './bridging/classificationStats';
5
8
  export { Config } from './bridging/config';
6
9
  export { ContextLength } from './bridging/contextLength';
7
10
  export { ContextMode } from './bridging/contextMode';
@@ -13,6 +16,8 @@ export { FinishReason } from './bridging/finishReason';
13
16
  export { GrammarConfig } from './bridging/grammarConfig';
14
17
  export { Input } from './bridging/input';
15
18
  export { Message } from './bridging/message';
19
+ export { Model } from './bridging/model';
20
+ export { ModelKind } from './bridging/modelKind';
16
21
  export { ModelType } from './bridging/modelType';
17
22
  export { Output } from './bridging/output';
18
23
  export { ParsedText } from './bridging/parsedText';
@@ -23,10 +28,12 @@ export { RunConfig } from './bridging/runConfig';
23
28
  export { RunStats } from './bridging/runStats';
24
29
  export { SamplingMethod } from './bridging/samplingMethod';
25
30
  export { SamplingPolicy } from './bridging/samplingPolicy';
31
+ export { SamplingProcessingOrder } from './bridging/samplingProcessingOrder';
26
32
  export { SamplingSeed } from './bridging/samplingSeed';
27
33
  export { Stats } from './bridging/stats';
28
34
  export { StepStats } from './bridging/stepStats';
29
35
  export { Text } from './bridging/text';
36
+ export { TextToSpeechSession } from './bridging/textToSpeechSession';
30
37
  export { TotalStats } from './bridging/totalStats';
31
38
  export { EngineError } from './error';
32
39
  export { ChatModelInteractor } from './interactors/chatModelInteractor';
@@ -1,12 +1,12 @@
1
1
  import { AsyncBatchSize } from '../bridging/asyncBatchSize';
2
- import { ChatModel } from '../bridging/chatModel';
3
2
  import { Config } from '../bridging/config';
4
3
  import { ContextLength } from '../bridging/contextLength';
5
4
  import { ContextMode } from '../bridging/contextMode';
6
5
  import { DownloadProgressUpdate } from '../bridging/downloadProgressUpdate';
7
6
  import { DownloadPhase } from '../bridging/downloadState';
8
7
  import { Message } from '../bridging/message';
9
- import { ModelType } from '../bridging/modelType';
8
+ import { Model } from '../bridging/model';
9
+ import { ModelKind } from '../bridging/modelKind';
10
10
  import { Output } from '../bridging/output';
11
11
  import { PrefillStepSize } from '../bridging/prefillStepSize';
12
12
  import { Preset } from '../bridging/preset';
@@ -17,18 +17,18 @@ import { ChatSessionInteractor } from './chatSessionInteractor';
17
17
  import { DownloadInteractor } from './downloadInteractor';
18
18
  import { Interactor, InteractorEntity } from './interactor';
19
19
 
20
- export class ChatModelInteractor implements Interactor<ChatModel> {
20
+ export class ChatModelInteractor implements Interactor<Model> {
21
21
  readonly modelsInteractor: ChatModelsInteractor;
22
- readonly entity: InteractorEntity<ChatModel>;
22
+ readonly entity: InteractorEntity<Model>;
23
23
  readonly config: Config;
24
24
 
25
- constructor(modelsInteractor: ChatModelsInteractor, model: InteractorEntity<ChatModel>, config: Config) {
25
+ constructor(modelsInteractor: ChatModelsInteractor, model: InteractorEntity<Model>, config: Config) {
26
26
  this.modelsInteractor = modelsInteractor;
27
27
  this.entity = model;
28
28
  this.config = config;
29
29
  }
30
30
 
31
- async finalize(): Promise<ChatModel> {
31
+ async finalize(): Promise<Model> {
32
32
  return await this.entity;
33
33
  }
34
34
 
@@ -103,7 +103,7 @@ export class ChatModelInteractor implements Interactor<ChatModel> {
103
103
  const engine = await this.modelsInteractor.engineInteractor.finalize();
104
104
 
105
105
  let model = await this.finalize();
106
- if (model.type === ModelType.Local) {
106
+ if (model.kind === ModelKind.Local) {
107
107
  model = await this.download().finalize();
108
108
  }
109
109
 
@@ -1,20 +1,20 @@
1
- import { ChatModel } from '../bridging/chatModel';
2
1
  import { Config } from '../bridging/config';
2
+ import { Model } from '../bridging/model';
3
3
  import { EngineErrorCode, unwrapOrThrow } from '../error';
4
4
  import { ChatModelInteractor } from './chatModelInteractor';
5
5
  import { EngineInteractor } from './engineInteractor';
6
6
  import { Interactor, InteractorEntity } from './interactor';
7
7
 
8
- export class ChatModelsInteractor implements Interactor<ChatModel[]> {
8
+ export class ChatModelsInteractor implements Interactor<Model[]> {
9
9
  readonly engineInteractor: EngineInteractor;
10
- readonly entity: InteractorEntity<ChatModel[]>;
10
+ readonly entity: InteractorEntity<Model[]>;
11
11
 
12
- constructor(engineInteractor: EngineInteractor, models: InteractorEntity<ChatModel[]>) {
12
+ constructor(engineInteractor: EngineInteractor, models: InteractorEntity<Model[]>) {
13
13
  this.engineInteractor = engineInteractor;
14
14
  this.entity = models;
15
15
  }
16
16
 
17
- async finalize(): Promise<ChatModel[]> {
17
+ async finalize(): Promise<Model[]> {
18
18
  return await this.entity;
19
19
  }
20
20
 
@@ -1,16 +1,16 @@
1
1
  import { Engine } from '../bridging/engine';
2
- import { ModelType } from '../bridging/modelType';
2
+ import { ModelKind } from '../bridging/modelKind';
3
3
  import { ChatModelInteractor } from './chatModelInteractor';
4
4
  import { ChatModelsInteractor } from './chatModelsInteractor';
5
5
  import { Interactor, InteractorEntity } from './interactor';
6
6
 
7
7
  export class EngineInteractor implements Interactor<Engine> {
8
8
  readonly entity: InteractorEntity<Engine>;
9
- readonly modelTypeFilter: ModelType[] | null;
9
+ readonly modelKindFilter: ModelKind[] | null;
10
10
 
11
- constructor(engine: InteractorEntity<Engine>, modelTypeFilter: ModelType[] | null = null) {
11
+ constructor(engine: InteractorEntity<Engine>, modelKindFilter: ModelKind[] | null = null) {
12
12
  this.entity = engine;
13
- this.modelTypeFilter = modelTypeFilter;
13
+ this.modelKindFilter = modelKindFilter;
14
14
  }
15
15
 
16
16
  async finalize(): Promise<Engine> {
@@ -19,14 +19,14 @@ export class EngineInteractor implements Interactor<Engine> {
19
19
 
20
20
  /* Models */
21
21
 
22
- filterTypes(types: ModelType[] | null): EngineInteractor {
23
- return new EngineInteractor(this.entity, types);
22
+ filterKinds(kinds: ModelKind[] | null): EngineInteractor {
23
+ return new EngineInteractor(this.entity, kinds);
24
24
  }
25
25
 
26
26
  chatModels(): ChatModelsInteractor {
27
27
  const modelsPromise = (async () => {
28
28
  const engine = await this.finalize();
29
- return await engine.chatModels(this.modelTypeFilter);
29
+ return await engine.chatModels(this.modelKindFilter);
30
30
  })();
31
31
  return new ChatModelsInteractor(this, modelsPromise);
32
32
  }
package/src/napi/uzu.d.ts CHANGED
@@ -5,17 +5,25 @@ export declare class ChatSession {
5
5
  reset(): void
6
6
  }
7
7
 
8
+ export declare class ClassificationSession {
9
+ run(input: Input): ClassificationOutput
10
+ }
11
+
8
12
  export declare class Engine {
9
13
  activate(apiKey: string): Promise<LicenseStatus>
10
- getChatModels(types: Array<ModelType>): Promise<Array<ChatModel>>
14
+ getChatModels(kinds: Array<ModelKind>): Promise<Array<Model>>
15
+ getTextToSpeechModels(): Promise<Array<Model>>
16
+ getClassificationModels(): Promise<Array<Model>>
11
17
  getModelDownloadState(repoId: string): ModelDownloadState
12
18
  createModelDownloadHandle(repoId: string): ModelDownloadHandle
13
19
  benchmark(task: BenchmarksTask, prefillStepSize?: number | undefined | null): Promise<Array<BenchmarksResult>>
14
20
  constructor()
15
- createChatSession(model: ChatModel, config: Config): ChatSession
21
+ createChatSession(model: Model, config: Config): ChatSession
22
+ createTextToSpeechSession(model: Model): TextToSpeechSession
23
+ createClassificationSession(model: Model): ClassificationSession
16
24
  registerLicenseStatusHandler(callback?: ((arg: LicenseStatus) => void) | undefined | null): void
17
25
  registerModelDownloadStateHandler(callback?: ((arg0: string, arg1: ModelDownloadState) => void) | undefined | null): void
18
- registerChatModelsHandler(callback?: ((arg: Array<ChatModel>) => void) | undefined | null): void
26
+ registerModelsHandler(callback?: ((arg: Array<Model>) => void) | undefined | null): void
19
27
  }
20
28
 
21
29
  export declare class ModelDownloadHandle {
@@ -40,6 +48,10 @@ export declare class ProgressUpdate {
40
48
  progress: number
41
49
  }
42
50
 
51
+ export declare class TextToSpeechSession {
52
+ run(input: Input, outputPath: string): void
53
+ }
54
+
43
55
  export type AsyncBatchSize =
44
56
  | { type: 'Default' }
45
57
  | { type: 'Custom', size: number }
@@ -74,20 +86,36 @@ export interface BenchmarksTask {
74
86
  greedy: boolean
75
87
  }
76
88
 
77
- export interface ChatModel {
78
- readonly repoId: string
79
- readonly type: ModelType
80
- readonly name: string
81
- readonly vendor: string
82
- readonly quantization?: string
83
- readonly outputParserRegex?: string
84
- }
85
-
86
89
  export interface ClassificationFeature {
87
90
  name: string
88
91
  values: Array<string>
89
92
  }
90
93
 
94
+ export interface ClassificationLabel {
95
+ index: number
96
+ label: string
97
+ title: string
98
+ description: string
99
+ recommendedThreshold: number
100
+ }
101
+
102
+ export interface ClassificationOutput {
103
+ logits: Array<number>
104
+ probabilities: Record<string, number>
105
+ stats: ClassificationStats
106
+ }
107
+
108
+ export interface ClassificationStats {
109
+ preprocessingDuration: number
110
+ forwardPassDuration: number
111
+ postprocessingDuration: number
112
+ totalDuration: number
113
+ tokensCount: number
114
+ tokensPerSecond: number
115
+ predictedLabel: string
116
+ confidence: number
117
+ }
118
+
91
119
  export interface Config {
92
120
  preset: Preset
93
121
  contextMode: ContextMode
@@ -148,6 +176,17 @@ export interface Message {
148
176
  reasoningContent?: string
149
177
  }
150
178
 
179
+ export interface Model {
180
+ readonly repoId: string
181
+ readonly type: ModelType
182
+ readonly kind: ModelKind
183
+ readonly name: string
184
+ readonly vendor: string
185
+ readonly quantization?: string
186
+ readonly outputParserRegex?: string
187
+ readonly classificationLabels: Array<ClassificationLabel>
188
+ }
189
+
151
190
  export declare const enum ModelDownloadPhase {
152
191
  NotDownloaded = 0,
153
192
  Downloading = 1,
@@ -168,6 +207,11 @@ export interface ModelDownloadState {
168
207
  readonly error?: string
169
208
  }
170
209
 
210
+ export declare const enum ModelKind {
211
+ Local = 0,
212
+ Cloud = 1
213
+ }
214
+
171
215
  export type ModelStorageError =
172
216
  | { type: 'Io', message: string }
173
217
  | { type: 'Network', message: string }
@@ -179,8 +223,9 @@ export type ModelStorageError =
179
223
  | { type: 'Paused' }
180
224
 
181
225
  export declare const enum ModelType {
182
- Local = 0,
183
- Cloud = 1
226
+ Chat = 0,
227
+ Classification = 1,
228
+ TTS = 2
184
229
  }
185
230
 
186
231
  export interface Output {
@@ -226,12 +271,17 @@ export interface RunStats {
226
271
 
227
272
  export type SamplingMethod =
228
273
  | { type: 'Greedy' }
229
- | { type: 'Stochastic', temperature?: number, topK?: number, topP?: number, minP?: number }
274
+ | { type: 'Stochastic', temperature?: number, topK?: number, topP?: number, minP?: number, processingOrder: SamplingProcessingOrder }
230
275
 
231
276
  export type SamplingPolicy =
232
277
  | { type: 'Default' }
233
278
  | { type: 'Custom', value: SamplingMethod }
234
279
 
280
+ export declare const enum SamplingProcessingOrder {
281
+ TemperatureThenFilters = 0,
282
+ FiltersThenTemperature = 1
283
+ }
284
+
235
285
  export type SamplingSeed =
236
286
  | { type: 'Default' }
237
287
  | { type: 'Custom', seed: number }
@@ -250,6 +300,8 @@ export interface StepStats {
250
300
  processedTokensPerSecond: number
251
301
  modelRun: RunStats
252
302
  run?: RunStats
303
+ speculatorProposed: bigint
304
+ speculatorAccepted: bigint
253
305
  }
254
306
 
255
307
  export type StorageError =
package/src/napi/uzu.js CHANGED
@@ -22,23 +22,30 @@ try {
22
22
  // Re-export all runtime exports
23
23
  const {
24
24
  ChatSession,
25
+ ClassificationSession,
25
26
  Engine,
26
27
  ModelDownloadHandle,
27
28
  ProgressStream,
28
29
  ProgressUpdate,
30
+ TextToSpeechSession,
29
31
  DataType,
30
32
  FinishReason,
31
33
  ModelDownloadPhase,
34
+ ModelKind,
32
35
  ModelType,
33
36
  Role,
37
+ SamplingProcessingOrder,
34
38
  version,
35
39
  BenchmarksDevice,
36
40
  BenchmarksResult,
37
41
  BenchmarksTask,
38
- ChatModel,
39
42
  ClassificationFeature,
43
+ ClassificationLabel,
44
+ ClassificationOutput,
45
+ ClassificationStats,
40
46
  Config,
41
47
  Message,
48
+ Model,
42
49
  ModelDownloadState,
43
50
  Output,
44
51
  ParsedText,
@@ -65,23 +72,30 @@ const {
65
72
 
66
73
  module.exports = {
67
74
  ChatSession,
75
+ ClassificationSession,
68
76
  Engine,
69
77
  ModelDownloadHandle,
70
78
  ProgressStream,
71
79
  ProgressUpdate,
80
+ TextToSpeechSession,
72
81
  DataType,
73
82
  FinishReason,
74
83
  ModelDownloadPhase,
84
+ ModelKind,
75
85
  ModelType,
76
86
  Role,
87
+ SamplingProcessingOrder,
77
88
  version,
78
89
  BenchmarksDevice,
79
90
  BenchmarksResult,
80
91
  BenchmarksTask,
81
- ChatModel,
82
92
  ClassificationFeature,
93
+ ClassificationLabel,
94
+ ClassificationOutput,
95
+ ClassificationStats,
83
96
  Config,
84
97
  Message,
98
+ Model,
85
99
  ModelDownloadState,
86
100
  Output,
87
101
  ParsedText,
package/src/napi/uzu.mjs CHANGED
@@ -22,23 +22,30 @@ try {
22
22
  // Re-export all runtime exports as named exports
23
23
  export const {
24
24
  ChatSession,
25
+ ClassificationSession,
25
26
  Engine,
26
27
  ModelDownloadHandle,
27
28
  ProgressStream,
28
29
  ProgressUpdate,
30
+ TextToSpeechSession,
29
31
  DataType,
30
32
  FinishReason,
31
33
  ModelDownloadPhase,
34
+ ModelKind,
32
35
  ModelType,
33
36
  Role,
37
+ SamplingProcessingOrder,
34
38
  version,
35
39
  BenchmarksDevice,
36
40
  BenchmarksResult,
37
41
  BenchmarksTask,
38
- ChatModel,
39
42
  ClassificationFeature,
43
+ ClassificationLabel,
44
+ ClassificationOutput,
45
+ ClassificationStats,
40
46
  Config,
41
47
  Message,
48
+ Model,
42
49
  ModelDownloadState,
43
50
  Output,
44
51
  ParsedText,
package/src/napi/uzu.node CHANGED
Binary file
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.2.20';
1
+ export const VERSION = '0.3.1';
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.2.20";
1
+ export declare const VERSION = "0.3.1";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.mts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.mts","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,WAAW,CAAC"}
1
+ {"version":3,"file":"version.d.mts","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,UAAU,CAAC"}
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.2.20";
1
+ export declare const VERSION = "0.3.1";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,WAAW,CAAC"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,UAAU,CAAC"}
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '0.2.20';
4
+ exports.VERSION = '0.3.1';
5
5
  //# sourceMappingURL=version.js.map
package/version.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,QAAQ,CAAC"}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,OAAO,CAAC"}
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '0.2.20';
1
+ export const VERSION = '0.3.1';
2
2
  //# sourceMappingURL=version.mjs.map
package/version.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"version.mjs","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC"}
1
+ {"version":3,"file":"version.mjs","sourceRoot":"","sources":["src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC"}