react-native-nobodywho 2.4.0 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/generated/cpp/nobodywho.cpp +70 -10
- package/generated/cpp/nobodywho.hpp +7 -0
- package/generated/ts/nobodywho-ffi.ts +6 -4
- package/generated/ts/nobodywho.ts +154 -12
- package/package.json +1 -1
- package/src/chat.ts +19 -0
- package/src/model.ts +6 -1
- package/src/tts.ts +10 -1
|
@@ -119,7 +119,7 @@ void uniffi_nobodywho_uniffi_fn_free_rustchat(
|
|
|
119
119
|
/*handle*/ uint64_t uniffi_nobodywho_uniffi_fn_constructor_rustchat_new(
|
|
120
120
|
/*handle*/ uint64_t model, RustBuffer system_prompt, uint32_t context_size,
|
|
121
121
|
RustBuffer template_variables, RustBuffer tools, RustBuffer sampler,
|
|
122
|
-
RustCallStatus *uniffi_out_err);
|
|
122
|
+
RustBuffer mtp, RustBuffer thread_count, RustCallStatus *uniffi_out_err);
|
|
123
123
|
/*handle*/ uint64_t uniffi_nobodywho_uniffi_fn_method_rustchat_ask(
|
|
124
124
|
/*handle*/ uint64_t ptr, RustBuffer message,
|
|
125
125
|
RustCallStatus *uniffi_out_err);
|
|
@@ -141,6 +141,9 @@ uniffi_nobodywho_uniffi_fn_method_rustchat_get_system_prompt(
|
|
|
141
141
|
/*handle*/ uint64_t
|
|
142
142
|
uniffi_nobodywho_uniffi_fn_method_rustchat_get_template_variables(
|
|
143
143
|
/*handle*/ uint64_t ptr);
|
|
144
|
+
/*handle*/ uint64_t
|
|
145
|
+
uniffi_nobodywho_uniffi_fn_method_rustchat_mtp_acceptance_rate(
|
|
146
|
+
/*handle*/ uint64_t ptr);
|
|
144
147
|
/*handle*/ uint64_t uniffi_nobodywho_uniffi_fn_method_rustchat_reset_context(
|
|
145
148
|
/*handle*/ uint64_t ptr, RustBuffer system_prompt, RustBuffer tools);
|
|
146
149
|
/*handle*/ uint64_t uniffi_nobodywho_uniffi_fn_method_rustchat_reset_history(
|
|
@@ -247,7 +250,8 @@ void uniffi_nobodywho_uniffi_fn_free_rusttts(
|
|
|
247
250
|
/*handle*/ uint64_t uniffi_nobodywho_uniffi_fn_constructor_rusttts_new(
|
|
248
251
|
RustBuffer source, RustBuffer architecture, RustBuffer voice,
|
|
249
252
|
RustBuffer language, RustBuffer speed, RustBuffer steps,
|
|
250
|
-
RustBuffer silence_duration, RustBuffer
|
|
253
|
+
RustBuffer silence_duration, RustBuffer precision, RustBuffer temperature,
|
|
254
|
+
RustBuffer huggingface_token, RustBuffer device,
|
|
251
255
|
RustCallStatus *uniffi_out_err);
|
|
252
256
|
RustBuffer uniffi_nobodywho_uniffi_fn_method_rusttts_synthesize(
|
|
253
257
|
/*handle*/ uint64_t ptr, RustBuffer text, RustCallStatus *uniffi_out_err);
|
|
@@ -321,11 +325,12 @@ RustBuffer uniffi_nobodywho_uniffi_fn_func_get_cached_models(
|
|
|
321
325
|
RustCallStatus *uniffi_out_err);
|
|
322
326
|
/*handle*/ uint64_t uniffi_nobodywho_uniffi_fn_func_load_model(
|
|
323
327
|
RustBuffer model_path, int8_t use_gpu, RustBuffer projection_model_path,
|
|
324
|
-
RustBuffer on_download_progress);
|
|
328
|
+
RustBuffer draft_model_path, RustBuffer on_download_progress);
|
|
325
329
|
/*handle*/ uint64_t uniffi_nobodywho_uniffi_fn_func_load_tts(
|
|
326
330
|
RustBuffer source, RustBuffer architecture, RustBuffer voice,
|
|
327
331
|
RustBuffer language, RustBuffer speed, RustBuffer steps,
|
|
328
|
-
RustBuffer silence_duration, RustBuffer
|
|
332
|
+
RustBuffer silence_duration, RustBuffer precision, RustBuffer temperature,
|
|
333
|
+
RustBuffer huggingface_token, RustBuffer device);
|
|
329
334
|
/*handle*/ uint64_t
|
|
330
335
|
uniffi_nobodywho_uniffi_fn_func_sampler_preset_constrain_with_grammar(
|
|
331
336
|
RustBuffer grammar, RustCallStatus *uniffi_out_err);
|
|
@@ -500,6 +505,7 @@ uint16_t uniffi_nobodywho_uniffi_checksum_method_rustchat_get_stats();
|
|
|
500
505
|
uint16_t uniffi_nobodywho_uniffi_checksum_method_rustchat_get_system_prompt();
|
|
501
506
|
uint16_t
|
|
502
507
|
uniffi_nobodywho_uniffi_checksum_method_rustchat_get_template_variables();
|
|
508
|
+
uint16_t uniffi_nobodywho_uniffi_checksum_method_rustchat_mtp_acceptance_rate();
|
|
503
509
|
uint16_t uniffi_nobodywho_uniffi_checksum_method_rustchat_reset_context();
|
|
504
510
|
uint16_t uniffi_nobodywho_uniffi_checksum_method_rustchat_reset_history();
|
|
505
511
|
uint16_t uniffi_nobodywho_uniffi_checksum_method_rustchat_set_chat_history();
|
|
@@ -2734,7 +2740,7 @@ NativeNobodywho::NativeNobodywho(
|
|
|
2734
2740
|
rt,
|
|
2735
2741
|
jsi::PropNameID::forAscii(
|
|
2736
2742
|
rt, "ubrn_uniffi_nobodywho_uniffi_fn_constructor_rustchat_new"),
|
|
2737
|
-
|
|
2743
|
+
8,
|
|
2738
2744
|
[this](jsi::Runtime &rt, const jsi::Value &thisVal,
|
|
2739
2745
|
const jsi::Value *args, size_t count) -> jsi::Value {
|
|
2740
2746
|
return this
|
|
@@ -2836,6 +2842,18 @@ NativeNobodywho::NativeNobodywho(
|
|
|
2836
2842
|
->cpp_uniffi_nobodywho_uniffi_fn_method_rustchat_get_template_variables(
|
|
2837
2843
|
rt, thisVal, args, count);
|
|
2838
2844
|
});
|
|
2845
|
+
props["ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_mtp_acceptance_rate"] =
|
|
2846
|
+
jsi::Function::createFromHostFunction(
|
|
2847
|
+
rt,
|
|
2848
|
+
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_nobodywho_uniffi_fn_"
|
|
2849
|
+
"method_rustchat_mtp_acceptance_rate"),
|
|
2850
|
+
1,
|
|
2851
|
+
[this](jsi::Runtime &rt, const jsi::Value &thisVal,
|
|
2852
|
+
const jsi::Value *args, size_t count) -> jsi::Value {
|
|
2853
|
+
return this
|
|
2854
|
+
->cpp_uniffi_nobodywho_uniffi_fn_method_rustchat_mtp_acceptance_rate(
|
|
2855
|
+
rt, thisVal, args, count);
|
|
2856
|
+
});
|
|
2839
2857
|
props["ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_reset_context"] =
|
|
2840
2858
|
jsi::Function::createFromHostFunction(
|
|
2841
2859
|
rt,
|
|
@@ -3360,7 +3378,7 @@ NativeNobodywho::NativeNobodywho(
|
|
|
3360
3378
|
rt,
|
|
3361
3379
|
jsi::PropNameID::forAscii(
|
|
3362
3380
|
rt, "ubrn_uniffi_nobodywho_uniffi_fn_constructor_rusttts_new"),
|
|
3363
|
-
|
|
3381
|
+
11,
|
|
3364
3382
|
[this](jsi::Runtime &rt, const jsi::Value &thisVal,
|
|
3365
3383
|
const jsi::Value *args, size_t count) -> jsi::Value {
|
|
3366
3384
|
return this->cpp_uniffi_nobodywho_uniffi_fn_constructor_rusttts_new(
|
|
@@ -3708,7 +3726,7 @@ NativeNobodywho::NativeNobodywho(
|
|
|
3708
3726
|
rt,
|
|
3709
3727
|
jsi::PropNameID::forAscii(
|
|
3710
3728
|
rt, "ubrn_uniffi_nobodywho_uniffi_fn_func_load_model"),
|
|
3711
|
-
|
|
3729
|
+
5,
|
|
3712
3730
|
[this](jsi::Runtime &rt, const jsi::Value &thisVal,
|
|
3713
3731
|
const jsi::Value *args, size_t count) -> jsi::Value {
|
|
3714
3732
|
return this->cpp_uniffi_nobodywho_uniffi_fn_func_load_model(
|
|
@@ -3719,7 +3737,7 @@ NativeNobodywho::NativeNobodywho(
|
|
|
3719
3737
|
rt,
|
|
3720
3738
|
jsi::PropNameID::forAscii(
|
|
3721
3739
|
rt, "ubrn_uniffi_nobodywho_uniffi_fn_func_load_tts"),
|
|
3722
|
-
|
|
3740
|
+
11,
|
|
3723
3741
|
[this](jsi::Runtime &rt, const jsi::Value &thisVal,
|
|
3724
3742
|
const jsi::Value *args, size_t count) -> jsi::Value {
|
|
3725
3743
|
return this->cpp_uniffi_nobodywho_uniffi_fn_func_load_tts(
|
|
@@ -4681,6 +4699,18 @@ NativeNobodywho::NativeNobodywho(
|
|
|
4681
4699
|
->cpp_uniffi_nobodywho_uniffi_checksum_method_rustchat_get_template_variables(
|
|
4682
4700
|
rt, thisVal, args, count);
|
|
4683
4701
|
});
|
|
4702
|
+
props["ubrn_uniffi_nobodywho_uniffi_checksum_method_rustchat_mtp_acceptance_"
|
|
4703
|
+
"rate"] = jsi::Function::createFromHostFunction(
|
|
4704
|
+
rt,
|
|
4705
|
+
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_nobodywho_uniffi_checksum_"
|
|
4706
|
+
"method_rustchat_mtp_acceptance_rate"),
|
|
4707
|
+
0,
|
|
4708
|
+
[this](jsi::Runtime &rt, const jsi::Value &thisVal,
|
|
4709
|
+
const jsi::Value *args, size_t count) -> jsi::Value {
|
|
4710
|
+
return this
|
|
4711
|
+
->cpp_uniffi_nobodywho_uniffi_checksum_method_rustchat_mtp_acceptance_rate(
|
|
4712
|
+
rt, thisVal, args, count);
|
|
4713
|
+
});
|
|
4684
4714
|
props["ubrn_uniffi_nobodywho_uniffi_checksum_method_rustchat_reset_context"] =
|
|
4685
4715
|
jsi::Function::createFromHostFunction(
|
|
4686
4716
|
rt,
|
|
@@ -5735,6 +5765,8 @@ NativeNobodywho::cpp_uniffi_nobodywho_uniffi_fn_constructor_rustchat_new(
|
|
|
5735
5765
|
uniffi::nobodywho::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[3]),
|
|
5736
5766
|
uniffi::nobodywho::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[4]),
|
|
5737
5767
|
uniffi::nobodywho::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[5]),
|
|
5768
|
+
uniffi::nobodywho::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[6]),
|
|
5769
|
+
uniffi::nobodywho::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[7]),
|
|
5738
5770
|
&status);
|
|
5739
5771
|
uniffi::nobodywho::Bridging<RustCallStatus>::copyIntoJs(
|
|
5740
5772
|
rt, callInvoker, status, args[count - 1]);
|
|
@@ -5849,6 +5881,17 @@ jsi::Value NativeNobodywho::
|
|
|
5849
5881
|
return uniffi_jsi::Bridging</*handle*/ uint64_t>::toJs(rt, callInvoker,
|
|
5850
5882
|
value);
|
|
5851
5883
|
}
|
|
5884
|
+
jsi::Value NativeNobodywho::
|
|
5885
|
+
cpp_uniffi_nobodywho_uniffi_fn_method_rustchat_mtp_acceptance_rate(
|
|
5886
|
+
jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
|
|
5887
|
+
size_t count) {
|
|
5888
|
+
auto value = uniffi_nobodywho_uniffi_fn_method_rustchat_mtp_acceptance_rate(
|
|
5889
|
+
uniffi_jsi::Bridging</*handle*/ uint64_t>::fromJs(rt, callInvoker,
|
|
5890
|
+
args[0]));
|
|
5891
|
+
|
|
5892
|
+
return uniffi_jsi::Bridging</*handle*/ uint64_t>::toJs(rt, callInvoker,
|
|
5893
|
+
value);
|
|
5894
|
+
}
|
|
5852
5895
|
jsi::Value
|
|
5853
5896
|
NativeNobodywho::cpp_uniffi_nobodywho_uniffi_fn_method_rustchat_reset_context(
|
|
5854
5897
|
jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
|
|
@@ -6496,6 +6539,10 @@ NativeNobodywho::cpp_uniffi_nobodywho_uniffi_fn_constructor_rusttts_new(
|
|
|
6496
6539
|
uniffi::nobodywho::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[5]),
|
|
6497
6540
|
uniffi::nobodywho::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[6]),
|
|
6498
6541
|
uniffi::nobodywho::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[7]),
|
|
6542
|
+
uniffi::nobodywho::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[8]),
|
|
6543
|
+
uniffi::nobodywho::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[9]),
|
|
6544
|
+
uniffi::nobodywho::Bridging<RustBuffer>::fromJs(rt, callInvoker,
|
|
6545
|
+
args[10]),
|
|
6499
6546
|
&status);
|
|
6500
6547
|
uniffi::nobodywho::Bridging<RustCallStatus>::copyIntoJs(
|
|
6501
6548
|
rt, callInvoker, status, args[count - 1]);
|
|
@@ -6957,8 +7004,9 @@ jsi::Value NativeNobodywho::cpp_uniffi_nobodywho_uniffi_fn_func_load_model(
|
|
|
6957
7004
|
uniffi::nobodywho::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[0]),
|
|
6958
7005
|
uniffi_jsi::Bridging<int8_t>::fromJs(rt, callInvoker, args[1]),
|
|
6959
7006
|
uniffi::nobodywho::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[2]),
|
|
7007
|
+
uniffi::nobodywho::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[3]),
|
|
6960
7008
|
uniffi::nobodywho::Bridging<RustBuffer>::fromJs(rt, callInvoker,
|
|
6961
|
-
args[
|
|
7009
|
+
args[4]));
|
|
6962
7010
|
|
|
6963
7011
|
return uniffi_jsi::Bridging</*handle*/ uint64_t>::toJs(rt, callInvoker,
|
|
6964
7012
|
value);
|
|
@@ -6974,8 +7022,11 @@ jsi::Value NativeNobodywho::cpp_uniffi_nobodywho_uniffi_fn_func_load_tts(
|
|
|
6974
7022
|
uniffi::nobodywho::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[4]),
|
|
6975
7023
|
uniffi::nobodywho::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[5]),
|
|
6976
7024
|
uniffi::nobodywho::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[6]),
|
|
7025
|
+
uniffi::nobodywho::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[7]),
|
|
7026
|
+
uniffi::nobodywho::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[8]),
|
|
7027
|
+
uniffi::nobodywho::Bridging<RustBuffer>::fromJs(rt, callInvoker, args[9]),
|
|
6977
7028
|
uniffi::nobodywho::Bridging<RustBuffer>::fromJs(rt, callInvoker,
|
|
6978
|
-
args[
|
|
7029
|
+
args[10]));
|
|
6979
7030
|
|
|
6980
7031
|
return uniffi_jsi::Bridging</*handle*/ uint64_t>::toJs(rt, callInvoker,
|
|
6981
7032
|
value);
|
|
@@ -7885,6 +7936,15 @@ jsi::Value NativeNobodywho::
|
|
|
7885
7936
|
|
|
7886
7937
|
return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
|
|
7887
7938
|
}
|
|
7939
|
+
jsi::Value NativeNobodywho::
|
|
7940
|
+
cpp_uniffi_nobodywho_uniffi_checksum_method_rustchat_mtp_acceptance_rate(
|
|
7941
|
+
jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
|
|
7942
|
+
size_t count) {
|
|
7943
|
+
auto value =
|
|
7944
|
+
uniffi_nobodywho_uniffi_checksum_method_rustchat_mtp_acceptance_rate();
|
|
7945
|
+
|
|
7946
|
+
return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
|
|
7947
|
+
}
|
|
7888
7948
|
jsi::Value NativeNobodywho::
|
|
7889
7949
|
cpp_uniffi_nobodywho_uniffi_checksum_method_rustchat_reset_context(
|
|
7890
7950
|
jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
|
|
@@ -64,6 +64,9 @@ protected:
|
|
|
64
64
|
cpp_uniffi_nobodywho_uniffi_fn_method_rustchat_get_template_variables(
|
|
65
65
|
jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
|
|
66
66
|
size_t count);
|
|
67
|
+
jsi::Value cpp_uniffi_nobodywho_uniffi_fn_method_rustchat_mtp_acceptance_rate(
|
|
68
|
+
jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
|
|
69
|
+
size_t count);
|
|
67
70
|
jsi::Value cpp_uniffi_nobodywho_uniffi_fn_method_rustchat_reset_context(
|
|
68
71
|
jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
|
|
69
72
|
size_t count);
|
|
@@ -557,6 +560,10 @@ protected:
|
|
|
557
560
|
cpp_uniffi_nobodywho_uniffi_checksum_method_rustchat_get_template_variables(
|
|
558
561
|
jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
|
|
559
562
|
size_t count);
|
|
563
|
+
jsi::Value
|
|
564
|
+
cpp_uniffi_nobodywho_uniffi_checksum_method_rustchat_mtp_acceptance_rate(
|
|
565
|
+
jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
|
|
566
|
+
size_t count);
|
|
560
567
|
jsi::Value cpp_uniffi_nobodywho_uniffi_checksum_method_rustchat_reset_context(
|
|
561
568
|
jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
|
|
562
569
|
size_t count);
|
|
@@ -20,7 +20,7 @@ interface NativeModuleInterface {
|
|
|
20
20
|
ubrn_uniffi_internal_fn_func_ffi__arraybuffer_to_string(buffer: Uint8Array, uniffi_out_err: UniffiRustCallStatus): string;
|
|
21
21
|
ubrn_uniffi_nobodywho_uniffi_fn_clone_rustchat(handle: bigint, uniffi_out_err: UniffiRustCallStatus): bigint;
|
|
22
22
|
ubrn_uniffi_nobodywho_uniffi_fn_free_rustchat(handle: bigint, uniffi_out_err: UniffiRustCallStatus): void;
|
|
23
|
-
ubrn_uniffi_nobodywho_uniffi_fn_constructor_rustchat_new(model: bigint, systemPrompt: Uint8Array, contextSize: number, templateVariables: Uint8Array, tools: Uint8Array, sampler: Uint8Array, uniffi_out_err: UniffiRustCallStatus): bigint;
|
|
23
|
+
ubrn_uniffi_nobodywho_uniffi_fn_constructor_rustchat_new(model: bigint, systemPrompt: Uint8Array, contextSize: number, templateVariables: Uint8Array, tools: Uint8Array, sampler: Uint8Array, mtp: Uint8Array, threadCount: Uint8Array, uniffi_out_err: UniffiRustCallStatus): bigint;
|
|
24
24
|
ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_ask(ptr: bigint, message: Uint8Array, uniffi_out_err: UniffiRustCallStatus): bigint;
|
|
25
25
|
ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_ask_with_json_prompt(ptr: bigint, json: Uint8Array, uniffi_out_err: UniffiRustCallStatus): bigint;
|
|
26
26
|
ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_ask_with_prompt(ptr: bigint, parts: Uint8Array, uniffi_out_err: UniffiRustCallStatus): bigint;
|
|
@@ -29,6 +29,7 @@ interface NativeModuleInterface {
|
|
|
29
29
|
ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_get_stats(ptr: bigint): bigint;
|
|
30
30
|
ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_get_system_prompt(ptr: bigint): bigint;
|
|
31
31
|
ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_get_template_variables(ptr: bigint): bigint;
|
|
32
|
+
ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_mtp_acceptance_rate(ptr: bigint): bigint;
|
|
32
33
|
ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_reset_context(ptr: bigint, systemPrompt: Uint8Array, tools: Uint8Array): bigint;
|
|
33
34
|
ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_reset_history(ptr: bigint): bigint;
|
|
34
35
|
ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_set_chat_history(ptr: bigint, messages: Uint8Array): bigint;
|
|
@@ -73,7 +74,7 @@ interface NativeModuleInterface {
|
|
|
73
74
|
ubrn_uniffi_nobodywho_uniffi_fn_method_rusttool_resolve_pending_call(ptr: bigint, callId: Uint8Array, result: Uint8Array, uniffi_out_err: UniffiRustCallStatus): void;
|
|
74
75
|
ubrn_uniffi_nobodywho_uniffi_fn_clone_rusttts(handle: bigint, uniffi_out_err: UniffiRustCallStatus): bigint;
|
|
75
76
|
ubrn_uniffi_nobodywho_uniffi_fn_free_rusttts(handle: bigint, uniffi_out_err: UniffiRustCallStatus): void;
|
|
76
|
-
ubrn_uniffi_nobodywho_uniffi_fn_constructor_rusttts_new(source: Uint8Array, architecture: Uint8Array, voice: Uint8Array, language: Uint8Array, speed: Uint8Array, steps: Uint8Array, silenceDuration: Uint8Array, device: Uint8Array, uniffi_out_err: UniffiRustCallStatus): bigint;
|
|
77
|
+
ubrn_uniffi_nobodywho_uniffi_fn_constructor_rusttts_new(source: Uint8Array, architecture: Uint8Array, voice: Uint8Array, language: Uint8Array, speed: Uint8Array, steps: Uint8Array, silenceDuration: Uint8Array, precision: Uint8Array, temperature: Uint8Array, huggingfaceToken: Uint8Array, device: Uint8Array, uniffi_out_err: UniffiRustCallStatus): bigint;
|
|
77
78
|
ubrn_uniffi_nobodywho_uniffi_fn_method_rusttts_synthesize(ptr: bigint, text: Uint8Array, uniffi_out_err: UniffiRustCallStatus): Uint8Array;
|
|
78
79
|
ubrn_uniffi_nobodywho_uniffi_fn_method_rusttts_synthesize_async(ptr: bigint, text: Uint8Array): bigint;
|
|
79
80
|
ubrn_uniffi_nobodywho_uniffi_fn_clone_samplerbuilder(handle: bigint, uniffi_out_err: UniffiRustCallStatus): bigint;
|
|
@@ -102,8 +103,8 @@ interface NativeModuleInterface {
|
|
|
102
103
|
ubrn_uniffi_nobodywho_uniffi_fn_func_cosine_similarity(a: Uint8Array, b: Uint8Array, uniffi_out_err: UniffiRustCallStatus): number;
|
|
103
104
|
ubrn_uniffi_nobodywho_uniffi_fn_func_download_model(modelPath: Uint8Array, headers: Uint8Array, onDownloadProgress: Uint8Array): bigint;
|
|
104
105
|
ubrn_uniffi_nobodywho_uniffi_fn_func_get_cached_models(uniffi_out_err: UniffiRustCallStatus): Uint8Array;
|
|
105
|
-
ubrn_uniffi_nobodywho_uniffi_fn_func_load_model(modelPath: Uint8Array, useGpu: number, projectionModelPath: Uint8Array, onDownloadProgress: Uint8Array): bigint;
|
|
106
|
-
ubrn_uniffi_nobodywho_uniffi_fn_func_load_tts(source: Uint8Array, architecture: Uint8Array, voice: Uint8Array, language: Uint8Array, speed: Uint8Array, steps: Uint8Array, silenceDuration: Uint8Array, device: Uint8Array): bigint;
|
|
106
|
+
ubrn_uniffi_nobodywho_uniffi_fn_func_load_model(modelPath: Uint8Array, useGpu: number, projectionModelPath: Uint8Array, draftModelPath: Uint8Array, onDownloadProgress: Uint8Array): bigint;
|
|
107
|
+
ubrn_uniffi_nobodywho_uniffi_fn_func_load_tts(source: Uint8Array, architecture: Uint8Array, voice: Uint8Array, language: Uint8Array, speed: Uint8Array, steps: Uint8Array, silenceDuration: Uint8Array, precision: Uint8Array, temperature: Uint8Array, huggingfaceToken: Uint8Array, device: Uint8Array): bigint;
|
|
107
108
|
ubrn_uniffi_nobodywho_uniffi_fn_func_sampler_preset_constrain_with_grammar(grammar: Uint8Array, uniffi_out_err: UniffiRustCallStatus): bigint;
|
|
108
109
|
ubrn_uniffi_nobodywho_uniffi_fn_func_sampler_preset_constrain_with_json_schema(schema: Uint8Array, uniffi_out_err: UniffiRustCallStatus): bigint;
|
|
109
110
|
ubrn_uniffi_nobodywho_uniffi_fn_func_sampler_preset_constrain_with_regex(pattern: Uint8Array, uniffi_out_err: UniffiRustCallStatus): bigint;
|
|
@@ -187,6 +188,7 @@ interface NativeModuleInterface {
|
|
|
187
188
|
ubrn_uniffi_nobodywho_uniffi_checksum_method_rustchat_get_stats(): number;
|
|
188
189
|
ubrn_uniffi_nobodywho_uniffi_checksum_method_rustchat_get_system_prompt(): number;
|
|
189
190
|
ubrn_uniffi_nobodywho_uniffi_checksum_method_rustchat_get_template_variables(): number;
|
|
191
|
+
ubrn_uniffi_nobodywho_uniffi_checksum_method_rustchat_mtp_acceptance_rate(): number;
|
|
190
192
|
ubrn_uniffi_nobodywho_uniffi_checksum_method_rustchat_reset_context(): number;
|
|
191
193
|
ubrn_uniffi_nobodywho_uniffi_checksum_method_rustchat_reset_history(): number;
|
|
192
194
|
ubrn_uniffi_nobodywho_uniffi_checksum_method_rustchat_set_chat_history(): number;
|
|
@@ -145,20 +145,28 @@ export function getCachedModels(): Array<CachedModel> /*throws*/ {
|
|
|
145
145
|
/**
|
|
146
146
|
* Load a GGUF model from a local path or remote URL.
|
|
147
147
|
*
|
|
148
|
-
* Accepts local filesystem paths, `hf://owner/repo/file.gguf`
|
|
149
|
-
* or `
|
|
148
|
+
* Accepts local filesystem paths, `hf://owner/repo/file.gguf`, `https://` URLs,
|
|
149
|
+
* or `auto` for memory-based selection. Downloaded models are cached automatically.
|
|
150
|
+
*
|
|
151
|
+
* # MTP speculative decoding
|
|
152
|
+
*
|
|
153
|
+
* Pass `draft_model_path` pointing to a compatible MTP heads gguf (e.g.
|
|
154
|
+
* `mtp-gemma-4-E2B-it.gguf` for Gemma-4-E2B) to enable MTP
|
|
155
|
+
* speculative decoding on chats built from this model. Whether MTP is
|
|
156
|
+
* actually used is a per-chat decision — pass it through
|
|
157
|
+
* `Chat`-level config on the wrapping binding.
|
|
150
158
|
*
|
|
151
159
|
* This is a free function instead of an async constructor because
|
|
152
160
|
* uniffi-bindgen-react-native generates invalid JS (`async static` instead
|
|
153
161
|
* of `static async`) for async constructors.
|
|
154
162
|
*/
|
|
155
|
-
export async function loadModel(modelPath: string, useGpu: boolean, projectionModelPath: string | undefined, onDownloadProgress: RustDownloadProgressCallback | undefined, asyncOpts_?: { signal: AbortSignal }): Promise<RustModelInterface> /*throws*/ {
|
|
163
|
+
export async function loadModel(modelPath: string, useGpu: boolean, projectionModelPath: string | undefined, draftModelPath: string | undefined, onDownloadProgress: RustDownloadProgressCallback | undefined, asyncOpts_?: { signal: AbortSignal }): Promise<RustModelInterface> /*throws*/ {
|
|
156
164
|
const __stack = uniffiIsDebug ? new Error().stack : undefined;
|
|
157
165
|
try {
|
|
158
166
|
return await uniffiRustCallAsync(
|
|
159
167
|
/*rustCaller:*/ uniffiCaller,
|
|
160
168
|
/*rustFutureFunc:*/ () => {
|
|
161
|
-
return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_func_load_model(FfiConverterString.lower(modelPath),FfiConverterBool.lower(useGpu),FfiConverterOptionalString.lower(projectionModelPath),FfiConverterOptionalTypeRustDownloadProgressCallback.lower(onDownloadProgress)
|
|
169
|
+
return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_func_load_model(FfiConverterString.lower(modelPath),FfiConverterBool.lower(useGpu),FfiConverterOptionalString.lower(projectionModelPath),FfiConverterOptionalString.lower(draftModelPath),FfiConverterOptionalTypeRustDownloadProgressCallback.lower(onDownloadProgress)
|
|
162
170
|
);
|
|
163
171
|
},
|
|
164
172
|
/*pollFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_poll_u64,
|
|
@@ -180,13 +188,13 @@ export async function loadModel(modelPath: string, useGpu: boolean, projectionMo
|
|
|
180
188
|
/**
|
|
181
189
|
* Create a TTS synthesizer.
|
|
182
190
|
*/
|
|
183
|
-
export async function loadTts(source: string, architecture: string | undefined, voice: string | undefined, language: string | undefined, speed: /*f32*/number | undefined, steps: /*u32*/number | undefined, silenceDuration: /*f32*/number | undefined, device: string | undefined, asyncOpts_?: { signal: AbortSignal }): Promise<RustTtsInterface> /*throws*/ {
|
|
191
|
+
export async function loadTts(source: string, architecture: string | undefined, voice: string | undefined, language: string | undefined, speed: /*f32*/number | undefined, steps: /*u32*/number | undefined, silenceDuration: /*f32*/number | undefined, precision: string | undefined, temperature: /*f32*/number | undefined, huggingfaceToken: string | undefined, device: string | undefined, asyncOpts_?: { signal: AbortSignal }): Promise<RustTtsInterface> /*throws*/ {
|
|
184
192
|
const __stack = uniffiIsDebug ? new Error().stack : undefined;
|
|
185
193
|
try {
|
|
186
194
|
return await uniffiRustCallAsync(
|
|
187
195
|
/*rustCaller:*/ uniffiCaller,
|
|
188
196
|
/*rustFutureFunc:*/ () => {
|
|
189
|
-
return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_func_load_tts(FfiConverterString.lower(source),FfiConverterOptionalString.lower(architecture),FfiConverterOptionalString.lower(voice),FfiConverterOptionalString.lower(language),FfiConverterOptionalFloat32.lower(speed),FfiConverterOptionalUInt32.lower(steps),FfiConverterOptionalFloat32.lower(silenceDuration),FfiConverterOptionalString.lower(device)
|
|
197
|
+
return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_func_load_tts(FfiConverterString.lower(source),FfiConverterOptionalString.lower(architecture),FfiConverterOptionalString.lower(voice),FfiConverterOptionalString.lower(language),FfiConverterOptionalFloat32.lower(speed),FfiConverterOptionalUInt32.lower(steps),FfiConverterOptionalFloat32.lower(silenceDuration),FfiConverterOptionalString.lower(precision),FfiConverterOptionalFloat32.lower(temperature),FfiConverterOptionalString.lower(huggingfaceToken),FfiConverterOptionalString.lower(device)
|
|
190
198
|
);
|
|
191
199
|
},
|
|
192
200
|
/*pollFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_poll_u64,
|
|
@@ -656,6 +664,78 @@ const FfiConverterTypeChatStats = (() => {
|
|
|
656
664
|
})();
|
|
657
665
|
|
|
658
666
|
|
|
667
|
+
/**
|
|
668
|
+
* Tuning for MTP speculative decoding. Passing one to `RustChat::new`
|
|
669
|
+
* enables MTP; `null` runs the solo decode path. Requires the model to
|
|
670
|
+
* have been loaded with a compatible `draft_model_path`.
|
|
671
|
+
*/
|
|
672
|
+
export type MtpConfig = {
|
|
673
|
+
/**
|
|
674
|
+
* Maximum draft tokens proposed per speculative step (llama.cpp `n_max`).
|
|
675
|
+
* Higher values draft more per decode; returns diminish past ~4–6.
|
|
676
|
+
*/
|
|
677
|
+
kMax: /*u32*/number,
|
|
678
|
+
/**
|
|
679
|
+
* Minimum draft-token probability the drafter will propose (llama.cpp
|
|
680
|
+
* `p_min`). `0.0` accepts all proposals; raise it to skip low-confidence
|
|
681
|
+
* drafts.
|
|
682
|
+
*/
|
|
683
|
+
pMin: /*f32*/number
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
/**
|
|
687
|
+
* Generated factory for {@link MtpConfig} record objects.
|
|
688
|
+
*/
|
|
689
|
+
export const MtpConfig = (() => {
|
|
690
|
+
const defaults = () => ({kMax: 3,pMin: 0.0
|
|
691
|
+
});
|
|
692
|
+
const create = (() => {
|
|
693
|
+
return uniffiCreateRecord<MtpConfig, ReturnType<typeof defaults>>(defaults);
|
|
694
|
+
})();
|
|
695
|
+
return Object.freeze({
|
|
696
|
+
/**
|
|
697
|
+
* Create a frozen instance of {@link MtpConfig}, with defaults specified
|
|
698
|
+
* in Rust, in the {@link nobodywho} crate.
|
|
699
|
+
*/
|
|
700
|
+
create,
|
|
701
|
+
|
|
702
|
+
/**
|
|
703
|
+
* Create a frozen instance of {@link MtpConfig}, with defaults specified
|
|
704
|
+
* in Rust, in the {@link nobodywho} crate.
|
|
705
|
+
*/
|
|
706
|
+
new: create,
|
|
707
|
+
|
|
708
|
+
/**
|
|
709
|
+
* Defaults specified in the {@link nobodywho} crate.
|
|
710
|
+
*/
|
|
711
|
+
defaults: () => Object.freeze(defaults()) as Partial<MtpConfig>,
|
|
712
|
+
|
|
713
|
+
});
|
|
714
|
+
})();
|
|
715
|
+
|
|
716
|
+
const FfiConverterTypeMtpConfig = (() => {
|
|
717
|
+
type TypeName = MtpConfig;
|
|
718
|
+
class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
|
|
719
|
+
read(from: RustBuffer): TypeName {
|
|
720
|
+
return {
|
|
721
|
+
kMax: FfiConverterUInt32.read(from),
|
|
722
|
+
pMin: FfiConverterFloat32.read(from)
|
|
723
|
+
};
|
|
724
|
+
}
|
|
725
|
+
write(value: TypeName, into: RustBuffer): void {
|
|
726
|
+
FfiConverterUInt32.write(value.kMax, into);
|
|
727
|
+
FfiConverterFloat32.write(value.pMin, into);
|
|
728
|
+
}
|
|
729
|
+
allocationSize(value: TypeName): number {
|
|
730
|
+
return FfiConverterUInt32.allocationSize(value.kMax) +
|
|
731
|
+
FfiConverterFloat32.allocationSize(value.pMin);
|
|
732
|
+
|
|
733
|
+
}
|
|
734
|
+
};
|
|
735
|
+
return new FFIConverter();
|
|
736
|
+
})();
|
|
737
|
+
|
|
738
|
+
|
|
659
739
|
/**
|
|
660
740
|
* A pending tool call waiting for resolution from the language binding.
|
|
661
741
|
*/
|
|
@@ -1418,6 +1498,12 @@ export interface RustChatInterface {
|
|
|
1418
1498
|
* Get all template variables.
|
|
1419
1499
|
*/
|
|
1420
1500
|
getTemplateVariables(asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<Map<string, boolean>>;
|
|
1501
|
+
/**
|
|
1502
|
+
* MTP draft acceptance rate for the most recent generation, in `[0.0, 1.0]`.
|
|
1503
|
+
*
|
|
1504
|
+
* Resets each generation. `null` when MTP is disabled or no drafts were proposed.
|
|
1505
|
+
*/
|
|
1506
|
+
mtpAcceptanceRate(asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise</*f32*/number | undefined>;
|
|
1421
1507
|
/**
|
|
1422
1508
|
* Reset the chat context with a new system prompt and tools.
|
|
1423
1509
|
*/
|
|
@@ -1469,8 +1555,18 @@ export class RustChat extends UniffiAbstractObject implements RustChatInterface
|
|
|
1469
1555
|
readonly [pointerLiteralSymbol]: UniffiHandle;
|
|
1470
1556
|
/**
|
|
1471
1557
|
* Create a new chat session.
|
|
1558
|
+
*
|
|
1559
|
+
* Pass an `mtp` config to enable MTP speculative decoding for this
|
|
1560
|
+
* chat; `null` disables it. Requires the `RustModel` to have been
|
|
1561
|
+
* loaded with a compatible `draft_model_path`; otherwise construction
|
|
1562
|
+
* fails. Adds around 5% to VRAM usage.
|
|
1563
|
+
*
|
|
1564
|
+
* `thread_count` is the number of CPU threads used for inference; `null`
|
|
1565
|
+
* detects the device's physical core count (performance cores only, on
|
|
1566
|
+
* Apple silicon), since hyperthreads and efficiency cores make inference
|
|
1567
|
+
* slower. Clamped to the CPU count.
|
|
1472
1568
|
*/
|
|
1473
|
-
constructor(model: RustModelInterface, systemPrompt: string | undefined, contextSize: /*u32*/number, templateVariables: Map<string, boolean> | undefined, tools: Array<RustToolInterface> | undefined, sampler: SamplerConfigInterface | undefined) /*throws*/ {
|
|
1569
|
+
constructor(model: RustModelInterface, systemPrompt: string | undefined, contextSize: /*u32*/number, templateVariables: Map<string, boolean> | undefined, tools: Array<RustToolInterface> | undefined, sampler: SamplerConfigInterface | undefined, mtp: MtpConfig | undefined, threadCount: /*u32*/number | undefined) /*throws*/ {
|
|
1474
1570
|
super();
|
|
1475
1571
|
const pointer =
|
|
1476
1572
|
|
|
@@ -1484,6 +1580,8 @@ export class RustChat extends UniffiAbstractObject implements RustChatInterface
|
|
|
1484
1580
|
FfiConverterOptionalMapStringBool.lower(templateVariables),
|
|
1485
1581
|
FfiConverterOptionalArrayTypeRustTool.lower(tools),
|
|
1486
1582
|
FfiConverterOptionalTypeSamplerConfig.lower(sampler),
|
|
1583
|
+
FfiConverterOptionalTypeMtpConfig.lower(mtp),
|
|
1584
|
+
FfiConverterOptionalUInt32.lower(threadCount),
|
|
1487
1585
|
callStatus);
|
|
1488
1586
|
},
|
|
1489
1587
|
/*liftString:*/ FfiConverterString.lift,
|
|
@@ -1700,6 +1798,39 @@ async getTemplateVariables(asyncOpts_?: { signal: AbortSignal }): Promise<Map<s
|
|
|
1700
1798
|
}
|
|
1701
1799
|
}
|
|
1702
1800
|
|
|
1801
|
+
/**
|
|
1802
|
+
* MTP draft acceptance rate for the most recent generation, in `[0.0, 1.0]`.
|
|
1803
|
+
*
|
|
1804
|
+
* Resets each generation. `null` when MTP is disabled or no drafts were proposed.
|
|
1805
|
+
*/
|
|
1806
|
+
async mtpAcceptanceRate(asyncOpts_?: { signal: AbortSignal }): Promise</*f32*/number | undefined> /*throws*/ {
|
|
1807
|
+
const __stack = uniffiIsDebug ? new Error().stack : undefined;
|
|
1808
|
+
try {
|
|
1809
|
+
return await uniffiRustCallAsync(
|
|
1810
|
+
/*rustCaller:*/ uniffiCaller,
|
|
1811
|
+
/*rustFutureFunc:*/ () => {
|
|
1812
|
+
return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_mtp_acceptance_rate(
|
|
1813
|
+
uniffiTypeRustChatObjectFactory.clonePointer(this)
|
|
1814
|
+
|
|
1815
|
+
);
|
|
1816
|
+
},
|
|
1817
|
+
/*pollFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_poll_rust_buffer,
|
|
1818
|
+
/*cancelFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_cancel_rust_buffer,
|
|
1819
|
+
/*completeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_complete_rust_buffer,
|
|
1820
|
+
/*freeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_free_rust_buffer,
|
|
1821
|
+
/*liftFunc:*/ FfiConverterOptionalFloat32.lift.bind(FfiConverterOptionalFloat32),
|
|
1822
|
+
/*liftString:*/ FfiConverterString.lift,
|
|
1823
|
+
/*asyncOpts:*/ asyncOpts_,
|
|
1824
|
+
/*errorHandler:*/ FfiConverterTypeNobodyWhoError.lift.bind(FfiConverterTypeNobodyWhoError)
|
|
1825
|
+
);
|
|
1826
|
+
} catch (__error: any) {
|
|
1827
|
+
if (uniffiIsDebug && __error instanceof Error) {
|
|
1828
|
+
__error.stack = __stack;
|
|
1829
|
+
}
|
|
1830
|
+
throw __error;
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
|
|
1703
1834
|
/**
|
|
1704
1835
|
* Reset the chat context with a new system prompt and tools.
|
|
1705
1836
|
*/
|
|
@@ -3218,7 +3349,7 @@ export class RustTts extends UniffiAbstractObject implements RustTtsInterface {
|
|
|
3218
3349
|
/**
|
|
3219
3350
|
* Create a TTS synthesizer.
|
|
3220
3351
|
*/
|
|
3221
|
-
constructor(source: string, architecture: string | undefined, voice: string | undefined, language: string | undefined, speed: /*f32*/number | undefined, steps: /*u32*/number | undefined, silenceDuration: /*f32*/number | undefined, device: string | undefined) /*throws*/ {
|
|
3352
|
+
constructor(source: string, architecture: string | undefined, voice: string | undefined, language: string | undefined, speed: /*f32*/number | undefined, steps: /*u32*/number | undefined, silenceDuration: /*f32*/number | undefined, precision: string | undefined, temperature: /*f32*/number | undefined, huggingfaceToken: string | undefined, device: string | undefined) /*throws*/ {
|
|
3222
3353
|
super();
|
|
3223
3354
|
const pointer =
|
|
3224
3355
|
|
|
@@ -3233,6 +3364,9 @@ export class RustTts extends UniffiAbstractObject implements RustTtsInterface {
|
|
|
3233
3364
|
FfiConverterOptionalFloat32.lower(speed),
|
|
3234
3365
|
FfiConverterOptionalUInt32.lower(steps),
|
|
3235
3366
|
FfiConverterOptionalFloat32.lower(silenceDuration),
|
|
3367
|
+
FfiConverterOptionalString.lower(precision),
|
|
3368
|
+
FfiConverterOptionalFloat32.lower(temperature),
|
|
3369
|
+
FfiConverterOptionalString.lower(huggingfaceToken),
|
|
3236
3370
|
FfiConverterOptionalString.lower(device),
|
|
3237
3371
|
callStatus);
|
|
3238
3372
|
},
|
|
@@ -3883,6 +4017,10 @@ const FfiConverterOptionalFloat32 = new FfiConverterOptional(FfiConverterFloat32
|
|
|
3883
4017
|
const FfiConverterOptionalInt32 = new FfiConverterOptional(FfiConverterInt32);
|
|
3884
4018
|
|
|
3885
4019
|
|
|
4020
|
+
// FfiConverter for MtpConfig | undefined
|
|
4021
|
+
const FfiConverterOptionalTypeMtpConfig = new FfiConverterOptional(FfiConverterTypeMtpConfig);
|
|
4022
|
+
|
|
4023
|
+
|
|
3886
4024
|
// FfiConverter for PendingToolCall | undefined
|
|
3887
4025
|
const FfiConverterOptionalTypePendingToolCall = new FfiConverterOptional(FfiConverterTypePendingToolCall);
|
|
3888
4026
|
|
|
@@ -3985,10 +4123,10 @@ function uniffiEnsureInitialized() {
|
|
|
3985
4123
|
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_func_get_cached_models() !== 12002) {
|
|
3986
4124
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_func_get_cached_models");
|
|
3987
4125
|
}
|
|
3988
|
-
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_func_load_model() !==
|
|
4126
|
+
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_func_load_model() !== 22964) {
|
|
3989
4127
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_func_load_model");
|
|
3990
4128
|
}
|
|
3991
|
-
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_func_load_tts() !==
|
|
4129
|
+
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_func_load_tts() !== 26587) {
|
|
3992
4130
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_func_load_tts");
|
|
3993
4131
|
}
|
|
3994
4132
|
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_func_sampler_preset_constrain_with_grammar() !== 13698) {
|
|
@@ -4048,6 +4186,9 @@ function uniffiEnsureInitialized() {
|
|
|
4048
4186
|
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustchat_get_template_variables() !== 19616) {
|
|
4049
4187
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_rustchat_get_template_variables");
|
|
4050
4188
|
}
|
|
4189
|
+
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustchat_mtp_acceptance_rate() !== 727) {
|
|
4190
|
+
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_rustchat_mtp_acceptance_rate");
|
|
4191
|
+
}
|
|
4051
4192
|
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustchat_reset_context() !== 47191) {
|
|
4052
4193
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_rustchat_reset_context");
|
|
4053
4194
|
}
|
|
@@ -4168,7 +4309,7 @@ function uniffiEnsureInitialized() {
|
|
|
4168
4309
|
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_samplerconfig_to_json() !== 51798) {
|
|
4169
4310
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_samplerconfig_to_json");
|
|
4170
4311
|
}
|
|
4171
|
-
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_constructor_rustchat_new() !==
|
|
4312
|
+
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_constructor_rustchat_new() !== 2313) {
|
|
4172
4313
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_constructor_rustchat_new");
|
|
4173
4314
|
}
|
|
4174
4315
|
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_constructor_rustcrossencoder_new() !== 9022) {
|
|
@@ -4186,7 +4327,7 @@ function uniffiEnsureInitialized() {
|
|
|
4186
4327
|
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_constructor_rusttool_new_async() !== 54521) {
|
|
4187
4328
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_constructor_rusttool_new_async");
|
|
4188
4329
|
}
|
|
4189
|
-
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_constructor_rusttts_new() !==
|
|
4330
|
+
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_constructor_rusttts_new() !== 34899) {
|
|
4190
4331
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_constructor_rusttts_new");
|
|
4191
4332
|
}
|
|
4192
4333
|
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_constructor_samplerbuilder_new() !== 50214) {
|
|
@@ -4213,6 +4354,7 @@ export default Object.freeze({
|
|
|
4213
4354
|
FfiConverterTypeCachedModel,
|
|
4214
4355
|
FfiConverterTypeChatStats,
|
|
4215
4356
|
FfiConverterTypeMessage,
|
|
4357
|
+
FfiConverterTypeMtpConfig,
|
|
4216
4358
|
FfiConverterTypeNobodyWhoError,
|
|
4217
4359
|
FfiConverterTypePendingToolCall,
|
|
4218
4360
|
FfiConverterTypePromptPart,
|
package/package.json
CHANGED
package/src/chat.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
RustChat,
|
|
3
3
|
SamplerConfig,
|
|
4
|
+
MtpConfig,
|
|
4
5
|
type ChatStats,
|
|
5
6
|
} from "../generated/ts/nobodywho";
|
|
6
7
|
import { Model } from "./model";
|
|
@@ -31,6 +32,12 @@ export class Chat {
|
|
|
31
32
|
/** @internal */
|
|
32
33
|
private readonly _inner: RustChat;
|
|
33
34
|
|
|
35
|
+
/**
|
|
36
|
+
* `threadCount` is the number of CPU threads used for inference. Omit it to detect the
|
|
37
|
+
* device's physical core count (performance cores only, on Apple silicon) — hyperthreads
|
|
38
|
+
* and efficiency cores make inference slower, not faster. Lower it to leave CPU headroom
|
|
39
|
+
* for the rest of the app.
|
|
40
|
+
*/
|
|
34
41
|
constructor(opts: {
|
|
35
42
|
model: Model;
|
|
36
43
|
systemPrompt?: string;
|
|
@@ -38,6 +45,8 @@ export class Chat {
|
|
|
38
45
|
templateVariables?: Record<string, boolean>;
|
|
39
46
|
tools?: Tool[];
|
|
40
47
|
sampler?: SamplerConfig;
|
|
48
|
+
mtp?: Partial<MtpConfig>;
|
|
49
|
+
threadCount?: number;
|
|
41
50
|
}) {
|
|
42
51
|
this._inner = new RustChat(
|
|
43
52
|
opts.model._inner,
|
|
@@ -46,6 +55,8 @@ export class Chat {
|
|
|
46
55
|
opts.templateVariables ? new Map(Object.entries(opts.templateVariables)) : undefined,
|
|
47
56
|
opts.tools?.map((t) => t._inner) ?? undefined,
|
|
48
57
|
opts.sampler ?? undefined,
|
|
58
|
+
opts.mtp !== undefined ? MtpConfig.create(opts.mtp) : undefined,
|
|
59
|
+
opts.threadCount ?? undefined,
|
|
49
60
|
);
|
|
50
61
|
}
|
|
51
62
|
|
|
@@ -65,17 +76,21 @@ export class Chat {
|
|
|
65
76
|
modelPath: string;
|
|
66
77
|
useGpu?: boolean;
|
|
67
78
|
projectionModelPath?: string;
|
|
79
|
+
draftModelPath?: string;
|
|
68
80
|
systemPrompt?: string;
|
|
69
81
|
contextSize?: number;
|
|
70
82
|
templateVariables?: Record<string, boolean>;
|
|
71
83
|
tools?: Tool[];
|
|
72
84
|
sampler?: SamplerConfig;
|
|
85
|
+
mtp?: Partial<MtpConfig>;
|
|
86
|
+
threadCount?: number;
|
|
73
87
|
onDownloadProgress?: (downloaded: number, total: number) => void;
|
|
74
88
|
}): Promise<Chat> {
|
|
75
89
|
const model = await Model.load({
|
|
76
90
|
modelPath: opts.modelPath,
|
|
77
91
|
useGpu: opts.useGpu,
|
|
78
92
|
projectionModelPath: opts.projectionModelPath,
|
|
93
|
+
draftModelPath: opts.draftModelPath,
|
|
79
94
|
onDownloadProgress: opts.onDownloadProgress,
|
|
80
95
|
});
|
|
81
96
|
return new Chat({ model, ...opts });
|
|
@@ -173,6 +188,10 @@ export class Chat {
|
|
|
173
188
|
return this._inner.getStats();
|
|
174
189
|
}
|
|
175
190
|
|
|
191
|
+
async mtpAcceptanceRate(): Promise<number | undefined> {
|
|
192
|
+
return this._inner.mtpAcceptanceRate();
|
|
193
|
+
}
|
|
194
|
+
|
|
176
195
|
/**
|
|
177
196
|
* Immediately free the underlying Rust resources (model context, KV cache, etc.).
|
|
178
197
|
* After calling this, the Chat instance is no longer usable.
|
package/src/model.ts
CHANGED
|
@@ -36,15 +36,19 @@ export class Model {
|
|
|
36
36
|
/**
|
|
37
37
|
* Load a GGUF model from a local path or remote URL.
|
|
38
38
|
*
|
|
39
|
-
* @param opts.modelPath -
|
|
39
|
+
* @param opts.modelPath - Local path, `hf://` or `https://` URL, or `auto` for memory-based model selection
|
|
40
40
|
* @param opts.useGpu - Use GPU acceleration if available (default: true)
|
|
41
41
|
* @param opts.projectionModelPath - Path to a multimodal projector file for vision models
|
|
42
|
+
* @param opts.draftModelPath - Optional MTP draft-heads gguf. Loading it lets `Chat`
|
|
43
|
+
* instances opt into MTP speculative decoding via `new Chat({ ..., mtp: true })`.
|
|
44
|
+
* Adds around 5% to VRAM usage.
|
|
42
45
|
* @param opts.onDownloadProgress - Invoked with `(downloaded, total)` byte counts while a remote model is being downloaded. Throttled to ~10 Hz with a guaranteed final emit on completion. Not invoked for cached/local files.
|
|
43
46
|
*/
|
|
44
47
|
static async load(opts: {
|
|
45
48
|
modelPath: string;
|
|
46
49
|
useGpu?: boolean;
|
|
47
50
|
projectionModelPath?: string;
|
|
51
|
+
draftModelPath?: string;
|
|
48
52
|
onDownloadProgress?: (downloaded: number, total: number) => void;
|
|
49
53
|
}): Promise<Model> {
|
|
50
54
|
const cb = opts.onDownloadProgress;
|
|
@@ -55,6 +59,7 @@ export class Model {
|
|
|
55
59
|
opts.modelPath,
|
|
56
60
|
opts.useGpu ?? true,
|
|
57
61
|
opts.projectionModelPath,
|
|
62
|
+
opts.draftModelPath,
|
|
58
63
|
progressCallback,
|
|
59
64
|
);
|
|
60
65
|
return new Model(inner);
|
package/src/tts.ts
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
type RustTtsInterface,
|
|
5
5
|
} from "../generated/ts/nobodywho";
|
|
6
6
|
|
|
7
|
-
export type TtsArchitecture = "kokoro" | "supertonic";
|
|
7
|
+
export type TtsArchitecture = "kokoro" | "pocket-tts" | "supertonic";
|
|
8
8
|
export type TtsDevice = "auto" | "cpu" | "cuda";
|
|
9
9
|
|
|
10
10
|
export type TtsOptions = {
|
|
@@ -15,6 +15,9 @@ export type TtsOptions = {
|
|
|
15
15
|
speed?: number;
|
|
16
16
|
steps?: number;
|
|
17
17
|
silenceDuration?: number;
|
|
18
|
+
precision?: "int8" | "fp32";
|
|
19
|
+
temperature?: number;
|
|
20
|
+
huggingfaceToken?: string;
|
|
18
21
|
device?: TtsDevice;
|
|
19
22
|
};
|
|
20
23
|
|
|
@@ -33,6 +36,9 @@ export class Tts {
|
|
|
33
36
|
opts.speed,
|
|
34
37
|
opts.steps,
|
|
35
38
|
opts.silenceDuration,
|
|
39
|
+
opts.precision,
|
|
40
|
+
opts.temperature,
|
|
41
|
+
opts.huggingfaceToken,
|
|
36
42
|
opts.device ?? "auto",
|
|
37
43
|
);
|
|
38
44
|
}
|
|
@@ -53,6 +59,9 @@ export class Tts {
|
|
|
53
59
|
opts.speed,
|
|
54
60
|
opts.steps,
|
|
55
61
|
opts.silenceDuration,
|
|
62
|
+
opts.precision,
|
|
63
|
+
opts.temperature,
|
|
64
|
+
opts.huggingfaceToken,
|
|
56
65
|
opts.device ?? "auto",
|
|
57
66
|
);
|
|
58
67
|
return Tts.fromInner(inner);
|