react-native-nobodywho 2.1.0 → 2.2.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.
@@ -268,6 +268,8 @@ void uniffi_nobodywho_uniffi_fn_init_callback_vtable_rusttoolcallback(
268
268
  UniffiVTableCallbackInterfaceRustToolCallback *vtable);
269
269
  float uniffi_nobodywho_uniffi_fn_func_cosine_similarity(
270
270
  RustBuffer a, RustBuffer b, RustCallStatus *uniffi_out_err);
271
+ /*handle*/ uint64_t uniffi_nobodywho_uniffi_fn_func_download_model(
272
+ RustBuffer model_path, RustBuffer headers, RustBuffer on_download_progress);
271
273
  /*handle*/ uint64_t uniffi_nobodywho_uniffi_fn_func_load_model(
272
274
  RustBuffer model_path, int8_t use_gpu, RustBuffer projection_model_path,
273
275
  RustBuffer on_download_progress);
@@ -416,6 +418,7 @@ void ffi_nobodywho_uniffi_rust_future_free_void(
416
418
  void ffi_nobodywho_uniffi_rust_future_complete_void(
417
419
  /*handle*/ uint64_t handle, RustCallStatus *uniffi_out_err);
418
420
  uint16_t uniffi_nobodywho_uniffi_checksum_func_cosine_similarity();
421
+ uint16_t uniffi_nobodywho_uniffi_checksum_func_download_model();
419
422
  uint16_t uniffi_nobodywho_uniffi_checksum_func_load_model();
420
423
  uint16_t
421
424
  uniffi_nobodywho_uniffi_checksum_func_sampler_preset_constrain_with_grammar();
@@ -3372,6 +3375,17 @@ NativeNobodywho::NativeNobodywho(
3372
3375
  return this->cpp_uniffi_nobodywho_uniffi_fn_func_cosine_similarity(
3373
3376
  rt, thisVal, args, count);
3374
3377
  });
3378
+ props["ubrn_uniffi_nobodywho_uniffi_fn_func_download_model"] =
3379
+ jsi::Function::createFromHostFunction(
3380
+ rt,
3381
+ jsi::PropNameID::forAscii(
3382
+ rt, "ubrn_uniffi_nobodywho_uniffi_fn_func_download_model"),
3383
+ 3,
3384
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal,
3385
+ const jsi::Value *args, size_t count) -> jsi::Value {
3386
+ return this->cpp_uniffi_nobodywho_uniffi_fn_func_download_model(
3387
+ rt, thisVal, args, count);
3388
+ });
3375
3389
  props["ubrn_uniffi_nobodywho_uniffi_fn_func_load_model"] =
3376
3390
  jsi::Function::createFromHostFunction(
3377
3391
  rt,
@@ -4060,6 +4074,18 @@ NativeNobodywho::NativeNobodywho(
4060
4074
  ->cpp_uniffi_nobodywho_uniffi_checksum_func_cosine_similarity(
4061
4075
  rt, thisVal, args, count);
4062
4076
  });
4077
+ props["ubrn_uniffi_nobodywho_uniffi_checksum_func_download_model"] =
4078
+ jsi::Function::createFromHostFunction(
4079
+ rt,
4080
+ jsi::PropNameID::forAscii(
4081
+ rt, "ubrn_uniffi_nobodywho_uniffi_checksum_func_download_model"),
4082
+ 0,
4083
+ [this](jsi::Runtime &rt, const jsi::Value &thisVal,
4084
+ const jsi::Value *args, size_t count) -> jsi::Value {
4085
+ return this
4086
+ ->cpp_uniffi_nobodywho_uniffi_checksum_func_download_model(
4087
+ rt, thisVal, args, count);
4088
+ });
4063
4089
  props["ubrn_uniffi_nobodywho_uniffi_checksum_func_load_model"] =
4064
4090
  jsi::Function::createFromHostFunction(
4065
4091
  rt,
@@ -5997,6 +6023,18 @@ NativeNobodywho::cpp_uniffi_nobodywho_uniffi_fn_func_cosine_similarity(
5997
6023
 
5998
6024
  return uniffi_jsi::Bridging<float>::toJs(rt, callInvoker, value);
5999
6025
  }
6026
+ jsi::Value NativeNobodywho::cpp_uniffi_nobodywho_uniffi_fn_func_download_model(
6027
+ jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
6028
+ size_t count) {
6029
+ auto value = uniffi_nobodywho_uniffi_fn_func_download_model(
6030
+ uniffi::nobodywho::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[0]),
6031
+ uniffi::nobodywho::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[1]),
6032
+ uniffi::nobodywho::Bridging<RustBuffer>::fromJs(rt, callInvoker,
6033
+ args[2]));
6034
+
6035
+ return uniffi_jsi::Bridging</*handle*/ uint64_t>::toJs(rt, callInvoker,
6036
+ value);
6037
+ }
6000
6038
  jsi::Value NativeNobodywho::cpp_uniffi_nobodywho_uniffi_fn_func_load_model(
6001
6039
  jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
6002
6040
  size_t count) {
@@ -6723,6 +6761,14 @@ NativeNobodywho::cpp_uniffi_nobodywho_uniffi_checksum_func_cosine_similarity(
6723
6761
  return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
6724
6762
  }
6725
6763
  jsi::Value
6764
+ NativeNobodywho::cpp_uniffi_nobodywho_uniffi_checksum_func_download_model(
6765
+ jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
6766
+ size_t count) {
6767
+ auto value = uniffi_nobodywho_uniffi_checksum_func_download_model();
6768
+
6769
+ return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
6770
+ }
6771
+ jsi::Value
6726
6772
  NativeNobodywho::cpp_uniffi_nobodywho_uniffi_checksum_func_load_model(
6727
6773
  jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
6728
6774
  size_t count) {
@@ -221,6 +221,9 @@ protected:
221
221
  jsi::Value cpp_uniffi_nobodywho_uniffi_fn_func_cosine_similarity(
222
222
  jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
223
223
  size_t count);
224
+ jsi::Value cpp_uniffi_nobodywho_uniffi_fn_func_download_model(
225
+ jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
226
+ size_t count);
224
227
  jsi::Value cpp_uniffi_nobodywho_uniffi_fn_func_load_model(
225
228
  jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
226
229
  size_t count);
@@ -407,6 +410,9 @@ protected:
407
410
  jsi::Value cpp_uniffi_nobodywho_uniffi_checksum_func_cosine_similarity(
408
411
  jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
409
412
  size_t count);
413
+ jsi::Value cpp_uniffi_nobodywho_uniffi_checksum_func_download_model(
414
+ jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
415
+ size_t count);
410
416
  jsi::Value cpp_uniffi_nobodywho_uniffi_checksum_func_load_model(
411
417
  jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
412
418
  size_t count);
@@ -80,6 +80,7 @@ interface NativeModuleInterface {
80
80
  ubrn_uniffi_nobodywho_uniffi_fn_init_callback_vtable_rustdownloadprogresscallback(vtable: UniffiVTableCallbackInterfaceRustDownloadProgressCallback): void;
81
81
  ubrn_uniffi_nobodywho_uniffi_fn_init_callback_vtable_rusttoolcallback(vtable: UniffiVTableCallbackInterfaceRustToolCallback): void;
82
82
  ubrn_uniffi_nobodywho_uniffi_fn_func_cosine_similarity(a: Uint8Array, b: Uint8Array, uniffi_out_err: UniffiRustCallStatus): number;
83
+ ubrn_uniffi_nobodywho_uniffi_fn_func_download_model(modelPath: Uint8Array, headers: Uint8Array, onDownloadProgress: Uint8Array): bigint;
83
84
  ubrn_uniffi_nobodywho_uniffi_fn_func_load_model(modelPath: Uint8Array, useGpu: number, projectionModelPath: Uint8Array, onDownloadProgress: Uint8Array): bigint;
84
85
  ubrn_uniffi_nobodywho_uniffi_fn_func_sampler_preset_constrain_with_grammar(grammar: Uint8Array, uniffi_out_err: UniffiRustCallStatus): bigint;
85
86
  ubrn_uniffi_nobodywho_uniffi_fn_func_sampler_preset_constrain_with_json_schema(schema: Uint8Array, uniffi_out_err: UniffiRustCallStatus): bigint;
@@ -141,6 +142,7 @@ interface NativeModuleInterface {
141
142
  ubrn_ffi_nobodywho_uniffi_rust_future_free_void(handle: bigint): void;
142
143
  ubrn_ffi_nobodywho_uniffi_rust_future_complete_void(handle: bigint, uniffi_out_err: UniffiRustCallStatus): void;
143
144
  ubrn_uniffi_nobodywho_uniffi_checksum_func_cosine_similarity(): number;
145
+ ubrn_uniffi_nobodywho_uniffi_checksum_func_download_model(): number;
144
146
  ubrn_uniffi_nobodywho_uniffi_checksum_func_load_model(): number;
145
147
  ubrn_uniffi_nobodywho_uniffi_checksum_func_sampler_preset_constrain_with_grammar(): number;
146
148
  ubrn_uniffi_nobodywho_uniffi_checksum_func_sampler_preset_constrain_with_json_schema(): number;
@@ -95,6 +95,37 @@ export function cosineSimilarity(a: Array</*f32*/number>, b: Array</*f32*/number
95
95
  /*liftString:*/ FfiConverterString.lift,
96
96
  ));
97
97
  }
98
+ /**
99
+ * Download a GGUF model from a remote URL or HuggingFace path and return the local file path.
100
+ *
101
+ * Use this when you need custom headers, e.g. for gated models that require authentication.
102
+ * For unauthenticated downloads, pass the URL directly to `load_model`.
103
+ */
104
+ export async function downloadModel(modelPath: string, headers: Map<string, string> | undefined, onDownloadProgress: RustDownloadProgressCallback | undefined, asyncOpts_?: { signal: AbortSignal }): Promise<string> /*throws*/ {
105
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
106
+ try {
107
+ return await uniffiRustCallAsync(
108
+ /*rustCaller:*/ uniffiCaller,
109
+ /*rustFutureFunc:*/ () => {
110
+ return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_func_download_model(FfiConverterString.lower(modelPath),FfiConverterOptionalMapStringString.lower(headers),FfiConverterOptionalTypeRustDownloadProgressCallback.lower(onDownloadProgress)
111
+ );
112
+ },
113
+ /*pollFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_poll_rust_buffer,
114
+ /*cancelFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_cancel_rust_buffer,
115
+ /*completeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_complete_rust_buffer,
116
+ /*freeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_free_rust_buffer,
117
+ /*liftFunc:*/ FfiConverterString.lift.bind(FfiConverterString),
118
+ /*liftString:*/ FfiConverterString.lift,
119
+ /*asyncOpts:*/ asyncOpts_,
120
+ /*errorHandler:*/ FfiConverterTypeNobodyWhoError.lift.bind(FfiConverterTypeNobodyWhoError)
121
+ );
122
+ } catch (__error: any) {
123
+ if (uniffiIsDebug && __error instanceof Error) {
124
+ __error.stack = __stack;
125
+ }
126
+ throw __error;
127
+ }
128
+ }
98
129
  /**
99
130
  * Load a GGUF model from a local path or remote URL.
100
131
  *
@@ -1176,6 +1207,10 @@ const FfiConverterTypePromptPart = (() => {
1176
1207
  const FfiConverterMapStringBool = new FfiConverterMap(FfiConverterString, FfiConverterBool);
1177
1208
 
1178
1209
 
1210
+ // FfiConverter for Map<string, string>
1211
+ const FfiConverterMapStringString = new FfiConverterMap(FfiConverterString, FfiConverterString);
1212
+
1213
+
1179
1214
  export interface RustChatInterface {
1180
1215
 
1181
1216
  /**
@@ -1248,10 +1283,12 @@ export class RustChat extends UniffiAbstractObject implements RustChatInterface
1248
1283
  /**
1249
1284
  * Create a new chat session.
1250
1285
  */
1251
- constructor(model: RustModelInterface, systemPrompt: string | undefined, contextSize: /*u32*/number, templateVariables: Map<string, boolean> | undefined, tools: Array<RustToolInterface> | undefined, sampler: SamplerConfigInterface | undefined) {
1286
+ constructor(model: RustModelInterface, systemPrompt: string | undefined, contextSize: /*u32*/number, templateVariables: Map<string, boolean> | undefined, tools: Array<RustToolInterface> | undefined, sampler: SamplerConfigInterface | undefined) /*throws*/ {
1252
1287
  super();
1253
1288
  const pointer =
1254
- uniffiCaller.rustCall(
1289
+
1290
+ uniffiCaller.rustCallWithError(
1291
+ /*liftError:*/ FfiConverterTypeNobodyWhoError.lift.bind(FfiConverterTypeNobodyWhoError),
1255
1292
  /*caller:*/ (callStatus) => {
1256
1293
  return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_constructor_rustchat_new(
1257
1294
  FfiConverterTypeRustModel.lower(model),
@@ -2154,9 +2191,9 @@ export interface RustTokenStreamInterface {
2154
2191
  */
2155
2192
  completed(asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<string>;
2156
2193
  /**
2157
- * Get the next token. Returns None when generation is complete.
2194
+ * Get the next token. Returns None when generation is complete, or an error if generation failed.
2158
2195
  */
2159
- nextToken(asyncOpts_?: { signal: AbortSignal }) : Promise<string | undefined>;
2196
+ nextToken(asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<string | undefined>;
2160
2197
  }
2161
2198
 
2162
2199
 
@@ -2207,9 +2244,9 @@ async completed(asyncOpts_?: { signal: AbortSignal }): Promise<string> /*throws
2207
2244
  }
2208
2245
 
2209
2246
  /**
2210
- * Get the next token. Returns None when generation is complete.
2247
+ * Get the next token. Returns None when generation is complete, or an error if generation failed.
2211
2248
  */
2212
- async nextToken(asyncOpts_?: { signal: AbortSignal }): Promise<string | undefined> {
2249
+ async nextToken(asyncOpts_?: { signal: AbortSignal }): Promise<string | undefined> /*throws*/ {
2213
2250
  const __stack = uniffiIsDebug ? new Error().stack : undefined;
2214
2251
  try {
2215
2252
  return await uniffiRustCallAsync(
@@ -2227,7 +2264,7 @@ async nextToken(asyncOpts_?: { signal: AbortSignal }): Promise<string | undefin
2227
2264
  /*liftFunc:*/ FfiConverterOptionalString.lift.bind(FfiConverterOptionalString),
2228
2265
  /*liftString:*/ FfiConverterString.lift,
2229
2266
  /*asyncOpts:*/ asyncOpts_,
2230
-
2267
+ /*errorHandler:*/ FfiConverterTypeNobodyWhoError.lift.bind(FfiConverterTypeNobodyWhoError)
2231
2268
  );
2232
2269
  } catch (__error: any) {
2233
2270
  if (uniffiIsDebug && __error instanceof Error) {
@@ -3034,6 +3071,10 @@ const FfiConverterArrayString = new FfiConverterArray(FfiConverterString);
3034
3071
  const FfiConverterOptionalMapStringBool = new FfiConverterOptional(FfiConverterMapStringBool);
3035
3072
 
3036
3073
 
3074
+ // FfiConverter for Map<string, string> | undefined
3075
+ const FfiConverterOptionalMapStringString = new FfiConverterOptional(FfiConverterMapStringString);
3076
+
3077
+
3037
3078
  // FfiConverter for SamplerConfigInterface | undefined
3038
3079
  const FfiConverterOptionalTypeSamplerConfig = new FfiConverterOptional(FfiConverterTypeSamplerConfig);
3039
3080
 
@@ -3078,6 +3119,9 @@ function uniffiEnsureInitialized() {
3078
3119
  if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_func_cosine_similarity() !== 63439) {
3079
3120
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_func_cosine_similarity");
3080
3121
  }
3122
+ if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_func_download_model() !== 31331) {
3123
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_func_download_model");
3124
+ }
3081
3125
  if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_func_load_model() !== 33587) {
3082
3126
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_func_load_model");
3083
3127
  }
@@ -3168,7 +3212,7 @@ function uniffiEnsureInitialized() {
3168
3212
  if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rusttokenstream_completed() !== 26060) {
3169
3213
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_rusttokenstream_completed");
3170
3214
  }
3171
- if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rusttokenstream_next_token() !== 44770) {
3215
+ if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rusttokenstream_next_token() !== 59210) {
3172
3216
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_rusttokenstream_next_token");
3173
3217
  }
3174
3218
  if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rusttool_get_schema_json() !== 4679) {
@@ -3222,7 +3266,7 @@ function uniffiEnsureInitialized() {
3222
3266
  if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_samplerconfig_to_json() !== 51798) {
3223
3267
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_samplerconfig_to_json");
3224
3268
  }
3225
- if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_constructor_rustchat_new() !== 38902) {
3269
+ if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_constructor_rustchat_new() !== 24505) {
3226
3270
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_constructor_rustchat_new");
3227
3271
  }
3228
3272
  if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_constructor_rustcrossencoder_new() !== 9022) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-nobodywho",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "Run LLMs locally with offline inference — React Native bindings",
5
5
  "main": "src/wrapper.ts",
6
6
  "types": "src/wrapper.ts",