react-native-nobodywho 0.1.2 → 0.3.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.
@@ -95,25 +95,29 @@ export function cosineSimilarity(a: Array</*f32*/number>, b: Array</*f32*/number
95
95
  ));
96
96
  }
97
97
  /**
98
- * Load a GGUF model from disk.
98
+ * Load a GGUF model from a local path or remote URL.
99
+ *
100
+ * Accepts local filesystem paths, `hf://owner/repo/file.gguf` for HuggingFace downloads,
101
+ * or `https://` URLs. Downloaded models are cached automatically.
102
+ *
99
103
  * This is a free function instead of an async constructor because
100
104
  * uniffi-bindgen-react-native generates invalid JS (`async static` instead
101
105
  * of `static async`) for async constructors.
102
106
  */
103
- export async function loadModel(modelPath: string, useGpu: boolean, imageModelPath: string | undefined, asyncOpts_?: { signal: AbortSignal }): Promise<ModelInterface> /*throws*/ {
107
+ export async function loadModel(modelPath: string, useGpu: boolean, projectionModelPath: string | undefined, asyncOpts_?: { signal: AbortSignal }): Promise<RustModelInterface> /*throws*/ {
104
108
  const __stack = uniffiIsDebug ? new Error().stack : undefined;
105
109
  try {
106
110
  return await uniffiRustCallAsync(
107
111
  /*rustCaller:*/ uniffiCaller,
108
112
  /*rustFutureFunc:*/ () => {
109
- return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_func_load_model(FfiConverterString.lower(modelPath),FfiConverterBool.lower(useGpu),FfiConverterOptionalString.lower(imageModelPath)
113
+ return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_func_load_model(FfiConverterString.lower(modelPath),FfiConverterBool.lower(useGpu),FfiConverterOptionalString.lower(projectionModelPath)
110
114
  );
111
115
  },
112
116
  /*pollFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_poll_u64,
113
117
  /*cancelFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_cancel_u64,
114
118
  /*completeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_complete_u64,
115
119
  /*freeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_free_u64,
116
- /*liftFunc:*/ FfiConverterTypeModel.lift.bind(FfiConverterTypeModel),
120
+ /*liftFunc:*/ FfiConverterTypeRustModel.lift.bind(FfiConverterTypeRustModel),
117
121
  /*liftString:*/ FfiConverterString.lift,
118
122
  /*asyncOpts:*/ asyncOpts_,
119
123
  /*errorHandler:*/ FfiConverterTypeNobodyWhoError.lift.bind(FfiConverterTypeNobodyWhoError)
@@ -1008,67 +1012,151 @@ const FfiConverterTypeRole = (() => {
1008
1012
  const FfiConverterMapStringBool = new FfiConverterMap(FfiConverterString, FfiConverterBool);
1009
1013
 
1010
1014
 
1011
- export interface CrossEncoderInterface {
1015
+ export interface RustChatInterface {
1012
1016
 
1013
1017
  /**
1014
- * Rank documents by relevance to a query. Returns similarity scores.
1018
+ * Send a message and get a token stream for the response.
1015
1019
  */
1016
- rank(query: string, documents: Array<string>, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<Array</*f32*/number>>;
1020
+ ask(message: string) : RustTokenStreamInterface;
1017
1021
  /**
1018
- * Rank documents and return them sorted by descending relevance.
1019
- * Returns a JSON string of [document, score] pairs since UniFFI
1020
- * doesn't support tuples directly.
1022
+ * Send a multimodal prompt (text + images/audio) and get a token stream.
1023
+ *
1024
+ * `parts` is an ordered list of `PromptPart` items.
1025
+ * Image and audio parts should contain a local file-system path.
1021
1026
  */
1022
- rankAndSortJson(query: string, documents: Array<string>, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<string>;
1027
+ askWithPrompt(parts: Array<PromptPart>) : RustTokenStreamInterface;
1028
+ /**
1029
+ * Get the current chat history as a list of messages.
1030
+ */
1031
+ getChatHistory(asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<Array<Message>>;
1032
+ /**
1033
+ * Get the current sampler configuration as a JSON string.
1034
+ */
1035
+ getSamplerConfigJson(asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<string>;
1036
+ /**
1037
+ * Get the current system prompt.
1038
+ */
1039
+ getSystemPrompt(asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<string | undefined>;
1040
+ /**
1041
+ * Get all template variables.
1042
+ */
1043
+ getTemplateVariables(asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<Map<string, boolean>>;
1044
+ /**
1045
+ * Reset the chat context with a new system prompt and tools.
1046
+ */
1047
+ resetContext(systemPrompt: string | undefined, tools: Array<RustToolInterface> | undefined, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<void>;
1048
+ /**
1049
+ * Reset the chat history, keeping the system prompt and tools.
1050
+ */
1051
+ resetHistory(asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<void>;
1052
+ /**
1053
+ * Set the chat history from a list of messages.
1054
+ */
1055
+ setChatHistory(messages: Array<Message>, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<void>;
1056
+ /**
1057
+ * Set the sampler configuration.
1058
+ */
1059
+ setSamplerConfig(sampler: SamplerConfigInterface, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<void>;
1060
+ /**
1061
+ * Set the system prompt.
1062
+ */
1063
+ setSystemPrompt(systemPrompt: string | undefined, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<void>;
1064
+ /**
1065
+ * Set a template variable.
1066
+ */
1067
+ setTemplateVariable(name: string, value: boolean, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<void>;
1068
+ /**
1069
+ * Set the tools available to the model.
1070
+ */
1071
+ setTools(tools: Array<RustToolInterface>, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<void>;
1072
+ /**
1073
+ * Stop the current generation.
1074
+ */
1075
+ stopGeneration() : void;
1023
1076
  }
1024
1077
 
1025
1078
 
1026
- export class CrossEncoder extends UniffiAbstractObject implements CrossEncoderInterface {
1079
+ export class RustChat extends UniffiAbstractObject implements RustChatInterface {
1027
1080
 
1028
- readonly [uniffiTypeNameSymbol] = "CrossEncoder";
1081
+ readonly [uniffiTypeNameSymbol] = "RustChat";
1029
1082
  readonly [destructorGuardSymbol]: UniffiGcObject;
1030
1083
  readonly [pointerLiteralSymbol]: UniffiHandle;
1031
1084
  /**
1032
- * Create a new cross-encoder for ranking documents by relevance.
1085
+ * Create a new chat session.
1033
1086
  */
1034
- constructor(model: ModelInterface, contextSize: /*u32*/number | undefined) {
1087
+ constructor(model: RustModelInterface, systemPrompt: string | undefined, contextSize: /*u32*/number, templateVariables: Map<string, boolean> | undefined, tools: Array<RustToolInterface> | undefined, sampler: SamplerConfigInterface | undefined) {
1035
1088
  super();
1036
1089
  const pointer =
1037
1090
  uniffiCaller.rustCall(
1038
1091
  /*caller:*/ (callStatus) => {
1039
- return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_constructor_crossencoder_new(
1040
- FfiConverterTypeModel.lower(model),
1041
- FfiConverterOptionalUInt32.lower(contextSize),
1092
+ return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_constructor_rustchat_new(
1093
+ FfiConverterTypeRustModel.lower(model),
1094
+ FfiConverterOptionalString.lower(systemPrompt),
1095
+ FfiConverterUInt32.lower(contextSize),
1096
+ FfiConverterOptionalMapStringBool.lower(templateVariables),
1097
+ FfiConverterOptionalArrayTypeRustTool.lower(tools),
1098
+ FfiConverterOptionalTypeSamplerConfig.lower(sampler),
1042
1099
  callStatus);
1043
1100
  },
1044
1101
  /*liftString:*/ FfiConverterString.lift,
1045
1102
  );
1046
1103
  this[pointerLiteralSymbol] = pointer;
1047
- this[destructorGuardSymbol] = uniffiTypeCrossEncoderObjectFactory.bless(pointer);
1104
+ this[destructorGuardSymbol] = uniffiTypeRustChatObjectFactory.bless(pointer);
1048
1105
  }
1049
1106
 
1050
1107
 
1051
1108
 
1052
1109
 
1053
1110
  /**
1054
- * Rank documents by relevance to a query. Returns similarity scores.
1111
+ * Send a message and get a token stream for the response.
1055
1112
  */
1056
- async rank(query: string, documents: Array<string>, asyncOpts_?: { signal: AbortSignal }): Promise<Array</*f32*/number>> /*throws*/ {
1113
+ ask(message: string): RustTokenStreamInterface {
1114
+ return FfiConverterTypeRustTokenStream.lift(uniffiCaller.rustCall(
1115
+ /*caller:*/ (callStatus) => {
1116
+ return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_ask(uniffiTypeRustChatObjectFactory.clonePointer(this),
1117
+ FfiConverterString.lower(message),
1118
+ callStatus);
1119
+ },
1120
+ /*liftString:*/ FfiConverterString.lift,
1121
+ ));
1122
+ }
1123
+
1124
+ /**
1125
+ * Send a multimodal prompt (text + images/audio) and get a token stream.
1126
+ *
1127
+ * `parts` is an ordered list of `PromptPart` items.
1128
+ * Image and audio parts should contain a local file-system path.
1129
+ */
1130
+ askWithPrompt(parts: Array<PromptPart>): RustTokenStreamInterface {
1131
+ return FfiConverterTypeRustTokenStream.lift(uniffiCaller.rustCall(
1132
+ /*caller:*/ (callStatus) => {
1133
+ return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_ask_with_prompt(uniffiTypeRustChatObjectFactory.clonePointer(this),
1134
+ FfiConverterArrayTypePromptPart.lower(parts),
1135
+ callStatus);
1136
+ },
1137
+ /*liftString:*/ FfiConverterString.lift,
1138
+ ));
1139
+ }
1140
+
1141
+ /**
1142
+ * Get the current chat history as a list of messages.
1143
+ */
1144
+ async getChatHistory(asyncOpts_?: { signal: AbortSignal }): Promise<Array<Message>> /*throws*/ {
1057
1145
  const __stack = uniffiIsDebug ? new Error().stack : undefined;
1058
1146
  try {
1059
1147
  return await uniffiRustCallAsync(
1060
1148
  /*rustCaller:*/ uniffiCaller,
1061
1149
  /*rustFutureFunc:*/ () => {
1062
- return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_crossencoder_rank(
1063
- uniffiTypeCrossEncoderObjectFactory.clonePointer(this),
1064
- FfiConverterString.lower(query),FfiConverterArrayString.lower(documents)
1150
+ return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_get_chat_history(
1151
+ uniffiTypeRustChatObjectFactory.clonePointer(this)
1152
+
1065
1153
  );
1066
1154
  },
1067
1155
  /*pollFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_poll_rust_buffer,
1068
1156
  /*cancelFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_cancel_rust_buffer,
1069
1157
  /*completeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_complete_rust_buffer,
1070
1158
  /*freeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_free_rust_buffer,
1071
- /*liftFunc:*/ FfiConverterArrayFloat32.lift.bind(FfiConverterArrayFloat32),
1159
+ /*liftFunc:*/ FfiConverterArrayTypeMessage.lift.bind(FfiConverterArrayTypeMessage),
1072
1160
  /*liftString:*/ FfiConverterString.lift,
1073
1161
  /*asyncOpts:*/ asyncOpts_,
1074
1162
  /*errorHandler:*/ FfiConverterTypeNobodyWhoError.lift.bind(FfiConverterTypeNobodyWhoError)
@@ -1082,19 +1170,17 @@ async rank(query: string, documents: Array<string>, asyncOpts_?: { signal: Abor
1082
1170
  }
1083
1171
 
1084
1172
  /**
1085
- * Rank documents and return them sorted by descending relevance.
1086
- * Returns a JSON string of [document, score] pairs since UniFFI
1087
- * doesn't support tuples directly.
1173
+ * Get the current sampler configuration as a JSON string.
1088
1174
  */
1089
- async rankAndSortJson(query: string, documents: Array<string>, asyncOpts_?: { signal: AbortSignal }): Promise<string> /*throws*/ {
1175
+ async getSamplerConfigJson(asyncOpts_?: { signal: AbortSignal }): Promise<string> /*throws*/ {
1090
1176
  const __stack = uniffiIsDebug ? new Error().stack : undefined;
1091
1177
  try {
1092
1178
  return await uniffiRustCallAsync(
1093
1179
  /*rustCaller:*/ uniffiCaller,
1094
1180
  /*rustFutureFunc:*/ () => {
1095
- return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_crossencoder_rank_and_sort_json(
1096
- uniffiTypeCrossEncoderObjectFactory.clonePointer(this),
1097
- FfiConverterString.lower(query),FfiConverterArrayString.lower(documents)
1181
+ return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_get_sampler_config_json(
1182
+ uniffiTypeRustChatObjectFactory.clonePointer(this)
1183
+
1098
1184
  );
1099
1185
  },
1100
1186
  /*pollFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_poll_rust_buffer,
@@ -1114,136 +1200,56 @@ async rankAndSortJson(query: string, documents: Array<string>, asyncOpts_?: { s
1114
1200
  }
1115
1201
  }
1116
1202
 
1117
-
1118
- /**
1119
- * {@inheritDoc uniffi-bindgen-react-native#UniffiAbstractObject.uniffiDestroy}
1120
- */
1121
- uniffiDestroy(): void {
1122
- const ptr = (this as any)[destructorGuardSymbol];
1123
- if (ptr !== undefined) {
1124
- const pointer = uniffiTypeCrossEncoderObjectFactory.pointer(this);
1125
- uniffiTypeCrossEncoderObjectFactory.freePointer(pointer);
1126
- uniffiTypeCrossEncoderObjectFactory.unbless(ptr);
1127
- delete (this as any)[destructorGuardSymbol];
1128
- }
1129
- }
1130
-
1131
- static instanceOf(obj: any): obj is CrossEncoder {
1132
- return uniffiTypeCrossEncoderObjectFactory.isConcreteType(obj);
1133
- }
1134
-
1135
-
1136
- }
1137
-
1138
- const uniffiTypeCrossEncoderObjectFactory: UniffiObjectFactory<CrossEncoderInterface> = (() => {
1139
-
1140
- return {
1141
- create(pointer: UniffiHandle): CrossEncoderInterface {
1142
- const instance = Object.create(CrossEncoder.prototype);
1143
- instance[pointerLiteralSymbol] = pointer;
1144
- instance[destructorGuardSymbol] = this.bless(pointer);
1145
- instance[uniffiTypeNameSymbol] = "CrossEncoder";
1146
- return instance;
1147
- },
1148
-
1149
-
1150
- bless(p: UniffiHandle): UniffiGcObject {
1151
- return uniffiCaller.rustCall(
1152
- /*caller:*/ (status) =>
1153
- nativeModule().ubrn_uniffi_internal_fn_method_crossencoder_ffi__bless_pointer(p, status),
1154
- /*liftString:*/ FfiConverterString.lift
1155
- );
1156
- },
1157
-
1158
- unbless(ptr: UniffiGcObject) {
1159
- ptr.markDestroyed();
1160
- },
1161
-
1162
- pointer(obj: CrossEncoderInterface): UniffiHandle {
1163
- if ((obj as any)[destructorGuardSymbol] === undefined) {
1164
- throw new UniffiInternalError.UnexpectedNullPointer();
1165
- }
1166
- return (obj as any)[pointerLiteralSymbol];
1167
- },
1168
-
1169
- clonePointer(obj: CrossEncoderInterface): UniffiHandle {
1170
- const pointer = this.pointer(obj);
1171
- return uniffiCaller.rustCall(
1172
- /*caller:*/ (callStatus) => nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_clone_crossencoder(pointer, callStatus),
1173
- /*liftString:*/ FfiConverterString.lift
1174
- );
1175
- },
1176
-
1177
- freePointer(pointer: UniffiHandle): void {
1178
- uniffiCaller.rustCall(
1179
- /*caller:*/ (callStatus) => nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_free_crossencoder(pointer, callStatus),
1180
- /*liftString:*/ FfiConverterString.lift
1181
- );
1182
- },
1183
-
1184
- isConcreteType(obj: any): obj is CrossEncoderInterface {
1185
- return obj[destructorGuardSymbol] && obj[uniffiTypeNameSymbol] === "CrossEncoder";
1186
- },
1187
- }})();
1188
- // FfiConverter for CrossEncoderInterface
1189
- const FfiConverterTypeCrossEncoder = new FfiConverterObject(uniffiTypeCrossEncoderObjectFactory);
1190
-
1191
-
1192
- export interface EncoderInterface {
1193
-
1194
- /**
1195
- * Encode text into an embedding vector.
1196
- */
1197
- encode(text: string, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<Array</*f32*/number>>;
1198
- }
1199
-
1200
-
1201
- export class Encoder extends UniffiAbstractObject implements EncoderInterface {
1202
-
1203
- readonly [uniffiTypeNameSymbol] = "Encoder";
1204
- readonly [destructorGuardSymbol]: UniffiGcObject;
1205
- readonly [pointerLiteralSymbol]: UniffiHandle;
1206
1203
  /**
1207
- * Create a new encoder for generating text embeddings.
1204
+ * Get the current system prompt.
1208
1205
  */
1209
- constructor(model: ModelInterface, contextSize: /*u32*/number | undefined) {
1210
- super();
1211
- const pointer =
1212
- uniffiCaller.rustCall(
1213
- /*caller:*/ (callStatus) => {
1214
- return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_constructor_encoder_new(
1215
- FfiConverterTypeModel.lower(model),
1216
- FfiConverterOptionalUInt32.lower(contextSize),
1217
- callStatus);
1206
+ async getSystemPrompt(asyncOpts_?: { signal: AbortSignal }): Promise<string | undefined> /*throws*/ {
1207
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
1208
+ try {
1209
+ return await uniffiRustCallAsync(
1210
+ /*rustCaller:*/ uniffiCaller,
1211
+ /*rustFutureFunc:*/ () => {
1212
+ return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_get_system_prompt(
1213
+ uniffiTypeRustChatObjectFactory.clonePointer(this)
1214
+
1215
+ );
1218
1216
  },
1217
+ /*pollFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_poll_rust_buffer,
1218
+ /*cancelFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_cancel_rust_buffer,
1219
+ /*completeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_complete_rust_buffer,
1220
+ /*freeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_free_rust_buffer,
1221
+ /*liftFunc:*/ FfiConverterOptionalString.lift.bind(FfiConverterOptionalString),
1219
1222
  /*liftString:*/ FfiConverterString.lift,
1220
- );
1221
- this[pointerLiteralSymbol] = pointer;
1222
- this[destructorGuardSymbol] = uniffiTypeEncoderObjectFactory.bless(pointer);
1223
+ /*asyncOpts:*/ asyncOpts_,
1224
+ /*errorHandler:*/ FfiConverterTypeNobodyWhoError.lift.bind(FfiConverterTypeNobodyWhoError)
1225
+ );
1226
+ } catch (__error: any) {
1227
+ if (uniffiIsDebug && __error instanceof Error) {
1228
+ __error.stack = __stack;
1229
+ }
1230
+ throw __error;
1231
+ }
1223
1232
  }
1224
-
1225
-
1226
-
1227
1233
 
1228
1234
  /**
1229
- * Encode text into an embedding vector.
1235
+ * Get all template variables.
1230
1236
  */
1231
- async encode(text: string, asyncOpts_?: { signal: AbortSignal }): Promise<Array</*f32*/number>> /*throws*/ {
1237
+ async getTemplateVariables(asyncOpts_?: { signal: AbortSignal }): Promise<Map<string, boolean>> /*throws*/ {
1232
1238
  const __stack = uniffiIsDebug ? new Error().stack : undefined;
1233
1239
  try {
1234
1240
  return await uniffiRustCallAsync(
1235
1241
  /*rustCaller:*/ uniffiCaller,
1236
1242
  /*rustFutureFunc:*/ () => {
1237
- return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_encoder_encode(
1238
- uniffiTypeEncoderObjectFactory.clonePointer(this),
1239
- FfiConverterString.lower(text)
1243
+ return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_get_template_variables(
1244
+ uniffiTypeRustChatObjectFactory.clonePointer(this)
1245
+
1240
1246
  );
1241
1247
  },
1242
1248
  /*pollFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_poll_rust_buffer,
1243
1249
  /*cancelFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_cancel_rust_buffer,
1244
1250
  /*completeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_complete_rust_buffer,
1245
1251
  /*freeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_free_rust_buffer,
1246
- /*liftFunc:*/ FfiConverterArrayFloat32.lift.bind(FfiConverterArrayFloat32),
1252
+ /*liftFunc:*/ FfiConverterMapStringBool.lift.bind(FfiConverterMapStringBool),
1247
1253
  /*liftString:*/ FfiConverterString.lift,
1248
1254
  /*asyncOpts:*/ asyncOpts_,
1249
1255
  /*errorHandler:*/ FfiConverterTypeNobodyWhoError.lift.bind(FfiConverterTypeNobodyWhoError)
@@ -1256,321 +1262,25 @@ async encode(text: string, asyncOpts_?: { signal: AbortSignal }): Promise<Array
1256
1262
  }
1257
1263
  }
1258
1264
 
1259
-
1260
1265
  /**
1261
- * {@inheritDoc uniffi-bindgen-react-native#UniffiAbstractObject.uniffiDestroy}
1266
+ * Reset the chat context with a new system prompt and tools.
1262
1267
  */
1263
- uniffiDestroy(): void {
1264
- const ptr = (this as any)[destructorGuardSymbol];
1265
- if (ptr !== undefined) {
1266
- const pointer = uniffiTypeEncoderObjectFactory.pointer(this);
1267
- uniffiTypeEncoderObjectFactory.freePointer(pointer);
1268
- uniffiTypeEncoderObjectFactory.unbless(ptr);
1269
- delete (this as any)[destructorGuardSymbol];
1270
- }
1271
- }
1272
-
1273
- static instanceOf(obj: any): obj is Encoder {
1274
- return uniffiTypeEncoderObjectFactory.isConcreteType(obj);
1275
- }
1276
-
1277
-
1278
- }
1279
-
1280
- const uniffiTypeEncoderObjectFactory: UniffiObjectFactory<EncoderInterface> = (() => {
1281
-
1282
- return {
1283
- create(pointer: UniffiHandle): EncoderInterface {
1284
- const instance = Object.create(Encoder.prototype);
1285
- instance[pointerLiteralSymbol] = pointer;
1286
- instance[destructorGuardSymbol] = this.bless(pointer);
1287
- instance[uniffiTypeNameSymbol] = "Encoder";
1288
- return instance;
1289
- },
1290
-
1291
-
1292
- bless(p: UniffiHandle): UniffiGcObject {
1293
- return uniffiCaller.rustCall(
1294
- /*caller:*/ (status) =>
1295
- nativeModule().ubrn_uniffi_internal_fn_method_encoder_ffi__bless_pointer(p, status),
1296
- /*liftString:*/ FfiConverterString.lift
1297
- );
1298
- },
1299
-
1300
- unbless(ptr: UniffiGcObject) {
1301
- ptr.markDestroyed();
1302
- },
1303
-
1304
- pointer(obj: EncoderInterface): UniffiHandle {
1305
- if ((obj as any)[destructorGuardSymbol] === undefined) {
1306
- throw new UniffiInternalError.UnexpectedNullPointer();
1307
- }
1308
- return (obj as any)[pointerLiteralSymbol];
1309
- },
1310
-
1311
- clonePointer(obj: EncoderInterface): UniffiHandle {
1312
- const pointer = this.pointer(obj);
1313
- return uniffiCaller.rustCall(
1314
- /*caller:*/ (callStatus) => nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_clone_encoder(pointer, callStatus),
1315
- /*liftString:*/ FfiConverterString.lift
1316
- );
1317
- },
1318
-
1319
- freePointer(pointer: UniffiHandle): void {
1320
- uniffiCaller.rustCall(
1321
- /*caller:*/ (callStatus) => nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_free_encoder(pointer, callStatus),
1322
- /*liftString:*/ FfiConverterString.lift
1323
- );
1324
- },
1325
-
1326
- isConcreteType(obj: any): obj is EncoderInterface {
1327
- return obj[destructorGuardSymbol] && obj[uniffiTypeNameSymbol] === "Encoder";
1328
- },
1329
- }})();
1330
- // FfiConverter for EncoderInterface
1331
- const FfiConverterTypeEncoder = new FfiConverterObject(uniffiTypeEncoderObjectFactory);
1332
-
1333
-
1334
- export interface ModelInterface {
1335
-
1336
- }
1337
-
1338
-
1339
- export class Model extends UniffiAbstractObject implements ModelInterface {
1340
-
1341
- readonly [uniffiTypeNameSymbol] = "Model";
1342
- readonly [destructorGuardSymbol]: UniffiGcObject;
1343
- readonly [pointerLiteralSymbol]: UniffiHandle;
1344
- // No primary constructor declared for this class.
1345
- private constructor(pointer: UniffiHandle) {
1346
- super();
1347
- this[pointerLiteralSymbol] = pointer;
1348
- this[destructorGuardSymbol] = uniffiTypeModelObjectFactory.bless(pointer);
1349
- }
1350
-
1351
-
1352
-
1353
-
1354
-
1355
- /**
1356
- * {@inheritDoc uniffi-bindgen-react-native#UniffiAbstractObject.uniffiDestroy}
1357
- */
1358
- uniffiDestroy(): void {
1359
- const ptr = (this as any)[destructorGuardSymbol];
1360
- if (ptr !== undefined) {
1361
- const pointer = uniffiTypeModelObjectFactory.pointer(this);
1362
- uniffiTypeModelObjectFactory.freePointer(pointer);
1363
- uniffiTypeModelObjectFactory.unbless(ptr);
1364
- delete (this as any)[destructorGuardSymbol];
1365
- }
1366
- }
1367
-
1368
- static instanceOf(obj: any): obj is Model {
1369
- return uniffiTypeModelObjectFactory.isConcreteType(obj);
1370
- }
1371
-
1372
-
1373
- }
1374
-
1375
- const uniffiTypeModelObjectFactory: UniffiObjectFactory<ModelInterface> = (() => {
1376
-
1377
- return {
1378
- create(pointer: UniffiHandle): ModelInterface {
1379
- const instance = Object.create(Model.prototype);
1380
- instance[pointerLiteralSymbol] = pointer;
1381
- instance[destructorGuardSymbol] = this.bless(pointer);
1382
- instance[uniffiTypeNameSymbol] = "Model";
1383
- return instance;
1384
- },
1385
-
1386
-
1387
- bless(p: UniffiHandle): UniffiGcObject {
1388
- return uniffiCaller.rustCall(
1389
- /*caller:*/ (status) =>
1390
- nativeModule().ubrn_uniffi_internal_fn_method_model_ffi__bless_pointer(p, status),
1391
- /*liftString:*/ FfiConverterString.lift
1392
- );
1393
- },
1394
-
1395
- unbless(ptr: UniffiGcObject) {
1396
- ptr.markDestroyed();
1397
- },
1398
-
1399
- pointer(obj: ModelInterface): UniffiHandle {
1400
- if ((obj as any)[destructorGuardSymbol] === undefined) {
1401
- throw new UniffiInternalError.UnexpectedNullPointer();
1402
- }
1403
- return (obj as any)[pointerLiteralSymbol];
1404
- },
1405
-
1406
- clonePointer(obj: ModelInterface): UniffiHandle {
1407
- const pointer = this.pointer(obj);
1408
- return uniffiCaller.rustCall(
1409
- /*caller:*/ (callStatus) => nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_clone_model(pointer, callStatus),
1410
- /*liftString:*/ FfiConverterString.lift
1411
- );
1412
- },
1413
-
1414
- freePointer(pointer: UniffiHandle): void {
1415
- uniffiCaller.rustCall(
1416
- /*caller:*/ (callStatus) => nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_free_model(pointer, callStatus),
1417
- /*liftString:*/ FfiConverterString.lift
1418
- );
1419
- },
1420
-
1421
- isConcreteType(obj: any): obj is ModelInterface {
1422
- return obj[destructorGuardSymbol] && obj[uniffiTypeNameSymbol] === "Model";
1423
- },
1424
- }})();
1425
- // FfiConverter for ModelInterface
1426
- const FfiConverterTypeModel = new FfiConverterObject(uniffiTypeModelObjectFactory);
1427
-
1428
-
1429
- export interface RustChatInterface {
1430
-
1431
- /**
1432
- * Send a message and get a token stream for the response.
1433
- */
1434
- ask(message: string) : RustTokenStreamInterface;
1435
- /**
1436
- * Send a multimodal prompt (text + images/audio) and get a token stream.
1437
- *
1438
- * `parts` is an ordered list of `PromptPart` items.
1439
- * Image and audio parts should contain a local file-system path.
1440
- */
1441
- askWithPrompt(parts: Array<PromptPart>) : RustTokenStreamInterface;
1442
- /**
1443
- * Get the current chat history as a list of messages.
1444
- */
1445
- getChatHistory(asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<Array<Message>>;
1446
- /**
1447
- * Get the current sampler configuration as a JSON string.
1448
- */
1449
- getSamplerConfigJson(asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<string>;
1450
- /**
1451
- * Get the current system prompt.
1452
- */
1453
- getSystemPrompt(asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<string | undefined>;
1454
- /**
1455
- * Get all template variables.
1456
- */
1457
- getTemplateVariables(asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<Map<string, boolean>>;
1458
- /**
1459
- * Reset the chat context with a new system prompt and tools.
1460
- */
1461
- resetContext(systemPrompt: string | undefined, tools: Array<RustToolInterface> | undefined, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<void>;
1462
- /**
1463
- * Reset the chat history, keeping the system prompt and tools.
1464
- */
1465
- resetHistory(asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<void>;
1466
- /**
1467
- * Set the chat history from a list of messages.
1468
- */
1469
- setChatHistory(messages: Array<Message>, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<void>;
1470
- /**
1471
- * Set the sampler configuration.
1472
- */
1473
- setSamplerConfig(sampler: SamplerConfigInterface, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<void>;
1474
- /**
1475
- * Set the system prompt.
1476
- */
1477
- setSystemPrompt(systemPrompt: string | undefined, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<void>;
1478
- /**
1479
- * Set a template variable.
1480
- */
1481
- setTemplateVariable(name: string, value: boolean, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<void>;
1482
- /**
1483
- * Set the tools available to the model.
1484
- */
1485
- setTools(tools: Array<RustToolInterface>, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<void>;
1486
- /**
1487
- * Stop the current generation.
1488
- */
1489
- stopGeneration() : void;
1490
- }
1491
-
1492
-
1493
- export class RustChat extends UniffiAbstractObject implements RustChatInterface {
1494
-
1495
- readonly [uniffiTypeNameSymbol] = "RustChat";
1496
- readonly [destructorGuardSymbol]: UniffiGcObject;
1497
- readonly [pointerLiteralSymbol]: UniffiHandle;
1498
- /**
1499
- * Create a new chat session.
1500
- */
1501
- constructor(model: ModelInterface, systemPrompt: string | undefined, contextSize: /*u32*/number, templateVariables: Map<string, boolean> | undefined, tools: Array<RustToolInterface> | undefined, sampler: SamplerConfigInterface | undefined) {
1502
- super();
1503
- const pointer =
1504
- uniffiCaller.rustCall(
1505
- /*caller:*/ (callStatus) => {
1506
- return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_constructor_rustchat_new(
1507
- FfiConverterTypeModel.lower(model),
1508
- FfiConverterOptionalString.lower(systemPrompt),
1509
- FfiConverterUInt32.lower(contextSize),
1510
- FfiConverterOptionalMapStringBool.lower(templateVariables),
1511
- FfiConverterOptionalArrayTypeRustTool.lower(tools),
1512
- FfiConverterOptionalTypeSamplerConfig.lower(sampler),
1513
- callStatus);
1514
- },
1515
- /*liftString:*/ FfiConverterString.lift,
1516
- );
1517
- this[pointerLiteralSymbol] = pointer;
1518
- this[destructorGuardSymbol] = uniffiTypeRustChatObjectFactory.bless(pointer);
1519
- }
1520
-
1521
-
1522
-
1523
-
1524
- /**
1525
- * Send a message and get a token stream for the response.
1526
- */
1527
- ask(message: string): RustTokenStreamInterface {
1528
- return FfiConverterTypeRustTokenStream.lift(uniffiCaller.rustCall(
1529
- /*caller:*/ (callStatus) => {
1530
- return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_ask(uniffiTypeRustChatObjectFactory.clonePointer(this),
1531
- FfiConverterString.lower(message),
1532
- callStatus);
1533
- },
1534
- /*liftString:*/ FfiConverterString.lift,
1535
- ));
1536
- }
1537
-
1538
- /**
1539
- * Send a multimodal prompt (text + images/audio) and get a token stream.
1540
- *
1541
- * `parts` is an ordered list of `PromptPart` items.
1542
- * Image and audio parts should contain a local file-system path.
1543
- */
1544
- askWithPrompt(parts: Array<PromptPart>): RustTokenStreamInterface {
1545
- return FfiConverterTypeRustTokenStream.lift(uniffiCaller.rustCall(
1546
- /*caller:*/ (callStatus) => {
1547
- return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_ask_with_prompt(uniffiTypeRustChatObjectFactory.clonePointer(this),
1548
- FfiConverterArrayTypePromptPart.lower(parts),
1549
- callStatus);
1550
- },
1551
- /*liftString:*/ FfiConverterString.lift,
1552
- ));
1553
- }
1554
-
1555
- /**
1556
- * Get the current chat history as a list of messages.
1557
- */
1558
- async getChatHistory(asyncOpts_?: { signal: AbortSignal }): Promise<Array<Message>> /*throws*/ {
1268
+ async resetContext(systemPrompt: string | undefined, tools: Array<RustToolInterface> | undefined, asyncOpts_?: { signal: AbortSignal }): Promise<void> /*throws*/ {
1559
1269
  const __stack = uniffiIsDebug ? new Error().stack : undefined;
1560
1270
  try {
1561
1271
  return await uniffiRustCallAsync(
1562
1272
  /*rustCaller:*/ uniffiCaller,
1563
1273
  /*rustFutureFunc:*/ () => {
1564
- return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_get_chat_history(
1565
- uniffiTypeRustChatObjectFactory.clonePointer(this)
1566
-
1274
+ return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_reset_context(
1275
+ uniffiTypeRustChatObjectFactory.clonePointer(this),
1276
+ FfiConverterOptionalString.lower(systemPrompt),FfiConverterOptionalArrayTypeRustTool.lower(tools)
1567
1277
  );
1568
1278
  },
1569
- /*pollFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_poll_rust_buffer,
1570
- /*cancelFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_cancel_rust_buffer,
1571
- /*completeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_complete_rust_buffer,
1572
- /*freeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_free_rust_buffer,
1573
- /*liftFunc:*/ FfiConverterArrayTypeMessage.lift.bind(FfiConverterArrayTypeMessage),
1279
+ /*pollFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_poll_void,
1280
+ /*cancelFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_cancel_void,
1281
+ /*completeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_complete_void,
1282
+ /*freeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_free_void,
1283
+ /*liftFunc:*/ (_v) => {},
1574
1284
  /*liftString:*/ FfiConverterString.lift,
1575
1285
  /*asyncOpts:*/ asyncOpts_,
1576
1286
  /*errorHandler:*/ FfiConverterTypeNobodyWhoError.lift.bind(FfiConverterTypeNobodyWhoError)
@@ -1584,24 +1294,24 @@ async getChatHistory(asyncOpts_?: { signal: AbortSignal }): Promise<Array<Messa
1584
1294
  }
1585
1295
 
1586
1296
  /**
1587
- * Get the current sampler configuration as a JSON string.
1297
+ * Reset the chat history, keeping the system prompt and tools.
1588
1298
  */
1589
- async getSamplerConfigJson(asyncOpts_?: { signal: AbortSignal }): Promise<string> /*throws*/ {
1299
+ async resetHistory(asyncOpts_?: { signal: AbortSignal }): Promise<void> /*throws*/ {
1590
1300
  const __stack = uniffiIsDebug ? new Error().stack : undefined;
1591
1301
  try {
1592
1302
  return await uniffiRustCallAsync(
1593
1303
  /*rustCaller:*/ uniffiCaller,
1594
1304
  /*rustFutureFunc:*/ () => {
1595
- return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_get_sampler_config_json(
1305
+ return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_reset_history(
1596
1306
  uniffiTypeRustChatObjectFactory.clonePointer(this)
1597
1307
 
1598
1308
  );
1599
1309
  },
1600
- /*pollFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_poll_rust_buffer,
1601
- /*cancelFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_cancel_rust_buffer,
1602
- /*completeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_complete_rust_buffer,
1603
- /*freeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_free_rust_buffer,
1604
- /*liftFunc:*/ FfiConverterString.lift.bind(FfiConverterString),
1310
+ /*pollFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_poll_void,
1311
+ /*cancelFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_cancel_void,
1312
+ /*completeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_complete_void,
1313
+ /*freeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_free_void,
1314
+ /*liftFunc:*/ (_v) => {},
1605
1315
  /*liftString:*/ FfiConverterString.lift,
1606
1316
  /*asyncOpts:*/ asyncOpts_,
1607
1317
  /*errorHandler:*/ FfiConverterTypeNobodyWhoError.lift.bind(FfiConverterTypeNobodyWhoError)
@@ -1615,24 +1325,24 @@ async getSamplerConfigJson(asyncOpts_?: { signal: AbortSignal }): Promise<strin
1615
1325
  }
1616
1326
 
1617
1327
  /**
1618
- * Get the current system prompt.
1328
+ * Set the chat history from a list of messages.
1619
1329
  */
1620
- async getSystemPrompt(asyncOpts_?: { signal: AbortSignal }): Promise<string | undefined> /*throws*/ {
1330
+ async setChatHistory(messages: Array<Message>, asyncOpts_?: { signal: AbortSignal }): Promise<void> /*throws*/ {
1621
1331
  const __stack = uniffiIsDebug ? new Error().stack : undefined;
1622
1332
  try {
1623
1333
  return await uniffiRustCallAsync(
1624
1334
  /*rustCaller:*/ uniffiCaller,
1625
1335
  /*rustFutureFunc:*/ () => {
1626
- return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_get_system_prompt(
1627
- uniffiTypeRustChatObjectFactory.clonePointer(this)
1628
-
1336
+ return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_set_chat_history(
1337
+ uniffiTypeRustChatObjectFactory.clonePointer(this),
1338
+ FfiConverterArrayTypeMessage.lower(messages)
1629
1339
  );
1630
1340
  },
1631
- /*pollFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_poll_rust_buffer,
1632
- /*cancelFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_cancel_rust_buffer,
1633
- /*completeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_complete_rust_buffer,
1634
- /*freeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_free_rust_buffer,
1635
- /*liftFunc:*/ FfiConverterOptionalString.lift.bind(FfiConverterOptionalString),
1341
+ /*pollFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_poll_void,
1342
+ /*cancelFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_cancel_void,
1343
+ /*completeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_complete_void,
1344
+ /*freeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_free_void,
1345
+ /*liftFunc:*/ (_v) => {},
1636
1346
  /*liftString:*/ FfiConverterString.lift,
1637
1347
  /*asyncOpts:*/ asyncOpts_,
1638
1348
  /*errorHandler:*/ FfiConverterTypeNobodyWhoError.lift.bind(FfiConverterTypeNobodyWhoError)
@@ -1646,24 +1356,24 @@ async getSystemPrompt(asyncOpts_?: { signal: AbortSignal }): Promise<string | u
1646
1356
  }
1647
1357
 
1648
1358
  /**
1649
- * Get all template variables.
1359
+ * Set the sampler configuration.
1650
1360
  */
1651
- async getTemplateVariables(asyncOpts_?: { signal: AbortSignal }): Promise<Map<string, boolean>> /*throws*/ {
1361
+ async setSamplerConfig(sampler: SamplerConfigInterface, asyncOpts_?: { signal: AbortSignal }): Promise<void> /*throws*/ {
1652
1362
  const __stack = uniffiIsDebug ? new Error().stack : undefined;
1653
1363
  try {
1654
1364
  return await uniffiRustCallAsync(
1655
1365
  /*rustCaller:*/ uniffiCaller,
1656
1366
  /*rustFutureFunc:*/ () => {
1657
- return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_get_template_variables(
1658
- uniffiTypeRustChatObjectFactory.clonePointer(this)
1659
-
1367
+ return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_set_sampler_config(
1368
+ uniffiTypeRustChatObjectFactory.clonePointer(this),
1369
+ FfiConverterTypeSamplerConfig.lower(sampler)
1660
1370
  );
1661
1371
  },
1662
- /*pollFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_poll_rust_buffer,
1663
- /*cancelFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_cancel_rust_buffer,
1664
- /*completeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_complete_rust_buffer,
1665
- /*freeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_free_rust_buffer,
1666
- /*liftFunc:*/ FfiConverterMapStringBool.lift.bind(FfiConverterMapStringBool),
1372
+ /*pollFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_poll_void,
1373
+ /*cancelFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_cancel_void,
1374
+ /*completeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_complete_void,
1375
+ /*freeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_free_void,
1376
+ /*liftFunc:*/ (_v) => {},
1667
1377
  /*liftString:*/ FfiConverterString.lift,
1668
1378
  /*asyncOpts:*/ asyncOpts_,
1669
1379
  /*errorHandler:*/ FfiConverterTypeNobodyWhoError.lift.bind(FfiConverterTypeNobodyWhoError)
@@ -1677,17 +1387,17 @@ async getTemplateVariables(asyncOpts_?: { signal: AbortSignal }): Promise<Map<s
1677
1387
  }
1678
1388
 
1679
1389
  /**
1680
- * Reset the chat context with a new system prompt and tools.
1390
+ * Set the system prompt.
1681
1391
  */
1682
- async resetContext(systemPrompt: string | undefined, tools: Array<RustToolInterface> | undefined, asyncOpts_?: { signal: AbortSignal }): Promise<void> /*throws*/ {
1392
+ async setSystemPrompt(systemPrompt: string | undefined, asyncOpts_?: { signal: AbortSignal }): Promise<void> /*throws*/ {
1683
1393
  const __stack = uniffiIsDebug ? new Error().stack : undefined;
1684
1394
  try {
1685
1395
  return await uniffiRustCallAsync(
1686
1396
  /*rustCaller:*/ uniffiCaller,
1687
1397
  /*rustFutureFunc:*/ () => {
1688
- return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_reset_context(
1398
+ return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_set_system_prompt(
1689
1399
  uniffiTypeRustChatObjectFactory.clonePointer(this),
1690
- FfiConverterOptionalString.lower(systemPrompt),FfiConverterOptionalArrayTypeRustTool.lower(tools)
1400
+ FfiConverterOptionalString.lower(systemPrompt)
1691
1401
  );
1692
1402
  },
1693
1403
  /*pollFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_poll_void,
@@ -1708,17 +1418,17 @@ async resetContext(systemPrompt: string | undefined, tools: Array<RustToolInter
1708
1418
  }
1709
1419
 
1710
1420
  /**
1711
- * Reset the chat history, keeping the system prompt and tools.
1421
+ * Set a template variable.
1712
1422
  */
1713
- async resetHistory(asyncOpts_?: { signal: AbortSignal }): Promise<void> /*throws*/ {
1423
+ async setTemplateVariable(name: string, value: boolean, asyncOpts_?: { signal: AbortSignal }): Promise<void> /*throws*/ {
1714
1424
  const __stack = uniffiIsDebug ? new Error().stack : undefined;
1715
1425
  try {
1716
1426
  return await uniffiRustCallAsync(
1717
1427
  /*rustCaller:*/ uniffiCaller,
1718
1428
  /*rustFutureFunc:*/ () => {
1719
- return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_reset_history(
1720
- uniffiTypeRustChatObjectFactory.clonePointer(this)
1721
-
1429
+ return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_set_template_variable(
1430
+ uniffiTypeRustChatObjectFactory.clonePointer(this),
1431
+ FfiConverterString.lower(name),FfiConverterBool.lower(value)
1722
1432
  );
1723
1433
  },
1724
1434
  /*pollFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_poll_void,
@@ -1739,17 +1449,17 @@ async resetHistory(asyncOpts_?: { signal: AbortSignal }): Promise<void> /*throw
1739
1449
  }
1740
1450
 
1741
1451
  /**
1742
- * Set the chat history from a list of messages.
1452
+ * Set the tools available to the model.
1743
1453
  */
1744
- async setChatHistory(messages: Array<Message>, asyncOpts_?: { signal: AbortSignal }): Promise<void> /*throws*/ {
1454
+ async setTools(tools: Array<RustToolInterface>, asyncOpts_?: { signal: AbortSignal }): Promise<void> /*throws*/ {
1745
1455
  const __stack = uniffiIsDebug ? new Error().stack : undefined;
1746
1456
  try {
1747
1457
  return await uniffiRustCallAsync(
1748
1458
  /*rustCaller:*/ uniffiCaller,
1749
1459
  /*rustFutureFunc:*/ () => {
1750
- return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_set_chat_history(
1460
+ return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_set_tools(
1751
1461
  uniffiTypeRustChatObjectFactory.clonePointer(this),
1752
- FfiConverterArrayTypeMessage.lower(messages)
1462
+ FfiConverterArrayTypeRustTool.lower(tools)
1753
1463
  );
1754
1464
  },
1755
1465
  /*pollFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_poll_void,
@@ -1770,55 +1480,152 @@ async setChatHistory(messages: Array<Message>, asyncOpts_?: { signal: AbortSign
1770
1480
  }
1771
1481
 
1772
1482
  /**
1773
- * Set the sampler configuration.
1483
+ * Stop the current generation.
1774
1484
  */
1775
- async setSamplerConfig(sampler: SamplerConfigInterface, asyncOpts_?: { signal: AbortSignal }): Promise<void> /*throws*/ {
1776
- const __stack = uniffiIsDebug ? new Error().stack : undefined;
1777
- try {
1778
- return await uniffiRustCallAsync(
1779
- /*rustCaller:*/ uniffiCaller,
1780
- /*rustFutureFunc:*/ () => {
1781
- return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_set_sampler_config(
1782
- uniffiTypeRustChatObjectFactory.clonePointer(this),
1783
- FfiConverterTypeSamplerConfig.lower(sampler)
1784
- );
1485
+ stopGeneration(): void {uniffiCaller.rustCall(
1486
+ /*caller:*/ (callStatus) => { nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_stop_generation(uniffiTypeRustChatObjectFactory.clonePointer(this),
1487
+ callStatus);
1785
1488
  },
1786
- /*pollFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_poll_void,
1787
- /*cancelFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_cancel_void,
1788
- /*completeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_complete_void,
1789
- /*freeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_free_void,
1790
- /*liftFunc:*/ (_v) => {},
1791
1489
  /*liftString:*/ FfiConverterString.lift,
1792
- /*asyncOpts:*/ asyncOpts_,
1793
- /*errorHandler:*/ FfiConverterTypeNobodyWhoError.lift.bind(FfiConverterTypeNobodyWhoError)
1794
- );
1795
- } catch (__error: any) {
1796
- if (uniffiIsDebug && __error instanceof Error) {
1797
- __error.stack = __stack;
1490
+ );
1491
+ }
1492
+
1493
+
1494
+ /**
1495
+ * {@inheritDoc uniffi-bindgen-react-native#UniffiAbstractObject.uniffiDestroy}
1496
+ */
1497
+ uniffiDestroy(): void {
1498
+ const ptr = (this as any)[destructorGuardSymbol];
1499
+ if (ptr !== undefined) {
1500
+ const pointer = uniffiTypeRustChatObjectFactory.pointer(this);
1501
+ uniffiTypeRustChatObjectFactory.freePointer(pointer);
1502
+ uniffiTypeRustChatObjectFactory.unbless(ptr);
1503
+ delete (this as any)[destructorGuardSymbol];
1798
1504
  }
1799
- throw __error;
1800
1505
  }
1506
+
1507
+ static instanceOf(obj: any): obj is RustChat {
1508
+ return uniffiTypeRustChatObjectFactory.isConcreteType(obj);
1509
+ }
1510
+
1511
+
1512
+ }
1513
+
1514
+ const uniffiTypeRustChatObjectFactory: UniffiObjectFactory<RustChatInterface> = (() => {
1515
+
1516
+ return {
1517
+ create(pointer: UniffiHandle): RustChatInterface {
1518
+ const instance = Object.create(RustChat.prototype);
1519
+ instance[pointerLiteralSymbol] = pointer;
1520
+ instance[destructorGuardSymbol] = this.bless(pointer);
1521
+ instance[uniffiTypeNameSymbol] = "RustChat";
1522
+ return instance;
1523
+ },
1524
+
1525
+
1526
+ bless(p: UniffiHandle): UniffiGcObject {
1527
+ return uniffiCaller.rustCall(
1528
+ /*caller:*/ (status) =>
1529
+ nativeModule().ubrn_uniffi_internal_fn_method_rustchat_ffi__bless_pointer(p, status),
1530
+ /*liftString:*/ FfiConverterString.lift
1531
+ );
1532
+ },
1533
+
1534
+ unbless(ptr: UniffiGcObject) {
1535
+ ptr.markDestroyed();
1536
+ },
1537
+
1538
+ pointer(obj: RustChatInterface): UniffiHandle {
1539
+ if ((obj as any)[destructorGuardSymbol] === undefined) {
1540
+ throw new UniffiInternalError.UnexpectedNullPointer();
1541
+ }
1542
+ return (obj as any)[pointerLiteralSymbol];
1543
+ },
1544
+
1545
+ clonePointer(obj: RustChatInterface): UniffiHandle {
1546
+ const pointer = this.pointer(obj);
1547
+ return uniffiCaller.rustCall(
1548
+ /*caller:*/ (callStatus) => nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_clone_rustchat(pointer, callStatus),
1549
+ /*liftString:*/ FfiConverterString.lift
1550
+ );
1551
+ },
1552
+
1553
+ freePointer(pointer: UniffiHandle): void {
1554
+ uniffiCaller.rustCall(
1555
+ /*caller:*/ (callStatus) => nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_free_rustchat(pointer, callStatus),
1556
+ /*liftString:*/ FfiConverterString.lift
1557
+ );
1558
+ },
1559
+
1560
+ isConcreteType(obj: any): obj is RustChatInterface {
1561
+ return obj[destructorGuardSymbol] && obj[uniffiTypeNameSymbol] === "RustChat";
1562
+ },
1563
+ }})();
1564
+ // FfiConverter for RustChatInterface
1565
+ const FfiConverterTypeRustChat = new FfiConverterObject(uniffiTypeRustChatObjectFactory);
1566
+
1567
+
1568
+ export interface RustCrossEncoderInterface {
1569
+
1570
+ /**
1571
+ * Rank documents by relevance to a query. Returns similarity scores.
1572
+ */
1573
+ rank(query: string, documents: Array<string>, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<Array</*f32*/number>>;
1574
+ /**
1575
+ * Rank documents and return them sorted by descending relevance.
1576
+ * Returns a JSON string of [document, score] pairs since UniFFI
1577
+ * doesn't support tuples directly.
1578
+ */
1579
+ rankAndSortJson(query: string, documents: Array<string>, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<string>;
1580
+ }
1581
+
1582
+
1583
+ export class RustCrossEncoder extends UniffiAbstractObject implements RustCrossEncoderInterface {
1584
+
1585
+ readonly [uniffiTypeNameSymbol] = "RustCrossEncoder";
1586
+ readonly [destructorGuardSymbol]: UniffiGcObject;
1587
+ readonly [pointerLiteralSymbol]: UniffiHandle;
1588
+ /**
1589
+ * Create a new cross-encoder for ranking documents by relevance.
1590
+ */
1591
+ constructor(model: RustModelInterface, contextSize: /*u32*/number | undefined) {
1592
+ super();
1593
+ const pointer =
1594
+ uniffiCaller.rustCall(
1595
+ /*caller:*/ (callStatus) => {
1596
+ return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_constructor_rustcrossencoder_new(
1597
+ FfiConverterTypeRustModel.lower(model),
1598
+ FfiConverterOptionalUInt32.lower(contextSize),
1599
+ callStatus);
1600
+ },
1601
+ /*liftString:*/ FfiConverterString.lift,
1602
+ );
1603
+ this[pointerLiteralSymbol] = pointer;
1604
+ this[destructorGuardSymbol] = uniffiTypeRustCrossEncoderObjectFactory.bless(pointer);
1801
1605
  }
1606
+
1607
+
1608
+
1802
1609
 
1803
1610
  /**
1804
- * Set the system prompt.
1611
+ * Rank documents by relevance to a query. Returns similarity scores.
1805
1612
  */
1806
- async setSystemPrompt(systemPrompt: string | undefined, asyncOpts_?: { signal: AbortSignal }): Promise<void> /*throws*/ {
1613
+ async rank(query: string, documents: Array<string>, asyncOpts_?: { signal: AbortSignal }): Promise<Array</*f32*/number>> /*throws*/ {
1807
1614
  const __stack = uniffiIsDebug ? new Error().stack : undefined;
1808
1615
  try {
1809
1616
  return await uniffiRustCallAsync(
1810
1617
  /*rustCaller:*/ uniffiCaller,
1811
1618
  /*rustFutureFunc:*/ () => {
1812
- return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_set_system_prompt(
1813
- uniffiTypeRustChatObjectFactory.clonePointer(this),
1814
- FfiConverterOptionalString.lower(systemPrompt)
1619
+ return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_rustcrossencoder_rank(
1620
+ uniffiTypeRustCrossEncoderObjectFactory.clonePointer(this),
1621
+ FfiConverterString.lower(query),FfiConverterArrayString.lower(documents)
1815
1622
  );
1816
1623
  },
1817
- /*pollFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_poll_void,
1818
- /*cancelFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_cancel_void,
1819
- /*completeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_complete_void,
1820
- /*freeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_free_void,
1821
- /*liftFunc:*/ (_v) => {},
1624
+ /*pollFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_poll_rust_buffer,
1625
+ /*cancelFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_cancel_rust_buffer,
1626
+ /*completeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_complete_rust_buffer,
1627
+ /*freeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_free_rust_buffer,
1628
+ /*liftFunc:*/ FfiConverterArrayFloat32.lift.bind(FfiConverterArrayFloat32),
1822
1629
  /*liftString:*/ FfiConverterString.lift,
1823
1630
  /*asyncOpts:*/ asyncOpts_,
1824
1631
  /*errorHandler:*/ FfiConverterTypeNobodyWhoError.lift.bind(FfiConverterTypeNobodyWhoError)
@@ -1832,24 +1639,26 @@ async setSystemPrompt(systemPrompt: string | undefined, asyncOpts_?: { signal:
1832
1639
  }
1833
1640
 
1834
1641
  /**
1835
- * Set a template variable.
1642
+ * Rank documents and return them sorted by descending relevance.
1643
+ * Returns a JSON string of [document, score] pairs since UniFFI
1644
+ * doesn't support tuples directly.
1836
1645
  */
1837
- async setTemplateVariable(name: string, value: boolean, asyncOpts_?: { signal: AbortSignal }): Promise<void> /*throws*/ {
1646
+ async rankAndSortJson(query: string, documents: Array<string>, asyncOpts_?: { signal: AbortSignal }): Promise<string> /*throws*/ {
1838
1647
  const __stack = uniffiIsDebug ? new Error().stack : undefined;
1839
1648
  try {
1840
1649
  return await uniffiRustCallAsync(
1841
1650
  /*rustCaller:*/ uniffiCaller,
1842
1651
  /*rustFutureFunc:*/ () => {
1843
- return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_set_template_variable(
1844
- uniffiTypeRustChatObjectFactory.clonePointer(this),
1845
- FfiConverterString.lower(name),FfiConverterBool.lower(value)
1652
+ return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_rustcrossencoder_rank_and_sort_json(
1653
+ uniffiTypeRustCrossEncoderObjectFactory.clonePointer(this),
1654
+ FfiConverterString.lower(query),FfiConverterArrayString.lower(documents)
1846
1655
  );
1847
1656
  },
1848
- /*pollFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_poll_void,
1849
- /*cancelFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_cancel_void,
1850
- /*completeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_complete_void,
1851
- /*freeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_free_void,
1852
- /*liftFunc:*/ (_v) => {},
1657
+ /*pollFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_poll_rust_buffer,
1658
+ /*cancelFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_cancel_rust_buffer,
1659
+ /*completeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_complete_rust_buffer,
1660
+ /*freeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_free_rust_buffer,
1661
+ /*liftFunc:*/ FfiConverterString.lift.bind(FfiConverterString),
1853
1662
  /*liftString:*/ FfiConverterString.lift,
1854
1663
  /*asyncOpts:*/ asyncOpts_,
1855
1664
  /*errorHandler:*/ FfiConverterTypeNobodyWhoError.lift.bind(FfiConverterTypeNobodyWhoError)
@@ -1862,25 +1671,136 @@ async setTemplateVariable(name: string, value: boolean, asyncOpts_?: { signal:
1862
1671
  }
1863
1672
  }
1864
1673
 
1674
+
1865
1675
  /**
1866
- * Set the tools available to the model.
1676
+ * {@inheritDoc uniffi-bindgen-react-native#UniffiAbstractObject.uniffiDestroy}
1867
1677
  */
1868
- async setTools(tools: Array<RustToolInterface>, asyncOpts_?: { signal: AbortSignal }): Promise<void> /*throws*/ {
1678
+ uniffiDestroy(): void {
1679
+ const ptr = (this as any)[destructorGuardSymbol];
1680
+ if (ptr !== undefined) {
1681
+ const pointer = uniffiTypeRustCrossEncoderObjectFactory.pointer(this);
1682
+ uniffiTypeRustCrossEncoderObjectFactory.freePointer(pointer);
1683
+ uniffiTypeRustCrossEncoderObjectFactory.unbless(ptr);
1684
+ delete (this as any)[destructorGuardSymbol];
1685
+ }
1686
+ }
1687
+
1688
+ static instanceOf(obj: any): obj is RustCrossEncoder {
1689
+ return uniffiTypeRustCrossEncoderObjectFactory.isConcreteType(obj);
1690
+ }
1691
+
1692
+
1693
+ }
1694
+
1695
+ const uniffiTypeRustCrossEncoderObjectFactory: UniffiObjectFactory<RustCrossEncoderInterface> = (() => {
1696
+
1697
+ return {
1698
+ create(pointer: UniffiHandle): RustCrossEncoderInterface {
1699
+ const instance = Object.create(RustCrossEncoder.prototype);
1700
+ instance[pointerLiteralSymbol] = pointer;
1701
+ instance[destructorGuardSymbol] = this.bless(pointer);
1702
+ instance[uniffiTypeNameSymbol] = "RustCrossEncoder";
1703
+ return instance;
1704
+ },
1705
+
1706
+
1707
+ bless(p: UniffiHandle): UniffiGcObject {
1708
+ return uniffiCaller.rustCall(
1709
+ /*caller:*/ (status) =>
1710
+ nativeModule().ubrn_uniffi_internal_fn_method_rustcrossencoder_ffi__bless_pointer(p, status),
1711
+ /*liftString:*/ FfiConverterString.lift
1712
+ );
1713
+ },
1714
+
1715
+ unbless(ptr: UniffiGcObject) {
1716
+ ptr.markDestroyed();
1717
+ },
1718
+
1719
+ pointer(obj: RustCrossEncoderInterface): UniffiHandle {
1720
+ if ((obj as any)[destructorGuardSymbol] === undefined) {
1721
+ throw new UniffiInternalError.UnexpectedNullPointer();
1722
+ }
1723
+ return (obj as any)[pointerLiteralSymbol];
1724
+ },
1725
+
1726
+ clonePointer(obj: RustCrossEncoderInterface): UniffiHandle {
1727
+ const pointer = this.pointer(obj);
1728
+ return uniffiCaller.rustCall(
1729
+ /*caller:*/ (callStatus) => nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_clone_rustcrossencoder(pointer, callStatus),
1730
+ /*liftString:*/ FfiConverterString.lift
1731
+ );
1732
+ },
1733
+
1734
+ freePointer(pointer: UniffiHandle): void {
1735
+ uniffiCaller.rustCall(
1736
+ /*caller:*/ (callStatus) => nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_free_rustcrossencoder(pointer, callStatus),
1737
+ /*liftString:*/ FfiConverterString.lift
1738
+ );
1739
+ },
1740
+
1741
+ isConcreteType(obj: any): obj is RustCrossEncoderInterface {
1742
+ return obj[destructorGuardSymbol] && obj[uniffiTypeNameSymbol] === "RustCrossEncoder";
1743
+ },
1744
+ }})();
1745
+ // FfiConverter for RustCrossEncoderInterface
1746
+ const FfiConverterTypeRustCrossEncoder = new FfiConverterObject(uniffiTypeRustCrossEncoderObjectFactory);
1747
+
1748
+
1749
+ export interface RustEncoderInterface {
1750
+
1751
+ /**
1752
+ * Encode text into an embedding vector.
1753
+ */
1754
+ encode(text: string, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<Array</*f32*/number>>;
1755
+ }
1756
+
1757
+
1758
+ export class RustEncoder extends UniffiAbstractObject implements RustEncoderInterface {
1759
+
1760
+ readonly [uniffiTypeNameSymbol] = "RustEncoder";
1761
+ readonly [destructorGuardSymbol]: UniffiGcObject;
1762
+ readonly [pointerLiteralSymbol]: UniffiHandle;
1763
+ /**
1764
+ * Create a new encoder for generating text embeddings.
1765
+ */
1766
+ constructor(model: RustModelInterface, contextSize: /*u32*/number | undefined) {
1767
+ super();
1768
+ const pointer =
1769
+ uniffiCaller.rustCall(
1770
+ /*caller:*/ (callStatus) => {
1771
+ return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_constructor_rustencoder_new(
1772
+ FfiConverterTypeRustModel.lower(model),
1773
+ FfiConverterOptionalUInt32.lower(contextSize),
1774
+ callStatus);
1775
+ },
1776
+ /*liftString:*/ FfiConverterString.lift,
1777
+ );
1778
+ this[pointerLiteralSymbol] = pointer;
1779
+ this[destructorGuardSymbol] = uniffiTypeRustEncoderObjectFactory.bless(pointer);
1780
+ }
1781
+
1782
+
1783
+
1784
+
1785
+ /**
1786
+ * Encode text into an embedding vector.
1787
+ */
1788
+ async encode(text: string, asyncOpts_?: { signal: AbortSignal }): Promise<Array</*f32*/number>> /*throws*/ {
1869
1789
  const __stack = uniffiIsDebug ? new Error().stack : undefined;
1870
1790
  try {
1871
1791
  return await uniffiRustCallAsync(
1872
1792
  /*rustCaller:*/ uniffiCaller,
1873
1793
  /*rustFutureFunc:*/ () => {
1874
- return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_set_tools(
1875
- uniffiTypeRustChatObjectFactory.clonePointer(this),
1876
- FfiConverterArrayTypeRustTool.lower(tools)
1794
+ return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_rustencoder_encode(
1795
+ uniffiTypeRustEncoderObjectFactory.clonePointer(this),
1796
+ FfiConverterString.lower(text)
1877
1797
  );
1878
1798
  },
1879
- /*pollFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_poll_void,
1880
- /*cancelFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_cancel_void,
1881
- /*completeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_complete_void,
1882
- /*freeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_free_void,
1883
- /*liftFunc:*/ (_v) => {},
1799
+ /*pollFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_poll_rust_buffer,
1800
+ /*cancelFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_cancel_rust_buffer,
1801
+ /*completeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_complete_rust_buffer,
1802
+ /*freeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_free_rust_buffer,
1803
+ /*liftFunc:*/ FfiConverterArrayFloat32.lift.bind(FfiConverterArrayFloat32),
1884
1804
  /*liftString:*/ FfiConverterString.lift,
1885
1805
  /*asyncOpts:*/ asyncOpts_,
1886
1806
  /*errorHandler:*/ FfiConverterTypeNobodyWhoError.lift.bind(FfiConverterTypeNobodyWhoError)
@@ -1893,16 +1813,100 @@ async setTools(tools: Array<RustToolInterface>, asyncOpts_?: { signal: AbortSig
1893
1813
  }
1894
1814
  }
1895
1815
 
1816
+
1896
1817
  /**
1897
- * Stop the current generation.
1818
+ * {@inheritDoc uniffi-bindgen-react-native#UniffiAbstractObject.uniffiDestroy}
1898
1819
  */
1899
- stopGeneration(): void {uniffiCaller.rustCall(
1900
- /*caller:*/ (callStatus) => { nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_stop_generation(uniffiTypeRustChatObjectFactory.clonePointer(this),
1901
- callStatus);
1902
- },
1903
- /*liftString:*/ FfiConverterString.lift,
1904
- );
1820
+ uniffiDestroy(): void {
1821
+ const ptr = (this as any)[destructorGuardSymbol];
1822
+ if (ptr !== undefined) {
1823
+ const pointer = uniffiTypeRustEncoderObjectFactory.pointer(this);
1824
+ uniffiTypeRustEncoderObjectFactory.freePointer(pointer);
1825
+ uniffiTypeRustEncoderObjectFactory.unbless(ptr);
1826
+ delete (this as any)[destructorGuardSymbol];
1827
+ }
1905
1828
  }
1829
+
1830
+ static instanceOf(obj: any): obj is RustEncoder {
1831
+ return uniffiTypeRustEncoderObjectFactory.isConcreteType(obj);
1832
+ }
1833
+
1834
+
1835
+ }
1836
+
1837
+ const uniffiTypeRustEncoderObjectFactory: UniffiObjectFactory<RustEncoderInterface> = (() => {
1838
+
1839
+ return {
1840
+ create(pointer: UniffiHandle): RustEncoderInterface {
1841
+ const instance = Object.create(RustEncoder.prototype);
1842
+ instance[pointerLiteralSymbol] = pointer;
1843
+ instance[destructorGuardSymbol] = this.bless(pointer);
1844
+ instance[uniffiTypeNameSymbol] = "RustEncoder";
1845
+ return instance;
1846
+ },
1847
+
1848
+
1849
+ bless(p: UniffiHandle): UniffiGcObject {
1850
+ return uniffiCaller.rustCall(
1851
+ /*caller:*/ (status) =>
1852
+ nativeModule().ubrn_uniffi_internal_fn_method_rustencoder_ffi__bless_pointer(p, status),
1853
+ /*liftString:*/ FfiConverterString.lift
1854
+ );
1855
+ },
1856
+
1857
+ unbless(ptr: UniffiGcObject) {
1858
+ ptr.markDestroyed();
1859
+ },
1860
+
1861
+ pointer(obj: RustEncoderInterface): UniffiHandle {
1862
+ if ((obj as any)[destructorGuardSymbol] === undefined) {
1863
+ throw new UniffiInternalError.UnexpectedNullPointer();
1864
+ }
1865
+ return (obj as any)[pointerLiteralSymbol];
1866
+ },
1867
+
1868
+ clonePointer(obj: RustEncoderInterface): UniffiHandle {
1869
+ const pointer = this.pointer(obj);
1870
+ return uniffiCaller.rustCall(
1871
+ /*caller:*/ (callStatus) => nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_clone_rustencoder(pointer, callStatus),
1872
+ /*liftString:*/ FfiConverterString.lift
1873
+ );
1874
+ },
1875
+
1876
+ freePointer(pointer: UniffiHandle): void {
1877
+ uniffiCaller.rustCall(
1878
+ /*caller:*/ (callStatus) => nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_free_rustencoder(pointer, callStatus),
1879
+ /*liftString:*/ FfiConverterString.lift
1880
+ );
1881
+ },
1882
+
1883
+ isConcreteType(obj: any): obj is RustEncoderInterface {
1884
+ return obj[destructorGuardSymbol] && obj[uniffiTypeNameSymbol] === "RustEncoder";
1885
+ },
1886
+ }})();
1887
+ // FfiConverter for RustEncoderInterface
1888
+ const FfiConverterTypeRustEncoder = new FfiConverterObject(uniffiTypeRustEncoderObjectFactory);
1889
+
1890
+
1891
+ export interface RustModelInterface {
1892
+
1893
+ }
1894
+
1895
+
1896
+ export class RustModel extends UniffiAbstractObject implements RustModelInterface {
1897
+
1898
+ readonly [uniffiTypeNameSymbol] = "RustModel";
1899
+ readonly [destructorGuardSymbol]: UniffiGcObject;
1900
+ readonly [pointerLiteralSymbol]: UniffiHandle;
1901
+ // No primary constructor declared for this class.
1902
+ private constructor(pointer: UniffiHandle) {
1903
+ super();
1904
+ this[pointerLiteralSymbol] = pointer;
1905
+ this[destructorGuardSymbol] = uniffiTypeRustModelObjectFactory.bless(pointer);
1906
+ }
1907
+
1908
+
1909
+
1906
1910
 
1907
1911
 
1908
1912
  /**
@@ -1911,28 +1915,28 @@ async setTools(tools: Array<RustToolInterface>, asyncOpts_?: { signal: AbortSig
1911
1915
  uniffiDestroy(): void {
1912
1916
  const ptr = (this as any)[destructorGuardSymbol];
1913
1917
  if (ptr !== undefined) {
1914
- const pointer = uniffiTypeRustChatObjectFactory.pointer(this);
1915
- uniffiTypeRustChatObjectFactory.freePointer(pointer);
1916
- uniffiTypeRustChatObjectFactory.unbless(ptr);
1918
+ const pointer = uniffiTypeRustModelObjectFactory.pointer(this);
1919
+ uniffiTypeRustModelObjectFactory.freePointer(pointer);
1920
+ uniffiTypeRustModelObjectFactory.unbless(ptr);
1917
1921
  delete (this as any)[destructorGuardSymbol];
1918
1922
  }
1919
1923
  }
1920
1924
 
1921
- static instanceOf(obj: any): obj is RustChat {
1922
- return uniffiTypeRustChatObjectFactory.isConcreteType(obj);
1925
+ static instanceOf(obj: any): obj is RustModel {
1926
+ return uniffiTypeRustModelObjectFactory.isConcreteType(obj);
1923
1927
  }
1924
1928
 
1925
1929
 
1926
1930
  }
1927
1931
 
1928
- const uniffiTypeRustChatObjectFactory: UniffiObjectFactory<RustChatInterface> = (() => {
1932
+ const uniffiTypeRustModelObjectFactory: UniffiObjectFactory<RustModelInterface> = (() => {
1929
1933
 
1930
1934
  return {
1931
- create(pointer: UniffiHandle): RustChatInterface {
1932
- const instance = Object.create(RustChat.prototype);
1935
+ create(pointer: UniffiHandle): RustModelInterface {
1936
+ const instance = Object.create(RustModel.prototype);
1933
1937
  instance[pointerLiteralSymbol] = pointer;
1934
1938
  instance[destructorGuardSymbol] = this.bless(pointer);
1935
- instance[uniffiTypeNameSymbol] = "RustChat";
1939
+ instance[uniffiTypeNameSymbol] = "RustModel";
1936
1940
  return instance;
1937
1941
  },
1938
1942
 
@@ -1940,7 +1944,7 @@ const uniffiTypeRustChatObjectFactory: UniffiObjectFactory<RustChatInterface> =
1940
1944
  bless(p: UniffiHandle): UniffiGcObject {
1941
1945
  return uniffiCaller.rustCall(
1942
1946
  /*caller:*/ (status) =>
1943
- nativeModule().ubrn_uniffi_internal_fn_method_rustchat_ffi__bless_pointer(p, status),
1947
+ nativeModule().ubrn_uniffi_internal_fn_method_rustmodel_ffi__bless_pointer(p, status),
1944
1948
  /*liftString:*/ FfiConverterString.lift
1945
1949
  );
1946
1950
  },
@@ -1949,34 +1953,34 @@ const uniffiTypeRustChatObjectFactory: UniffiObjectFactory<RustChatInterface> =
1949
1953
  ptr.markDestroyed();
1950
1954
  },
1951
1955
 
1952
- pointer(obj: RustChatInterface): UniffiHandle {
1956
+ pointer(obj: RustModelInterface): UniffiHandle {
1953
1957
  if ((obj as any)[destructorGuardSymbol] === undefined) {
1954
1958
  throw new UniffiInternalError.UnexpectedNullPointer();
1955
1959
  }
1956
1960
  return (obj as any)[pointerLiteralSymbol];
1957
1961
  },
1958
1962
 
1959
- clonePointer(obj: RustChatInterface): UniffiHandle {
1963
+ clonePointer(obj: RustModelInterface): UniffiHandle {
1960
1964
  const pointer = this.pointer(obj);
1961
1965
  return uniffiCaller.rustCall(
1962
- /*caller:*/ (callStatus) => nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_clone_rustchat(pointer, callStatus),
1966
+ /*caller:*/ (callStatus) => nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_clone_rustmodel(pointer, callStatus),
1963
1967
  /*liftString:*/ FfiConverterString.lift
1964
1968
  );
1965
1969
  },
1966
1970
 
1967
1971
  freePointer(pointer: UniffiHandle): void {
1968
1972
  uniffiCaller.rustCall(
1969
- /*caller:*/ (callStatus) => nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_free_rustchat(pointer, callStatus),
1973
+ /*caller:*/ (callStatus) => nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_free_rustmodel(pointer, callStatus),
1970
1974
  /*liftString:*/ FfiConverterString.lift
1971
1975
  );
1972
1976
  },
1973
1977
 
1974
- isConcreteType(obj: any): obj is RustChatInterface {
1975
- return obj[destructorGuardSymbol] && obj[uniffiTypeNameSymbol] === "RustChat";
1978
+ isConcreteType(obj: any): obj is RustModelInterface {
1979
+ return obj[destructorGuardSymbol] && obj[uniffiTypeNameSymbol] === "RustModel";
1976
1980
  },
1977
1981
  }})();
1978
- // FfiConverter for RustChatInterface
1979
- const FfiConverterTypeRustChat = new FfiConverterObject(uniffiTypeRustChatObjectFactory);
1982
+ // FfiConverter for RustModelInterface
1983
+ const FfiConverterTypeRustModel = new FfiConverterObject(uniffiTypeRustModelObjectFactory);
1980
1984
 
1981
1985
 
1982
1986
  export interface RustTokenStreamInterface {
@@ -2840,7 +2844,7 @@ function uniffiEnsureInitialized() {
2840
2844
  if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_func_cosine_similarity() !== 63439) {
2841
2845
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_func_cosine_similarity");
2842
2846
  }
2843
- if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_func_load_model() !== 19243) {
2847
+ if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_func_load_model() !== 63144) {
2844
2848
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_func_load_model");
2845
2849
  }
2846
2850
  if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_func_sampler_preset_default() !== 10834) {
@@ -2867,15 +2871,6 @@ function uniffiEnsureInitialized() {
2867
2871
  if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_func_sampler_preset_top_p() !== 54893) {
2868
2872
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_func_sampler_preset_top_p");
2869
2873
  }
2870
- if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_crossencoder_rank() !== 14399) {
2871
- throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_crossencoder_rank");
2872
- }
2873
- if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_crossencoder_rank_and_sort_json() !== 4173) {
2874
- throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_crossencoder_rank_and_sort_json");
2875
- }
2876
- if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_encoder_encode() !== 21765) {
2877
- throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_encoder_encode");
2878
- }
2879
2874
  if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustchat_ask() !== 53575) {
2880
2875
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_rustchat_ask");
2881
2876
  }
@@ -2918,6 +2913,15 @@ function uniffiEnsureInitialized() {
2918
2913
  if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustchat_stop_generation() !== 24711) {
2919
2914
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_rustchat_stop_generation");
2920
2915
  }
2916
+ if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustcrossencoder_rank() !== 55500) {
2917
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_rustcrossencoder_rank");
2918
+ }
2919
+ if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustcrossencoder_rank_and_sort_json() !== 24587) {
2920
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_rustcrossencoder_rank_and_sort_json");
2921
+ }
2922
+ if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustencoder_encode() !== 52601) {
2923
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_rustencoder_encode");
2924
+ }
2921
2925
  if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rusttokenstream_completed() !== 26060) {
2922
2926
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_rusttokenstream_completed");
2923
2927
  }
@@ -2969,14 +2973,14 @@ function uniffiEnsureInitialized() {
2969
2973
  if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_samplerconfig_to_json() !== 51798) {
2970
2974
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_samplerconfig_to_json");
2971
2975
  }
2972
- if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_constructor_crossencoder_new() !== 12491) {
2973
- throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_constructor_crossencoder_new");
2976
+ if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_constructor_rustchat_new() !== 38902) {
2977
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_constructor_rustchat_new");
2974
2978
  }
2975
- if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_constructor_encoder_new() !== 32094) {
2976
- throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_constructor_encoder_new");
2979
+ if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_constructor_rustcrossencoder_new() !== 9022) {
2980
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_constructor_rustcrossencoder_new");
2977
2981
  }
2978
- if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_constructor_rustchat_new() !== 6355) {
2979
- throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_constructor_rustchat_new");
2982
+ if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_constructor_rustencoder_new() !== 27902) {
2983
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_constructor_rustencoder_new");
2980
2984
  }
2981
2985
  if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_constructor_rusttool_new() !== 54104) {
2982
2986
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_constructor_rusttool_new");
@@ -2998,14 +3002,14 @@ export default Object.freeze({
2998
3002
  initialize: uniffiEnsureInitialized,
2999
3003
  converters: {
3000
3004
  FfiConverterTypeAsset,
3001
- FfiConverterTypeCrossEncoder,
3002
- FfiConverterTypeEncoder,
3003
3005
  FfiConverterTypeMessage,
3004
- FfiConverterTypeModel,
3005
3006
  FfiConverterTypeNobodyWhoError,
3006
3007
  FfiConverterTypePromptPart,
3007
3008
  FfiConverterTypeRole,
3008
3009
  FfiConverterTypeRustChat,
3010
+ FfiConverterTypeRustCrossEncoder,
3011
+ FfiConverterTypeRustEncoder,
3012
+ FfiConverterTypeRustModel,
3009
3013
  FfiConverterTypeRustTokenStream,
3010
3014
  FfiConverterTypeRustTool,
3011
3015
  FfiConverterTypeSamplerBuilder,