react-native-nobodywho 4.0.0 → 5.1.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.
@@ -152,7 +152,9 @@ export function getCachedModels(): Array<CachedModel> /*throws*/ {
152
152
  *
153
153
  * Pass `draft_model_path` pointing to a compatible MTP heads gguf (e.g.
154
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
155
+ * speculative decoding on chats built from this model. For models that
156
+ * bundle MTP layers (e.g. Qwen3.5), pass the model file itself; it is only
157
+ * loaded once. Whether MTP is
156
158
  * actually used is a per-chat decision — pass it through
157
159
  * `Chat`-level config on the wrapping binding.
158
160
  *
@@ -344,19 +346,6 @@ export function samplerPresetDry(): SamplerConfigInterface {
344
346
  /*liftString:*/ FfiConverterString.lift,
345
347
  ));
346
348
  }
347
- /**
348
- * Create a sampler with a custom grammar constraint.
349
- */
350
- export function samplerPresetGrammar(grammar: string): SamplerConfigInterface {
351
- return FfiConverterTypeSamplerConfig.lift(uniffiCaller.rustCall(
352
- /*caller:*/ (callStatus) => {
353
- return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_func_sampler_preset_grammar(
354
- FfiConverterString.lower(grammar),
355
- callStatus);
356
- },
357
- /*liftString:*/ FfiConverterString.lift,
358
- ));
359
- }
360
349
  /**
361
350
  * Create a greedy sampler (always picks most probable token).
362
351
  */
@@ -369,6 +358,9 @@ export function samplerPresetGreedy(): SamplerConfigInterface {
369
358
  /*liftString:*/ FfiConverterString.lift,
370
359
  ));
371
360
  }
361
+ /**
362
+ * Constrain output to a JSON object of any shape.
363
+ */
372
364
  export function samplerPresetJson(): SamplerConfigInterface {
373
365
  return FfiConverterTypeSamplerConfig.lift(uniffiCaller.rustCall(
374
366
  /*caller:*/ (callStatus) => {
@@ -392,7 +384,7 @@ export function samplerPresetTemperature(temperature: /*f32*/number): SamplerCon
392
384
  ));
393
385
  }
394
386
  /**
395
- * Create a sampler with top-k filtering only.
387
+ * Create a sampler with the default steps, but top-k overridden.
396
388
  */
397
389
  export function samplerPresetTopK(topK: /*i32*/number): SamplerConfigInterface {
398
390
  return FfiConverterTypeSamplerConfig.lift(uniffiCaller.rustCall(
@@ -405,7 +397,7 @@ export function samplerPresetTopK(topK: /*i32*/number): SamplerConfigInterface {
405
397
  ));
406
398
  }
407
399
  /**
408
- * Create a sampler with nucleus (top-p) sampling.
400
+ * Create a sampler with the default steps, but nucleus (top-p) overridden.
409
401
  */
410
402
  export function samplerPresetTopP(topP: /*f32*/number): SamplerConfigInterface {
411
403
  return FfiConverterTypeSamplerConfig.lift(uniffiCaller.rustCall(
@@ -674,6 +666,88 @@ const FfiConverterTypeChatStats = (() => {
674
666
  })();
675
667
 
676
668
 
669
+ /**
670
+ * How a chat forgets old turns when its context is full. A turn is a user
671
+ * message and everything up to the next one; system messages are always kept.
672
+ */
673
+ export type ContextShiftOptions = {
674
+ /**
675
+ * `false` disables shifting, so a full context is an error instead.
676
+ */
677
+ enabled: boolean,
678
+ /**
679
+ * Turns always kept at the start of the history.
680
+ */
681
+ keepFirstTurns: /*u32*/number,
682
+ /**
683
+ * Turns always kept at the end of the history; at least 1.
684
+ */
685
+ keepLastTurns: /*u32*/number,
686
+ /**
687
+ * Size the history is shrunk to. `null` means half the context size.
688
+ */
689
+ target: ShiftTarget | undefined
690
+ }
691
+
692
+ /**
693
+ * Generated factory for {@link ContextShiftOptions} record objects.
694
+ */
695
+ export const ContextShiftOptions = (() => {
696
+ const defaults = () => ({enabled: true,keepFirstTurns: 1,keepLastTurns: 2,target: undefined
697
+ });
698
+ const create = (() => {
699
+ return uniffiCreateRecord<ContextShiftOptions, ReturnType<typeof defaults>>(defaults);
700
+ })();
701
+ return Object.freeze({
702
+ /**
703
+ * Create a frozen instance of {@link ContextShiftOptions}, with defaults specified
704
+ * in Rust, in the {@link nobodywho} crate.
705
+ */
706
+ create,
707
+
708
+ /**
709
+ * Create a frozen instance of {@link ContextShiftOptions}, with defaults specified
710
+ * in Rust, in the {@link nobodywho} crate.
711
+ */
712
+ new: create,
713
+
714
+ /**
715
+ * Defaults specified in the {@link nobodywho} crate.
716
+ */
717
+ defaults: () => Object.freeze(defaults()) as Partial<ContextShiftOptions>,
718
+
719
+ });
720
+ })();
721
+
722
+ const FfiConverterTypeContextShiftOptions = (() => {
723
+ type TypeName = ContextShiftOptions;
724
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
725
+ read(from: RustBuffer): TypeName {
726
+ return {
727
+ enabled: FfiConverterBool.read(from),
728
+ keepFirstTurns: FfiConverterUInt32.read(from),
729
+ keepLastTurns: FfiConverterUInt32.read(from),
730
+ target: FfiConverterOptionalTypeShiftTarget.read(from)
731
+ };
732
+ }
733
+ write(value: TypeName, into: RustBuffer): void {
734
+ FfiConverterBool.write(value.enabled, into);
735
+ FfiConverterUInt32.write(value.keepFirstTurns, into);
736
+ FfiConverterUInt32.write(value.keepLastTurns, into);
737
+ FfiConverterOptionalTypeShiftTarget.write(value.target, into);
738
+ }
739
+ allocationSize(value: TypeName): number {
740
+ return FfiConverterBool.allocationSize(value.enabled) +
741
+ FfiConverterUInt32.allocationSize(value.keepFirstTurns) +
742
+ FfiConverterUInt32.allocationSize(value.keepLastTurns) +
743
+ FfiConverterOptionalTypeShiftTarget.allocationSize(value.target);
744
+
745
+ }
746
+ };
747
+ return new FFIConverter();
748
+ })();
749
+
750
+
677
751
  /**
678
752
  * Tuning for MTP speculative decoding. Passing one to `RustChat::new`
679
753
  * enables MTP; `null` runs the solo decode path. Requires the model to
@@ -1732,6 +1806,163 @@ const FfiConverterTypeNobodyWhoError = (() => {
1732
1806
  })();
1733
1807
 
1734
1808
 
1809
+ // Enum: ShiftTarget
1810
+ export enum ShiftTarget_Tags {
1811
+ Fraction = "Fraction",
1812
+ Tokens = "Tokens"
1813
+ }
1814
+ /**
1815
+ * Size a context shift shrinks the chat history to.
1816
+ */
1817
+ export const ShiftTarget = (() => {
1818
+
1819
+
1820
+ type Fraction__interface = {
1821
+ tag: ShiftTarget_Tags.Fraction;
1822
+ inner: Readonly<{fraction: /*f32*/number}>
1823
+ };
1824
+
1825
+
1826
+ /**
1827
+ * A fraction of the context size, in `(0, 1)`.
1828
+ */
1829
+ class Fraction_ extends UniffiEnum implements Fraction__interface {
1830
+ /**
1831
+ * @private
1832
+ * This field is private and should not be used, use `tag` instead.
1833
+ */
1834
+ readonly [uniffiTypeNameSymbol] = "ShiftTarget";
1835
+ readonly tag = ShiftTarget_Tags.Fraction;
1836
+ readonly inner: Readonly<{fraction: /*f32*/number}>;
1837
+ constructor(inner: { fraction: /*f32*/number }) {
1838
+ super("ShiftTarget", "Fraction");
1839
+ this.inner = Object.freeze(inner);
1840
+ }
1841
+
1842
+ static new(inner: { fraction: /*f32*/number }): Fraction_ {
1843
+ return new Fraction_(inner);
1844
+ }
1845
+
1846
+ static instanceOf(obj: any): obj is Fraction_ {
1847
+ return obj.tag === ShiftTarget_Tags.Fraction;
1848
+ }
1849
+
1850
+
1851
+
1852
+
1853
+ }
1854
+
1855
+
1856
+ type Tokens__interface = {
1857
+ tag: ShiftTarget_Tags.Tokens;
1858
+ inner: Readonly<{tokens: /*u32*/number}>
1859
+ };
1860
+
1861
+
1862
+ /**
1863
+ * A number of tokens, below the context size.
1864
+ */
1865
+ class Tokens_ extends UniffiEnum implements Tokens__interface {
1866
+ /**
1867
+ * @private
1868
+ * This field is private and should not be used, use `tag` instead.
1869
+ */
1870
+ readonly [uniffiTypeNameSymbol] = "ShiftTarget";
1871
+ readonly tag = ShiftTarget_Tags.Tokens;
1872
+ readonly inner: Readonly<{tokens: /*u32*/number}>;
1873
+ constructor(inner: { tokens: /*u32*/number }) {
1874
+ super("ShiftTarget", "Tokens");
1875
+ this.inner = Object.freeze(inner);
1876
+ }
1877
+
1878
+ static new(inner: { tokens: /*u32*/number }): Tokens_ {
1879
+ return new Tokens_(inner);
1880
+ }
1881
+
1882
+ static instanceOf(obj: any): obj is Tokens_ {
1883
+ return obj.tag === ShiftTarget_Tags.Tokens;
1884
+ }
1885
+
1886
+
1887
+
1888
+
1889
+ }
1890
+
1891
+ function instanceOf(obj: any): obj is ShiftTarget {
1892
+ return obj[uniffiTypeNameSymbol] === "ShiftTarget";
1893
+ }
1894
+
1895
+ return Object.freeze({
1896
+ instanceOf,
1897
+ Fraction: Fraction_,
1898
+ Tokens: Tokens_
1899
+ });
1900
+
1901
+ })();
1902
+
1903
+
1904
+ /**
1905
+ * Size a context shift shrinks the chat history to.
1906
+ */
1907
+
1908
+ export type ShiftTarget = InstanceType<
1909
+ typeof ShiftTarget[keyof Omit<typeof ShiftTarget, 'instanceOf'>]
1910
+ >;
1911
+
1912
+ // FfiConverter for enum ShiftTarget
1913
+ const FfiConverterTypeShiftTarget = (() => {
1914
+ const ordinalConverter = FfiConverterInt32;
1915
+ type TypeName = ShiftTarget;
1916
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
1917
+ read(from: RustBuffer): TypeName {
1918
+ switch (ordinalConverter.read(from)) {
1919
+ case 1: return new ShiftTarget.Fraction({fraction: FfiConverterFloat32.read(from) });
1920
+ case 2: return new ShiftTarget.Tokens({tokens: FfiConverterUInt32.read(from) });
1921
+ default: throw new UniffiInternalError.UnexpectedEnumCase();
1922
+ }
1923
+ }
1924
+ write(value: TypeName, into: RustBuffer): void {
1925
+ switch (value.tag) {
1926
+ case ShiftTarget_Tags.Fraction: {
1927
+ ordinalConverter.write(1, into);
1928
+ const inner = value.inner;
1929
+ FfiConverterFloat32.write(inner.fraction, into);
1930
+ return;
1931
+ }
1932
+ case ShiftTarget_Tags.Tokens: {
1933
+ ordinalConverter.write(2, into);
1934
+ const inner = value.inner;
1935
+ FfiConverterUInt32.write(inner.tokens, into);
1936
+ return;
1937
+ }
1938
+ default:
1939
+ // Throwing from here means that ShiftTarget_Tags hasn't matched an ordinal.
1940
+ throw new UniffiInternalError.UnexpectedEnumCase();
1941
+ }
1942
+ }
1943
+ allocationSize(value: TypeName): number {
1944
+ switch (value.tag) {
1945
+ case ShiftTarget_Tags.Fraction: {
1946
+ const inner = value.inner;
1947
+ let size = ordinalConverter.allocationSize(1);
1948
+ size += FfiConverterFloat32.allocationSize(inner.fraction);
1949
+ return size;
1950
+ }
1951
+ case ShiftTarget_Tags.Tokens: {
1952
+ const inner = value.inner;
1953
+ let size = ordinalConverter.allocationSize(2);
1954
+ size += FfiConverterUInt32.allocationSize(inner.tokens);
1955
+ return size;
1956
+ }
1957
+ default: throw new UniffiInternalError.UnexpectedEnumCase();
1958
+ }
1959
+ }
1960
+ }
1961
+ return new FFIConverter();
1962
+ })();
1963
+
1964
+
1965
+
1735
1966
  /**
1736
1967
  * `push` always returns one of these: `Speech`/`Silence` for the confirmed
1737
1968
  * state when unchanged since the last call, or `SpeechStarted`/`SpeechEnded`
@@ -1812,11 +2043,11 @@ export interface RustChatInterface {
1812
2043
  * Answer a full list of messages and get a token stream, replacing the chat
1813
2044
  * history.
1814
2045
  *
1815
- * The list is the whole conversation, used as given: it must be non-empty, end
1816
- * in a user or tool message, and carry a system message only first. That system
1817
- * message sets the chat's system prompt; leave it out and the prompt already on
1818
- * the chat is kept. The response is appended, and the next `ask` continues from
1819
- * there.
2046
+ * The list is the whole conversation, used as given: it must be non-empty and
2047
+ * end in a user or tool message. A leading system message sets the chat's system
2048
+ * prompt; leave it out and the prompt already on the chat is kept. A later one
2049
+ * stays in the history, for the chat template to render in place. The response
2050
+ * is appended, and the next `ask` continues from there.
1820
2051
  *
1821
2052
  * `options` follows the same rule for the chat's other settings.
1822
2053
  */
@@ -1859,6 +2090,10 @@ export interface RustChatInterface {
1859
2090
  * Set the chat history from a list of messages.
1860
2091
  */
1861
2092
  setChatHistory(messages: Array<Message>, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<void>;
2093
+ /**
2094
+ * Set how old turns are forgotten when the context is full.
2095
+ */
2096
+ setContextShift(options: ContextShiftOptions, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<void>;
1862
2097
  /**
1863
2098
  * Set the sampler configuration.
1864
2099
  */
@@ -1908,8 +2143,11 @@ export class RustChat extends UniffiAbstractObject implements RustChatInterface
1908
2143
  * detects the device's physical core count (performance cores only, on
1909
2144
  * Apple silicon), since hyperthreads and efficiency cores make inference
1910
2145
  * slower. Clamped to the CPU count.
2146
+ *
2147
+ * `context_shift` sets how old turns are forgotten when the context is
2148
+ * full; `null` uses the defaults.
1911
2149
  */
1912
- 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*/ {
2150
+ 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, contextShift: ContextShiftOptions | undefined) /*throws*/ {
1913
2151
  super();
1914
2152
  const pointer =
1915
2153
 
@@ -1925,6 +2163,7 @@ export class RustChat extends UniffiAbstractObject implements RustChatInterface
1925
2163
  FfiConverterOptionalTypeSamplerConfig.lower(sampler),
1926
2164
  FfiConverterOptionalTypeMtpConfig.lower(mtp),
1927
2165
  FfiConverterOptionalUInt32.lower(threadCount),
2166
+ FfiConverterOptionalTypeContextShiftOptions.lower(contextShift),
1928
2167
  callStatus);
1929
2168
  },
1930
2169
  /*liftString:*/ FfiConverterString.lift,
@@ -1990,11 +2229,11 @@ export class RustChat extends UniffiAbstractObject implements RustChatInterface
1990
2229
  * Answer a full list of messages and get a token stream, replacing the chat
1991
2230
  * history.
1992
2231
  *
1993
- * The list is the whole conversation, used as given: it must be non-empty, end
1994
- * in a user or tool message, and carry a system message only first. That system
1995
- * message sets the chat's system prompt; leave it out and the prompt already on
1996
- * the chat is kept. The response is appended, and the next `ask` continues from
1997
- * there.
2232
+ * The list is the whole conversation, used as given: it must be non-empty and
2233
+ * end in a user or tool message. A leading system message sets the chat's system
2234
+ * prompt; leave it out and the prompt already on the chat is kept. A later one
2235
+ * stays in the history, for the chat template to render in place. The response
2236
+ * is appended, and the next `ask` continues from there.
1998
2237
  *
1999
2238
  * `options` follows the same rule for the chat's other settings.
2000
2239
  */
@@ -2293,6 +2532,37 @@ async setChatHistory(messages: Array<Message>, asyncOpts_?: { signal: AbortSign
2293
2532
  }
2294
2533
  }
2295
2534
 
2535
+ /**
2536
+ * Set how old turns are forgotten when the context is full.
2537
+ */
2538
+ async setContextShift(options: ContextShiftOptions, asyncOpts_?: { signal: AbortSignal }): Promise<void> /*throws*/ {
2539
+ const __stack = uniffiIsDebug ? new Error().stack : undefined;
2540
+ try {
2541
+ return await uniffiRustCallAsync(
2542
+ /*rustCaller:*/ uniffiCaller,
2543
+ /*rustFutureFunc:*/ () => {
2544
+ return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_set_context_shift(
2545
+ uniffiTypeRustChatObjectFactory.clonePointer(this),
2546
+ FfiConverterTypeContextShiftOptions.lower(options)
2547
+ );
2548
+ },
2549
+ /*pollFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_poll_void,
2550
+ /*cancelFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_cancel_void,
2551
+ /*completeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_complete_void,
2552
+ /*freeFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_free_void,
2553
+ /*liftFunc:*/ (_v) => {},
2554
+ /*liftString:*/ FfiConverterString.lift,
2555
+ /*asyncOpts:*/ asyncOpts_,
2556
+ /*errorHandler:*/ FfiConverterTypeNobodyWhoError.lift.bind(FfiConverterTypeNobodyWhoError)
2557
+ );
2558
+ } catch (__error: any) {
2559
+ if (uniffiIsDebug && __error instanceof Error) {
2560
+ __error.stack = __stack;
2561
+ }
2562
+ throw __error;
2563
+ }
2564
+ }
2565
+
2296
2566
  /**
2297
2567
  * Set the sampler configuration.
2298
2568
  */
@@ -2927,6 +3197,7 @@ const FfiConverterTypeRustEncoder = new FfiConverterObject(uniffiTypeRustEncode
2927
3197
  export interface RustModelInterface {
2928
3198
 
2929
3199
  maxCtx() : /*u32*/number;
3200
+ source() : string;
2930
3201
  }
2931
3202
 
2932
3203
 
@@ -2955,6 +3226,16 @@ private constructor(pointer: UniffiHandle) {
2955
3226
  ));
2956
3227
  }
2957
3228
 
3229
+ source(): string {
3230
+ return FfiConverterString.lift(uniffiCaller.rustCall(
3231
+ /*caller:*/ (callStatus) => {
3232
+ return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_rustmodel_source(uniffiTypeRustModelObjectFactory.clonePointer(this),
3233
+ callStatus);
3234
+ },
3235
+ /*liftString:*/ FfiConverterString.lift,
3236
+ ));
3237
+ }
3238
+
2958
3239
 
2959
3240
  /**
2960
3241
  * {@inheritDoc uniffi-bindgen-react-native#UniffiAbstractObject.uniffiDestroy}
@@ -4116,6 +4397,18 @@ const FfiConverterTypeRustVoiceActivityDetection = new FfiConverterObject(uniff
4116
4397
 
4117
4398
  export interface SamplerBuilderInterface {
4118
4399
 
4400
+ /**
4401
+ * Constrain output to a grammar, given as either Lark or GBNF.
4402
+ */
4403
+ constrainWithGrammar(grammar: string) : SamplerBuilderInterface;
4404
+ /**
4405
+ * Constrain output to a JSON schema, given as a JSON string.
4406
+ */
4407
+ constrainWithJsonSchema(schema: string) : SamplerBuilderInterface;
4408
+ /**
4409
+ * Constrain output to a regular expression.
4410
+ */
4411
+ constrainWithRegex(pattern: string) : SamplerBuilderInterface;
4119
4412
  /**
4120
4413
  * Sample from the probability distribution (weighted random selection).
4121
4414
  */
@@ -4134,14 +4427,15 @@ export interface SamplerBuilderInterface {
4134
4427
  * exponent: Temperature is calculated as `entropy^exponent` (bounded by the range above)
4135
4428
  */
4136
4429
  dynamicTemperature(temperature: /*f32*/number, delta: /*f32*/number, exponent: /*f32*/number) : SamplerBuilderInterface;
4137
- /**
4138
- * Deprecated: Use `sampler_preset_constrain_with_grammar()` instead. It accepts both Lark and GBNF strings.
4139
- */
4140
- grammar(grammar: string, triggerOn: string | undefined, root: string) : SamplerBuilderInterface;
4141
4430
  /**
4142
4431
  * Always select the most probable token (deterministic).
4143
4432
  */
4144
4433
  greedy() : SamplerConfigInterface;
4434
+ /**
4435
+ * Constrain output to a JSON object of any shape. Use
4436
+ * `constrain_with_json_schema()` to pin down the structure too.
4437
+ */
4438
+ json() : SamplerBuilderInterface;
4145
4439
  /**
4146
4440
  * Modify the likelihood of specific tokens.
4147
4441
  *
@@ -4229,6 +4523,48 @@ export class SamplerBuilder extends UniffiAbstractObject implements SamplerBuild
4229
4523
 
4230
4524
 
4231
4525
 
4526
+ /**
4527
+ * Constrain output to a grammar, given as either Lark or GBNF.
4528
+ */
4529
+ constrainWithGrammar(grammar: string): SamplerBuilderInterface {
4530
+ return FfiConverterTypeSamplerBuilder.lift(uniffiCaller.rustCall(
4531
+ /*caller:*/ (callStatus) => {
4532
+ return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_samplerbuilder_constrain_with_grammar(uniffiTypeSamplerBuilderObjectFactory.clonePointer(this),
4533
+ FfiConverterString.lower(grammar),
4534
+ callStatus);
4535
+ },
4536
+ /*liftString:*/ FfiConverterString.lift,
4537
+ ));
4538
+ }
4539
+
4540
+ /**
4541
+ * Constrain output to a JSON schema, given as a JSON string.
4542
+ */
4543
+ constrainWithJsonSchema(schema: string): SamplerBuilderInterface {
4544
+ return FfiConverterTypeSamplerBuilder.lift(uniffiCaller.rustCall(
4545
+ /*caller:*/ (callStatus) => {
4546
+ return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_samplerbuilder_constrain_with_json_schema(uniffiTypeSamplerBuilderObjectFactory.clonePointer(this),
4547
+ FfiConverterString.lower(schema),
4548
+ callStatus);
4549
+ },
4550
+ /*liftString:*/ FfiConverterString.lift,
4551
+ ));
4552
+ }
4553
+
4554
+ /**
4555
+ * Constrain output to a regular expression.
4556
+ */
4557
+ constrainWithRegex(pattern: string): SamplerBuilderInterface {
4558
+ return FfiConverterTypeSamplerBuilder.lift(uniffiCaller.rustCall(
4559
+ /*caller:*/ (callStatus) => {
4560
+ return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_samplerbuilder_constrain_with_regex(uniffiTypeSamplerBuilderObjectFactory.clonePointer(this),
4561
+ FfiConverterString.lower(pattern),
4562
+ callStatus);
4563
+ },
4564
+ /*liftString:*/ FfiConverterString.lift,
4565
+ ));
4566
+ }
4567
+
4232
4568
  /**
4233
4569
  * Sample from the probability distribution (weighted random selection).
4234
4570
  */
@@ -4283,15 +4619,12 @@ export class SamplerBuilder extends UniffiAbstractObject implements SamplerBuild
4283
4619
  }
4284
4620
 
4285
4621
  /**
4286
- * Deprecated: Use `sampler_preset_constrain_with_grammar()` instead. It accepts both Lark and GBNF strings.
4622
+ * Always select the most probable token (deterministic).
4287
4623
  */
4288
- grammar(grammar: string, triggerOn: string | undefined, root: string): SamplerBuilderInterface {
4289
- return FfiConverterTypeSamplerBuilder.lift(uniffiCaller.rustCall(
4624
+ greedy(): SamplerConfigInterface {
4625
+ return FfiConverterTypeSamplerConfig.lift(uniffiCaller.rustCall(
4290
4626
  /*caller:*/ (callStatus) => {
4291
- return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_samplerbuilder_grammar(uniffiTypeSamplerBuilderObjectFactory.clonePointer(this),
4292
- FfiConverterString.lower(grammar),
4293
- FfiConverterOptionalString.lower(triggerOn),
4294
- FfiConverterString.lower(root),
4627
+ return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_samplerbuilder_greedy(uniffiTypeSamplerBuilderObjectFactory.clonePointer(this),
4295
4628
  callStatus);
4296
4629
  },
4297
4630
  /*liftString:*/ FfiConverterString.lift,
@@ -4299,12 +4632,13 @@ export class SamplerBuilder extends UniffiAbstractObject implements SamplerBuild
4299
4632
  }
4300
4633
 
4301
4634
  /**
4302
- * Always select the most probable token (deterministic).
4635
+ * Constrain output to a JSON object of any shape. Use
4636
+ * `constrain_with_json_schema()` to pin down the structure too.
4303
4637
  */
4304
- greedy(): SamplerConfigInterface {
4305
- return FfiConverterTypeSamplerConfig.lift(uniffiCaller.rustCall(
4638
+ json(): SamplerBuilderInterface {
4639
+ return FfiConverterTypeSamplerBuilder.lift(uniffiCaller.rustCall(
4306
4640
  /*caller:*/ (callStatus) => {
4307
- return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_samplerbuilder_greedy(uniffiTypeSamplerBuilderObjectFactory.clonePointer(this),
4641
+ return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_samplerbuilder_json(uniffiTypeSamplerBuilderObjectFactory.clonePointer(this),
4308
4642
  callStatus);
4309
4643
  },
4310
4644
  /*liftString:*/ FfiConverterString.lift,
@@ -4718,6 +5052,10 @@ const FfiConverterOptionalFloat32 = new FfiConverterOptional(FfiConverterFloat32
4718
5052
  const FfiConverterOptionalInt32 = new FfiConverterOptional(FfiConverterInt32);
4719
5053
 
4720
5054
 
5055
+ // FfiConverter for ContextShiftOptions | undefined
5056
+ const FfiConverterOptionalTypeContextShiftOptions = new FfiConverterOptional(FfiConverterTypeContextShiftOptions);
5057
+
5058
+
4721
5059
  // FfiConverter for MtpConfig | undefined
4722
5060
  const FfiConverterOptionalTypeMtpConfig = new FfiConverterOptional(FfiConverterTypeMtpConfig);
4723
5061
 
@@ -4758,6 +5096,10 @@ const FfiConverterArrayTypeToolParameter = new FfiConverterArray(FfiConverterTyp
4758
5096
  const FfiConverterArrayString = new FfiConverterArray(FfiConverterString);
4759
5097
 
4760
5098
 
5099
+ // FfiConverter for ShiftTarget | undefined
5100
+ const FfiConverterOptionalTypeShiftTarget = new FfiConverterOptional(FfiConverterTypeShiftTarget);
5101
+
5102
+
4761
5103
  // FfiConverter for Map<string, boolean> | undefined
4762
5104
  const FfiConverterOptionalMapStringBool = new FfiConverterOptional(FfiConverterMapStringBool);
4763
5105
 
@@ -4828,7 +5170,7 @@ function uniffiEnsureInitialized() {
4828
5170
  if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_func_get_cached_models() !== 12002) {
4829
5171
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_func_get_cached_models");
4830
5172
  }
4831
- if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_func_load_model() !== 22964) {
5173
+ if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_func_load_model() !== 8315) {
4832
5174
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_func_load_model");
4833
5175
  }
4834
5176
  if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_func_load_speech_to_text() !== 3224) {
@@ -4855,22 +5197,19 @@ function uniffiEnsureInitialized() {
4855
5197
  if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_func_sampler_preset_dry() !== 55378) {
4856
5198
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_func_sampler_preset_dry");
4857
5199
  }
4858
- if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_func_sampler_preset_grammar() !== 29288) {
4859
- throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_func_sampler_preset_grammar");
4860
- }
4861
5200
  if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_func_sampler_preset_greedy() !== 13219) {
4862
5201
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_func_sampler_preset_greedy");
4863
5202
  }
4864
- if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_func_sampler_preset_json() !== 8103) {
5203
+ if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_func_sampler_preset_json() !== 42303) {
4865
5204
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_func_sampler_preset_json");
4866
5205
  }
4867
5206
  if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_func_sampler_preset_temperature() !== 64803) {
4868
5207
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_func_sampler_preset_temperature");
4869
5208
  }
4870
- if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_func_sampler_preset_top_k() !== 44137) {
5209
+ if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_func_sampler_preset_top_k() !== 56996) {
4871
5210
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_func_sampler_preset_top_k");
4872
5211
  }
4873
- if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_func_sampler_preset_top_p() !== 54893) {
5212
+ if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_func_sampler_preset_top_p() !== 22588) {
4874
5213
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_func_sampler_preset_top_p");
4875
5214
  }
4876
5215
  if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustchat_ask() !== 53575) {
@@ -4882,7 +5221,7 @@ function uniffiEnsureInitialized() {
4882
5221
  if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustchat_ask_with_prompt() !== 46807) {
4883
5222
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_rustchat_ask_with_prompt");
4884
5223
  }
4885
- if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustchat_complete() !== 37833) {
5224
+ if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustchat_complete() !== 24327) {
4886
5225
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_rustchat_complete");
4887
5226
  }
4888
5227
  if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustchat_get_chat_history() !== 12722) {
@@ -4912,6 +5251,9 @@ function uniffiEnsureInitialized() {
4912
5251
  if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustchat_set_chat_history() !== 6058) {
4913
5252
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_rustchat_set_chat_history");
4914
5253
  }
5254
+ if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustchat_set_context_shift() !== 58540) {
5255
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_rustchat_set_context_shift");
5256
+ }
4915
5257
  if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustchat_set_sampler_config() !== 28012) {
4916
5258
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_rustchat_set_sampler_config");
4917
5259
  }
@@ -4948,6 +5290,9 @@ function uniffiEnsureInitialized() {
4948
5290
  if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustmodel_max_ctx() !== 52004) {
4949
5291
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_rustmodel_max_ctx");
4950
5292
  }
5293
+ if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustmodel_source() !== 39358) {
5294
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_rustmodel_source");
5295
+ }
4951
5296
  if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustspeechtotext_transcribe_file() !== 59975) {
4952
5297
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_rustspeechtotext_transcribe_file");
4953
5298
  }
@@ -4990,6 +5335,15 @@ function uniffiEnsureInitialized() {
4990
5335
  if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustvoiceactivitydetection_segment() !== 39967) {
4991
5336
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_rustvoiceactivitydetection_segment");
4992
5337
  }
5338
+ if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_constrain_with_grammar() !== 36786) {
5339
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_constrain_with_grammar");
5340
+ }
5341
+ if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_constrain_with_json_schema() !== 45268) {
5342
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_constrain_with_json_schema");
5343
+ }
5344
+ if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_constrain_with_regex() !== 1166) {
5345
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_constrain_with_regex");
5346
+ }
4993
5347
  if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_dist() !== 23376) {
4994
5348
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_dist");
4995
5349
  }
@@ -4999,12 +5353,12 @@ function uniffiEnsureInitialized() {
4999
5353
  if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_dynamic_temperature() !== 5004) {
5000
5354
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_dynamic_temperature");
5001
5355
  }
5002
- if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_grammar() !== 3547) {
5003
- throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_grammar");
5004
- }
5005
5356
  if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_greedy() !== 32898) {
5006
5357
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_greedy");
5007
5358
  }
5359
+ if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_json() !== 18949) {
5360
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_json");
5361
+ }
5008
5362
  if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_logit_bias() !== 61844) {
5009
5363
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_logit_bias");
5010
5364
  }
@@ -5044,7 +5398,7 @@ function uniffiEnsureInitialized() {
5044
5398
  if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_samplerconfig_to_json() !== 51798) {
5045
5399
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_samplerconfig_to_json");
5046
5400
  }
5047
- if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_constructor_rustchat_new() !== 2313) {
5401
+ if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_constructor_rustchat_new() !== 4810) {
5048
5402
  throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_constructor_rustchat_new");
5049
5403
  }
5050
5404
  if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_constructor_rustcrossencoder_new() !== 9022) {
@@ -5091,6 +5445,7 @@ export default Object.freeze({
5091
5445
  FfiConverterTypeCachedModel,
5092
5446
  FfiConverterTypeChatStats,
5093
5447
  FfiConverterTypeContentPart,
5448
+ FfiConverterTypeContextShiftOptions,
5094
5449
  FfiConverterTypeMessage,
5095
5450
  FfiConverterTypeMessageContent,
5096
5451
  FfiConverterTypeMtpConfig,
@@ -5109,6 +5464,7 @@ export default Object.freeze({
5109
5464
  FfiConverterTypeRustVoiceActivityDetection,
5110
5465
  FfiConverterTypeSamplerBuilder,
5111
5466
  FfiConverterTypeSamplerConfig,
5467
+ FfiConverterTypeShiftTarget,
5112
5468
  FfiConverterTypeToolCall,
5113
5469
  FfiConverterTypeToolParameter,
5114
5470
  FfiConverterTypeVoiceActivityDetectionEvent,