react-native-nobodywho 3.0.0 → 4.0.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.
@@ -555,64 +555,6 @@ const FfiConverterTypeRustToolCallback = new FfiConverterCallback<RustToolCallba
555
555
 
556
556
 
557
557
 
558
- export type Asset = {
559
- id: string,
560
- path: string
561
- }
562
-
563
- /**
564
- * Generated factory for {@link Asset} record objects.
565
- */
566
- export const Asset = (() => {
567
- const defaults = () => ({
568
- });
569
- const create = (() => {
570
- return uniffiCreateRecord<Asset, ReturnType<typeof defaults>>(defaults);
571
- })();
572
- return Object.freeze({
573
- /**
574
- * Create a frozen instance of {@link Asset}, with defaults specified
575
- * in Rust, in the {@link nobodywho} crate.
576
- */
577
- create,
578
-
579
- /**
580
- * Create a frozen instance of {@link Asset}, with defaults specified
581
- * in Rust, in the {@link nobodywho} crate.
582
- */
583
- new: create,
584
-
585
- /**
586
- * Defaults specified in the {@link nobodywho} crate.
587
- */
588
- defaults: () => Object.freeze(defaults()) as Partial<Asset>,
589
-
590
- });
591
- })();
592
-
593
- const FfiConverterTypeAsset = (() => {
594
- type TypeName = Asset;
595
- class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
596
- read(from: RustBuffer): TypeName {
597
- return {
598
- id: FfiConverterString.read(from),
599
- path: FfiConverterString.read(from)
600
- };
601
- }
602
- write(value: TypeName, into: RustBuffer): void {
603
- FfiConverterString.write(value.id, into);
604
- FfiConverterString.write(value.path, into);
605
- }
606
- allocationSize(value: TypeName): number {
607
- return FfiConverterString.allocationSize(value.id) +
608
- FfiConverterString.allocationSize(value.path);
609
-
610
- }
611
- };
612
- return new FFIConverter();
613
- })();
614
-
615
-
616
558
  /**
617
559
  * A cached `.gguf` model and its on-disk size.
618
560
  */
@@ -804,6 +746,79 @@ const FfiConverterTypeMtpConfig = (() => {
804
746
  })();
805
747
 
806
748
 
749
+ /**
750
+ * Settings to apply before a `complete` turn. An unset field keeps what the
751
+ * chat has; a set one stays set, like a leading system message.
752
+ */
753
+ export type Options = {
754
+ sampler: SamplerConfigInterface | undefined,
755
+ /**
756
+ * Replaces the chat's template variables wholesale.
757
+ */
758
+ templateVariables: Map<string, boolean> | undefined,
759
+ /**
760
+ * Re-selects the chat template, so the turn re-prefills from near token
761
+ * zero. An empty list removes the tools.
762
+ */
763
+ tools: Array<RustToolInterface> | undefined
764
+ }
765
+
766
+ /**
767
+ * Generated factory for {@link Options} record objects.
768
+ */
769
+ export const Options = (() => {
770
+ const defaults = () => ({sampler: undefined,templateVariables: undefined,tools: undefined
771
+ });
772
+ const create = (() => {
773
+ return uniffiCreateRecord<Options, ReturnType<typeof defaults>>(defaults);
774
+ })();
775
+ return Object.freeze({
776
+ /**
777
+ * Create a frozen instance of {@link Options}, with defaults specified
778
+ * in Rust, in the {@link nobodywho} crate.
779
+ */
780
+ create,
781
+
782
+ /**
783
+ * Create a frozen instance of {@link Options}, with defaults specified
784
+ * in Rust, in the {@link nobodywho} crate.
785
+ */
786
+ new: create,
787
+
788
+ /**
789
+ * Defaults specified in the {@link nobodywho} crate.
790
+ */
791
+ defaults: () => Object.freeze(defaults()) as Partial<Options>,
792
+
793
+ });
794
+ })();
795
+
796
+ const FfiConverterTypeOptions = (() => {
797
+ type TypeName = Options;
798
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
799
+ read(from: RustBuffer): TypeName {
800
+ return {
801
+ sampler: FfiConverterOptionalTypeSamplerConfig.read(from),
802
+ templateVariables: FfiConverterOptionalMapStringBool.read(from),
803
+ tools: FfiConverterOptionalArrayTypeRustTool.read(from)
804
+ };
805
+ }
806
+ write(value: TypeName, into: RustBuffer): void {
807
+ FfiConverterOptionalTypeSamplerConfig.write(value.sampler, into);
808
+ FfiConverterOptionalMapStringBool.write(value.templateVariables, into);
809
+ FfiConverterOptionalArrayTypeRustTool.write(value.tools, into);
810
+ }
811
+ allocationSize(value: TypeName): number {
812
+ return FfiConverterOptionalTypeSamplerConfig.allocationSize(value.sampler) +
813
+ FfiConverterOptionalMapStringBool.allocationSize(value.templateVariables) +
814
+ FfiConverterOptionalArrayTypeRustTool.allocationSize(value.tools);
815
+
816
+ }
817
+ };
818
+ return new FFIConverter();
819
+ })();
820
+
821
+
807
822
  /**
808
823
  * A pending tool call waiting for resolution from the language binding.
809
824
  */
@@ -999,6 +1014,209 @@ const FfiConverterString = uniffiCreateFfiConverterString(stringConverter);
999
1014
 
1000
1015
 
1001
1016
 
1017
+ // Enum: ContentPart
1018
+ export enum ContentPart_Tags {
1019
+ Text = "Text",
1020
+ Image = "Image",
1021
+ Audio = "Audio"
1022
+ }
1023
+ /**
1024
+ * One piece of a message: a run of text, or a media file at this position.
1025
+ * The core type's bitmap id is worker-local, so it is not mirrored — media is
1026
+ * re-registered from the path whenever content is handed back in.
1027
+ */
1028
+ export const ContentPart = (() => {
1029
+
1030
+
1031
+ type Text__interface = {
1032
+ tag: ContentPart_Tags.Text;
1033
+ inner: Readonly<{text: string}>
1034
+ };
1035
+
1036
+
1037
+ class Text_ extends UniffiEnum implements Text__interface {
1038
+ /**
1039
+ * @private
1040
+ * This field is private and should not be used, use `tag` instead.
1041
+ */
1042
+ readonly [uniffiTypeNameSymbol] = "ContentPart";
1043
+ readonly tag = ContentPart_Tags.Text;
1044
+ readonly inner: Readonly<{text: string}>;
1045
+ constructor(inner: { text: string }) {
1046
+ super("ContentPart", "Text");
1047
+ this.inner = Object.freeze(inner);
1048
+ }
1049
+
1050
+ static new(inner: { text: string }): Text_ {
1051
+ return new Text_(inner);
1052
+ }
1053
+
1054
+ static instanceOf(obj: any): obj is Text_ {
1055
+ return obj.tag === ContentPart_Tags.Text;
1056
+ }
1057
+
1058
+
1059
+
1060
+
1061
+ }
1062
+
1063
+
1064
+ type Image__interface = {
1065
+ tag: ContentPart_Tags.Image;
1066
+ inner: Readonly<{path: string}>
1067
+ };
1068
+
1069
+
1070
+ class Image_ extends UniffiEnum implements Image__interface {
1071
+ /**
1072
+ * @private
1073
+ * This field is private and should not be used, use `tag` instead.
1074
+ */
1075
+ readonly [uniffiTypeNameSymbol] = "ContentPart";
1076
+ readonly tag = ContentPart_Tags.Image;
1077
+ readonly inner: Readonly<{path: string}>;
1078
+ constructor(inner: { path: string }) {
1079
+ super("ContentPart", "Image");
1080
+ this.inner = Object.freeze(inner);
1081
+ }
1082
+
1083
+ static new(inner: { path: string }): Image_ {
1084
+ return new Image_(inner);
1085
+ }
1086
+
1087
+ static instanceOf(obj: any): obj is Image_ {
1088
+ return obj.tag === ContentPart_Tags.Image;
1089
+ }
1090
+
1091
+
1092
+
1093
+
1094
+ }
1095
+
1096
+
1097
+ type Audio__interface = {
1098
+ tag: ContentPart_Tags.Audio;
1099
+ inner: Readonly<{path: string}>
1100
+ };
1101
+
1102
+
1103
+ class Audio_ extends UniffiEnum implements Audio__interface {
1104
+ /**
1105
+ * @private
1106
+ * This field is private and should not be used, use `tag` instead.
1107
+ */
1108
+ readonly [uniffiTypeNameSymbol] = "ContentPart";
1109
+ readonly tag = ContentPart_Tags.Audio;
1110
+ readonly inner: Readonly<{path: string}>;
1111
+ constructor(inner: { path: string }) {
1112
+ super("ContentPart", "Audio");
1113
+ this.inner = Object.freeze(inner);
1114
+ }
1115
+
1116
+ static new(inner: { path: string }): Audio_ {
1117
+ return new Audio_(inner);
1118
+ }
1119
+
1120
+ static instanceOf(obj: any): obj is Audio_ {
1121
+ return obj.tag === ContentPart_Tags.Audio;
1122
+ }
1123
+
1124
+
1125
+
1126
+
1127
+ }
1128
+
1129
+ function instanceOf(obj: any): obj is ContentPart {
1130
+ return obj[uniffiTypeNameSymbol] === "ContentPart";
1131
+ }
1132
+
1133
+ return Object.freeze({
1134
+ instanceOf,
1135
+ Text: Text_,
1136
+ Image: Image_,
1137
+ Audio: Audio_
1138
+ });
1139
+
1140
+ })();
1141
+
1142
+
1143
+ /**
1144
+ * One piece of a message: a run of text, or a media file at this position.
1145
+ * The core type's bitmap id is worker-local, so it is not mirrored — media is
1146
+ * re-registered from the path whenever content is handed back in.
1147
+ */
1148
+
1149
+ export type ContentPart = InstanceType<
1150
+ typeof ContentPart[keyof Omit<typeof ContentPart, 'instanceOf'>]
1151
+ >;
1152
+
1153
+ // FfiConverter for enum ContentPart
1154
+ const FfiConverterTypeContentPart = (() => {
1155
+ const ordinalConverter = FfiConverterInt32;
1156
+ type TypeName = ContentPart;
1157
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
1158
+ read(from: RustBuffer): TypeName {
1159
+ switch (ordinalConverter.read(from)) {
1160
+ case 1: return new ContentPart.Text({text: FfiConverterString.read(from) });
1161
+ case 2: return new ContentPart.Image({path: FfiConverterString.read(from) });
1162
+ case 3: return new ContentPart.Audio({path: FfiConverterString.read(from) });
1163
+ default: throw new UniffiInternalError.UnexpectedEnumCase();
1164
+ }
1165
+ }
1166
+ write(value: TypeName, into: RustBuffer): void {
1167
+ switch (value.tag) {
1168
+ case ContentPart_Tags.Text: {
1169
+ ordinalConverter.write(1, into);
1170
+ const inner = value.inner;
1171
+ FfiConverterString.write(inner.text, into);
1172
+ return;
1173
+ }
1174
+ case ContentPart_Tags.Image: {
1175
+ ordinalConverter.write(2, into);
1176
+ const inner = value.inner;
1177
+ FfiConverterString.write(inner.path, into);
1178
+ return;
1179
+ }
1180
+ case ContentPart_Tags.Audio: {
1181
+ ordinalConverter.write(3, into);
1182
+ const inner = value.inner;
1183
+ FfiConverterString.write(inner.path, into);
1184
+ return;
1185
+ }
1186
+ default:
1187
+ // Throwing from here means that ContentPart_Tags hasn't matched an ordinal.
1188
+ throw new UniffiInternalError.UnexpectedEnumCase();
1189
+ }
1190
+ }
1191
+ allocationSize(value: TypeName): number {
1192
+ switch (value.tag) {
1193
+ case ContentPart_Tags.Text: {
1194
+ const inner = value.inner;
1195
+ let size = ordinalConverter.allocationSize(1);
1196
+ size += FfiConverterString.allocationSize(inner.text);
1197
+ return size;
1198
+ }
1199
+ case ContentPart_Tags.Image: {
1200
+ const inner = value.inner;
1201
+ let size = ordinalConverter.allocationSize(2);
1202
+ size += FfiConverterString.allocationSize(inner.path);
1203
+ return size;
1204
+ }
1205
+ case ContentPart_Tags.Audio: {
1206
+ const inner = value.inner;
1207
+ let size = ordinalConverter.allocationSize(3);
1208
+ size += FfiConverterString.allocationSize(inner.path);
1209
+ return size;
1210
+ }
1211
+ default: throw new UniffiInternalError.UnexpectedEnumCase();
1212
+ }
1213
+ }
1214
+ }
1215
+ return new FFIConverter();
1216
+ })();
1217
+
1218
+
1219
+
1002
1220
  // Enum: Message
1003
1221
  export enum Message_Tags {
1004
1222
  User = "User",
@@ -1011,7 +1229,7 @@ export const Message = (() => {
1011
1229
 
1012
1230
  type User__interface = {
1013
1231
  tag: Message_Tags.User;
1014
- inner: Readonly<{content: string; assets: Array<Asset>}>
1232
+ inner: Readonly<{content: MessageContent}>
1015
1233
  };
1016
1234
 
1017
1235
 
@@ -1022,13 +1240,13 @@ export const Message = (() => {
1022
1240
  */
1023
1241
  readonly [uniffiTypeNameSymbol] = "Message";
1024
1242
  readonly tag = Message_Tags.User;
1025
- readonly inner: Readonly<{content: string; assets: Array<Asset>}>;
1026
- constructor(inner: { content: string, assets: Array<Asset> }) {
1243
+ readonly inner: Readonly<{content: MessageContent}>;
1244
+ constructor(inner: { content: MessageContent }) {
1027
1245
  super("Message", "User");
1028
1246
  this.inner = Object.freeze(inner);
1029
1247
  }
1030
1248
 
1031
- static new(inner: { content: string, assets: Array<Asset> }): User_ {
1249
+ static new(inner: { content: MessageContent }): User_ {
1032
1250
  return new User_(inner);
1033
1251
  }
1034
1252
 
@@ -1044,7 +1262,7 @@ export const Message = (() => {
1044
1262
 
1045
1263
  type Assistant__interface = {
1046
1264
  tag: Message_Tags.Assistant;
1047
- inner: Readonly<{content: string; toolCalls: Array<ToolCall> | undefined}>
1265
+ inner: Readonly<{content: MessageContent; toolCalls: Array<ToolCall> | undefined}>
1048
1266
  };
1049
1267
 
1050
1268
 
@@ -1055,13 +1273,13 @@ export const Message = (() => {
1055
1273
  */
1056
1274
  readonly [uniffiTypeNameSymbol] = "Message";
1057
1275
  readonly tag = Message_Tags.Assistant;
1058
- readonly inner: Readonly<{content: string; toolCalls: Array<ToolCall> | undefined}>;
1059
- constructor(inner: { content: string, toolCalls: Array<ToolCall> | undefined }) {
1276
+ readonly inner: Readonly<{content: MessageContent; toolCalls: Array<ToolCall> | undefined}>;
1277
+ constructor(inner: { content: MessageContent, toolCalls: Array<ToolCall> | undefined }) {
1060
1278
  super("Message", "Assistant");
1061
1279
  this.inner = Object.freeze(inner);
1062
1280
  }
1063
1281
 
1064
- static new(inner: { content: string, toolCalls: Array<ToolCall> | undefined }): Assistant_ {
1282
+ static new(inner: { content: MessageContent, toolCalls: Array<ToolCall> | undefined }): Assistant_ {
1065
1283
  return new Assistant_(inner);
1066
1284
  }
1067
1285
 
@@ -1077,7 +1295,7 @@ export const Message = (() => {
1077
1295
 
1078
1296
  type System__interface = {
1079
1297
  tag: Message_Tags.System;
1080
- inner: Readonly<{content: string}>
1298
+ inner: Readonly<{content: MessageContent}>
1081
1299
  };
1082
1300
 
1083
1301
 
@@ -1088,13 +1306,13 @@ export const Message = (() => {
1088
1306
  */
1089
1307
  readonly [uniffiTypeNameSymbol] = "Message";
1090
1308
  readonly tag = Message_Tags.System;
1091
- readonly inner: Readonly<{content: string}>;
1092
- constructor(inner: { content: string }) {
1309
+ readonly inner: Readonly<{content: MessageContent}>;
1310
+ constructor(inner: { content: MessageContent }) {
1093
1311
  super("Message", "System");
1094
1312
  this.inner = Object.freeze(inner);
1095
1313
  }
1096
1314
 
1097
- static new(inner: { content: string }): System_ {
1315
+ static new(inner: { content: MessageContent }): System_ {
1098
1316
  return new System_(inner);
1099
1317
  }
1100
1318
 
@@ -1110,7 +1328,7 @@ export const Message = (() => {
1110
1328
 
1111
1329
  type Tool__interface = {
1112
1330
  tag: Message_Tags.Tool;
1113
- inner: Readonly<{name: string; content: string}>
1331
+ inner: Readonly<{name: string; content: MessageContent}>
1114
1332
  };
1115
1333
 
1116
1334
 
@@ -1121,13 +1339,13 @@ export const Message = (() => {
1121
1339
  */
1122
1340
  readonly [uniffiTypeNameSymbol] = "Message";
1123
1341
  readonly tag = Message_Tags.Tool;
1124
- readonly inner: Readonly<{name: string; content: string}>;
1125
- constructor(inner: { name: string, content: string }) {
1342
+ readonly inner: Readonly<{name: string; content: MessageContent}>;
1343
+ constructor(inner: { name: string, content: MessageContent }) {
1126
1344
  super("Message", "Tool");
1127
1345
  this.inner = Object.freeze(inner);
1128
1346
  }
1129
1347
 
1130
- static new(inner: { name: string, content: string }): Tool_ {
1348
+ static new(inner: { name: string, content: MessageContent }): Tool_ {
1131
1349
  return new Tool_(inner);
1132
1350
  }
1133
1351
 
@@ -1167,10 +1385,10 @@ const FfiConverterTypeMessage = (() => {
1167
1385
  class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
1168
1386
  read(from: RustBuffer): TypeName {
1169
1387
  switch (ordinalConverter.read(from)) {
1170
- case 1: return new Message.User({content: FfiConverterString.read(from), assets: FfiConverterArrayTypeAsset.read(from) });
1171
- case 2: return new Message.Assistant({content: FfiConverterString.read(from), toolCalls: FfiConverterOptionalArrayTypeToolCall.read(from) });
1172
- case 3: return new Message.System({content: FfiConverterString.read(from) });
1173
- case 4: return new Message.Tool({name: FfiConverterString.read(from), content: FfiConverterString.read(from) });
1388
+ case 1: return new Message.User({content: FfiConverterTypeMessageContent.read(from) });
1389
+ case 2: return new Message.Assistant({content: FfiConverterTypeMessageContent.read(from), toolCalls: FfiConverterOptionalArrayTypeToolCall.read(from) });
1390
+ case 3: return new Message.System({content: FfiConverterTypeMessageContent.read(from) });
1391
+ case 4: return new Message.Tool({name: FfiConverterString.read(from), content: FfiConverterTypeMessageContent.read(from) });
1174
1392
  default: throw new UniffiInternalError.UnexpectedEnumCase();
1175
1393
  }
1176
1394
  }
@@ -1179,28 +1397,27 @@ const FfiConverterTypeMessage = (() => {
1179
1397
  case Message_Tags.User: {
1180
1398
  ordinalConverter.write(1, into);
1181
1399
  const inner = value.inner;
1182
- FfiConverterString.write(inner.content, into);
1183
- FfiConverterArrayTypeAsset.write(inner.assets, into);
1400
+ FfiConverterTypeMessageContent.write(inner.content, into);
1184
1401
  return;
1185
1402
  }
1186
1403
  case Message_Tags.Assistant: {
1187
1404
  ordinalConverter.write(2, into);
1188
1405
  const inner = value.inner;
1189
- FfiConverterString.write(inner.content, into);
1406
+ FfiConverterTypeMessageContent.write(inner.content, into);
1190
1407
  FfiConverterOptionalArrayTypeToolCall.write(inner.toolCalls, into);
1191
1408
  return;
1192
1409
  }
1193
1410
  case Message_Tags.System: {
1194
1411
  ordinalConverter.write(3, into);
1195
1412
  const inner = value.inner;
1196
- FfiConverterString.write(inner.content, into);
1413
+ FfiConverterTypeMessageContent.write(inner.content, into);
1197
1414
  return;
1198
1415
  }
1199
1416
  case Message_Tags.Tool: {
1200
1417
  ordinalConverter.write(4, into);
1201
1418
  const inner = value.inner;
1202
1419
  FfiConverterString.write(inner.name, into);
1203
- FfiConverterString.write(inner.content, into);
1420
+ FfiConverterTypeMessageContent.write(inner.content, into);
1204
1421
  return;
1205
1422
  }
1206
1423
  default:
@@ -1213,28 +1430,27 @@ const FfiConverterTypeMessage = (() => {
1213
1430
  case Message_Tags.User: {
1214
1431
  const inner = value.inner;
1215
1432
  let size = ordinalConverter.allocationSize(1);
1216
- size += FfiConverterString.allocationSize(inner.content);
1217
- size += FfiConverterArrayTypeAsset.allocationSize(inner.assets);
1433
+ size += FfiConverterTypeMessageContent.allocationSize(inner.content);
1218
1434
  return size;
1219
1435
  }
1220
1436
  case Message_Tags.Assistant: {
1221
1437
  const inner = value.inner;
1222
1438
  let size = ordinalConverter.allocationSize(2);
1223
- size += FfiConverterString.allocationSize(inner.content);
1439
+ size += FfiConverterTypeMessageContent.allocationSize(inner.content);
1224
1440
  size += FfiConverterOptionalArrayTypeToolCall.allocationSize(inner.toolCalls);
1225
1441
  return size;
1226
1442
  }
1227
1443
  case Message_Tags.System: {
1228
1444
  const inner = value.inner;
1229
1445
  let size = ordinalConverter.allocationSize(3);
1230
- size += FfiConverterString.allocationSize(inner.content);
1446
+ size += FfiConverterTypeMessageContent.allocationSize(inner.content);
1231
1447
  return size;
1232
1448
  }
1233
1449
  case Message_Tags.Tool: {
1234
1450
  const inner = value.inner;
1235
1451
  let size = ordinalConverter.allocationSize(4);
1236
1452
  size += FfiConverterString.allocationSize(inner.name);
1237
- size += FfiConverterString.allocationSize(inner.content);
1453
+ size += FfiConverterTypeMessageContent.allocationSize(inner.content);
1238
1454
  return size;
1239
1455
  }
1240
1456
  default: throw new UniffiInternalError.UnexpectedEnumCase();
@@ -1246,94 +1462,18 @@ const FfiConverterTypeMessage = (() => {
1246
1462
 
1247
1463
 
1248
1464
 
1249
-
1250
- // Flat error type: NobodyWhoError
1251
- export enum NobodyWhoError_Tags {
1252
- Error = "Error"
1253
- }
1254
- export const NobodyWhoError = (() => {
1255
- class Error extends UniffiError {
1256
- /**
1257
- * @private
1258
- * This field is private and should not be used.
1259
- */
1260
- readonly [uniffiTypeNameSymbol]: string = "NobodyWhoError";
1261
- /**
1262
- * @private
1263
- * This field is private and should not be used.
1264
- */
1265
- readonly [variantOrdinalSymbol] = 1;
1266
-
1267
- readonly tag = NobodyWhoError_Tags.Error;
1268
-
1269
- constructor(message: string) {
1270
- super("NobodyWhoError", "Error", message);
1271
- }
1272
-
1273
- static instanceOf(e: any): e is Error {
1274
- return (
1275
- instanceOf(e) && (e as any)[variantOrdinalSymbol] === 1
1276
- );
1277
- }
1278
- }
1279
-
1280
- // Utility function which does not rely on instanceof.
1281
- function instanceOf(e: any): e is NobodyWhoError {
1282
- return (e as any)[uniffiTypeNameSymbol] === "NobodyWhoError";
1283
- }
1284
- return {
1285
- Error,
1286
- instanceOf,
1287
- };
1288
- })();
1289
-
1290
- // Union type for NobodyWhoError error type.
1291
-
1292
-
1293
- export type NobodyWhoError = InstanceType<
1294
- typeof NobodyWhoError[keyof Omit<typeof NobodyWhoError, 'instanceOf'>]
1295
- >;
1296
-
1297
- const FfiConverterTypeNobodyWhoError = (() => {
1298
- const intConverter = FfiConverterInt32;
1299
- type TypeName = NobodyWhoError;
1300
- class FfiConverter extends AbstractFfiConverterByteArray<TypeName> {
1301
- read(from: RustBuffer): TypeName {
1302
- switch (intConverter.read(from)) {
1303
- case 1: return new NobodyWhoError.Error(FfiConverterString.read(from)
1304
- );
1305
-
1306
- default: throw new UniffiInternalError.UnexpectedEnumCase();
1307
- }
1308
- }
1309
- write(value: TypeName, into: RustBuffer): void {
1310
- const obj = value as any;
1311
- const index = obj[variantOrdinalSymbol] as number;
1312
- intConverter.write(index, into);
1313
- }
1314
- allocationSize(value: TypeName): number {
1315
- return intConverter.allocationSize(0);
1316
- }
1317
- }
1318
- return new FfiConverter();
1319
- })();
1320
-
1321
-
1322
- // Enum: PromptPart
1323
- export enum PromptPart_Tags {
1465
+ // Enum: MessageContent
1466
+ export enum MessageContent_Tags {
1324
1467
  Text = "Text",
1325
- Image = "Image",
1326
- Audio = "Audio"
1468
+ Parts = "Parts",
1469
+ Json = "Json"
1327
1470
  }
1328
- /**
1329
- * A part of a multimodal prompt. Mirrors the core `PromptPart` enum.
1330
- */
1331
- export const PromptPart = (() => {
1471
+ export const MessageContent = (() => {
1332
1472
 
1333
1473
 
1334
1474
  type Text__interface = {
1335
- tag: PromptPart_Tags.Text;
1336
- inner: Readonly<{content: string}>
1475
+ tag: MessageContent_Tags.Text;
1476
+ inner: Readonly<{text: string}>
1337
1477
  };
1338
1478
 
1339
1479
 
@@ -1342,20 +1482,20 @@ export const PromptPart = (() => {
1342
1482
  * @private
1343
1483
  * This field is private and should not be used, use `tag` instead.
1344
1484
  */
1345
- readonly [uniffiTypeNameSymbol] = "PromptPart";
1346
- readonly tag = PromptPart_Tags.Text;
1347
- readonly inner: Readonly<{content: string}>;
1348
- constructor(inner: { content: string }) {
1349
- super("PromptPart", "Text");
1485
+ readonly [uniffiTypeNameSymbol] = "MessageContent";
1486
+ readonly tag = MessageContent_Tags.Text;
1487
+ readonly inner: Readonly<{text: string}>;
1488
+ constructor(inner: { text: string }) {
1489
+ super("MessageContent", "Text");
1350
1490
  this.inner = Object.freeze(inner);
1351
1491
  }
1352
1492
 
1353
- static new(inner: { content: string }): Text_ {
1493
+ static new(inner: { text: string }): Text_ {
1354
1494
  return new Text_(inner);
1355
1495
  }
1356
1496
 
1357
1497
  static instanceOf(obj: any): obj is Text_ {
1358
- return obj.tag === PromptPart_Tags.Text;
1498
+ return obj.tag === MessageContent_Tags.Text;
1359
1499
  }
1360
1500
 
1361
1501
 
@@ -1364,31 +1504,31 @@ export const PromptPart = (() => {
1364
1504
  }
1365
1505
 
1366
1506
 
1367
- type Image__interface = {
1368
- tag: PromptPart_Tags.Image;
1369
- inner: Readonly<{path: string}>
1507
+ type Parts__interface = {
1508
+ tag: MessageContent_Tags.Parts;
1509
+ inner: Readonly<{parts: Array<ContentPart>}>
1370
1510
  };
1371
1511
 
1372
1512
 
1373
- class Image_ extends UniffiEnum implements Image__interface {
1513
+ class Parts_ extends UniffiEnum implements Parts__interface {
1374
1514
  /**
1375
1515
  * @private
1376
1516
  * This field is private and should not be used, use `tag` instead.
1377
1517
  */
1378
- readonly [uniffiTypeNameSymbol] = "PromptPart";
1379
- readonly tag = PromptPart_Tags.Image;
1380
- readonly inner: Readonly<{path: string}>;
1381
- constructor(inner: { path: string }) {
1382
- super("PromptPart", "Image");
1518
+ readonly [uniffiTypeNameSymbol] = "MessageContent";
1519
+ readonly tag = MessageContent_Tags.Parts;
1520
+ readonly inner: Readonly<{parts: Array<ContentPart>}>;
1521
+ constructor(inner: { parts: Array<ContentPart> }) {
1522
+ super("MessageContent", "Parts");
1383
1523
  this.inner = Object.freeze(inner);
1384
1524
  }
1385
1525
 
1386
- static new(inner: { path: string }): Image_ {
1387
- return new Image_(inner);
1526
+ static new(inner: { parts: Array<ContentPart> }): Parts_ {
1527
+ return new Parts_(inner);
1388
1528
  }
1389
1529
 
1390
- static instanceOf(obj: any): obj is Image_ {
1391
- return obj.tag === PromptPart_Tags.Image;
1530
+ static instanceOf(obj: any): obj is Parts_ {
1531
+ return obj.tag === MessageContent_Tags.Parts;
1392
1532
  }
1393
1533
 
1394
1534
 
@@ -1397,31 +1537,35 @@ export const PromptPart = (() => {
1397
1537
  }
1398
1538
 
1399
1539
 
1400
- type Audio__interface = {
1401
- tag: PromptPart_Tags.Audio;
1402
- inner: Readonly<{path: string}>
1540
+ type Json__interface = {
1541
+ tag: MessageContent_Tags.Json;
1542
+ inner: Readonly<{json: string}>
1403
1543
  };
1404
1544
 
1405
1545
 
1406
- class Audio_ extends UniffiEnum implements Audio__interface {
1546
+ /**
1547
+ * JSON-encoded. Chat templates written for structured content receive it
1548
+ * as a real list or map rather than as a string.
1549
+ */
1550
+ class Json_ extends UniffiEnum implements Json__interface {
1407
1551
  /**
1408
1552
  * @private
1409
1553
  * This field is private and should not be used, use `tag` instead.
1410
1554
  */
1411
- readonly [uniffiTypeNameSymbol] = "PromptPart";
1412
- readonly tag = PromptPart_Tags.Audio;
1413
- readonly inner: Readonly<{path: string}>;
1414
- constructor(inner: { path: string }) {
1415
- super("PromptPart", "Audio");
1555
+ readonly [uniffiTypeNameSymbol] = "MessageContent";
1556
+ readonly tag = MessageContent_Tags.Json;
1557
+ readonly inner: Readonly<{json: string}>;
1558
+ constructor(inner: { json: string }) {
1559
+ super("MessageContent", "Json");
1416
1560
  this.inner = Object.freeze(inner);
1417
1561
  }
1418
1562
 
1419
- static new(inner: { path: string }): Audio_ {
1420
- return new Audio_(inner);
1563
+ static new(inner: { json: string }): Json_ {
1564
+ return new Json_(inner);
1421
1565
  }
1422
1566
 
1423
- static instanceOf(obj: any): obj is Audio_ {
1424
- return obj.tag === PromptPart_Tags.Audio;
1567
+ static instanceOf(obj: any): obj is Json_ {
1568
+ return obj.tag === MessageContent_Tags.Json;
1425
1569
  }
1426
1570
 
1427
1571
 
@@ -1429,84 +1573,81 @@ export const PromptPart = (() => {
1429
1573
 
1430
1574
  }
1431
1575
 
1432
- function instanceOf(obj: any): obj is PromptPart {
1433
- return obj[uniffiTypeNameSymbol] === "PromptPart";
1576
+ function instanceOf(obj: any): obj is MessageContent {
1577
+ return obj[uniffiTypeNameSymbol] === "MessageContent";
1434
1578
  }
1435
1579
 
1436
1580
  return Object.freeze({
1437
1581
  instanceOf,
1438
1582
  Text: Text_,
1439
- Image: Image_,
1440
- Audio: Audio_
1583
+ Parts: Parts_,
1584
+ Json: Json_
1441
1585
  });
1442
1586
 
1443
1587
  })();
1444
1588
 
1445
1589
 
1446
- /**
1447
- * A part of a multimodal prompt. Mirrors the core `PromptPart` enum.
1448
- */
1449
1590
 
1450
- export type PromptPart = InstanceType<
1451
- typeof PromptPart[keyof Omit<typeof PromptPart, 'instanceOf'>]
1591
+ export type MessageContent = InstanceType<
1592
+ typeof MessageContent[keyof Omit<typeof MessageContent, 'instanceOf'>]
1452
1593
  >;
1453
1594
 
1454
- // FfiConverter for enum PromptPart
1455
- const FfiConverterTypePromptPart = (() => {
1595
+ // FfiConverter for enum MessageContent
1596
+ const FfiConverterTypeMessageContent = (() => {
1456
1597
  const ordinalConverter = FfiConverterInt32;
1457
- type TypeName = PromptPart;
1598
+ type TypeName = MessageContent;
1458
1599
  class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
1459
1600
  read(from: RustBuffer): TypeName {
1460
1601
  switch (ordinalConverter.read(from)) {
1461
- case 1: return new PromptPart.Text({content: FfiConverterString.read(from) });
1462
- case 2: return new PromptPart.Image({path: FfiConverterString.read(from) });
1463
- case 3: return new PromptPart.Audio({path: FfiConverterString.read(from) });
1602
+ case 1: return new MessageContent.Text({text: FfiConverterString.read(from) });
1603
+ case 2: return new MessageContent.Parts({parts: FfiConverterArrayTypeContentPart.read(from) });
1604
+ case 3: return new MessageContent.Json({json: FfiConverterString.read(from) });
1464
1605
  default: throw new UniffiInternalError.UnexpectedEnumCase();
1465
1606
  }
1466
1607
  }
1467
1608
  write(value: TypeName, into: RustBuffer): void {
1468
1609
  switch (value.tag) {
1469
- case PromptPart_Tags.Text: {
1610
+ case MessageContent_Tags.Text: {
1470
1611
  ordinalConverter.write(1, into);
1471
1612
  const inner = value.inner;
1472
- FfiConverterString.write(inner.content, into);
1613
+ FfiConverterString.write(inner.text, into);
1473
1614
  return;
1474
1615
  }
1475
- case PromptPart_Tags.Image: {
1616
+ case MessageContent_Tags.Parts: {
1476
1617
  ordinalConverter.write(2, into);
1477
1618
  const inner = value.inner;
1478
- FfiConverterString.write(inner.path, into);
1619
+ FfiConverterArrayTypeContentPart.write(inner.parts, into);
1479
1620
  return;
1480
1621
  }
1481
- case PromptPart_Tags.Audio: {
1622
+ case MessageContent_Tags.Json: {
1482
1623
  ordinalConverter.write(3, into);
1483
1624
  const inner = value.inner;
1484
- FfiConverterString.write(inner.path, into);
1625
+ FfiConverterString.write(inner.json, into);
1485
1626
  return;
1486
1627
  }
1487
1628
  default:
1488
- // Throwing from here means that PromptPart_Tags hasn't matched an ordinal.
1629
+ // Throwing from here means that MessageContent_Tags hasn't matched an ordinal.
1489
1630
  throw new UniffiInternalError.UnexpectedEnumCase();
1490
1631
  }
1491
1632
  }
1492
1633
  allocationSize(value: TypeName): number {
1493
1634
  switch (value.tag) {
1494
- case PromptPart_Tags.Text: {
1635
+ case MessageContent_Tags.Text: {
1495
1636
  const inner = value.inner;
1496
1637
  let size = ordinalConverter.allocationSize(1);
1497
- size += FfiConverterString.allocationSize(inner.content);
1638
+ size += FfiConverterString.allocationSize(inner.text);
1498
1639
  return size;
1499
1640
  }
1500
- case PromptPart_Tags.Image: {
1641
+ case MessageContent_Tags.Parts: {
1501
1642
  const inner = value.inner;
1502
1643
  let size = ordinalConverter.allocationSize(2);
1503
- size += FfiConverterString.allocationSize(inner.path);
1644
+ size += FfiConverterArrayTypeContentPart.allocationSize(inner.parts);
1504
1645
  return size;
1505
1646
  }
1506
- case PromptPart_Tags.Audio: {
1647
+ case MessageContent_Tags.Json: {
1507
1648
  const inner = value.inner;
1508
1649
  let size = ordinalConverter.allocationSize(3);
1509
- size += FfiConverterString.allocationSize(inner.path);
1650
+ size += FfiConverterString.allocationSize(inner.json);
1510
1651
  return size;
1511
1652
  }
1512
1653
  default: throw new UniffiInternalError.UnexpectedEnumCase();
@@ -1518,6 +1659,79 @@ const FfiConverterTypePromptPart = (() => {
1518
1659
 
1519
1660
 
1520
1661
 
1662
+
1663
+ // Flat error type: NobodyWhoError
1664
+ export enum NobodyWhoError_Tags {
1665
+ Error = "Error"
1666
+ }
1667
+ export const NobodyWhoError = (() => {
1668
+ class Error extends UniffiError {
1669
+ /**
1670
+ * @private
1671
+ * This field is private and should not be used.
1672
+ */
1673
+ readonly [uniffiTypeNameSymbol]: string = "NobodyWhoError";
1674
+ /**
1675
+ * @private
1676
+ * This field is private and should not be used.
1677
+ */
1678
+ readonly [variantOrdinalSymbol] = 1;
1679
+
1680
+ readonly tag = NobodyWhoError_Tags.Error;
1681
+
1682
+ constructor(message: string) {
1683
+ super("NobodyWhoError", "Error", message);
1684
+ }
1685
+
1686
+ static instanceOf(e: any): e is Error {
1687
+ return (
1688
+ instanceOf(e) && (e as any)[variantOrdinalSymbol] === 1
1689
+ );
1690
+ }
1691
+ }
1692
+
1693
+ // Utility function which does not rely on instanceof.
1694
+ function instanceOf(e: any): e is NobodyWhoError {
1695
+ return (e as any)[uniffiTypeNameSymbol] === "NobodyWhoError";
1696
+ }
1697
+ return {
1698
+ Error,
1699
+ instanceOf,
1700
+ };
1701
+ })();
1702
+
1703
+ // Union type for NobodyWhoError error type.
1704
+
1705
+
1706
+ export type NobodyWhoError = InstanceType<
1707
+ typeof NobodyWhoError[keyof Omit<typeof NobodyWhoError, 'instanceOf'>]
1708
+ >;
1709
+
1710
+ const FfiConverterTypeNobodyWhoError = (() => {
1711
+ const intConverter = FfiConverterInt32;
1712
+ type TypeName = NobodyWhoError;
1713
+ class FfiConverter extends AbstractFfiConverterByteArray<TypeName> {
1714
+ read(from: RustBuffer): TypeName {
1715
+ switch (intConverter.read(from)) {
1716
+ case 1: return new NobodyWhoError.Error(FfiConverterString.read(from)
1717
+ );
1718
+
1719
+ default: throw new UniffiInternalError.UnexpectedEnumCase();
1720
+ }
1721
+ }
1722
+ write(value: TypeName, into: RustBuffer): void {
1723
+ const obj = value as any;
1724
+ const index = obj[variantOrdinalSymbol] as number;
1725
+ intConverter.write(index, into);
1726
+ }
1727
+ allocationSize(value: TypeName): number {
1728
+ return intConverter.allocationSize(0);
1729
+ }
1730
+ }
1731
+ return new FfiConverter();
1732
+ })();
1733
+
1734
+
1521
1735
  /**
1522
1736
  * `push` always returns one of these: `Speech`/`Silence` for the confirmed
1523
1737
  * state when unchanged since the last call, or `SpeechStarted`/`SpeechEnded`
@@ -1562,6 +1776,10 @@ const FfiConverterTypeVoiceActivityDetectionEvent = (() => {
1562
1776
 
1563
1777
 
1564
1778
 
1779
+ // FfiConverter for Map</*i32*/number, /*f32*/number>
1780
+ const FfiConverterMapInt32Float32 = new FfiConverterMap(FfiConverterInt32, FfiConverterFloat32);
1781
+
1782
+
1565
1783
  // FfiConverter for Map<string, boolean>
1566
1784
  const FfiConverterMapStringBool = new FfiConverterMap(FfiConverterString, FfiConverterBool);
1567
1785
 
@@ -1586,10 +1804,23 @@ export interface RustChatInterface {
1586
1804
  /**
1587
1805
  * Send a multimodal prompt (text + images/audio) and get a token stream.
1588
1806
  *
1589
- * `parts` is an ordered list of `PromptPart` items.
1807
+ * `parts` is an ordered list of `ContentPart` items.
1590
1808
  * Image and audio parts should contain a local file-system path.
1591
1809
  */
1592
- askWithPrompt(parts: Array<PromptPart>) : RustTokenStreamInterface;
1810
+ askWithPrompt(parts: Array<ContentPart>) : RustTokenStreamInterface;
1811
+ /**
1812
+ * Answer a full list of messages and get a token stream, replacing the chat
1813
+ * history.
1814
+ *
1815
+ * The list is the whole conversation, used as given: it must be non-empty, end
1816
+ * in a user or tool message, and carry a system message only first. That system
1817
+ * message sets the chat's system prompt; leave it out and the prompt already on
1818
+ * the chat is kept. The response is appended, and the next `ask` continues from
1819
+ * there.
1820
+ *
1821
+ * `options` follows the same rule for the chat's other settings.
1822
+ */
1823
+ complete(messages: Array<Message>, options: Options) /*throws*/: RustTokenStreamInterface;
1593
1824
  /**
1594
1825
  * Get the current chat history as a list of messages.
1595
1826
  */
@@ -1656,7 +1887,7 @@ export interface RustChatInterface {
1656
1887
  * Tokenize a multimodal prompt and return the token IDs.
1657
1888
  * Text tokens produce an integer ID; image/audio embedding slots produce null.
1658
1889
  */
1659
- tokenizeWithPrompt(parts: Array<PromptPart>, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<Array</*i32*/number | undefined>>;
1890
+ tokenizeWithPrompt(parts: Array<ContentPart>, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<Array</*i32*/number | undefined>>;
1660
1891
  }
1661
1892
 
1662
1893
 
@@ -1741,14 +1972,40 @@ export class RustChat extends UniffiAbstractObject implements RustChatInterface
1741
1972
  /**
1742
1973
  * Send a multimodal prompt (text + images/audio) and get a token stream.
1743
1974
  *
1744
- * `parts` is an ordered list of `PromptPart` items.
1975
+ * `parts` is an ordered list of `ContentPart` items.
1745
1976
  * Image and audio parts should contain a local file-system path.
1746
1977
  */
1747
- askWithPrompt(parts: Array<PromptPart>): RustTokenStreamInterface {
1978
+ askWithPrompt(parts: Array<ContentPart>): RustTokenStreamInterface {
1748
1979
  return FfiConverterTypeRustTokenStream.lift(uniffiCaller.rustCall(
1749
1980
  /*caller:*/ (callStatus) => {
1750
1981
  return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_ask_with_prompt(uniffiTypeRustChatObjectFactory.clonePointer(this),
1751
- FfiConverterArrayTypePromptPart.lower(parts),
1982
+ FfiConverterArrayTypeContentPart.lower(parts),
1983
+ callStatus);
1984
+ },
1985
+ /*liftString:*/ FfiConverterString.lift,
1986
+ ));
1987
+ }
1988
+
1989
+ /**
1990
+ * Answer a full list of messages and get a token stream, replacing the chat
1991
+ * history.
1992
+ *
1993
+ * The list is the whole conversation, used as given: it must be non-empty, end
1994
+ * in a user or tool message, and carry a system message only first. That system
1995
+ * message sets the chat's system prompt; leave it out and the prompt already on
1996
+ * the chat is kept. The response is appended, and the next `ask` continues from
1997
+ * there.
1998
+ *
1999
+ * `options` follows the same rule for the chat's other settings.
2000
+ */
2001
+ complete(messages: Array<Message>, options: Options): RustTokenStreamInterface /*throws*/ {
2002
+ return FfiConverterTypeRustTokenStream.lift(
2003
+ uniffiCaller.rustCallWithError(
2004
+ /*liftError:*/ FfiConverterTypeNobodyWhoError.lift.bind(FfiConverterTypeNobodyWhoError),
2005
+ /*caller:*/ (callStatus) => {
2006
+ return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_complete(uniffiTypeRustChatObjectFactory.clonePointer(this),
2007
+ FfiConverterArrayTypeMessage.lower(messages),
2008
+ FfiConverterTypeOptions.lower(options),
1752
2009
  callStatus);
1753
2010
  },
1754
2011
  /*liftString:*/ FfiConverterString.lift,
@@ -2206,7 +2463,7 @@ async tokenize(message: string, asyncOpts_?: { signal: AbortSignal }): Promise<
2206
2463
  * Tokenize a multimodal prompt and return the token IDs.
2207
2464
  * Text tokens produce an integer ID; image/audio embedding slots produce null.
2208
2465
  */
2209
- async tokenizeWithPrompt(parts: Array<PromptPart>, asyncOpts_?: { signal: AbortSignal }): Promise<Array</*i32*/number | undefined>> /*throws*/ {
2466
+ async tokenizeWithPrompt(parts: Array<ContentPart>, asyncOpts_?: { signal: AbortSignal }): Promise<Array</*i32*/number | undefined>> /*throws*/ {
2210
2467
  const __stack = uniffiIsDebug ? new Error().stack : undefined;
2211
2468
  try {
2212
2469
  return await uniffiRustCallAsync(
@@ -2214,7 +2471,7 @@ async tokenizeWithPrompt(parts: Array<PromptPart>, asyncOpts_?: { signal: Abort
2214
2471
  /*rustFutureFunc:*/ () => {
2215
2472
  return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_tokenize_with_prompt(
2216
2473
  uniffiTypeRustChatObjectFactory.clonePointer(this),
2217
- FfiConverterArrayTypePromptPart.lower(parts)
2474
+ FfiConverterArrayTypeContentPart.lower(parts)
2218
2475
  );
2219
2476
  },
2220
2477
  /*pollFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_poll_rust_buffer,
@@ -3867,6 +4124,16 @@ export interface SamplerBuilderInterface {
3867
4124
  * DRY (Don't Repeat Yourself) sampler to reduce repetition.
3868
4125
  */
3869
4126
  dry(multiplier: /*f32*/number, base: /*f32*/number, allowedLength: /*i32*/number, penaltyLastN: /*i32*/number, seqBreakers: Array<string>) : SamplerBuilderInterface;
4127
+ /**
4128
+ * Apply dynamic temperature scaling (a.k.a. entropy) described in the paper
4129
+ * <https://arxiv.org/abs/2309.02772>.
4130
+ *
4131
+ * Args:
4132
+ * temperature: Temperature value (lower = more focused, higher = more random)
4133
+ * delta: Dynamic temperature range. The final temperature will be in the range of `[temperature - delta; temperature + delta]`.
4134
+ * exponent: Temperature is calculated as `entropy^exponent` (bounded by the range above)
4135
+ */
4136
+ dynamicTemperature(temperature: /*f32*/number, delta: /*f32*/number, exponent: /*f32*/number) : SamplerBuilderInterface;
3870
4137
  /**
3871
4138
  * Deprecated: Use `sampler_preset_constrain_with_grammar()` instead. It accepts both Lark and GBNF strings.
3872
4139
  */
@@ -3875,6 +4142,16 @@ export interface SamplerBuilderInterface {
3875
4142
  * Always select the most probable token (deterministic).
3876
4143
  */
3877
4144
  greedy() : SamplerConfigInterface;
4145
+ /**
4146
+ * Modify the likelihood of specific tokens.
4147
+ *
4148
+ * Args:
4149
+ * biases: Mapping from token ID to its bias.
4150
+ * The bias modifies the likelihood of the token being selected
4151
+ * (`>0.0` means higher probability of the token being selected).
4152
+ * Use `-Infinity` to ban a token.
4153
+ */
4154
+ logitBias(biases: Map</*i32*/number, /*f32*/number>) : SamplerBuilderInterface;
3878
4155
  /**
3879
4156
  * Keep tokens with probability above min_p * (probability of most likely token).
3880
4157
  */
@@ -3904,6 +4181,14 @@ export interface SamplerBuilderInterface {
3904
4181
  * Keep only the top K most probable tokens.
3905
4182
  */
3906
4183
  topK(topK: /*i32*/number) : SamplerBuilderInterface;
4184
+ /**
4185
+ * Top-nσ sampling as described in academic paper "Top-nσ: Not All Logits Are You Need"
4186
+ * <https://arxiv.org/pdf/2411.07641>
4187
+ *
4188
+ * Args:
4189
+ * n: Number of standard deviations from the mean to include in sampling.
4190
+ */
4191
+ topNSigma(n: /*f32*/number) : SamplerBuilderInterface;
3907
4192
  /**
3908
4193
  * Keep tokens whose cumulative probability is below top_p.
3909
4194
  */
@@ -3975,6 +4260,28 @@ export class SamplerBuilder extends UniffiAbstractObject implements SamplerBuild
3975
4260
  ));
3976
4261
  }
3977
4262
 
4263
+ /**
4264
+ * Apply dynamic temperature scaling (a.k.a. entropy) described in the paper
4265
+ * <https://arxiv.org/abs/2309.02772>.
4266
+ *
4267
+ * Args:
4268
+ * temperature: Temperature value (lower = more focused, higher = more random)
4269
+ * delta: Dynamic temperature range. The final temperature will be in the range of `[temperature - delta; temperature + delta]`.
4270
+ * exponent: Temperature is calculated as `entropy^exponent` (bounded by the range above)
4271
+ */
4272
+ dynamicTemperature(temperature: /*f32*/number, delta: /*f32*/number, exponent: /*f32*/number): SamplerBuilderInterface {
4273
+ return FfiConverterTypeSamplerBuilder.lift(uniffiCaller.rustCall(
4274
+ /*caller:*/ (callStatus) => {
4275
+ return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_samplerbuilder_dynamic_temperature(uniffiTypeSamplerBuilderObjectFactory.clonePointer(this),
4276
+ FfiConverterFloat32.lower(temperature),
4277
+ FfiConverterFloat32.lower(delta),
4278
+ FfiConverterFloat32.lower(exponent),
4279
+ callStatus);
4280
+ },
4281
+ /*liftString:*/ FfiConverterString.lift,
4282
+ ));
4283
+ }
4284
+
3978
4285
  /**
3979
4286
  * Deprecated: Use `sampler_preset_constrain_with_grammar()` instead. It accepts both Lark and GBNF strings.
3980
4287
  */
@@ -4004,6 +4311,26 @@ export class SamplerBuilder extends UniffiAbstractObject implements SamplerBuild
4004
4311
  ));
4005
4312
  }
4006
4313
 
4314
+ /**
4315
+ * Modify the likelihood of specific tokens.
4316
+ *
4317
+ * Args:
4318
+ * biases: Mapping from token ID to its bias.
4319
+ * The bias modifies the likelihood of the token being selected
4320
+ * (`>0.0` means higher probability of the token being selected).
4321
+ * Use `-Infinity` to ban a token.
4322
+ */
4323
+ logitBias(biases: Map</*i32*/number, /*f32*/number>): SamplerBuilderInterface {
4324
+ return FfiConverterTypeSamplerBuilder.lift(uniffiCaller.rustCall(
4325
+ /*caller:*/ (callStatus) => {
4326
+ return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_samplerbuilder_logit_bias(uniffiTypeSamplerBuilderObjectFactory.clonePointer(this),
4327
+ FfiConverterMapInt32Float32.lower(biases),
4328
+ callStatus);
4329
+ },
4330
+ /*liftString:*/ FfiConverterString.lift,
4331
+ ));
4332
+ }
4333
+
4007
4334
  /**
4008
4335
  * Keep tokens with probability above min_p * (probability of most likely token).
4009
4336
  */
@@ -4110,6 +4437,24 @@ export class SamplerBuilder extends UniffiAbstractObject implements SamplerBuild
4110
4437
  ));
4111
4438
  }
4112
4439
 
4440
+ /**
4441
+ * Top-nσ sampling as described in academic paper "Top-nσ: Not All Logits Are You Need"
4442
+ * <https://arxiv.org/pdf/2411.07641>
4443
+ *
4444
+ * Args:
4445
+ * n: Number of standard deviations from the mean to include in sampling.
4446
+ */
4447
+ topNSigma(n: /*f32*/number): SamplerBuilderInterface {
4448
+ return FfiConverterTypeSamplerBuilder.lift(uniffiCaller.rustCall(
4449
+ /*caller:*/ (callStatus) => {
4450
+ return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_samplerbuilder_top_n_sigma(uniffiTypeSamplerBuilderObjectFactory.clonePointer(this),
4451
+ FfiConverterFloat32.lower(n),
4452
+ callStatus);
4453
+ },
4454
+ /*liftString:*/ FfiConverterString.lift,
4455
+ ));
4456
+ }
4457
+
4113
4458
  /**
4114
4459
  * Keep tokens whose cumulative probability is below top_p.
4115
4460
  */
@@ -4397,10 +4742,6 @@ const FfiConverterArrayFloat32 = new FfiConverterArray(FfiConverterFloat32);
4397
4742
  const FfiConverterArrayInt16 = new FfiConverterArray(FfiConverterInt16);
4398
4743
 
4399
4744
 
4400
- // FfiConverter for Array<Asset>
4401
- const FfiConverterArrayTypeAsset = new FfiConverterArray(FfiConverterTypeAsset);
4402
-
4403
-
4404
4745
  // FfiConverter for Array<CachedModel>
4405
4746
  const FfiConverterArrayTypeCachedModel = new FfiConverterArray(FfiConverterTypeCachedModel);
4406
4747
 
@@ -4433,12 +4774,12 @@ const FfiConverterOptionalTypeSamplerConfig = new FfiConverterOptional(FfiConver
4433
4774
  const FfiConverterOptionalArrayTypeToolCall = new FfiConverterOptional(FfiConverterArrayTypeToolCall);
4434
4775
 
4435
4776
 
4436
- // FfiConverter for Array<Message>
4437
- const FfiConverterArrayTypeMessage = new FfiConverterArray(FfiConverterTypeMessage);
4777
+ // FfiConverter for Array<ContentPart>
4778
+ const FfiConverterArrayTypeContentPart = new FfiConverterArray(FfiConverterTypeContentPart);
4438
4779
 
4439
4780
 
4440
- // FfiConverter for Array<PromptPart>
4441
- const FfiConverterArrayTypePromptPart = new FfiConverterArray(FfiConverterTypePromptPart);
4781
+ // FfiConverter for Array<Message>
4782
+ const FfiConverterArrayTypeMessage = new FfiConverterArray(FfiConverterTypeMessage);
4442
4783
 
4443
4784
 
4444
4785
  // FfiConverter for Array<RustToolInterface>
@@ -4538,9 +4879,12 @@ function uniffiEnsureInitialized() {
4538
4879
  if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustchat_ask_with_json_prompt() !== 63877) {
4539
4880
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_rustchat_ask_with_json_prompt");
4540
4881
  }
4541
- if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustchat_ask_with_prompt() !== 65089) {
4882
+ if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustchat_ask_with_prompt() !== 46807) {
4542
4883
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_rustchat_ask_with_prompt");
4543
4884
  }
4885
+ if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustchat_complete() !== 37833) {
4886
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_rustchat_complete");
4887
+ }
4544
4888
  if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustchat_get_chat_history() !== 12722) {
4545
4889
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_rustchat_get_chat_history");
4546
4890
  }
@@ -4586,7 +4930,7 @@ function uniffiEnsureInitialized() {
4586
4930
  if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustchat_tokenize() !== 52520) {
4587
4931
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_rustchat_tokenize");
4588
4932
  }
4589
- if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustchat_tokenize_with_prompt() !== 60528) {
4933
+ if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustchat_tokenize_with_prompt() !== 15286) {
4590
4934
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_rustchat_tokenize_with_prompt");
4591
4935
  }
4592
4936
  if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustcrossencoder_rank() !== 55500) {
@@ -4652,12 +4996,18 @@ function uniffiEnsureInitialized() {
4652
4996
  if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_dry() !== 35315) {
4653
4997
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_dry");
4654
4998
  }
4999
+ if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_dynamic_temperature() !== 5004) {
5000
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_dynamic_temperature");
5001
+ }
4655
5002
  if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_grammar() !== 3547) {
4656
5003
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_grammar");
4657
5004
  }
4658
5005
  if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_greedy() !== 32898) {
4659
5006
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_greedy");
4660
5007
  }
5008
+ if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_logit_bias() !== 61844) {
5009
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_logit_bias");
5010
+ }
4661
5011
  if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_min_p() !== 33705) {
4662
5012
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_min_p");
4663
5013
  }
@@ -4679,6 +5029,9 @@ function uniffiEnsureInitialized() {
4679
5029
  if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_top_k() !== 26600) {
4680
5030
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_top_k");
4681
5031
  }
5032
+ if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_top_n_sigma() !== 44336) {
5033
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_top_n_sigma");
5034
+ }
4682
5035
  if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_top_p() !== 54577) {
4683
5036
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_top_p");
4684
5037
  }
@@ -4735,14 +5088,15 @@ function uniffiEnsureInitialized() {
4735
5088
  export default Object.freeze({
4736
5089
  initialize: uniffiEnsureInitialized,
4737
5090
  converters: {
4738
- FfiConverterTypeAsset,
4739
5091
  FfiConverterTypeCachedModel,
4740
5092
  FfiConverterTypeChatStats,
5093
+ FfiConverterTypeContentPart,
4741
5094
  FfiConverterTypeMessage,
5095
+ FfiConverterTypeMessageContent,
4742
5096
  FfiConverterTypeMtpConfig,
4743
5097
  FfiConverterTypeNobodyWhoError,
5098
+ FfiConverterTypeOptions,
4744
5099
  FfiConverterTypePendingToolCall,
4745
- FfiConverterTypePromptPart,
4746
5100
  FfiConverterTypeRustChat,
4747
5101
  FfiConverterTypeRustCrossEncoder,
4748
5102
  FfiConverterTypeRustEncoder,