litert-lm-edge-sys 0.2.3

Raw FFI bindings for the LiteRT-LM C API.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
/* automatically generated by rust-bindgen 0.71.1 */

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct LiteRtLmEngine {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct LiteRtLmSession {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct LiteRtLmResponses {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct LiteRtLmEngineSettings {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct LiteRtLmBenchmarkInfo {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct LiteRtLmRepetitionPenaltyConfig {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct LiteRtLmNoRepeatNgramConfig {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct LiteRtLmSuppressTokensConfig {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct LiteRtLmDetokenizeResult {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct LiteRtLmTokenizeResult {
    _unused: [u8; 0],
}
pub const kLiteRtLmTokenUnionTypeString: LiteRtLmTokenUnionType = 0;
pub const kLiteRtLmTokenUnionTypeIds: LiteRtLmTokenUnionType = 1;
pub type LiteRtLmTokenUnionType = ::std::os::raw::c_uint;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct LiteRtLmTokenUnion {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct LiteRtLmTokenUnions {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct LiteRtLmInputData {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct LiteRtLmSessionConfig {
    _unused: [u8; 0],
}
pub const kLiteRtLmSamplerTypeUnspecified: LiteRtLmSamplerType = 0;
pub const kLiteRtLmSamplerTypeTopK: LiteRtLmSamplerType = 1;
pub const kLiteRtLmSamplerTypeTopP: LiteRtLmSamplerType = 2;
pub const kLiteRtLmSamplerTypeGreedy: LiteRtLmSamplerType = 3;
pub type LiteRtLmSamplerType = ::std::os::raw::c_uint;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct LiteRtLmSamplerParams {
    _unused: [u8; 0],
}
unsafe extern "C" {
    pub fn litert_lm_sampler_params_create(
        type_: LiteRtLmSamplerType,
    ) -> *mut LiteRtLmSamplerParams;
}
unsafe extern "C" {
    pub fn litert_lm_sampler_params_delete(params: *mut LiteRtLmSamplerParams);
}
unsafe extern "C" {
    pub fn litert_lm_sampler_params_set_top_k(params: *mut LiteRtLmSamplerParams, top_k: i32);
}
unsafe extern "C" {
    pub fn litert_lm_sampler_params_set_top_p(params: *mut LiteRtLmSamplerParams, top_p: f32);
}
unsafe extern "C" {
    pub fn litert_lm_sampler_params_set_temperature(
        params: *mut LiteRtLmSamplerParams,
        temperature: f32,
    );
}
unsafe extern "C" {
    pub fn litert_lm_sampler_params_set_seed(params: *mut LiteRtLmSamplerParams, seed: i32);
}
unsafe extern "C" {
    pub fn litert_lm_session_config_create() -> *mut LiteRtLmSessionConfig;
}
unsafe extern "C" {
    pub fn litert_lm_session_config_set_max_output_tokens(
        config: *mut LiteRtLmSessionConfig,
        max_output_tokens: ::std::os::raw::c_int,
    );
}
unsafe extern "C" {
    pub fn litert_lm_session_config_set_apply_prompt_template(
        config: *mut LiteRtLmSessionConfig,
        apply_prompt_template: bool,
    );
}
unsafe extern "C" {
    pub fn litert_lm_session_config_set_sampler_params(
        config: *mut LiteRtLmSessionConfig,
        sampler_params: *const LiteRtLmSamplerParams,
    );
}
unsafe extern "C" {
    pub fn litert_lm_session_config_delete(config: *mut LiteRtLmSessionConfig);
}
unsafe extern "C" {
    pub fn litert_lm_session_config_set_lora_path(
        config: *mut LiteRtLmSessionConfig,
        lora_path: *const ::std::os::raw::c_char,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    pub fn litert_lm_session_config_set_audio_lora_path(
        config: *mut LiteRtLmSessionConfig,
        audio_lora_path: *const ::std::os::raw::c_char,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    pub fn litert_lm_repetition_penalty_config_create() -> *mut LiteRtLmRepetitionPenaltyConfig;
}
unsafe extern "C" {
    pub fn litert_lm_repetition_penalty_config_delete(config: *mut LiteRtLmRepetitionPenaltyConfig);
}
unsafe extern "C" {
    pub fn litert_lm_repetition_penalty_config_set_repetition_penalty(
        config: *mut LiteRtLmRepetitionPenaltyConfig,
        repetition_penalty: f32,
    );
}
unsafe extern "C" {
    pub fn litert_lm_repetition_penalty_config_set_presence_penalty(
        config: *mut LiteRtLmRepetitionPenaltyConfig,
        presence_penalty: f32,
    );
}
unsafe extern "C" {
    pub fn litert_lm_repetition_penalty_config_set_frequency_penalty(
        config: *mut LiteRtLmRepetitionPenaltyConfig,
        frequency_penalty: f32,
    );
}
unsafe extern "C" {
    pub fn litert_lm_repetition_penalty_config_set_window_size(
        config: *mut LiteRtLmRepetitionPenaltyConfig,
        window_size: ::std::os::raw::c_int,
    );
}
unsafe extern "C" {
    pub fn litert_lm_no_repeat_ngram_config_create() -> *mut LiteRtLmNoRepeatNgramConfig;
}
unsafe extern "C" {
    pub fn litert_lm_no_repeat_ngram_config_delete(config: *mut LiteRtLmNoRepeatNgramConfig);
}
unsafe extern "C" {
    pub fn litert_lm_no_repeat_ngram_config_set_no_repeat_ngram_size(
        config: *mut LiteRtLmNoRepeatNgramConfig,
        no_repeat_ngram_size: ::std::os::raw::c_int,
    );
}
unsafe extern "C" {
    pub fn litert_lm_no_repeat_ngram_config_set_window_size(
        config: *mut LiteRtLmNoRepeatNgramConfig,
        window_size: ::std::os::raw::c_int,
    );
}
unsafe extern "C" {
    pub fn litert_lm_suppress_tokens_config_create() -> *mut LiteRtLmSuppressTokensConfig;
}
unsafe extern "C" {
    pub fn litert_lm_suppress_tokens_config_delete(config: *mut LiteRtLmSuppressTokensConfig);
}
unsafe extern "C" {
    pub fn litert_lm_suppress_tokens_config_set_suppress_tokens(
        config: *mut LiteRtLmSuppressTokensConfig,
        suppress_tokens: *const ::std::os::raw::c_int,
        num_tokens: usize,
    );
}
pub const kLiteRtLmLogSeverityVerbose: LiteRtLmLogSeverity = 0;
pub const kLiteRtLmLogSeverityDebug: LiteRtLmLogSeverity = 1;
pub const kLiteRtLmLogSeverityInfo: LiteRtLmLogSeverity = 2;
pub const kLiteRtLmLogSeverityWarning: LiteRtLmLogSeverity = 3;
pub const kLiteRtLmLogSeverityError: LiteRtLmLogSeverity = 4;
pub const kLiteRtLmLogSeverityFatal: LiteRtLmLogSeverity = 5;
pub const kLiteRtLmLogSeveritySilent: LiteRtLmLogSeverity = 1000;
pub type LiteRtLmLogSeverity = ::std::os::raw::c_uint;
unsafe extern "C" {
    pub fn litert_lm_set_min_log_level(level: LiteRtLmLogSeverity);
}
pub const kLiteRtLmInputDataTypeText: LiteRtLmInputDataType = 0;
pub const kLiteRtLmInputDataTypeImage: LiteRtLmInputDataType = 1;
pub const kLiteRtLmInputDataTypeImageEnd: LiteRtLmInputDataType = 2;
pub const kLiteRtLmInputDataTypeAudio: LiteRtLmInputDataType = 3;
pub const kLiteRtLmInputDataTypeAudioEnd: LiteRtLmInputDataType = 4;
pub type LiteRtLmInputDataType = ::std::os::raw::c_uint;
unsafe extern "C" {
    pub fn litert_lm_input_data_create(
        type_: LiteRtLmInputDataType,
        data: *const ::std::os::raw::c_void,
        size: usize,
    ) -> *mut LiteRtLmInputData;
}
unsafe extern "C" {
    pub fn litert_lm_input_data_delete(input_data: *mut LiteRtLmInputData);
}
unsafe extern "C" {
    pub fn litert_lm_engine_settings_create(
        model_path: *const ::std::os::raw::c_char,
        backend_str: *const ::std::os::raw::c_char,
        vision_backend_str: *const ::std::os::raw::c_char,
        audio_backend_str: *const ::std::os::raw::c_char,
    ) -> *mut LiteRtLmEngineSettings;
}
unsafe extern "C" {
    pub fn litert_lm_engine_settings_create_from_raw_file_descriptor(
        fd: ::std::os::raw::c_int,
        backend_str: *const ::std::os::raw::c_char,
        vision_backend_str: *const ::std::os::raw::c_char,
        audio_backend_str: *const ::std::os::raw::c_char,
    ) -> *mut LiteRtLmEngineSettings;
}
unsafe extern "C" {
    pub fn litert_lm_engine_settings_delete(settings: *mut LiteRtLmEngineSettings);
}
unsafe extern "C" {
    pub fn litert_lm_engine_settings_set_max_num_tokens(
        settings: *mut LiteRtLmEngineSettings,
        max_num_tokens: ::std::os::raw::c_int,
    );
}
unsafe extern "C" {
    pub fn litert_lm_engine_settings_set_num_threads(
        settings: *mut LiteRtLmEngineSettings,
        num_threads: ::std::os::raw::c_int,
    );
}
unsafe extern "C" {
    pub fn litert_lm_engine_settings_set_audio_num_threads(
        settings: *mut LiteRtLmEngineSettings,
        num_threads: ::std::os::raw::c_int,
    );
}
unsafe extern "C" {
    pub fn litert_lm_engine_settings_set_parallel_file_section_loading(
        settings: *mut LiteRtLmEngineSettings,
        parallel_file_section_loading: bool,
    );
}
unsafe extern "C" {
    pub fn litert_lm_engine_settings_set_max_num_images(
        settings: *mut LiteRtLmEngineSettings,
        max_num_images: ::std::os::raw::c_int,
    );
}
unsafe extern "C" {
    pub fn litert_lm_engine_settings_set_max_vision_tokens_per_image(
        settings: *mut LiteRtLmEngineSettings,
        max_vision_tokens_per_image: ::std::os::raw::c_int,
    );
}
unsafe extern "C" {
    pub fn litert_lm_engine_settings_set_cache_dir(
        settings: *mut LiteRtLmEngineSettings,
        cache_dir: *const ::std::os::raw::c_char,
    );
}
unsafe extern "C" {
    pub fn litert_lm_engine_settings_set_litert_dispatch_lib_dir(
        settings: *mut LiteRtLmEngineSettings,
        lib_dir: *const ::std::os::raw::c_char,
    );
}
pub const kLiteRtLmActivationDataTypeFloat32: LiteRtLmActivationDataType = 0;
pub const kLiteRtLmActivationDataTypeFloat16: LiteRtLmActivationDataType = 1;
pub const kLiteRtLmActivationDataTypeInt16: LiteRtLmActivationDataType = 2;
pub const kLiteRtLmActivationDataTypeInt8: LiteRtLmActivationDataType = 3;
pub type LiteRtLmActivationDataType = ::std::os::raw::c_uint;
unsafe extern "C" {
    pub fn litert_lm_engine_settings_set_activation_data_type(
        settings: *mut LiteRtLmEngineSettings,
        activation_data_type: LiteRtLmActivationDataType,
    );
}
unsafe extern "C" {
    pub fn litert_lm_engine_settings_set_prefill_chunk_size(
        settings: *mut LiteRtLmEngineSettings,
        prefill_chunk_size: ::std::os::raw::c_int,
    );
}
unsafe extern "C" {
    pub fn litert_lm_engine_settings_set_enable_ynnpack(
        settings: *mut LiteRtLmEngineSettings,
        enable_ynnpack: bool,
    );
}
unsafe extern "C" {
    pub fn litert_lm_engine_settings_enable_benchmark(settings: *mut LiteRtLmEngineSettings);
}
unsafe extern "C" {
    pub fn litert_lm_engine_settings_set_num_prefill_tokens(
        settings: *mut LiteRtLmEngineSettings,
        num_prefill_tokens: ::std::os::raw::c_int,
    );
}
unsafe extern "C" {
    pub fn litert_lm_engine_settings_set_num_decode_tokens(
        settings: *mut LiteRtLmEngineSettings,
        num_decode_tokens: ::std::os::raw::c_int,
    );
}
unsafe extern "C" {
    pub fn litert_lm_engine_settings_set_enable_speculative_decoding(
        settings: *mut LiteRtLmEngineSettings,
        enable_speculative_decoding: bool,
    );
}
unsafe extern "C" {
    pub fn litert_lm_engine_settings_set_gpu_decode_steps_per_sync(
        settings: *mut LiteRtLmEngineSettings,
        num_decode_steps_per_sync: ::std::os::raw::c_int,
    );
}
unsafe extern "C" {
    pub fn litert_lm_engine_settings_set_gpu_wait_for_weight_uploads(
        settings: *mut LiteRtLmEngineSettings,
        wait_for_weight_uploads: bool,
    );
}
unsafe extern "C" {
    pub fn litert_lm_engine_settings_set_use_ringbuffers_local_attention(
        settings: *mut LiteRtLmEngineSettings,
        use_ringbuffers_local_attention: bool,
    );
}
unsafe extern "C" {
    pub fn litert_lm_engine_settings_set_lora_rank(
        settings: *mut LiteRtLmEngineSettings,
        lora_rank: ::std::os::raw::c_int,
    );
}
unsafe extern "C" {
    pub fn litert_lm_engine_settings_set_supported_lora_ranks(
        settings: *mut LiteRtLmEngineSettings,
        lora_ranks: *const ::std::os::raw::c_int,
        num_ranks: usize,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    pub fn litert_lm_engine_settings_set_audio_lora_rank(
        settings: *mut LiteRtLmEngineSettings,
        lora_rank: ::std::os::raw::c_int,
    );
}
unsafe extern "C" {
    pub fn litert_lm_engine_settings_set_supported_audio_lora_ranks(
        settings: *mut LiteRtLmEngineSettings,
        lora_ranks: *const ::std::os::raw::c_int,
        num_ranks: usize,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    pub fn litert_lm_engine_settings_set_gpu_enable_metal_residency_set(
        settings: *mut LiteRtLmEngineSettings,
        enable_metal_residency_set: bool,
    );
}
unsafe extern "C" {
    pub fn litert_lm_engine_create(settings: *const LiteRtLmEngineSettings) -> *mut LiteRtLmEngine;
}
unsafe extern "C" {
    pub fn litert_lm_engine_delete(engine: *mut LiteRtLmEngine);
}
unsafe extern "C" {
    pub fn litert_lm_engine_create_session(
        engine: *mut LiteRtLmEngine,
        config: *mut LiteRtLmSessionConfig,
    ) -> *mut LiteRtLmSession;
}
unsafe extern "C" {
    pub fn litert_lm_session_delete(session: *mut LiteRtLmSession);
}
unsafe extern "C" {
    pub fn litert_lm_session_cancel_process(session: *mut LiteRtLmSession);
}
unsafe extern "C" {
    pub fn litert_lm_session_save_checkpoint(
        session: *mut LiteRtLmSession,
        label: *const ::std::os::raw::c_char,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    pub fn litert_lm_session_rewind_to_checkpoint(
        session: *mut LiteRtLmSession,
        label: *const ::std::os::raw::c_char,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    pub fn litert_lm_session_rewind_to_step(
        session: *mut LiteRtLmSession,
        step: ::std::os::raw::c_int,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    pub fn litert_lm_session_run_prefill(
        session: *mut LiteRtLmSession,
        inputs: *const *const LiteRtLmInputData,
        num_inputs: usize,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    pub fn litert_lm_session_run_decode(session: *mut LiteRtLmSession) -> *mut LiteRtLmResponses;
}
unsafe extern "C" {
    pub fn litert_lm_session_run_text_scoring(
        session: *mut LiteRtLmSession,
        target_text: *mut *const ::std::os::raw::c_char,
        num_targets: usize,
        store_token_lengths: bool,
    ) -> *mut LiteRtLmResponses;
}
unsafe extern "C" {
    pub fn litert_lm_session_generate_content(
        session: *mut LiteRtLmSession,
        inputs: *const *const LiteRtLmInputData,
        num_inputs: usize,
    ) -> *mut LiteRtLmResponses;
}
unsafe extern "C" {
    pub fn litert_lm_responses_delete(responses: *mut LiteRtLmResponses);
}
unsafe extern "C" {
    pub fn litert_lm_responses_get_num_candidates(
        responses: *const LiteRtLmResponses,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    pub fn litert_lm_responses_get_response_text_at(
        responses: *const LiteRtLmResponses,
        index: ::std::os::raw::c_int,
    ) -> *const ::std::os::raw::c_char;
}
unsafe extern "C" {
    pub fn litert_lm_responses_has_score_at(
        responses: *const LiteRtLmResponses,
        index: ::std::os::raw::c_int,
    ) -> bool;
}
unsafe extern "C" {
    pub fn litert_lm_responses_get_score_at(
        responses: *const LiteRtLmResponses,
        index: ::std::os::raw::c_int,
    ) -> f32;
}
unsafe extern "C" {
    pub fn litert_lm_responses_has_token_length_at(
        responses: *const LiteRtLmResponses,
        index: ::std::os::raw::c_int,
    ) -> bool;
}
unsafe extern "C" {
    pub fn litert_lm_responses_get_token_length_at(
        responses: *const LiteRtLmResponses,
        index: ::std::os::raw::c_int,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    pub fn litert_lm_responses_has_token_scores_at(
        responses: *const LiteRtLmResponses,
        index: ::std::os::raw::c_int,
    ) -> bool;
}
unsafe extern "C" {
    pub fn litert_lm_responses_get_num_token_scores_at(
        responses: *const LiteRtLmResponses,
        index: ::std::os::raw::c_int,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    pub fn litert_lm_responses_get_token_scores_at(
        responses: *const LiteRtLmResponses,
        index: ::std::os::raw::c_int,
    ) -> *const f32;
}
unsafe extern "C" {
    pub fn litert_lm_session_get_benchmark_info(
        session: *mut LiteRtLmSession,
    ) -> *mut LiteRtLmBenchmarkInfo;
}
unsafe extern "C" {
    pub fn litert_lm_benchmark_info_delete(benchmark_info: *mut LiteRtLmBenchmarkInfo);
}
unsafe extern "C" {
    pub fn litert_lm_benchmark_info_get_time_to_first_token(
        benchmark_info: *const LiteRtLmBenchmarkInfo,
    ) -> f64;
}
unsafe extern "C" {
    pub fn litert_lm_benchmark_info_get_total_init_time_in_second(
        benchmark_info: *const LiteRtLmBenchmarkInfo,
    ) -> f64;
}
unsafe extern "C" {
    pub fn litert_lm_benchmark_info_get_num_prefill_turns(
        benchmark_info: *const LiteRtLmBenchmarkInfo,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    pub fn litert_lm_benchmark_info_get_num_decode_turns(
        benchmark_info: *const LiteRtLmBenchmarkInfo,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    pub fn litert_lm_benchmark_info_get_prefill_token_count_at(
        benchmark_info: *const LiteRtLmBenchmarkInfo,
        index: ::std::os::raw::c_int,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    pub fn litert_lm_benchmark_info_get_decode_token_count_at(
        benchmark_info: *const LiteRtLmBenchmarkInfo,
        index: ::std::os::raw::c_int,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    pub fn litert_lm_benchmark_info_get_prefill_tokens_per_sec_at(
        benchmark_info: *const LiteRtLmBenchmarkInfo,
        index: ::std::os::raw::c_int,
    ) -> f64;
}
unsafe extern "C" {
    pub fn litert_lm_benchmark_info_get_decode_tokens_per_sec_at(
        benchmark_info: *const LiteRtLmBenchmarkInfo,
        index: ::std::os::raw::c_int,
    ) -> f64;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct LiteRtLmStreamChunk {
    _unused: [u8; 0],
}
unsafe extern "C" {
    pub fn litert_lm_stream_chunk_get_text(
        chunk: *const LiteRtLmStreamChunk,
    ) -> *const ::std::os::raw::c_char;
}
unsafe extern "C" {
    pub fn litert_lm_stream_chunk_is_final(chunk: *const LiteRtLmStreamChunk) -> bool;
}
unsafe extern "C" {
    pub fn litert_lm_stream_chunk_get_error(
        chunk: *const LiteRtLmStreamChunk,
    ) -> *const ::std::os::raw::c_char;
}
pub type LiteRtLmStreamCallback = ::std::option::Option<
    unsafe extern "C" fn(
        callback_data: *mut ::std::os::raw::c_void,
        chunk: *const LiteRtLmStreamChunk,
    ),
>;
unsafe extern "C" {
    pub fn litert_lm_session_run_decode_async(
        session: *mut LiteRtLmSession,
        callback: LiteRtLmStreamCallback,
        callback_data: *mut ::std::os::raw::c_void,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    pub fn litert_lm_session_generate_content_stream(
        session: *mut LiteRtLmSession,
        inputs: *const *const LiteRtLmInputData,
        num_inputs: usize,
        callback: LiteRtLmStreamCallback,
        callback_data: *mut ::std::os::raw::c_void,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    pub fn litert_lm_engine_tokenize(
        engine: *mut LiteRtLmEngine,
        text: *const ::std::os::raw::c_char,
    ) -> *mut LiteRtLmTokenizeResult;
}
unsafe extern "C" {
    pub fn litert_lm_tokenize_result_delete(result: *mut LiteRtLmTokenizeResult);
}
unsafe extern "C" {
    pub fn litert_lm_tokenize_result_get_tokens(
        result: *const LiteRtLmTokenizeResult,
    ) -> *const ::std::os::raw::c_int;
}
unsafe extern "C" {
    pub fn litert_lm_tokenize_result_get_num_tokens(result: *const LiteRtLmTokenizeResult)
        -> usize;
}
unsafe extern "C" {
    pub fn litert_lm_engine_detokenize(
        engine: *mut LiteRtLmEngine,
        tokens: *const ::std::os::raw::c_int,
        num_tokens: usize,
    ) -> *mut LiteRtLmDetokenizeResult;
}
unsafe extern "C" {
    pub fn litert_lm_detokenize_result_delete(result: *mut LiteRtLmDetokenizeResult);
}
unsafe extern "C" {
    pub fn litert_lm_detokenize_result_get_string(
        result: *const LiteRtLmDetokenizeResult,
    ) -> *const ::std::os::raw::c_char;
}
unsafe extern "C" {
    pub fn litert_lm_token_union_delete(token_union: *mut LiteRtLmTokenUnion);
}
unsafe extern "C" {
    pub fn litert_lm_token_union_get_type(
        token_union: *const LiteRtLmTokenUnion,
    ) -> LiteRtLmTokenUnionType;
}
unsafe extern "C" {
    pub fn litert_lm_token_union_get_string(
        token_union: *const LiteRtLmTokenUnion,
    ) -> *const ::std::os::raw::c_char;
}
unsafe extern "C" {
    pub fn litert_lm_token_union_get_ids(
        token_union: *const LiteRtLmTokenUnion,
        out_tokens: *mut *const ::std::os::raw::c_int,
        out_num_tokens: *mut usize,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    pub fn litert_lm_token_unions_delete(tokens: *mut LiteRtLmTokenUnions);
}
unsafe extern "C" {
    pub fn litert_lm_token_unions_get_num_tokens(tokens: *const LiteRtLmTokenUnions) -> usize;
}
unsafe extern "C" {
    pub fn litert_lm_token_unions_get_token_at(
        tokens: *const LiteRtLmTokenUnions,
        index: usize,
    ) -> *mut LiteRtLmTokenUnion;
}
unsafe extern "C" {
    pub fn litert_lm_engine_get_start_token(engine: *mut LiteRtLmEngine)
        -> *mut LiteRtLmTokenUnion;
}
unsafe extern "C" {
    pub fn litert_lm_engine_get_stop_tokens(
        engine: *mut LiteRtLmEngine,
    ) -> *mut LiteRtLmTokenUnions;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct LiteRtLmConversation {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct LiteRtLmConversationOptionalArgs {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct LiteRtLmJsonResponse {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct LiteRtLmConversationConfig {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct LiteRtLmThinkingConfig {
    _unused: [u8; 0],
}
pub const kLiteRtLmConstraintTypeNone: LiteRtLmConstraintType = 0;
pub const kLiteRtLmConstraintTypeRegex: LiteRtLmConstraintType = 1;
pub const kLiteRtLmConstraintTypeJsonSchema: LiteRtLmConstraintType = 2;
pub type LiteRtLmConstraintType = ::std::os::raw::c_uint;
pub const kLiteRtLmConstraintProviderTypeLlGuidance: LiteRtLmConstraintProviderType = 1;
pub type LiteRtLmConstraintProviderType = ::std::os::raw::c_uint;
unsafe extern "C" {
    pub fn litert_lm_conversation_config_create() -> *mut LiteRtLmConversationConfig;
}
unsafe extern "C" {
    pub fn litert_lm_conversation_config_set_session_config(
        config: *mut LiteRtLmConversationConfig,
        session_config: *const LiteRtLmSessionConfig,
    );
}
unsafe extern "C" {
    pub fn litert_lm_conversation_config_set_system_message(
        config: *mut LiteRtLmConversationConfig,
        system_message_json: *const ::std::os::raw::c_char,
    );
}
unsafe extern "C" {
    pub fn litert_lm_conversation_config_set_tools(
        config: *mut LiteRtLmConversationConfig,
        tools_json: *const ::std::os::raw::c_char,
    );
}
unsafe extern "C" {
    pub fn litert_lm_conversation_config_set_messages(
        config: *mut LiteRtLmConversationConfig,
        messages_json: *const ::std::os::raw::c_char,
    );
}
unsafe extern "C" {
    pub fn litert_lm_conversation_config_set_extra_context(
        config: *mut LiteRtLmConversationConfig,
        extra_context_json: *const ::std::os::raw::c_char,
    );
}
unsafe extern "C" {
    pub fn litert_lm_conversation_config_set_prompt_template(
        config: *mut LiteRtLmConversationConfig,
        prompt_template: *const ::std::os::raw::c_char,
    );
}
unsafe extern "C" {
    pub fn litert_lm_conversation_config_set_enable_constrained_decoding(
        config: *mut LiteRtLmConversationConfig,
        enable_constrained_decoding: bool,
    );
}
unsafe extern "C" {
    pub fn litert_lm_conversation_config_set_constraint_provider(
        config: *mut LiteRtLmConversationConfig,
        provider_type: *const LiteRtLmConstraintProviderType,
    );
}
unsafe extern "C" {
    pub fn litert_lm_conversation_config_set_filter_channel_content_from_kv_cache(
        config: *mut LiteRtLmConversationConfig,
        filter_channel_content_from_kv_cache: bool,
    );
}
unsafe extern "C" {
    pub fn litert_lm_conversation_config_set_stream_tool_calls(
        config: *mut LiteRtLmConversationConfig,
        stream_tool_calls: bool,
        channel_name: *const ::std::os::raw::c_char,
    );
}
unsafe extern "C" {
    pub fn litert_lm_thinking_config_create() -> *mut LiteRtLmThinkingConfig;
}
unsafe extern "C" {
    pub fn litert_lm_thinking_config_delete(config: *mut LiteRtLmThinkingConfig);
}
unsafe extern "C" {
    pub fn litert_lm_thinking_config_set_enable_thinking(
        config: *mut LiteRtLmThinkingConfig,
        enable_thinking: bool,
    );
}
unsafe extern "C" {
    pub fn litert_lm_thinking_config_set_thinking_token_budget(
        config: *mut LiteRtLmThinkingConfig,
        thinking_token_budget: ::std::os::raw::c_int,
    );
}
unsafe extern "C" {
    pub fn litert_lm_conversation_config_set_thinking_config(
        config: *mut LiteRtLmConversationConfig,
        thinking_config: *const LiteRtLmThinkingConfig,
    );
}
unsafe extern "C" {
    pub fn litert_lm_conversation_config_delete(config: *mut LiteRtLmConversationConfig);
}
unsafe extern "C" {
    pub fn litert_lm_conversation_optional_args_create() -> *mut LiteRtLmConversationOptionalArgs;
}
unsafe extern "C" {
    pub fn litert_lm_conversation_optional_args_delete(
        optional_args: *mut LiteRtLmConversationOptionalArgs,
    );
}
unsafe extern "C" {
    pub fn litert_lm_conversation_optional_args_set_repetition_penalty_config(
        optional_args: *mut LiteRtLmConversationOptionalArgs,
        repetition_penalty_config: *const LiteRtLmRepetitionPenaltyConfig,
    );
}
unsafe extern "C" {
    pub fn litert_lm_conversation_optional_args_set_no_repeat_ngram_config(
        optional_args: *mut LiteRtLmConversationOptionalArgs,
        no_repeat_ngram_config: *const LiteRtLmNoRepeatNgramConfig,
    );
}
unsafe extern "C" {
    pub fn litert_lm_conversation_optional_args_set_suppress_tokens_config(
        optional_args: *mut LiteRtLmConversationOptionalArgs,
        suppress_tokens_config: *const LiteRtLmSuppressTokensConfig,
    );
}
unsafe extern "C" {
    pub fn litert_lm_conversation_optional_args_set_visual_token_budget(
        optional_args: *mut LiteRtLmConversationOptionalArgs,
        visual_token_budget: ::std::os::raw::c_int,
    );
}
unsafe extern "C" {
    pub fn litert_lm_conversation_optional_args_set_max_output_tokens(
        optional_args: *mut LiteRtLmConversationOptionalArgs,
        max_output_tokens: ::std::os::raw::c_int,
    );
}
unsafe extern "C" {
    pub fn litert_lm_conversation_optional_args_set_thinking_config(
        optional_args: *mut LiteRtLmConversationOptionalArgs,
        thinking_config: *const LiteRtLmThinkingConfig,
    );
}
unsafe extern "C" {
    pub fn litert_lm_conversation_optional_args_set_constraint(
        optional_args: *mut LiteRtLmConversationOptionalArgs,
        constraint_type: LiteRtLmConstraintType,
        constraint_string: *const ::std::os::raw::c_char,
    );
}
unsafe extern "C" {
    pub fn litert_lm_conversation_create(
        engine: *mut LiteRtLmEngine,
        config: *mut LiteRtLmConversationConfig,
    ) -> *mut LiteRtLmConversation;
}
unsafe extern "C" {
    pub fn litert_lm_conversation_delete(conversation: *mut LiteRtLmConversation);
}
unsafe extern "C" {
    pub fn litert_lm_conversation_clone(
        conversation: *mut LiteRtLmConversation,
    ) -> *mut LiteRtLmConversation;
}
unsafe extern "C" {
    pub fn litert_lm_conversation_send_message(
        conversation: *mut LiteRtLmConversation,
        message_json: *const ::std::os::raw::c_char,
        extra_context: *const ::std::os::raw::c_char,
        optional_args: *const LiteRtLmConversationOptionalArgs,
    ) -> *mut LiteRtLmJsonResponse;
}
unsafe extern "C" {
    pub fn litert_lm_json_response_delete(response: *mut LiteRtLmJsonResponse);
}
unsafe extern "C" {
    pub fn litert_lm_json_response_get_string(
        response: *const LiteRtLmJsonResponse,
    ) -> *const ::std::os::raw::c_char;
}
unsafe extern "C" {
    pub fn litert_lm_conversation_send_message_stream(
        conversation: *mut LiteRtLmConversation,
        message_json: *const ::std::os::raw::c_char,
        extra_context: *const ::std::os::raw::c_char,
        optional_args: *const LiteRtLmConversationOptionalArgs,
        callback: LiteRtLmStreamCallback,
        callback_data: *mut ::std::os::raw::c_void,
    ) -> ::std::os::raw::c_int;
}
unsafe extern "C" {
    pub fn litert_lm_conversation_render_message_to_string(
        conversation: *mut LiteRtLmConversation,
        message_json: *const ::std::os::raw::c_char,
    ) -> *const ::std::os::raw::c_char;
}
unsafe extern "C" {
    pub fn litert_lm_conversation_render_preface_to_string(
        conversation: *mut LiteRtLmConversation,
    ) -> *const ::std::os::raw::c_char;
}
unsafe extern "C" {
    pub fn litert_lm_conversation_cancel_process(conversation: *mut LiteRtLmConversation);
}
unsafe extern "C" {
    pub fn litert_lm_conversation_get_benchmark_info(
        conversation: *mut LiteRtLmConversation,
    ) -> *mut LiteRtLmBenchmarkInfo;
}
unsafe extern "C" {
    pub fn litert_lm_conversation_get_token_count(
        conversation: *mut LiteRtLmConversation,
    ) -> ::std::os::raw::c_int;
}