react-native-nobodywho 4.0.0 → 5.0.0

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