react-native-nobodywho 3.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.
- package/README.md +113 -7
- package/android/build.gradle +5 -1
- package/generated/cpp/nobodywho.cpp +524 -80
- package/generated/cpp/nobodywho.hpp +67 -8
- package/generated/ts/nobodywho-ffi.ts +21 -5
- package/generated/ts/nobodywho.ts +978 -270
- package/package.json +7 -3
- package/src/chat.ts +50 -3
- package/src/message.ts +91 -24
- package/src/model.ts +5 -0
- package/src/prompt.ts +8 -8
- package/src/sampler_presets.ts +7 -11
- package/src/wrapper.ts +5 -3
|
@@ -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
|
|
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)
|
|
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(
|
|
@@ -555,29 +545,32 @@ const FfiConverterTypeRustToolCallback = new FfiConverterCallback<RustToolCallba
|
|
|
555
545
|
|
|
556
546
|
|
|
557
547
|
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
548
|
+
/**
|
|
549
|
+
* A cached `.gguf` model and its on-disk size.
|
|
550
|
+
*/
|
|
551
|
+
export type CachedModel = {
|
|
552
|
+
path: string,
|
|
553
|
+
size: /*u64*/bigint
|
|
561
554
|
}
|
|
562
555
|
|
|
563
556
|
/**
|
|
564
|
-
* Generated factory for {@link
|
|
557
|
+
* Generated factory for {@link CachedModel} record objects.
|
|
565
558
|
*/
|
|
566
|
-
export const
|
|
559
|
+
export const CachedModel = (() => {
|
|
567
560
|
const defaults = () => ({
|
|
568
561
|
});
|
|
569
562
|
const create = (() => {
|
|
570
|
-
return uniffiCreateRecord<
|
|
563
|
+
return uniffiCreateRecord<CachedModel, ReturnType<typeof defaults>>(defaults);
|
|
571
564
|
})();
|
|
572
565
|
return Object.freeze({
|
|
573
566
|
/**
|
|
574
|
-
* Create a frozen instance of {@link
|
|
567
|
+
* Create a frozen instance of {@link CachedModel}, with defaults specified
|
|
575
568
|
* in Rust, in the {@link nobodywho} crate.
|
|
576
569
|
*/
|
|
577
570
|
create,
|
|
578
571
|
|
|
579
572
|
/**
|
|
580
|
-
* Create a frozen instance of {@link
|
|
573
|
+
* Create a frozen instance of {@link CachedModel}, with defaults specified
|
|
581
574
|
* in Rust, in the {@link nobodywho} crate.
|
|
582
575
|
*/
|
|
583
576
|
new: create,
|
|
@@ -585,27 +578,27 @@ export const Asset = (() => {
|
|
|
585
578
|
/**
|
|
586
579
|
* Defaults specified in the {@link nobodywho} crate.
|
|
587
580
|
*/
|
|
588
|
-
defaults: () => Object.freeze(defaults()) as Partial<
|
|
581
|
+
defaults: () => Object.freeze(defaults()) as Partial<CachedModel>,
|
|
589
582
|
|
|
590
583
|
});
|
|
591
584
|
})();
|
|
592
585
|
|
|
593
|
-
const
|
|
594
|
-
type TypeName =
|
|
586
|
+
const FfiConverterTypeCachedModel = (() => {
|
|
587
|
+
type TypeName = CachedModel;
|
|
595
588
|
class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
|
|
596
589
|
read(from: RustBuffer): TypeName {
|
|
597
590
|
return {
|
|
598
|
-
|
|
599
|
-
|
|
591
|
+
path: FfiConverterString.read(from),
|
|
592
|
+
size: FfiConverterUInt64.read(from)
|
|
600
593
|
};
|
|
601
594
|
}
|
|
602
595
|
write(value: TypeName, into: RustBuffer): void {
|
|
603
|
-
FfiConverterString.write(value.id, into);
|
|
604
596
|
FfiConverterString.write(value.path, into);
|
|
597
|
+
FfiConverterUInt64.write(value.size, into);
|
|
605
598
|
}
|
|
606
599
|
allocationSize(value: TypeName): number {
|
|
607
|
-
return FfiConverterString.allocationSize(value.
|
|
608
|
-
|
|
600
|
+
return FfiConverterString.allocationSize(value.path) +
|
|
601
|
+
FfiConverterUInt64.allocationSize(value.size);
|
|
609
602
|
|
|
610
603
|
}
|
|
611
604
|
};
|
|
@@ -613,32 +606,29 @@ const FfiConverterTypeAsset = (() => {
|
|
|
613
606
|
})();
|
|
614
607
|
|
|
615
608
|
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
*/
|
|
619
|
-
export type CachedModel = {
|
|
620
|
-
path: string,
|
|
621
|
-
size: /*u64*/bigint
|
|
609
|
+
export type ChatStats = {
|
|
610
|
+
contextSize: /*u32*/number,
|
|
611
|
+
contextUsed: /*u32*/number
|
|
622
612
|
}
|
|
623
613
|
|
|
624
614
|
/**
|
|
625
|
-
* Generated factory for {@link
|
|
615
|
+
* Generated factory for {@link ChatStats} record objects.
|
|
626
616
|
*/
|
|
627
|
-
export const
|
|
617
|
+
export const ChatStats = (() => {
|
|
628
618
|
const defaults = () => ({
|
|
629
619
|
});
|
|
630
620
|
const create = (() => {
|
|
631
|
-
return uniffiCreateRecord<
|
|
621
|
+
return uniffiCreateRecord<ChatStats, ReturnType<typeof defaults>>(defaults);
|
|
632
622
|
})();
|
|
633
623
|
return Object.freeze({
|
|
634
624
|
/**
|
|
635
|
-
* Create a frozen instance of {@link
|
|
625
|
+
* Create a frozen instance of {@link ChatStats}, with defaults specified
|
|
636
626
|
* in Rust, in the {@link nobodywho} crate.
|
|
637
627
|
*/
|
|
638
628
|
create,
|
|
639
629
|
|
|
640
630
|
/**
|
|
641
|
-
* Create a frozen instance of {@link
|
|
631
|
+
* Create a frozen instance of {@link ChatStats}, with defaults specified
|
|
642
632
|
* in Rust, in the {@link nobodywho} crate.
|
|
643
633
|
*/
|
|
644
634
|
new: create,
|
|
@@ -646,27 +636,27 @@ export const CachedModel = (() => {
|
|
|
646
636
|
/**
|
|
647
637
|
* Defaults specified in the {@link nobodywho} crate.
|
|
648
638
|
*/
|
|
649
|
-
defaults: () => Object.freeze(defaults()) as Partial<
|
|
639
|
+
defaults: () => Object.freeze(defaults()) as Partial<ChatStats>,
|
|
650
640
|
|
|
651
641
|
});
|
|
652
642
|
})();
|
|
653
643
|
|
|
654
|
-
const
|
|
655
|
-
type TypeName =
|
|
644
|
+
const FfiConverterTypeChatStats = (() => {
|
|
645
|
+
type TypeName = ChatStats;
|
|
656
646
|
class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
|
|
657
647
|
read(from: RustBuffer): TypeName {
|
|
658
648
|
return {
|
|
659
|
-
|
|
660
|
-
|
|
649
|
+
contextSize: FfiConverterUInt32.read(from),
|
|
650
|
+
contextUsed: FfiConverterUInt32.read(from)
|
|
661
651
|
};
|
|
662
652
|
}
|
|
663
653
|
write(value: TypeName, into: RustBuffer): void {
|
|
664
|
-
|
|
665
|
-
|
|
654
|
+
FfiConverterUInt32.write(value.contextSize, into);
|
|
655
|
+
FfiConverterUInt32.write(value.contextUsed, into);
|
|
666
656
|
}
|
|
667
657
|
allocationSize(value: TypeName): number {
|
|
668
|
-
return
|
|
669
|
-
|
|
658
|
+
return FfiConverterUInt32.allocationSize(value.contextSize) +
|
|
659
|
+
FfiConverterUInt32.allocationSize(value.contextUsed);
|
|
670
660
|
|
|
671
661
|
}
|
|
672
662
|
};
|
|
@@ -674,29 +664,47 @@ const FfiConverterTypeCachedModel = (() => {
|
|
|
674
664
|
})();
|
|
675
665
|
|
|
676
666
|
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
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
|
|
680
688
|
}
|
|
681
689
|
|
|
682
690
|
/**
|
|
683
|
-
* Generated factory for {@link
|
|
691
|
+
* Generated factory for {@link ContextShiftOptions} record objects.
|
|
684
692
|
*/
|
|
685
|
-
export const
|
|
686
|
-
const defaults = () => ({
|
|
693
|
+
export const ContextShiftOptions = (() => {
|
|
694
|
+
const defaults = () => ({enabled: true,keepFirstTurns: 1,keepLastTurns: 2,target: undefined
|
|
687
695
|
});
|
|
688
696
|
const create = (() => {
|
|
689
|
-
return uniffiCreateRecord<
|
|
697
|
+
return uniffiCreateRecord<ContextShiftOptions, ReturnType<typeof defaults>>(defaults);
|
|
690
698
|
})();
|
|
691
699
|
return Object.freeze({
|
|
692
700
|
/**
|
|
693
|
-
* Create a frozen instance of {@link
|
|
701
|
+
* Create a frozen instance of {@link ContextShiftOptions}, with defaults specified
|
|
694
702
|
* in Rust, in the {@link nobodywho} crate.
|
|
695
703
|
*/
|
|
696
704
|
create,
|
|
697
705
|
|
|
698
706
|
/**
|
|
699
|
-
* Create a frozen instance of {@link
|
|
707
|
+
* Create a frozen instance of {@link ContextShiftOptions}, with defaults specified
|
|
700
708
|
* in Rust, in the {@link nobodywho} crate.
|
|
701
709
|
*/
|
|
702
710
|
new: create,
|
|
@@ -704,27 +712,33 @@ export const ChatStats = (() => {
|
|
|
704
712
|
/**
|
|
705
713
|
* Defaults specified in the {@link nobodywho} crate.
|
|
706
714
|
*/
|
|
707
|
-
defaults: () => Object.freeze(defaults()) as Partial<
|
|
715
|
+
defaults: () => Object.freeze(defaults()) as Partial<ContextShiftOptions>,
|
|
708
716
|
|
|
709
717
|
});
|
|
710
718
|
})();
|
|
711
719
|
|
|
712
|
-
const
|
|
713
|
-
type TypeName =
|
|
720
|
+
const FfiConverterTypeContextShiftOptions = (() => {
|
|
721
|
+
type TypeName = ContextShiftOptions;
|
|
714
722
|
class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
|
|
715
723
|
read(from: RustBuffer): TypeName {
|
|
716
724
|
return {
|
|
717
|
-
|
|
718
|
-
|
|
725
|
+
enabled: FfiConverterBool.read(from),
|
|
726
|
+
keepFirstTurns: FfiConverterUInt32.read(from),
|
|
727
|
+
keepLastTurns: FfiConverterUInt32.read(from),
|
|
728
|
+
target: FfiConverterOptionalTypeShiftTarget.read(from)
|
|
719
729
|
};
|
|
720
730
|
}
|
|
721
731
|
write(value: TypeName, into: RustBuffer): void {
|
|
722
|
-
|
|
723
|
-
FfiConverterUInt32.write(value.
|
|
732
|
+
FfiConverterBool.write(value.enabled, into);
|
|
733
|
+
FfiConverterUInt32.write(value.keepFirstTurns, into);
|
|
734
|
+
FfiConverterUInt32.write(value.keepLastTurns, into);
|
|
735
|
+
FfiConverterOptionalTypeShiftTarget.write(value.target, into);
|
|
724
736
|
}
|
|
725
737
|
allocationSize(value: TypeName): number {
|
|
726
|
-
return
|
|
727
|
-
FfiConverterUInt32.allocationSize(value.
|
|
738
|
+
return FfiConverterBool.allocationSize(value.enabled) +
|
|
739
|
+
FfiConverterUInt32.allocationSize(value.keepFirstTurns) +
|
|
740
|
+
FfiConverterUInt32.allocationSize(value.keepLastTurns) +
|
|
741
|
+
FfiConverterOptionalTypeShiftTarget.allocationSize(value.target);
|
|
728
742
|
|
|
729
743
|
}
|
|
730
744
|
};
|
|
@@ -804,6 +818,79 @@ const FfiConverterTypeMtpConfig = (() => {
|
|
|
804
818
|
})();
|
|
805
819
|
|
|
806
820
|
|
|
821
|
+
/**
|
|
822
|
+
* Settings to apply before a `complete` turn. An unset field keeps what the
|
|
823
|
+
* chat has; a set one stays set, like a leading system message.
|
|
824
|
+
*/
|
|
825
|
+
export type Options = {
|
|
826
|
+
sampler: SamplerConfigInterface | undefined,
|
|
827
|
+
/**
|
|
828
|
+
* Replaces the chat's template variables wholesale.
|
|
829
|
+
*/
|
|
830
|
+
templateVariables: Map<string, boolean> | undefined,
|
|
831
|
+
/**
|
|
832
|
+
* Re-selects the chat template, so the turn re-prefills from near token
|
|
833
|
+
* zero. An empty list removes the tools.
|
|
834
|
+
*/
|
|
835
|
+
tools: Array<RustToolInterface> | undefined
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
/**
|
|
839
|
+
* Generated factory for {@link Options} record objects.
|
|
840
|
+
*/
|
|
841
|
+
export const Options = (() => {
|
|
842
|
+
const defaults = () => ({sampler: undefined,templateVariables: undefined,tools: undefined
|
|
843
|
+
});
|
|
844
|
+
const create = (() => {
|
|
845
|
+
return uniffiCreateRecord<Options, ReturnType<typeof defaults>>(defaults);
|
|
846
|
+
})();
|
|
847
|
+
return Object.freeze({
|
|
848
|
+
/**
|
|
849
|
+
* Create a frozen instance of {@link Options}, with defaults specified
|
|
850
|
+
* in Rust, in the {@link nobodywho} crate.
|
|
851
|
+
*/
|
|
852
|
+
create,
|
|
853
|
+
|
|
854
|
+
/**
|
|
855
|
+
* Create a frozen instance of {@link Options}, with defaults specified
|
|
856
|
+
* in Rust, in the {@link nobodywho} crate.
|
|
857
|
+
*/
|
|
858
|
+
new: create,
|
|
859
|
+
|
|
860
|
+
/**
|
|
861
|
+
* Defaults specified in the {@link nobodywho} crate.
|
|
862
|
+
*/
|
|
863
|
+
defaults: () => Object.freeze(defaults()) as Partial<Options>,
|
|
864
|
+
|
|
865
|
+
});
|
|
866
|
+
})();
|
|
867
|
+
|
|
868
|
+
const FfiConverterTypeOptions = (() => {
|
|
869
|
+
type TypeName = Options;
|
|
870
|
+
class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
|
|
871
|
+
read(from: RustBuffer): TypeName {
|
|
872
|
+
return {
|
|
873
|
+
sampler: FfiConverterOptionalTypeSamplerConfig.read(from),
|
|
874
|
+
templateVariables: FfiConverterOptionalMapStringBool.read(from),
|
|
875
|
+
tools: FfiConverterOptionalArrayTypeRustTool.read(from)
|
|
876
|
+
};
|
|
877
|
+
}
|
|
878
|
+
write(value: TypeName, into: RustBuffer): void {
|
|
879
|
+
FfiConverterOptionalTypeSamplerConfig.write(value.sampler, into);
|
|
880
|
+
FfiConverterOptionalMapStringBool.write(value.templateVariables, into);
|
|
881
|
+
FfiConverterOptionalArrayTypeRustTool.write(value.tools, into);
|
|
882
|
+
}
|
|
883
|
+
allocationSize(value: TypeName): number {
|
|
884
|
+
return FfiConverterOptionalTypeSamplerConfig.allocationSize(value.sampler) +
|
|
885
|
+
FfiConverterOptionalMapStringBool.allocationSize(value.templateVariables) +
|
|
886
|
+
FfiConverterOptionalArrayTypeRustTool.allocationSize(value.tools);
|
|
887
|
+
|
|
888
|
+
}
|
|
889
|
+
};
|
|
890
|
+
return new FFIConverter();
|
|
891
|
+
})();
|
|
892
|
+
|
|
893
|
+
|
|
807
894
|
/**
|
|
808
895
|
* A pending tool call waiting for resolution from the language binding.
|
|
809
896
|
*/
|
|
@@ -999,6 +1086,209 @@ const FfiConverterString = uniffiCreateFfiConverterString(stringConverter);
|
|
|
999
1086
|
|
|
1000
1087
|
|
|
1001
1088
|
|
|
1089
|
+
// Enum: ContentPart
|
|
1090
|
+
export enum ContentPart_Tags {
|
|
1091
|
+
Text = "Text",
|
|
1092
|
+
Image = "Image",
|
|
1093
|
+
Audio = "Audio"
|
|
1094
|
+
}
|
|
1095
|
+
/**
|
|
1096
|
+
* One piece of a message: a run of text, or a media file at this position.
|
|
1097
|
+
* The core type's bitmap id is worker-local, so it is not mirrored — media is
|
|
1098
|
+
* re-registered from the path whenever content is handed back in.
|
|
1099
|
+
*/
|
|
1100
|
+
export const ContentPart = (() => {
|
|
1101
|
+
|
|
1102
|
+
|
|
1103
|
+
type Text__interface = {
|
|
1104
|
+
tag: ContentPart_Tags.Text;
|
|
1105
|
+
inner: Readonly<{text: string}>
|
|
1106
|
+
};
|
|
1107
|
+
|
|
1108
|
+
|
|
1109
|
+
class Text_ extends UniffiEnum implements Text__interface {
|
|
1110
|
+
/**
|
|
1111
|
+
* @private
|
|
1112
|
+
* This field is private and should not be used, use `tag` instead.
|
|
1113
|
+
*/
|
|
1114
|
+
readonly [uniffiTypeNameSymbol] = "ContentPart";
|
|
1115
|
+
readonly tag = ContentPart_Tags.Text;
|
|
1116
|
+
readonly inner: Readonly<{text: string}>;
|
|
1117
|
+
constructor(inner: { text: string }) {
|
|
1118
|
+
super("ContentPart", "Text");
|
|
1119
|
+
this.inner = Object.freeze(inner);
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
static new(inner: { text: string }): Text_ {
|
|
1123
|
+
return new Text_(inner);
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
static instanceOf(obj: any): obj is Text_ {
|
|
1127
|
+
return obj.tag === ContentPart_Tags.Text;
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
|
|
1131
|
+
|
|
1132
|
+
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
|
|
1136
|
+
type Image__interface = {
|
|
1137
|
+
tag: ContentPart_Tags.Image;
|
|
1138
|
+
inner: Readonly<{path: string}>
|
|
1139
|
+
};
|
|
1140
|
+
|
|
1141
|
+
|
|
1142
|
+
class Image_ extends UniffiEnum implements Image__interface {
|
|
1143
|
+
/**
|
|
1144
|
+
* @private
|
|
1145
|
+
* This field is private and should not be used, use `tag` instead.
|
|
1146
|
+
*/
|
|
1147
|
+
readonly [uniffiTypeNameSymbol] = "ContentPart";
|
|
1148
|
+
readonly tag = ContentPart_Tags.Image;
|
|
1149
|
+
readonly inner: Readonly<{path: string}>;
|
|
1150
|
+
constructor(inner: { path: string }) {
|
|
1151
|
+
super("ContentPart", "Image");
|
|
1152
|
+
this.inner = Object.freeze(inner);
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
static new(inner: { path: string }): Image_ {
|
|
1156
|
+
return new Image_(inner);
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
static instanceOf(obj: any): obj is Image_ {
|
|
1160
|
+
return obj.tag === ContentPart_Tags.Image;
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
|
|
1164
|
+
|
|
1165
|
+
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
|
|
1169
|
+
type Audio__interface = {
|
|
1170
|
+
tag: ContentPart_Tags.Audio;
|
|
1171
|
+
inner: Readonly<{path: string}>
|
|
1172
|
+
};
|
|
1173
|
+
|
|
1174
|
+
|
|
1175
|
+
class Audio_ extends UniffiEnum implements Audio__interface {
|
|
1176
|
+
/**
|
|
1177
|
+
* @private
|
|
1178
|
+
* This field is private and should not be used, use `tag` instead.
|
|
1179
|
+
*/
|
|
1180
|
+
readonly [uniffiTypeNameSymbol] = "ContentPart";
|
|
1181
|
+
readonly tag = ContentPart_Tags.Audio;
|
|
1182
|
+
readonly inner: Readonly<{path: string}>;
|
|
1183
|
+
constructor(inner: { path: string }) {
|
|
1184
|
+
super("ContentPart", "Audio");
|
|
1185
|
+
this.inner = Object.freeze(inner);
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
static new(inner: { path: string }): Audio_ {
|
|
1189
|
+
return new Audio_(inner);
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
static instanceOf(obj: any): obj is Audio_ {
|
|
1193
|
+
return obj.tag === ContentPart_Tags.Audio;
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
|
|
1197
|
+
|
|
1198
|
+
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
function instanceOf(obj: any): obj is ContentPart {
|
|
1202
|
+
return obj[uniffiTypeNameSymbol] === "ContentPart";
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
return Object.freeze({
|
|
1206
|
+
instanceOf,
|
|
1207
|
+
Text: Text_,
|
|
1208
|
+
Image: Image_,
|
|
1209
|
+
Audio: Audio_
|
|
1210
|
+
});
|
|
1211
|
+
|
|
1212
|
+
})();
|
|
1213
|
+
|
|
1214
|
+
|
|
1215
|
+
/**
|
|
1216
|
+
* One piece of a message: a run of text, or a media file at this position.
|
|
1217
|
+
* The core type's bitmap id is worker-local, so it is not mirrored — media is
|
|
1218
|
+
* re-registered from the path whenever content is handed back in.
|
|
1219
|
+
*/
|
|
1220
|
+
|
|
1221
|
+
export type ContentPart = InstanceType<
|
|
1222
|
+
typeof ContentPart[keyof Omit<typeof ContentPart, 'instanceOf'>]
|
|
1223
|
+
>;
|
|
1224
|
+
|
|
1225
|
+
// FfiConverter for enum ContentPart
|
|
1226
|
+
const FfiConverterTypeContentPart = (() => {
|
|
1227
|
+
const ordinalConverter = FfiConverterInt32;
|
|
1228
|
+
type TypeName = ContentPart;
|
|
1229
|
+
class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
|
|
1230
|
+
read(from: RustBuffer): TypeName {
|
|
1231
|
+
switch (ordinalConverter.read(from)) {
|
|
1232
|
+
case 1: return new ContentPart.Text({text: FfiConverterString.read(from) });
|
|
1233
|
+
case 2: return new ContentPart.Image({path: FfiConverterString.read(from) });
|
|
1234
|
+
case 3: return new ContentPart.Audio({path: FfiConverterString.read(from) });
|
|
1235
|
+
default: throw new UniffiInternalError.UnexpectedEnumCase();
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
write(value: TypeName, into: RustBuffer): void {
|
|
1239
|
+
switch (value.tag) {
|
|
1240
|
+
case ContentPart_Tags.Text: {
|
|
1241
|
+
ordinalConverter.write(1, into);
|
|
1242
|
+
const inner = value.inner;
|
|
1243
|
+
FfiConverterString.write(inner.text, into);
|
|
1244
|
+
return;
|
|
1245
|
+
}
|
|
1246
|
+
case ContentPart_Tags.Image: {
|
|
1247
|
+
ordinalConverter.write(2, into);
|
|
1248
|
+
const inner = value.inner;
|
|
1249
|
+
FfiConverterString.write(inner.path, into);
|
|
1250
|
+
return;
|
|
1251
|
+
}
|
|
1252
|
+
case ContentPart_Tags.Audio: {
|
|
1253
|
+
ordinalConverter.write(3, into);
|
|
1254
|
+
const inner = value.inner;
|
|
1255
|
+
FfiConverterString.write(inner.path, into);
|
|
1256
|
+
return;
|
|
1257
|
+
}
|
|
1258
|
+
default:
|
|
1259
|
+
// Throwing from here means that ContentPart_Tags hasn't matched an ordinal.
|
|
1260
|
+
throw new UniffiInternalError.UnexpectedEnumCase();
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
allocationSize(value: TypeName): number {
|
|
1264
|
+
switch (value.tag) {
|
|
1265
|
+
case ContentPart_Tags.Text: {
|
|
1266
|
+
const inner = value.inner;
|
|
1267
|
+
let size = ordinalConverter.allocationSize(1);
|
|
1268
|
+
size += FfiConverterString.allocationSize(inner.text);
|
|
1269
|
+
return size;
|
|
1270
|
+
}
|
|
1271
|
+
case ContentPart_Tags.Image: {
|
|
1272
|
+
const inner = value.inner;
|
|
1273
|
+
let size = ordinalConverter.allocationSize(2);
|
|
1274
|
+
size += FfiConverterString.allocationSize(inner.path);
|
|
1275
|
+
return size;
|
|
1276
|
+
}
|
|
1277
|
+
case ContentPart_Tags.Audio: {
|
|
1278
|
+
const inner = value.inner;
|
|
1279
|
+
let size = ordinalConverter.allocationSize(3);
|
|
1280
|
+
size += FfiConverterString.allocationSize(inner.path);
|
|
1281
|
+
return size;
|
|
1282
|
+
}
|
|
1283
|
+
default: throw new UniffiInternalError.UnexpectedEnumCase();
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
return new FFIConverter();
|
|
1288
|
+
})();
|
|
1289
|
+
|
|
1290
|
+
|
|
1291
|
+
|
|
1002
1292
|
// Enum: Message
|
|
1003
1293
|
export enum Message_Tags {
|
|
1004
1294
|
User = "User",
|
|
@@ -1011,7 +1301,7 @@ export const Message = (() => {
|
|
|
1011
1301
|
|
|
1012
1302
|
type User__interface = {
|
|
1013
1303
|
tag: Message_Tags.User;
|
|
1014
|
-
inner: Readonly<{content:
|
|
1304
|
+
inner: Readonly<{content: MessageContent}>
|
|
1015
1305
|
};
|
|
1016
1306
|
|
|
1017
1307
|
|
|
@@ -1022,13 +1312,13 @@ export const Message = (() => {
|
|
|
1022
1312
|
*/
|
|
1023
1313
|
readonly [uniffiTypeNameSymbol] = "Message";
|
|
1024
1314
|
readonly tag = Message_Tags.User;
|
|
1025
|
-
readonly inner: Readonly<{content:
|
|
1026
|
-
constructor(inner: { content:
|
|
1315
|
+
readonly inner: Readonly<{content: MessageContent}>;
|
|
1316
|
+
constructor(inner: { content: MessageContent }) {
|
|
1027
1317
|
super("Message", "User");
|
|
1028
1318
|
this.inner = Object.freeze(inner);
|
|
1029
1319
|
}
|
|
1030
1320
|
|
|
1031
|
-
static new(inner: { content:
|
|
1321
|
+
static new(inner: { content: MessageContent }): User_ {
|
|
1032
1322
|
return new User_(inner);
|
|
1033
1323
|
}
|
|
1034
1324
|
|
|
@@ -1044,7 +1334,7 @@ export const Message = (() => {
|
|
|
1044
1334
|
|
|
1045
1335
|
type Assistant__interface = {
|
|
1046
1336
|
tag: Message_Tags.Assistant;
|
|
1047
|
-
inner: Readonly<{content:
|
|
1337
|
+
inner: Readonly<{content: MessageContent; toolCalls: Array<ToolCall> | undefined}>
|
|
1048
1338
|
};
|
|
1049
1339
|
|
|
1050
1340
|
|
|
@@ -1055,13 +1345,13 @@ export const Message = (() => {
|
|
|
1055
1345
|
*/
|
|
1056
1346
|
readonly [uniffiTypeNameSymbol] = "Message";
|
|
1057
1347
|
readonly tag = Message_Tags.Assistant;
|
|
1058
|
-
readonly inner: Readonly<{content:
|
|
1059
|
-
constructor(inner: { content:
|
|
1348
|
+
readonly inner: Readonly<{content: MessageContent; toolCalls: Array<ToolCall> | undefined}>;
|
|
1349
|
+
constructor(inner: { content: MessageContent, toolCalls: Array<ToolCall> | undefined }) {
|
|
1060
1350
|
super("Message", "Assistant");
|
|
1061
1351
|
this.inner = Object.freeze(inner);
|
|
1062
1352
|
}
|
|
1063
1353
|
|
|
1064
|
-
static new(inner: { content:
|
|
1354
|
+
static new(inner: { content: MessageContent, toolCalls: Array<ToolCall> | undefined }): Assistant_ {
|
|
1065
1355
|
return new Assistant_(inner);
|
|
1066
1356
|
}
|
|
1067
1357
|
|
|
@@ -1077,7 +1367,7 @@ export const Message = (() => {
|
|
|
1077
1367
|
|
|
1078
1368
|
type System__interface = {
|
|
1079
1369
|
tag: Message_Tags.System;
|
|
1080
|
-
inner: Readonly<{content:
|
|
1370
|
+
inner: Readonly<{content: MessageContent}>
|
|
1081
1371
|
};
|
|
1082
1372
|
|
|
1083
1373
|
|
|
@@ -1088,13 +1378,13 @@ export const Message = (() => {
|
|
|
1088
1378
|
*/
|
|
1089
1379
|
readonly [uniffiTypeNameSymbol] = "Message";
|
|
1090
1380
|
readonly tag = Message_Tags.System;
|
|
1091
|
-
readonly inner: Readonly<{content:
|
|
1092
|
-
constructor(inner: { content:
|
|
1381
|
+
readonly inner: Readonly<{content: MessageContent}>;
|
|
1382
|
+
constructor(inner: { content: MessageContent }) {
|
|
1093
1383
|
super("Message", "System");
|
|
1094
1384
|
this.inner = Object.freeze(inner);
|
|
1095
1385
|
}
|
|
1096
1386
|
|
|
1097
|
-
static new(inner: { content:
|
|
1387
|
+
static new(inner: { content: MessageContent }): System_ {
|
|
1098
1388
|
return new System_(inner);
|
|
1099
1389
|
}
|
|
1100
1390
|
|
|
@@ -1110,7 +1400,7 @@ export const Message = (() => {
|
|
|
1110
1400
|
|
|
1111
1401
|
type Tool__interface = {
|
|
1112
1402
|
tag: Message_Tags.Tool;
|
|
1113
|
-
inner: Readonly<{name: string; content:
|
|
1403
|
+
inner: Readonly<{name: string; content: MessageContent}>
|
|
1114
1404
|
};
|
|
1115
1405
|
|
|
1116
1406
|
|
|
@@ -1121,13 +1411,13 @@ export const Message = (() => {
|
|
|
1121
1411
|
*/
|
|
1122
1412
|
readonly [uniffiTypeNameSymbol] = "Message";
|
|
1123
1413
|
readonly tag = Message_Tags.Tool;
|
|
1124
|
-
readonly inner: Readonly<{name: string; content:
|
|
1125
|
-
constructor(inner: { name: string, content:
|
|
1414
|
+
readonly inner: Readonly<{name: string; content: MessageContent}>;
|
|
1415
|
+
constructor(inner: { name: string, content: MessageContent }) {
|
|
1126
1416
|
super("Message", "Tool");
|
|
1127
1417
|
this.inner = Object.freeze(inner);
|
|
1128
1418
|
}
|
|
1129
1419
|
|
|
1130
|
-
static new(inner: { name: string, content:
|
|
1420
|
+
static new(inner: { name: string, content: MessageContent }): Tool_ {
|
|
1131
1421
|
return new Tool_(inner);
|
|
1132
1422
|
}
|
|
1133
1423
|
|
|
@@ -1140,101 +1430,296 @@ export const Message = (() => {
|
|
|
1140
1430
|
|
|
1141
1431
|
}
|
|
1142
1432
|
|
|
1143
|
-
function instanceOf(obj: any): obj is Message {
|
|
1144
|
-
return obj[uniffiTypeNameSymbol] === "Message";
|
|
1433
|
+
function instanceOf(obj: any): obj is Message {
|
|
1434
|
+
return obj[uniffiTypeNameSymbol] === "Message";
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1437
|
+
return Object.freeze({
|
|
1438
|
+
instanceOf,
|
|
1439
|
+
User: User_,
|
|
1440
|
+
Assistant: Assistant_,
|
|
1441
|
+
System: System_,
|
|
1442
|
+
Tool: Tool_
|
|
1443
|
+
});
|
|
1444
|
+
|
|
1445
|
+
})();
|
|
1446
|
+
|
|
1447
|
+
|
|
1448
|
+
|
|
1449
|
+
export type Message = InstanceType<
|
|
1450
|
+
typeof Message[keyof Omit<typeof Message, 'instanceOf'>]
|
|
1451
|
+
>;
|
|
1452
|
+
|
|
1453
|
+
// FfiConverter for enum Message
|
|
1454
|
+
const FfiConverterTypeMessage = (() => {
|
|
1455
|
+
const ordinalConverter = FfiConverterInt32;
|
|
1456
|
+
type TypeName = Message;
|
|
1457
|
+
class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
|
|
1458
|
+
read(from: RustBuffer): TypeName {
|
|
1459
|
+
switch (ordinalConverter.read(from)) {
|
|
1460
|
+
case 1: return new Message.User({content: FfiConverterTypeMessageContent.read(from) });
|
|
1461
|
+
case 2: return new Message.Assistant({content: FfiConverterTypeMessageContent.read(from), toolCalls: FfiConverterOptionalArrayTypeToolCall.read(from) });
|
|
1462
|
+
case 3: return new Message.System({content: FfiConverterTypeMessageContent.read(from) });
|
|
1463
|
+
case 4: return new Message.Tool({name: FfiConverterString.read(from), content: FfiConverterTypeMessageContent.read(from) });
|
|
1464
|
+
default: throw new UniffiInternalError.UnexpectedEnumCase();
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
write(value: TypeName, into: RustBuffer): void {
|
|
1468
|
+
switch (value.tag) {
|
|
1469
|
+
case Message_Tags.User: {
|
|
1470
|
+
ordinalConverter.write(1, into);
|
|
1471
|
+
const inner = value.inner;
|
|
1472
|
+
FfiConverterTypeMessageContent.write(inner.content, into);
|
|
1473
|
+
return;
|
|
1474
|
+
}
|
|
1475
|
+
case Message_Tags.Assistant: {
|
|
1476
|
+
ordinalConverter.write(2, into);
|
|
1477
|
+
const inner = value.inner;
|
|
1478
|
+
FfiConverterTypeMessageContent.write(inner.content, into);
|
|
1479
|
+
FfiConverterOptionalArrayTypeToolCall.write(inner.toolCalls, into);
|
|
1480
|
+
return;
|
|
1481
|
+
}
|
|
1482
|
+
case Message_Tags.System: {
|
|
1483
|
+
ordinalConverter.write(3, into);
|
|
1484
|
+
const inner = value.inner;
|
|
1485
|
+
FfiConverterTypeMessageContent.write(inner.content, into);
|
|
1486
|
+
return;
|
|
1487
|
+
}
|
|
1488
|
+
case Message_Tags.Tool: {
|
|
1489
|
+
ordinalConverter.write(4, into);
|
|
1490
|
+
const inner = value.inner;
|
|
1491
|
+
FfiConverterString.write(inner.name, into);
|
|
1492
|
+
FfiConverterTypeMessageContent.write(inner.content, into);
|
|
1493
|
+
return;
|
|
1494
|
+
}
|
|
1495
|
+
default:
|
|
1496
|
+
// Throwing from here means that Message_Tags hasn't matched an ordinal.
|
|
1497
|
+
throw new UniffiInternalError.UnexpectedEnumCase();
|
|
1498
|
+
}
|
|
1499
|
+
}
|
|
1500
|
+
allocationSize(value: TypeName): number {
|
|
1501
|
+
switch (value.tag) {
|
|
1502
|
+
case Message_Tags.User: {
|
|
1503
|
+
const inner = value.inner;
|
|
1504
|
+
let size = ordinalConverter.allocationSize(1);
|
|
1505
|
+
size += FfiConverterTypeMessageContent.allocationSize(inner.content);
|
|
1506
|
+
return size;
|
|
1507
|
+
}
|
|
1508
|
+
case Message_Tags.Assistant: {
|
|
1509
|
+
const inner = value.inner;
|
|
1510
|
+
let size = ordinalConverter.allocationSize(2);
|
|
1511
|
+
size += FfiConverterTypeMessageContent.allocationSize(inner.content);
|
|
1512
|
+
size += FfiConverterOptionalArrayTypeToolCall.allocationSize(inner.toolCalls);
|
|
1513
|
+
return size;
|
|
1514
|
+
}
|
|
1515
|
+
case Message_Tags.System: {
|
|
1516
|
+
const inner = value.inner;
|
|
1517
|
+
let size = ordinalConverter.allocationSize(3);
|
|
1518
|
+
size += FfiConverterTypeMessageContent.allocationSize(inner.content);
|
|
1519
|
+
return size;
|
|
1520
|
+
}
|
|
1521
|
+
case Message_Tags.Tool: {
|
|
1522
|
+
const inner = value.inner;
|
|
1523
|
+
let size = ordinalConverter.allocationSize(4);
|
|
1524
|
+
size += FfiConverterString.allocationSize(inner.name);
|
|
1525
|
+
size += FfiConverterTypeMessageContent.allocationSize(inner.content);
|
|
1526
|
+
return size;
|
|
1527
|
+
}
|
|
1528
|
+
default: throw new UniffiInternalError.UnexpectedEnumCase();
|
|
1529
|
+
}
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
return new FFIConverter();
|
|
1533
|
+
})();
|
|
1534
|
+
|
|
1535
|
+
|
|
1536
|
+
|
|
1537
|
+
// Enum: MessageContent
|
|
1538
|
+
export enum MessageContent_Tags {
|
|
1539
|
+
Text = "Text",
|
|
1540
|
+
Parts = "Parts",
|
|
1541
|
+
Json = "Json"
|
|
1542
|
+
}
|
|
1543
|
+
export const MessageContent = (() => {
|
|
1544
|
+
|
|
1545
|
+
|
|
1546
|
+
type Text__interface = {
|
|
1547
|
+
tag: MessageContent_Tags.Text;
|
|
1548
|
+
inner: Readonly<{text: string}>
|
|
1549
|
+
};
|
|
1550
|
+
|
|
1551
|
+
|
|
1552
|
+
class Text_ extends UniffiEnum implements Text__interface {
|
|
1553
|
+
/**
|
|
1554
|
+
* @private
|
|
1555
|
+
* This field is private and should not be used, use `tag` instead.
|
|
1556
|
+
*/
|
|
1557
|
+
readonly [uniffiTypeNameSymbol] = "MessageContent";
|
|
1558
|
+
readonly tag = MessageContent_Tags.Text;
|
|
1559
|
+
readonly inner: Readonly<{text: string}>;
|
|
1560
|
+
constructor(inner: { text: string }) {
|
|
1561
|
+
super("MessageContent", "Text");
|
|
1562
|
+
this.inner = Object.freeze(inner);
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1565
|
+
static new(inner: { text: string }): Text_ {
|
|
1566
|
+
return new Text_(inner);
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1569
|
+
static instanceOf(obj: any): obj is Text_ {
|
|
1570
|
+
return obj.tag === MessageContent_Tags.Text;
|
|
1571
|
+
}
|
|
1572
|
+
|
|
1573
|
+
|
|
1574
|
+
|
|
1575
|
+
|
|
1576
|
+
}
|
|
1577
|
+
|
|
1578
|
+
|
|
1579
|
+
type Parts__interface = {
|
|
1580
|
+
tag: MessageContent_Tags.Parts;
|
|
1581
|
+
inner: Readonly<{parts: Array<ContentPart>}>
|
|
1582
|
+
};
|
|
1583
|
+
|
|
1584
|
+
|
|
1585
|
+
class Parts_ extends UniffiEnum implements Parts__interface {
|
|
1586
|
+
/**
|
|
1587
|
+
* @private
|
|
1588
|
+
* This field is private and should not be used, use `tag` instead.
|
|
1589
|
+
*/
|
|
1590
|
+
readonly [uniffiTypeNameSymbol] = "MessageContent";
|
|
1591
|
+
readonly tag = MessageContent_Tags.Parts;
|
|
1592
|
+
readonly inner: Readonly<{parts: Array<ContentPart>}>;
|
|
1593
|
+
constructor(inner: { parts: Array<ContentPart> }) {
|
|
1594
|
+
super("MessageContent", "Parts");
|
|
1595
|
+
this.inner = Object.freeze(inner);
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1598
|
+
static new(inner: { parts: Array<ContentPart> }): Parts_ {
|
|
1599
|
+
return new Parts_(inner);
|
|
1600
|
+
}
|
|
1601
|
+
|
|
1602
|
+
static instanceOf(obj: any): obj is Parts_ {
|
|
1603
|
+
return obj.tag === MessageContent_Tags.Parts;
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
|
|
1607
|
+
|
|
1608
|
+
|
|
1609
|
+
}
|
|
1610
|
+
|
|
1611
|
+
|
|
1612
|
+
type Json__interface = {
|
|
1613
|
+
tag: MessageContent_Tags.Json;
|
|
1614
|
+
inner: Readonly<{json: string}>
|
|
1615
|
+
};
|
|
1616
|
+
|
|
1617
|
+
|
|
1618
|
+
/**
|
|
1619
|
+
* JSON-encoded. Chat templates written for structured content receive it
|
|
1620
|
+
* as a real list or map rather than as a string.
|
|
1621
|
+
*/
|
|
1622
|
+
class Json_ extends UniffiEnum implements Json__interface {
|
|
1623
|
+
/**
|
|
1624
|
+
* @private
|
|
1625
|
+
* This field is private and should not be used, use `tag` instead.
|
|
1626
|
+
*/
|
|
1627
|
+
readonly [uniffiTypeNameSymbol] = "MessageContent";
|
|
1628
|
+
readonly tag = MessageContent_Tags.Json;
|
|
1629
|
+
readonly inner: Readonly<{json: string}>;
|
|
1630
|
+
constructor(inner: { json: string }) {
|
|
1631
|
+
super("MessageContent", "Json");
|
|
1632
|
+
this.inner = Object.freeze(inner);
|
|
1633
|
+
}
|
|
1634
|
+
|
|
1635
|
+
static new(inner: { json: string }): Json_ {
|
|
1636
|
+
return new Json_(inner);
|
|
1637
|
+
}
|
|
1638
|
+
|
|
1639
|
+
static instanceOf(obj: any): obj is Json_ {
|
|
1640
|
+
return obj.tag === MessageContent_Tags.Json;
|
|
1641
|
+
}
|
|
1642
|
+
|
|
1643
|
+
|
|
1644
|
+
|
|
1645
|
+
|
|
1646
|
+
}
|
|
1647
|
+
|
|
1648
|
+
function instanceOf(obj: any): obj is MessageContent {
|
|
1649
|
+
return obj[uniffiTypeNameSymbol] === "MessageContent";
|
|
1145
1650
|
}
|
|
1146
1651
|
|
|
1147
1652
|
return Object.freeze({
|
|
1148
1653
|
instanceOf,
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
Tool: Tool_
|
|
1654
|
+
Text: Text_,
|
|
1655
|
+
Parts: Parts_,
|
|
1656
|
+
Json: Json_
|
|
1153
1657
|
});
|
|
1154
1658
|
|
|
1155
1659
|
})();
|
|
1156
1660
|
|
|
1157
1661
|
|
|
1158
1662
|
|
|
1159
|
-
export type
|
|
1160
|
-
typeof
|
|
1663
|
+
export type MessageContent = InstanceType<
|
|
1664
|
+
typeof MessageContent[keyof Omit<typeof MessageContent, 'instanceOf'>]
|
|
1161
1665
|
>;
|
|
1162
1666
|
|
|
1163
|
-
// FfiConverter for enum
|
|
1164
|
-
const
|
|
1667
|
+
// FfiConverter for enum MessageContent
|
|
1668
|
+
const FfiConverterTypeMessageContent = (() => {
|
|
1165
1669
|
const ordinalConverter = FfiConverterInt32;
|
|
1166
|
-
type TypeName =
|
|
1670
|
+
type TypeName = MessageContent;
|
|
1167
1671
|
class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
|
|
1168
1672
|
read(from: RustBuffer): TypeName {
|
|
1169
1673
|
switch (ordinalConverter.read(from)) {
|
|
1170
|
-
case 1: return new
|
|
1171
|
-
case 2: return new
|
|
1172
|
-
case 3: return new
|
|
1173
|
-
case 4: return new Message.Tool({name: FfiConverterString.read(from), content: FfiConverterString.read(from) });
|
|
1674
|
+
case 1: return new MessageContent.Text({text: FfiConverterString.read(from) });
|
|
1675
|
+
case 2: return new MessageContent.Parts({parts: FfiConverterArrayTypeContentPart.read(from) });
|
|
1676
|
+
case 3: return new MessageContent.Json({json: FfiConverterString.read(from) });
|
|
1174
1677
|
default: throw new UniffiInternalError.UnexpectedEnumCase();
|
|
1175
1678
|
}
|
|
1176
1679
|
}
|
|
1177
1680
|
write(value: TypeName, into: RustBuffer): void {
|
|
1178
1681
|
switch (value.tag) {
|
|
1179
|
-
case
|
|
1682
|
+
case MessageContent_Tags.Text: {
|
|
1180
1683
|
ordinalConverter.write(1, into);
|
|
1181
1684
|
const inner = value.inner;
|
|
1182
|
-
FfiConverterString.write(inner.
|
|
1183
|
-
FfiConverterArrayTypeAsset.write(inner.assets, into);
|
|
1685
|
+
FfiConverterString.write(inner.text, into);
|
|
1184
1686
|
return;
|
|
1185
1687
|
}
|
|
1186
|
-
case
|
|
1688
|
+
case MessageContent_Tags.Parts: {
|
|
1187
1689
|
ordinalConverter.write(2, into);
|
|
1188
1690
|
const inner = value.inner;
|
|
1189
|
-
|
|
1190
|
-
FfiConverterOptionalArrayTypeToolCall.write(inner.toolCalls, into);
|
|
1691
|
+
FfiConverterArrayTypeContentPart.write(inner.parts, into);
|
|
1191
1692
|
return;
|
|
1192
1693
|
}
|
|
1193
|
-
case
|
|
1694
|
+
case MessageContent_Tags.Json: {
|
|
1194
1695
|
ordinalConverter.write(3, into);
|
|
1195
1696
|
const inner = value.inner;
|
|
1196
|
-
FfiConverterString.write(inner.
|
|
1197
|
-
return;
|
|
1198
|
-
}
|
|
1199
|
-
case Message_Tags.Tool: {
|
|
1200
|
-
ordinalConverter.write(4, into);
|
|
1201
|
-
const inner = value.inner;
|
|
1202
|
-
FfiConverterString.write(inner.name, into);
|
|
1203
|
-
FfiConverterString.write(inner.content, into);
|
|
1697
|
+
FfiConverterString.write(inner.json, into);
|
|
1204
1698
|
return;
|
|
1205
1699
|
}
|
|
1206
1700
|
default:
|
|
1207
|
-
// Throwing from here means that
|
|
1701
|
+
// Throwing from here means that MessageContent_Tags hasn't matched an ordinal.
|
|
1208
1702
|
throw new UniffiInternalError.UnexpectedEnumCase();
|
|
1209
1703
|
}
|
|
1210
1704
|
}
|
|
1211
1705
|
allocationSize(value: TypeName): number {
|
|
1212
1706
|
switch (value.tag) {
|
|
1213
|
-
case
|
|
1707
|
+
case MessageContent_Tags.Text: {
|
|
1214
1708
|
const inner = value.inner;
|
|
1215
1709
|
let size = ordinalConverter.allocationSize(1);
|
|
1216
|
-
size += FfiConverterString.allocationSize(inner.
|
|
1217
|
-
size += FfiConverterArrayTypeAsset.allocationSize(inner.assets);
|
|
1710
|
+
size += FfiConverterString.allocationSize(inner.text);
|
|
1218
1711
|
return size;
|
|
1219
1712
|
}
|
|
1220
|
-
case
|
|
1713
|
+
case MessageContent_Tags.Parts: {
|
|
1221
1714
|
const inner = value.inner;
|
|
1222
1715
|
let size = ordinalConverter.allocationSize(2);
|
|
1223
|
-
size +=
|
|
1224
|
-
size += FfiConverterOptionalArrayTypeToolCall.allocationSize(inner.toolCalls);
|
|
1716
|
+
size += FfiConverterArrayTypeContentPart.allocationSize(inner.parts);
|
|
1225
1717
|
return size;
|
|
1226
1718
|
}
|
|
1227
|
-
case
|
|
1719
|
+
case MessageContent_Tags.Json: {
|
|
1228
1720
|
const inner = value.inner;
|
|
1229
1721
|
let size = ordinalConverter.allocationSize(3);
|
|
1230
|
-
size += FfiConverterString.allocationSize(inner.
|
|
1231
|
-
return size;
|
|
1232
|
-
}
|
|
1233
|
-
case Message_Tags.Tool: {
|
|
1234
|
-
const inner = value.inner;
|
|
1235
|
-
let size = ordinalConverter.allocationSize(4);
|
|
1236
|
-
size += FfiConverterString.allocationSize(inner.name);
|
|
1237
|
-
size += FfiConverterString.allocationSize(inner.content);
|
|
1722
|
+
size += FfiConverterString.allocationSize(inner.json);
|
|
1238
1723
|
return size;
|
|
1239
1724
|
}
|
|
1240
1725
|
default: throw new UniffiInternalError.UnexpectedEnumCase();
|
|
@@ -1319,76 +1804,45 @@ const FfiConverterTypeNobodyWhoError = (() => {
|
|
|
1319
1804
|
})();
|
|
1320
1805
|
|
|
1321
1806
|
|
|
1322
|
-
// Enum:
|
|
1323
|
-
export enum
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
Audio = "Audio"
|
|
1807
|
+
// Enum: ShiftTarget
|
|
1808
|
+
export enum ShiftTarget_Tags {
|
|
1809
|
+
Fraction = "Fraction",
|
|
1810
|
+
Tokens = "Tokens"
|
|
1327
1811
|
}
|
|
1328
1812
|
/**
|
|
1329
|
-
*
|
|
1813
|
+
* Size a context shift shrinks the chat history to.
|
|
1330
1814
|
*/
|
|
1331
|
-
export const
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
type Text__interface = {
|
|
1335
|
-
tag: PromptPart_Tags.Text;
|
|
1336
|
-
inner: Readonly<{content: string}>
|
|
1337
|
-
};
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
class Text_ extends UniffiEnum implements Text__interface {
|
|
1341
|
-
/**
|
|
1342
|
-
* @private
|
|
1343
|
-
* This field is private and should not be used, use `tag` instead.
|
|
1344
|
-
*/
|
|
1345
|
-
readonly [uniffiTypeNameSymbol] = "PromptPart";
|
|
1346
|
-
readonly tag = PromptPart_Tags.Text;
|
|
1347
|
-
readonly inner: Readonly<{content: string}>;
|
|
1348
|
-
constructor(inner: { content: string }) {
|
|
1349
|
-
super("PromptPart", "Text");
|
|
1350
|
-
this.inner = Object.freeze(inner);
|
|
1351
|
-
}
|
|
1352
|
-
|
|
1353
|
-
static new(inner: { content: string }): Text_ {
|
|
1354
|
-
return new Text_(inner);
|
|
1355
|
-
}
|
|
1356
|
-
|
|
1357
|
-
static instanceOf(obj: any): obj is Text_ {
|
|
1358
|
-
return obj.tag === PromptPart_Tags.Text;
|
|
1359
|
-
}
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
}
|
|
1815
|
+
export const ShiftTarget = (() => {
|
|
1365
1816
|
|
|
1366
1817
|
|
|
1367
|
-
type
|
|
1368
|
-
tag:
|
|
1369
|
-
inner: Readonly<{
|
|
1818
|
+
type Fraction__interface = {
|
|
1819
|
+
tag: ShiftTarget_Tags.Fraction;
|
|
1820
|
+
inner: Readonly<{fraction: /*f32*/number}>
|
|
1370
1821
|
};
|
|
1371
1822
|
|
|
1372
1823
|
|
|
1373
|
-
|
|
1824
|
+
/**
|
|
1825
|
+
* A fraction of the context size, in `(0, 1)`.
|
|
1826
|
+
*/
|
|
1827
|
+
class Fraction_ extends UniffiEnum implements Fraction__interface {
|
|
1374
1828
|
/**
|
|
1375
1829
|
* @private
|
|
1376
1830
|
* This field is private and should not be used, use `tag` instead.
|
|
1377
1831
|
*/
|
|
1378
|
-
readonly [uniffiTypeNameSymbol] = "
|
|
1379
|
-
readonly tag =
|
|
1380
|
-
readonly inner: Readonly<{
|
|
1381
|
-
constructor(inner: {
|
|
1382
|
-
super("
|
|
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");
|
|
1383
1837
|
this.inner = Object.freeze(inner);
|
|
1384
1838
|
}
|
|
1385
1839
|
|
|
1386
|
-
static new(inner: {
|
|
1387
|
-
return new
|
|
1840
|
+
static new(inner: { fraction: /*f32*/number }): Fraction_ {
|
|
1841
|
+
return new Fraction_(inner);
|
|
1388
1842
|
}
|
|
1389
1843
|
|
|
1390
|
-
static instanceOf(obj: any): obj is
|
|
1391
|
-
return obj.tag ===
|
|
1844
|
+
static instanceOf(obj: any): obj is Fraction_ {
|
|
1845
|
+
return obj.tag === ShiftTarget_Tags.Fraction;
|
|
1392
1846
|
}
|
|
1393
1847
|
|
|
1394
1848
|
|
|
@@ -1397,31 +1851,34 @@ export const PromptPart = (() => {
|
|
|
1397
1851
|
}
|
|
1398
1852
|
|
|
1399
1853
|
|
|
1400
|
-
type
|
|
1401
|
-
tag:
|
|
1402
|
-
inner: Readonly<{
|
|
1854
|
+
type Tokens__interface = {
|
|
1855
|
+
tag: ShiftTarget_Tags.Tokens;
|
|
1856
|
+
inner: Readonly<{tokens: /*u32*/number}>
|
|
1403
1857
|
};
|
|
1404
1858
|
|
|
1405
1859
|
|
|
1406
|
-
|
|
1860
|
+
/**
|
|
1861
|
+
* A number of tokens, below the context size.
|
|
1862
|
+
*/
|
|
1863
|
+
class Tokens_ extends UniffiEnum implements Tokens__interface {
|
|
1407
1864
|
/**
|
|
1408
1865
|
* @private
|
|
1409
1866
|
* This field is private and should not be used, use `tag` instead.
|
|
1410
1867
|
*/
|
|
1411
|
-
readonly [uniffiTypeNameSymbol] = "
|
|
1412
|
-
readonly tag =
|
|
1413
|
-
readonly inner: Readonly<{
|
|
1414
|
-
constructor(inner: {
|
|
1415
|
-
super("
|
|
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");
|
|
1416
1873
|
this.inner = Object.freeze(inner);
|
|
1417
1874
|
}
|
|
1418
1875
|
|
|
1419
|
-
static new(inner: {
|
|
1420
|
-
return new
|
|
1876
|
+
static new(inner: { tokens: /*u32*/number }): Tokens_ {
|
|
1877
|
+
return new Tokens_(inner);
|
|
1421
1878
|
}
|
|
1422
1879
|
|
|
1423
|
-
static instanceOf(obj: any): obj is
|
|
1424
|
-
return obj.tag ===
|
|
1880
|
+
static instanceOf(obj: any): obj is Tokens_ {
|
|
1881
|
+
return obj.tag === ShiftTarget_Tags.Tokens;
|
|
1425
1882
|
}
|
|
1426
1883
|
|
|
1427
1884
|
|
|
@@ -1429,84 +1886,70 @@ export const PromptPart = (() => {
|
|
|
1429
1886
|
|
|
1430
1887
|
}
|
|
1431
1888
|
|
|
1432
|
-
function instanceOf(obj: any): obj is
|
|
1433
|
-
return obj[uniffiTypeNameSymbol] === "
|
|
1889
|
+
function instanceOf(obj: any): obj is ShiftTarget {
|
|
1890
|
+
return obj[uniffiTypeNameSymbol] === "ShiftTarget";
|
|
1434
1891
|
}
|
|
1435
1892
|
|
|
1436
1893
|
return Object.freeze({
|
|
1437
1894
|
instanceOf,
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
Audio: Audio_
|
|
1895
|
+
Fraction: Fraction_,
|
|
1896
|
+
Tokens: Tokens_
|
|
1441
1897
|
});
|
|
1442
1898
|
|
|
1443
1899
|
})();
|
|
1444
1900
|
|
|
1445
1901
|
|
|
1446
1902
|
/**
|
|
1447
|
-
*
|
|
1903
|
+
* Size a context shift shrinks the chat history to.
|
|
1448
1904
|
*/
|
|
1449
1905
|
|
|
1450
|
-
export type
|
|
1451
|
-
typeof
|
|
1906
|
+
export type ShiftTarget = InstanceType<
|
|
1907
|
+
typeof ShiftTarget[keyof Omit<typeof ShiftTarget, 'instanceOf'>]
|
|
1452
1908
|
>;
|
|
1453
1909
|
|
|
1454
|
-
// FfiConverter for enum
|
|
1455
|
-
const
|
|
1910
|
+
// FfiConverter for enum ShiftTarget
|
|
1911
|
+
const FfiConverterTypeShiftTarget = (() => {
|
|
1456
1912
|
const ordinalConverter = FfiConverterInt32;
|
|
1457
|
-
type TypeName =
|
|
1913
|
+
type TypeName = ShiftTarget;
|
|
1458
1914
|
class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
|
|
1459
1915
|
read(from: RustBuffer): TypeName {
|
|
1460
1916
|
switch (ordinalConverter.read(from)) {
|
|
1461
|
-
case 1: return new
|
|
1462
|
-
case 2: return new
|
|
1463
|
-
case 3: return new PromptPart.Audio({path: FfiConverterString.read(from) });
|
|
1917
|
+
case 1: return new ShiftTarget.Fraction({fraction: FfiConverterFloat32.read(from) });
|
|
1918
|
+
case 2: return new ShiftTarget.Tokens({tokens: FfiConverterUInt32.read(from) });
|
|
1464
1919
|
default: throw new UniffiInternalError.UnexpectedEnumCase();
|
|
1465
1920
|
}
|
|
1466
1921
|
}
|
|
1467
1922
|
write(value: TypeName, into: RustBuffer): void {
|
|
1468
1923
|
switch (value.tag) {
|
|
1469
|
-
case
|
|
1924
|
+
case ShiftTarget_Tags.Fraction: {
|
|
1470
1925
|
ordinalConverter.write(1, into);
|
|
1471
1926
|
const inner = value.inner;
|
|
1472
|
-
|
|
1927
|
+
FfiConverterFloat32.write(inner.fraction, into);
|
|
1473
1928
|
return;
|
|
1474
1929
|
}
|
|
1475
|
-
case
|
|
1930
|
+
case ShiftTarget_Tags.Tokens: {
|
|
1476
1931
|
ordinalConverter.write(2, into);
|
|
1477
1932
|
const inner = value.inner;
|
|
1478
|
-
|
|
1479
|
-
return;
|
|
1480
|
-
}
|
|
1481
|
-
case PromptPart_Tags.Audio: {
|
|
1482
|
-
ordinalConverter.write(3, into);
|
|
1483
|
-
const inner = value.inner;
|
|
1484
|
-
FfiConverterString.write(inner.path, into);
|
|
1933
|
+
FfiConverterUInt32.write(inner.tokens, into);
|
|
1485
1934
|
return;
|
|
1486
1935
|
}
|
|
1487
1936
|
default:
|
|
1488
|
-
// Throwing from here means that
|
|
1937
|
+
// Throwing from here means that ShiftTarget_Tags hasn't matched an ordinal.
|
|
1489
1938
|
throw new UniffiInternalError.UnexpectedEnumCase();
|
|
1490
1939
|
}
|
|
1491
1940
|
}
|
|
1492
1941
|
allocationSize(value: TypeName): number {
|
|
1493
1942
|
switch (value.tag) {
|
|
1494
|
-
case
|
|
1943
|
+
case ShiftTarget_Tags.Fraction: {
|
|
1495
1944
|
const inner = value.inner;
|
|
1496
1945
|
let size = ordinalConverter.allocationSize(1);
|
|
1497
|
-
size +=
|
|
1946
|
+
size += FfiConverterFloat32.allocationSize(inner.fraction);
|
|
1498
1947
|
return size;
|
|
1499
1948
|
}
|
|
1500
|
-
case
|
|
1949
|
+
case ShiftTarget_Tags.Tokens: {
|
|
1501
1950
|
const inner = value.inner;
|
|
1502
1951
|
let size = ordinalConverter.allocationSize(2);
|
|
1503
|
-
size +=
|
|
1504
|
-
return size;
|
|
1505
|
-
}
|
|
1506
|
-
case PromptPart_Tags.Audio: {
|
|
1507
|
-
const inner = value.inner;
|
|
1508
|
-
let size = ordinalConverter.allocationSize(3);
|
|
1509
|
-
size += FfiConverterString.allocationSize(inner.path);
|
|
1952
|
+
size += FfiConverterUInt32.allocationSize(inner.tokens);
|
|
1510
1953
|
return size;
|
|
1511
1954
|
}
|
|
1512
1955
|
default: throw new UniffiInternalError.UnexpectedEnumCase();
|
|
@@ -1562,6 +2005,10 @@ const FfiConverterTypeVoiceActivityDetectionEvent = (() => {
|
|
|
1562
2005
|
|
|
1563
2006
|
|
|
1564
2007
|
|
|
2008
|
+
// FfiConverter for Map</*i32*/number, /*f32*/number>
|
|
2009
|
+
const FfiConverterMapInt32Float32 = new FfiConverterMap(FfiConverterInt32, FfiConverterFloat32);
|
|
2010
|
+
|
|
2011
|
+
|
|
1565
2012
|
// FfiConverter for Map<string, boolean>
|
|
1566
2013
|
const FfiConverterMapStringBool = new FfiConverterMap(FfiConverterString, FfiConverterBool);
|
|
1567
2014
|
|
|
@@ -1586,10 +2033,23 @@ export interface RustChatInterface {
|
|
|
1586
2033
|
/**
|
|
1587
2034
|
* Send a multimodal prompt (text + images/audio) and get a token stream.
|
|
1588
2035
|
*
|
|
1589
|
-
* `parts` is an ordered list of `
|
|
2036
|
+
* `parts` is an ordered list of `ContentPart` items.
|
|
1590
2037
|
* Image and audio parts should contain a local file-system path.
|
|
1591
2038
|
*/
|
|
1592
|
-
askWithPrompt(parts: Array<
|
|
2039
|
+
askWithPrompt(parts: Array<ContentPart>) : RustTokenStreamInterface;
|
|
2040
|
+
/**
|
|
2041
|
+
* Answer a full list of messages and get a token stream, replacing the chat
|
|
2042
|
+
* history.
|
|
2043
|
+
*
|
|
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.
|
|
2049
|
+
*
|
|
2050
|
+
* `options` follows the same rule for the chat's other settings.
|
|
2051
|
+
*/
|
|
2052
|
+
complete(messages: Array<Message>, options: Options) /*throws*/: RustTokenStreamInterface;
|
|
1593
2053
|
/**
|
|
1594
2054
|
* Get the current chat history as a list of messages.
|
|
1595
2055
|
*/
|
|
@@ -1628,6 +2088,10 @@ export interface RustChatInterface {
|
|
|
1628
2088
|
* Set the chat history from a list of messages.
|
|
1629
2089
|
*/
|
|
1630
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>;
|
|
1631
2095
|
/**
|
|
1632
2096
|
* Set the sampler configuration.
|
|
1633
2097
|
*/
|
|
@@ -1656,7 +2120,7 @@ export interface RustChatInterface {
|
|
|
1656
2120
|
* Tokenize a multimodal prompt and return the token IDs.
|
|
1657
2121
|
* Text tokens produce an integer ID; image/audio embedding slots produce null.
|
|
1658
2122
|
*/
|
|
1659
|
-
tokenizeWithPrompt(parts: Array<
|
|
2123
|
+
tokenizeWithPrompt(parts: Array<ContentPart>, asyncOpts_?: { signal: AbortSignal }) /*throws*/: Promise<Array</*i32*/number | undefined>>;
|
|
1660
2124
|
}
|
|
1661
2125
|
|
|
1662
2126
|
|
|
@@ -1677,8 +2141,11 @@ export class RustChat extends UniffiAbstractObject implements RustChatInterface
|
|
|
1677
2141
|
* detects the device's physical core count (performance cores only, on
|
|
1678
2142
|
* Apple silicon), since hyperthreads and efficiency cores make inference
|
|
1679
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.
|
|
1680
2147
|
*/
|
|
1681
|
-
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*/ {
|
|
1682
2149
|
super();
|
|
1683
2150
|
const pointer =
|
|
1684
2151
|
|
|
@@ -1694,6 +2161,7 @@ export class RustChat extends UniffiAbstractObject implements RustChatInterface
|
|
|
1694
2161
|
FfiConverterOptionalTypeSamplerConfig.lower(sampler),
|
|
1695
2162
|
FfiConverterOptionalTypeMtpConfig.lower(mtp),
|
|
1696
2163
|
FfiConverterOptionalUInt32.lower(threadCount),
|
|
2164
|
+
FfiConverterOptionalTypeContextShiftOptions.lower(contextShift),
|
|
1697
2165
|
callStatus);
|
|
1698
2166
|
},
|
|
1699
2167
|
/*liftString:*/ FfiConverterString.lift,
|
|
@@ -1741,14 +2209,40 @@ export class RustChat extends UniffiAbstractObject implements RustChatInterface
|
|
|
1741
2209
|
/**
|
|
1742
2210
|
* Send a multimodal prompt (text + images/audio) and get a token stream.
|
|
1743
2211
|
*
|
|
1744
|
-
* `parts` is an ordered list of `
|
|
2212
|
+
* `parts` is an ordered list of `ContentPart` items.
|
|
1745
2213
|
* Image and audio parts should contain a local file-system path.
|
|
1746
2214
|
*/
|
|
1747
|
-
askWithPrompt(parts: Array<
|
|
2215
|
+
askWithPrompt(parts: Array<ContentPart>): RustTokenStreamInterface {
|
|
1748
2216
|
return FfiConverterTypeRustTokenStream.lift(uniffiCaller.rustCall(
|
|
1749
2217
|
/*caller:*/ (callStatus) => {
|
|
1750
2218
|
return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_ask_with_prompt(uniffiTypeRustChatObjectFactory.clonePointer(this),
|
|
1751
|
-
|
|
2219
|
+
FfiConverterArrayTypeContentPart.lower(parts),
|
|
2220
|
+
callStatus);
|
|
2221
|
+
},
|
|
2222
|
+
/*liftString:*/ FfiConverterString.lift,
|
|
2223
|
+
));
|
|
2224
|
+
}
|
|
2225
|
+
|
|
2226
|
+
/**
|
|
2227
|
+
* Answer a full list of messages and get a token stream, replacing the chat
|
|
2228
|
+
* history.
|
|
2229
|
+
*
|
|
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.
|
|
2235
|
+
*
|
|
2236
|
+
* `options` follows the same rule for the chat's other settings.
|
|
2237
|
+
*/
|
|
2238
|
+
complete(messages: Array<Message>, options: Options): RustTokenStreamInterface /*throws*/ {
|
|
2239
|
+
return FfiConverterTypeRustTokenStream.lift(
|
|
2240
|
+
uniffiCaller.rustCallWithError(
|
|
2241
|
+
/*liftError:*/ FfiConverterTypeNobodyWhoError.lift.bind(FfiConverterTypeNobodyWhoError),
|
|
2242
|
+
/*caller:*/ (callStatus) => {
|
|
2243
|
+
return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_complete(uniffiTypeRustChatObjectFactory.clonePointer(this),
|
|
2244
|
+
FfiConverterArrayTypeMessage.lower(messages),
|
|
2245
|
+
FfiConverterTypeOptions.lower(options),
|
|
1752
2246
|
callStatus);
|
|
1753
2247
|
},
|
|
1754
2248
|
/*liftString:*/ FfiConverterString.lift,
|
|
@@ -2036,6 +2530,37 @@ async setChatHistory(messages: Array<Message>, asyncOpts_?: { signal: AbortSign
|
|
|
2036
2530
|
}
|
|
2037
2531
|
}
|
|
2038
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
|
+
|
|
2039
2564
|
/**
|
|
2040
2565
|
* Set the sampler configuration.
|
|
2041
2566
|
*/
|
|
@@ -2206,7 +2731,7 @@ async tokenize(message: string, asyncOpts_?: { signal: AbortSignal }): Promise<
|
|
|
2206
2731
|
* Tokenize a multimodal prompt and return the token IDs.
|
|
2207
2732
|
* Text tokens produce an integer ID; image/audio embedding slots produce null.
|
|
2208
2733
|
*/
|
|
2209
|
-
async tokenizeWithPrompt(parts: Array<
|
|
2734
|
+
async tokenizeWithPrompt(parts: Array<ContentPart>, asyncOpts_?: { signal: AbortSignal }): Promise<Array</*i32*/number | undefined>> /*throws*/ {
|
|
2210
2735
|
const __stack = uniffiIsDebug ? new Error().stack : undefined;
|
|
2211
2736
|
try {
|
|
2212
2737
|
return await uniffiRustCallAsync(
|
|
@@ -2214,7 +2739,7 @@ async tokenizeWithPrompt(parts: Array<PromptPart>, asyncOpts_?: { signal: Abort
|
|
|
2214
2739
|
/*rustFutureFunc:*/ () => {
|
|
2215
2740
|
return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_rustchat_tokenize_with_prompt(
|
|
2216
2741
|
uniffiTypeRustChatObjectFactory.clonePointer(this),
|
|
2217
|
-
|
|
2742
|
+
FfiConverterArrayTypeContentPart.lower(parts)
|
|
2218
2743
|
);
|
|
2219
2744
|
},
|
|
2220
2745
|
/*pollFunc:*/ nativeModule().ubrn_ffi_nobodywho_uniffi_rust_future_poll_rust_buffer,
|
|
@@ -2670,6 +3195,7 @@ const FfiConverterTypeRustEncoder = new FfiConverterObject(uniffiTypeRustEncode
|
|
|
2670
3195
|
export interface RustModelInterface {
|
|
2671
3196
|
|
|
2672
3197
|
maxCtx() : /*u32*/number;
|
|
3198
|
+
source() : string;
|
|
2673
3199
|
}
|
|
2674
3200
|
|
|
2675
3201
|
|
|
@@ -2698,6 +3224,16 @@ private constructor(pointer: UniffiHandle) {
|
|
|
2698
3224
|
));
|
|
2699
3225
|
}
|
|
2700
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
|
+
|
|
2701
3237
|
|
|
2702
3238
|
/**
|
|
2703
3239
|
* {@inheritDoc uniffi-bindgen-react-native#UniffiAbstractObject.uniffiDestroy}
|
|
@@ -3859,6 +4395,18 @@ const FfiConverterTypeRustVoiceActivityDetection = new FfiConverterObject(uniff
|
|
|
3859
4395
|
|
|
3860
4396
|
export interface SamplerBuilderInterface {
|
|
3861
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;
|
|
3862
4410
|
/**
|
|
3863
4411
|
* Sample from the probability distribution (weighted random selection).
|
|
3864
4412
|
*/
|
|
@@ -3868,13 +4416,34 @@ export interface SamplerBuilderInterface {
|
|
|
3868
4416
|
*/
|
|
3869
4417
|
dry(multiplier: /*f32*/number, base: /*f32*/number, allowedLength: /*i32*/number, penaltyLastN: /*i32*/number, seqBreakers: Array<string>) : SamplerBuilderInterface;
|
|
3870
4418
|
/**
|
|
3871
|
-
*
|
|
4419
|
+
* Apply dynamic temperature scaling (a.k.a. entropy) described in the paper
|
|
4420
|
+
* <https://arxiv.org/abs/2309.02772>.
|
|
4421
|
+
*
|
|
4422
|
+
* Args:
|
|
4423
|
+
* temperature: Temperature value (lower = more focused, higher = more random)
|
|
4424
|
+
* delta: Dynamic temperature range. The final temperature will be in the range of `[temperature - delta; temperature + delta]`.
|
|
4425
|
+
* exponent: Temperature is calculated as `entropy^exponent` (bounded by the range above)
|
|
3872
4426
|
*/
|
|
3873
|
-
|
|
4427
|
+
dynamicTemperature(temperature: /*f32*/number, delta: /*f32*/number, exponent: /*f32*/number) : SamplerBuilderInterface;
|
|
3874
4428
|
/**
|
|
3875
4429
|
* Always select the most probable token (deterministic).
|
|
3876
4430
|
*/
|
|
3877
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;
|
|
4437
|
+
/**
|
|
4438
|
+
* Modify the likelihood of specific tokens.
|
|
4439
|
+
*
|
|
4440
|
+
* Args:
|
|
4441
|
+
* biases: Mapping from token ID to its bias.
|
|
4442
|
+
* The bias modifies the likelihood of the token being selected
|
|
4443
|
+
* (`>0.0` means higher probability of the token being selected).
|
|
4444
|
+
* Use `-Infinity` to ban a token.
|
|
4445
|
+
*/
|
|
4446
|
+
logitBias(biases: Map</*i32*/number, /*f32*/number>) : SamplerBuilderInterface;
|
|
3878
4447
|
/**
|
|
3879
4448
|
* Keep tokens with probability above min_p * (probability of most likely token).
|
|
3880
4449
|
*/
|
|
@@ -3904,6 +4473,14 @@ export interface SamplerBuilderInterface {
|
|
|
3904
4473
|
* Keep only the top K most probable tokens.
|
|
3905
4474
|
*/
|
|
3906
4475
|
topK(topK: /*i32*/number) : SamplerBuilderInterface;
|
|
4476
|
+
/**
|
|
4477
|
+
* Top-nσ sampling as described in academic paper "Top-nσ: Not All Logits Are You Need"
|
|
4478
|
+
* <https://arxiv.org/pdf/2411.07641>
|
|
4479
|
+
*
|
|
4480
|
+
* Args:
|
|
4481
|
+
* n: Number of standard deviations from the mean to include in sampling.
|
|
4482
|
+
*/
|
|
4483
|
+
topNSigma(n: /*f32*/number) : SamplerBuilderInterface;
|
|
3907
4484
|
/**
|
|
3908
4485
|
* Keep tokens whose cumulative probability is below top_p.
|
|
3909
4486
|
*/
|
|
@@ -3944,6 +4521,48 @@ export class SamplerBuilder extends UniffiAbstractObject implements SamplerBuild
|
|
|
3944
4521
|
|
|
3945
4522
|
|
|
3946
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
|
+
|
|
3947
4566
|
/**
|
|
3948
4567
|
* Sample from the probability distribution (weighted random selection).
|
|
3949
4568
|
*/
|
|
@@ -3976,15 +4595,21 @@ export class SamplerBuilder extends UniffiAbstractObject implements SamplerBuild
|
|
|
3976
4595
|
}
|
|
3977
4596
|
|
|
3978
4597
|
/**
|
|
3979
|
-
*
|
|
4598
|
+
* Apply dynamic temperature scaling (a.k.a. entropy) described in the paper
|
|
4599
|
+
* <https://arxiv.org/abs/2309.02772>.
|
|
4600
|
+
*
|
|
4601
|
+
* Args:
|
|
4602
|
+
* temperature: Temperature value (lower = more focused, higher = more random)
|
|
4603
|
+
* delta: Dynamic temperature range. The final temperature will be in the range of `[temperature - delta; temperature + delta]`.
|
|
4604
|
+
* exponent: Temperature is calculated as `entropy^exponent` (bounded by the range above)
|
|
3980
4605
|
*/
|
|
3981
|
-
|
|
4606
|
+
dynamicTemperature(temperature: /*f32*/number, delta: /*f32*/number, exponent: /*f32*/number): SamplerBuilderInterface {
|
|
3982
4607
|
return FfiConverterTypeSamplerBuilder.lift(uniffiCaller.rustCall(
|
|
3983
4608
|
/*caller:*/ (callStatus) => {
|
|
3984
|
-
return nativeModule().
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
4609
|
+
return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_samplerbuilder_dynamic_temperature(uniffiTypeSamplerBuilderObjectFactory.clonePointer(this),
|
|
4610
|
+
FfiConverterFloat32.lower(temperature),
|
|
4611
|
+
FfiConverterFloat32.lower(delta),
|
|
4612
|
+
FfiConverterFloat32.lower(exponent),
|
|
3988
4613
|
callStatus);
|
|
3989
4614
|
},
|
|
3990
4615
|
/*liftString:*/ FfiConverterString.lift,
|
|
@@ -4004,6 +4629,40 @@ export class SamplerBuilder extends UniffiAbstractObject implements SamplerBuild
|
|
|
4004
4629
|
));
|
|
4005
4630
|
}
|
|
4006
4631
|
|
|
4632
|
+
/**
|
|
4633
|
+
* Constrain output to a JSON object of any shape. Use
|
|
4634
|
+
* `constrain_with_json_schema()` to pin down the structure too.
|
|
4635
|
+
*/
|
|
4636
|
+
json(): SamplerBuilderInterface {
|
|
4637
|
+
return FfiConverterTypeSamplerBuilder.lift(uniffiCaller.rustCall(
|
|
4638
|
+
/*caller:*/ (callStatus) => {
|
|
4639
|
+
return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_samplerbuilder_json(uniffiTypeSamplerBuilderObjectFactory.clonePointer(this),
|
|
4640
|
+
callStatus);
|
|
4641
|
+
},
|
|
4642
|
+
/*liftString:*/ FfiConverterString.lift,
|
|
4643
|
+
));
|
|
4644
|
+
}
|
|
4645
|
+
|
|
4646
|
+
/**
|
|
4647
|
+
* Modify the likelihood of specific tokens.
|
|
4648
|
+
*
|
|
4649
|
+
* Args:
|
|
4650
|
+
* biases: Mapping from token ID to its bias.
|
|
4651
|
+
* The bias modifies the likelihood of the token being selected
|
|
4652
|
+
* (`>0.0` means higher probability of the token being selected).
|
|
4653
|
+
* Use `-Infinity` to ban a token.
|
|
4654
|
+
*/
|
|
4655
|
+
logitBias(biases: Map</*i32*/number, /*f32*/number>): SamplerBuilderInterface {
|
|
4656
|
+
return FfiConverterTypeSamplerBuilder.lift(uniffiCaller.rustCall(
|
|
4657
|
+
/*caller:*/ (callStatus) => {
|
|
4658
|
+
return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_samplerbuilder_logit_bias(uniffiTypeSamplerBuilderObjectFactory.clonePointer(this),
|
|
4659
|
+
FfiConverterMapInt32Float32.lower(biases),
|
|
4660
|
+
callStatus);
|
|
4661
|
+
},
|
|
4662
|
+
/*liftString:*/ FfiConverterString.lift,
|
|
4663
|
+
));
|
|
4664
|
+
}
|
|
4665
|
+
|
|
4007
4666
|
/**
|
|
4008
4667
|
* Keep tokens with probability above min_p * (probability of most likely token).
|
|
4009
4668
|
*/
|
|
@@ -4110,6 +4769,24 @@ export class SamplerBuilder extends UniffiAbstractObject implements SamplerBuild
|
|
|
4110
4769
|
));
|
|
4111
4770
|
}
|
|
4112
4771
|
|
|
4772
|
+
/**
|
|
4773
|
+
* Top-nσ sampling as described in academic paper "Top-nσ: Not All Logits Are You Need"
|
|
4774
|
+
* <https://arxiv.org/pdf/2411.07641>
|
|
4775
|
+
*
|
|
4776
|
+
* Args:
|
|
4777
|
+
* n: Number of standard deviations from the mean to include in sampling.
|
|
4778
|
+
*/
|
|
4779
|
+
topNSigma(n: /*f32*/number): SamplerBuilderInterface {
|
|
4780
|
+
return FfiConverterTypeSamplerBuilder.lift(uniffiCaller.rustCall(
|
|
4781
|
+
/*caller:*/ (callStatus) => {
|
|
4782
|
+
return nativeModule().ubrn_uniffi_nobodywho_uniffi_fn_method_samplerbuilder_top_n_sigma(uniffiTypeSamplerBuilderObjectFactory.clonePointer(this),
|
|
4783
|
+
FfiConverterFloat32.lower(n),
|
|
4784
|
+
callStatus);
|
|
4785
|
+
},
|
|
4786
|
+
/*liftString:*/ FfiConverterString.lift,
|
|
4787
|
+
));
|
|
4788
|
+
}
|
|
4789
|
+
|
|
4113
4790
|
/**
|
|
4114
4791
|
* Keep tokens whose cumulative probability is below top_p.
|
|
4115
4792
|
*/
|
|
@@ -4373,6 +5050,10 @@ const FfiConverterOptionalFloat32 = new FfiConverterOptional(FfiConverterFloat32
|
|
|
4373
5050
|
const FfiConverterOptionalInt32 = new FfiConverterOptional(FfiConverterInt32);
|
|
4374
5051
|
|
|
4375
5052
|
|
|
5053
|
+
// FfiConverter for ContextShiftOptions | undefined
|
|
5054
|
+
const FfiConverterOptionalTypeContextShiftOptions = new FfiConverterOptional(FfiConverterTypeContextShiftOptions);
|
|
5055
|
+
|
|
5056
|
+
|
|
4376
5057
|
// FfiConverter for MtpConfig | undefined
|
|
4377
5058
|
const FfiConverterOptionalTypeMtpConfig = new FfiConverterOptional(FfiConverterTypeMtpConfig);
|
|
4378
5059
|
|
|
@@ -4397,10 +5078,6 @@ const FfiConverterArrayFloat32 = new FfiConverterArray(FfiConverterFloat32);
|
|
|
4397
5078
|
const FfiConverterArrayInt16 = new FfiConverterArray(FfiConverterInt16);
|
|
4398
5079
|
|
|
4399
5080
|
|
|
4400
|
-
// FfiConverter for Array<Asset>
|
|
4401
|
-
const FfiConverterArrayTypeAsset = new FfiConverterArray(FfiConverterTypeAsset);
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
5081
|
// FfiConverter for Array<CachedModel>
|
|
4405
5082
|
const FfiConverterArrayTypeCachedModel = new FfiConverterArray(FfiConverterTypeCachedModel);
|
|
4406
5083
|
|
|
@@ -4417,6 +5094,10 @@ const FfiConverterArrayTypeToolParameter = new FfiConverterArray(FfiConverterTyp
|
|
|
4417
5094
|
const FfiConverterArrayString = new FfiConverterArray(FfiConverterString);
|
|
4418
5095
|
|
|
4419
5096
|
|
|
5097
|
+
// FfiConverter for ShiftTarget | undefined
|
|
5098
|
+
const FfiConverterOptionalTypeShiftTarget = new FfiConverterOptional(FfiConverterTypeShiftTarget);
|
|
5099
|
+
|
|
5100
|
+
|
|
4420
5101
|
// FfiConverter for Map<string, boolean> | undefined
|
|
4421
5102
|
const FfiConverterOptionalMapStringBool = new FfiConverterOptional(FfiConverterMapStringBool);
|
|
4422
5103
|
|
|
@@ -4433,12 +5114,12 @@ const FfiConverterOptionalTypeSamplerConfig = new FfiConverterOptional(FfiConver
|
|
|
4433
5114
|
const FfiConverterOptionalArrayTypeToolCall = new FfiConverterOptional(FfiConverterArrayTypeToolCall);
|
|
4434
5115
|
|
|
4435
5116
|
|
|
4436
|
-
// FfiConverter for Array<
|
|
4437
|
-
const
|
|
5117
|
+
// FfiConverter for Array<ContentPart>
|
|
5118
|
+
const FfiConverterArrayTypeContentPart = new FfiConverterArray(FfiConverterTypeContentPart);
|
|
4438
5119
|
|
|
4439
5120
|
|
|
4440
|
-
// FfiConverter for Array<
|
|
4441
|
-
const
|
|
5121
|
+
// FfiConverter for Array<Message>
|
|
5122
|
+
const FfiConverterArrayTypeMessage = new FfiConverterArray(FfiConverterTypeMessage);
|
|
4442
5123
|
|
|
4443
5124
|
|
|
4444
5125
|
// FfiConverter for Array<RustToolInterface>
|
|
@@ -4514,22 +5195,19 @@ function uniffiEnsureInitialized() {
|
|
|
4514
5195
|
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_func_sampler_preset_dry() !== 55378) {
|
|
4515
5196
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_func_sampler_preset_dry");
|
|
4516
5197
|
}
|
|
4517
|
-
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_func_sampler_preset_grammar() !== 29288) {
|
|
4518
|
-
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_func_sampler_preset_grammar");
|
|
4519
|
-
}
|
|
4520
5198
|
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_func_sampler_preset_greedy() !== 13219) {
|
|
4521
5199
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_func_sampler_preset_greedy");
|
|
4522
5200
|
}
|
|
4523
|
-
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_func_sampler_preset_json() !==
|
|
5201
|
+
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_func_sampler_preset_json() !== 42303) {
|
|
4524
5202
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_func_sampler_preset_json");
|
|
4525
5203
|
}
|
|
4526
5204
|
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_func_sampler_preset_temperature() !== 64803) {
|
|
4527
5205
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_func_sampler_preset_temperature");
|
|
4528
5206
|
}
|
|
4529
|
-
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_func_sampler_preset_top_k() !==
|
|
5207
|
+
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_func_sampler_preset_top_k() !== 56996) {
|
|
4530
5208
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_func_sampler_preset_top_k");
|
|
4531
5209
|
}
|
|
4532
|
-
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_func_sampler_preset_top_p() !==
|
|
5210
|
+
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_func_sampler_preset_top_p() !== 22588) {
|
|
4533
5211
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_func_sampler_preset_top_p");
|
|
4534
5212
|
}
|
|
4535
5213
|
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustchat_ask() !== 53575) {
|
|
@@ -4538,9 +5216,12 @@ function uniffiEnsureInitialized() {
|
|
|
4538
5216
|
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustchat_ask_with_json_prompt() !== 63877) {
|
|
4539
5217
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_rustchat_ask_with_json_prompt");
|
|
4540
5218
|
}
|
|
4541
|
-
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustchat_ask_with_prompt() !==
|
|
5219
|
+
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustchat_ask_with_prompt() !== 46807) {
|
|
4542
5220
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_rustchat_ask_with_prompt");
|
|
4543
5221
|
}
|
|
5222
|
+
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustchat_complete() !== 24327) {
|
|
5223
|
+
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_rustchat_complete");
|
|
5224
|
+
}
|
|
4544
5225
|
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustchat_get_chat_history() !== 12722) {
|
|
4545
5226
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_rustchat_get_chat_history");
|
|
4546
5227
|
}
|
|
@@ -4568,6 +5249,9 @@ function uniffiEnsureInitialized() {
|
|
|
4568
5249
|
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustchat_set_chat_history() !== 6058) {
|
|
4569
5250
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_rustchat_set_chat_history");
|
|
4570
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
|
+
}
|
|
4571
5255
|
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustchat_set_sampler_config() !== 28012) {
|
|
4572
5256
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_rustchat_set_sampler_config");
|
|
4573
5257
|
}
|
|
@@ -4586,7 +5270,7 @@ function uniffiEnsureInitialized() {
|
|
|
4586
5270
|
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustchat_tokenize() !== 52520) {
|
|
4587
5271
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_rustchat_tokenize");
|
|
4588
5272
|
}
|
|
4589
|
-
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustchat_tokenize_with_prompt() !==
|
|
5273
|
+
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustchat_tokenize_with_prompt() !== 15286) {
|
|
4590
5274
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_rustchat_tokenize_with_prompt");
|
|
4591
5275
|
}
|
|
4592
5276
|
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustcrossencoder_rank() !== 55500) {
|
|
@@ -4604,6 +5288,9 @@ function uniffiEnsureInitialized() {
|
|
|
4604
5288
|
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustmodel_max_ctx() !== 52004) {
|
|
4605
5289
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_rustmodel_max_ctx");
|
|
4606
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
|
+
}
|
|
4607
5294
|
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustspeechtotext_transcribe_file() !== 59975) {
|
|
4608
5295
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_rustspeechtotext_transcribe_file");
|
|
4609
5296
|
}
|
|
@@ -4646,18 +5333,33 @@ function uniffiEnsureInitialized() {
|
|
|
4646
5333
|
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_rustvoiceactivitydetection_segment() !== 39967) {
|
|
4647
5334
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_rustvoiceactivitydetection_segment");
|
|
4648
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
|
+
}
|
|
4649
5345
|
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_dist() !== 23376) {
|
|
4650
5346
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_dist");
|
|
4651
5347
|
}
|
|
4652
5348
|
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_dry() !== 35315) {
|
|
4653
5349
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_dry");
|
|
4654
5350
|
}
|
|
4655
|
-
if (nativeModule().
|
|
4656
|
-
throw new UniffiInternalError.ApiChecksumMismatch("
|
|
5351
|
+
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_dynamic_temperature() !== 5004) {
|
|
5352
|
+
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_dynamic_temperature");
|
|
4657
5353
|
}
|
|
4658
5354
|
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_greedy() !== 32898) {
|
|
4659
5355
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_greedy");
|
|
4660
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
|
+
}
|
|
5360
|
+
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_logit_bias() !== 61844) {
|
|
5361
|
+
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_logit_bias");
|
|
5362
|
+
}
|
|
4661
5363
|
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_min_p() !== 33705) {
|
|
4662
5364
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_min_p");
|
|
4663
5365
|
}
|
|
@@ -4679,6 +5381,9 @@ function uniffiEnsureInitialized() {
|
|
|
4679
5381
|
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_top_k() !== 26600) {
|
|
4680
5382
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_top_k");
|
|
4681
5383
|
}
|
|
5384
|
+
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_top_n_sigma() !== 44336) {
|
|
5385
|
+
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_top_n_sigma");
|
|
5386
|
+
}
|
|
4682
5387
|
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_top_p() !== 54577) {
|
|
4683
5388
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_samplerbuilder_top_p");
|
|
4684
5389
|
}
|
|
@@ -4691,7 +5396,7 @@ function uniffiEnsureInitialized() {
|
|
|
4691
5396
|
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_method_samplerconfig_to_json() !== 51798) {
|
|
4692
5397
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_method_samplerconfig_to_json");
|
|
4693
5398
|
}
|
|
4694
|
-
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_constructor_rustchat_new() !==
|
|
5399
|
+
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_constructor_rustchat_new() !== 4810) {
|
|
4695
5400
|
throw new UniffiInternalError.ApiChecksumMismatch("uniffi_nobodywho_uniffi_checksum_constructor_rustchat_new");
|
|
4696
5401
|
}
|
|
4697
5402
|
if (nativeModule().ubrn_uniffi_nobodywho_uniffi_checksum_constructor_rustcrossencoder_new() !== 9022) {
|
|
@@ -4735,14 +5440,16 @@ function uniffiEnsureInitialized() {
|
|
|
4735
5440
|
export default Object.freeze({
|
|
4736
5441
|
initialize: uniffiEnsureInitialized,
|
|
4737
5442
|
converters: {
|
|
4738
|
-
FfiConverterTypeAsset,
|
|
4739
5443
|
FfiConverterTypeCachedModel,
|
|
4740
5444
|
FfiConverterTypeChatStats,
|
|
5445
|
+
FfiConverterTypeContentPart,
|
|
5446
|
+
FfiConverterTypeContextShiftOptions,
|
|
4741
5447
|
FfiConverterTypeMessage,
|
|
5448
|
+
FfiConverterTypeMessageContent,
|
|
4742
5449
|
FfiConverterTypeMtpConfig,
|
|
4743
5450
|
FfiConverterTypeNobodyWhoError,
|
|
5451
|
+
FfiConverterTypeOptions,
|
|
4744
5452
|
FfiConverterTypePendingToolCall,
|
|
4745
|
-
FfiConverterTypePromptPart,
|
|
4746
5453
|
FfiConverterTypeRustChat,
|
|
4747
5454
|
FfiConverterTypeRustCrossEncoder,
|
|
4748
5455
|
FfiConverterTypeRustEncoder,
|
|
@@ -4755,6 +5462,7 @@ export default Object.freeze({
|
|
|
4755
5462
|
FfiConverterTypeRustVoiceActivityDetection,
|
|
4756
5463
|
FfiConverterTypeSamplerBuilder,
|
|
4757
5464
|
FfiConverterTypeSamplerConfig,
|
|
5465
|
+
FfiConverterTypeShiftTarget,
|
|
4758
5466
|
FfiConverterTypeToolCall,
|
|
4759
5467
|
FfiConverterTypeToolParameter,
|
|
4760
5468
|
FfiConverterTypeVoiceActivityDetectionEvent,
|