liter_llm 2.0.3 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  // This file is auto-generated by alef. DO NOT EDIT.
2
- // alef:hash:6423443d8189e0b67fd55f0b3e0fad7fdb360e3c24a0f3334fd01896befda4b5
2
+ // alef:hash:c38ee16af03a7f5880934b3b89c3209a36af80d907b6491debc2153c4df4d7bf
3
3
  // Re-generate with: alef generate
4
4
  #![allow(dead_code, unused_imports, unused_variables)]
5
5
  #![allow(
@@ -4724,7 +4724,12 @@ impl EmbeddingRequest {
4724
4724
  format!("invalid value for `input`: {}", e),
4725
4725
  )
4726
4726
  })?,
4727
- None => Default::default(),
4727
+ None => {
4728
+ return Err(magnus::Error::new(
4729
+ unsafe { magnus::Ruby::get_unchecked() }.exception_arg_error(),
4730
+ "missing required field: input",
4731
+ ));
4732
+ }
4728
4733
  },
4729
4734
  encoding_format: match kwargs.get(ruby.to_symbol("encoding_format")).filter(|v| !v.is_nil()) {
4730
4735
  Some(v) => Some(EmbeddingFormat::try_convert(v).map_err(|e| {
@@ -8135,7 +8140,12 @@ impl ModerationRequest {
8135
8140
  format!("invalid value for `input`: {}", e),
8136
8141
  )
8137
8142
  })?,
8138
- None => Default::default(),
8143
+ None => {
8144
+ return Err(magnus::Error::new(
8145
+ unsafe { magnus::Ruby::get_unchecked() }.exception_arg_error(),
8146
+ "missing required field: input",
8147
+ ));
8148
+ }
8139
8149
  },
8140
8150
  model: match kwargs.get(ruby.to_symbol("model")).filter(|v| !v.is_nil()) {
8141
8151
  Some(v) => Some(String::try_convert(v).map_err(|e| {
@@ -8623,7 +8633,12 @@ impl OcrRequest {
8623
8633
  format!("invalid value for `document`: {}", e),
8624
8634
  )
8625
8635
  })?,
8626
- None => Default::default(),
8636
+ None => {
8637
+ return Err(magnus::Error::new(
8638
+ unsafe { magnus::Ruby::get_unchecked() }.exception_arg_error(),
8639
+ "missing required field: document",
8640
+ ));
8641
+ }
8627
8642
  },
8628
8643
  pages: match kwargs.get(ruby.to_symbol("pages")).filter(|v| !v.is_nil()) {
8629
8644
  Some(v) => Some(<Vec<u32>>::try_convert(v).map_err(|e| {
@@ -11227,7 +11242,12 @@ impl SystemMessage {
11227
11242
  format!("invalid value for `content`: {}", e),
11228
11243
  )
11229
11244
  })?,
11230
- None => Default::default(),
11245
+ None => {
11246
+ return Err(magnus::Error::new(
11247
+ unsafe { magnus::Ruby::get_unchecked() }.exception_arg_error(),
11248
+ "missing required field: content",
11249
+ ));
11250
+ }
11231
11251
  },
11232
11252
  name: match kwargs.get(ruby.to_symbol("name")).filter(|v| !v.is_nil()) {
11233
11253
  Some(v) => Some(String::try_convert(v).map_err(|e| {
@@ -11412,7 +11432,12 @@ impl ToolMessage {
11412
11432
  format!("invalid value for `content`: {}", e),
11413
11433
  )
11414
11434
  })?,
11415
- None => Default::default(),
11435
+ None => {
11436
+ return Err(magnus::Error::new(
11437
+ unsafe { magnus::Ruby::get_unchecked() }.exception_arg_error(),
11438
+ "missing required field: content",
11439
+ ));
11440
+ }
11416
11441
  },
11417
11442
  tool_call_id: match kwargs.get(ruby.to_symbol("tool_call_id")) {
11418
11443
  Some(v) => String::try_convert(v).map_err(|e| {
@@ -11852,7 +11877,12 @@ impl UserMessage {
11852
11877
  format!("invalid value for `content`: {}", e),
11853
11878
  )
11854
11879
  })?,
11855
- None => Default::default(),
11880
+ None => {
11881
+ return Err(magnus::Error::new(
11882
+ unsafe { magnus::Ruby::get_unchecked() }.exception_arg_error(),
11883
+ "missing required field: content",
11884
+ ));
11885
+ }
11856
11886
  },
11857
11887
  name: match kwargs.get(ruby.to_symbol("name")).filter(|v| !v.is_nil()) {
11858
11888
  Some(v) => Some(String::try_convert(v).map_err(|e| {
@@ -11995,12 +12025,6 @@ pub enum AssistantContent {
11995
12025
  Parts(Vec<AssistantPart>),
11996
12026
  }
11997
12027
 
11998
- impl Default for AssistantContent {
11999
- fn default() -> Self {
12000
- Self::Text(Default::default())
12001
- }
12002
- }
12003
-
12004
12028
  impl magnus::IntoValue for AssistantContent {
12005
12029
  fn into_value_with(self, handle: &Ruby) -> magnus::Value {
12006
12030
  match serde_json::to_value(&self) {
@@ -12054,14 +12078,6 @@ pub enum AssistantPart {
12054
12078
  OutputAudio { audio: AudioContent },
12055
12079
  }
12056
12080
 
12057
- impl Default for AssistantPart {
12058
- fn default() -> Self {
12059
- Self::Text {
12060
- text: Default::default(),
12061
- }
12062
- }
12063
- }
12064
-
12065
12081
  impl magnus::IntoValue for AssistantPart {
12066
12082
  fn into_value_with(self, handle: &Ruby) -> magnus::Value {
12067
12083
  match serde_json::to_value(&self) {
@@ -12073,7 +12089,8 @@ impl magnus::IntoValue for AssistantPart {
12073
12089
 
12074
12090
  impl magnus::TryConvert for AssistantPart {
12075
12091
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
12076
- // For data enums with fields (e.g., PageAction), try to deserialize from JSON first.
12092
+ // Generated Data variants carry native DTOs, not JSON-compatible display strings.
12093
+ let class_name: Option<String> = val.class().funcall("name", ())?; // For data enums with fields (e.g., PageAction), try to deserialize from JSON first.
12077
12094
  // For unit enums or when passed as a string, fall back to string-based conversion.
12078
12095
  let json_str: String = if let Ok(s) = <String as magnus::TryConvert>::try_convert(val) {
12079
12096
  s
@@ -12105,12 +12122,13 @@ impl magnus::TryConvert for AssistantPart {
12105
12122
 
12106
12123
  unsafe impl IntoValueFromNative for AssistantPart {}
12107
12124
  unsafe impl TryConvertOwned for AssistantPart {}
12125
+
12108
12126
  impl AssistantPart {}
12109
12127
 
12110
12128
  #[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
12111
12129
  pub enum AuthHeaderFormat {
12112
12130
  Bearer,
12113
- ApiKey { _0: String },
12131
+ ApiKey(String),
12114
12132
  None,
12115
12133
  }
12116
12134
 
@@ -12163,7 +12181,7 @@ impl magnus::TryConvert for AuthHeaderFormat {
12163
12181
  unsafe impl IntoValueFromNative for AuthHeaderFormat {}
12164
12182
  unsafe impl TryConvertOwned for AuthHeaderFormat {}
12165
12183
 
12166
- #[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
12184
+ #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, serde::Serialize, serde::Deserialize)]
12167
12185
  #[serde(rename_all = "kebab-case")]
12168
12186
  pub enum AuthType {
12169
12187
  Bearer,
@@ -12192,7 +12210,14 @@ impl magnus::IntoValue for AuthType {
12192
12210
 
12193
12211
  impl magnus::TryConvert for AuthType {
12194
12212
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
12195
- let s: String = magnus::TryConvert::try_convert(val)?;
12213
+ // IntoValue emits Symbols, including when this enum is a Hash key.
12214
+ // Accept that exact representation as well as String inputs; do not
12215
+ // coerce arbitrary objects through to_s.
12216
+ let s: String = if let Some(symbol) = magnus::Symbol::from_value(val) {
12217
+ symbol.name()?.into_owned()
12218
+ } else {
12219
+ magnus::TryConvert::try_convert(val)?
12220
+ };
12196
12221
  // Accept the real serde wire value, the legacy always-snake_case symbol Magnus used to
12197
12222
  // emit unconditionally, and the verbatim PascalCase Rust variant name, so fixtures and
12198
12223
  // existing consumer code written in any of those styles keep working.
@@ -12212,7 +12237,7 @@ impl magnus::TryConvert for AuthType {
12212
12237
  unsafe impl IntoValueFromNative for AuthType {}
12213
12238
  unsafe impl TryConvertOwned for AuthType {}
12214
12239
 
12215
- #[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
12240
+ #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, serde::Serialize, serde::Deserialize)]
12216
12241
  #[serde(rename_all = "snake_case")]
12217
12242
  pub enum BatchStatus {
12218
12243
  Validating,
@@ -12249,7 +12274,14 @@ impl magnus::IntoValue for BatchStatus {
12249
12274
 
12250
12275
  impl magnus::TryConvert for BatchStatus {
12251
12276
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
12252
- let s: String = magnus::TryConvert::try_convert(val)?;
12277
+ // IntoValue emits Symbols, including when this enum is a Hash key.
12278
+ // Accept that exact representation as well as String inputs; do not
12279
+ // coerce arbitrary objects through to_s.
12280
+ let s: String = if let Some(symbol) = magnus::Symbol::from_value(val) {
12281
+ symbol.name()?.into_owned()
12282
+ } else {
12283
+ magnus::TryConvert::try_convert(val)?
12284
+ };
12253
12285
  // Accept the real serde wire value, the legacy always-snake_case symbol Magnus used to
12254
12286
  // emit unconditionally, and the verbatim PascalCase Rust variant name, so fixtures and
12255
12287
  // existing consumer code written in any of those styles keep working.
@@ -12298,7 +12330,8 @@ impl magnus::IntoValue for CacheBackend {
12298
12330
 
12299
12331
  impl magnus::TryConvert for CacheBackend {
12300
12332
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
12301
- // For data enums with fields (e.g., PageAction), try to deserialize from JSON first.
12333
+ // Generated Data variants carry native DTOs, not JSON-compatible display strings.
12334
+ let class_name: Option<String> = val.class().funcall("name", ())?; // For data enums with fields (e.g., PageAction), try to deserialize from JSON first.
12302
12335
  // For unit enums or when passed as a string, fall back to string-based conversion.
12303
12336
  let json_str: String = if let Ok(s) = <String as magnus::TryConvert>::try_convert(val) {
12304
12337
  s
@@ -12330,9 +12363,10 @@ impl magnus::TryConvert for CacheBackend {
12330
12363
 
12331
12364
  unsafe impl IntoValueFromNative for CacheBackend {}
12332
12365
  unsafe impl TryConvertOwned for CacheBackend {}
12366
+
12333
12367
  impl CacheBackend {}
12334
12368
 
12335
- #[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
12369
+ #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, serde::Serialize, serde::Deserialize)]
12336
12370
  pub enum CircuitState {
12337
12371
  Closed,
12338
12372
  Open,
@@ -12358,7 +12392,14 @@ impl magnus::IntoValue for CircuitState {
12358
12392
 
12359
12393
  impl magnus::TryConvert for CircuitState {
12360
12394
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
12361
- let s: String = magnus::TryConvert::try_convert(val)?;
12395
+ // IntoValue emits Symbols, including when this enum is a Hash key.
12396
+ // Accept that exact representation as well as String inputs; do not
12397
+ // coerce arbitrary objects through to_s.
12398
+ let s: String = if let Some(symbol) = magnus::Symbol::from_value(val) {
12399
+ symbol.name()?.into_owned()
12400
+ } else {
12401
+ magnus::TryConvert::try_convert(val)?
12402
+ };
12362
12403
  // Accept the real serde wire value, the legacy always-snake_case symbol Magnus used to
12363
12404
  // emit unconditionally, and the verbatim PascalCase Rust variant name, so fixtures and
12364
12405
  // existing consumer code written in any of those styles keep working.
@@ -12390,14 +12431,6 @@ pub enum ContentPart {
12390
12431
  InputAudio { input_audio: AudioContent },
12391
12432
  }
12392
12433
 
12393
- impl Default for ContentPart {
12394
- fn default() -> Self {
12395
- Self::Text {
12396
- text: Default::default(),
12397
- }
12398
- }
12399
- }
12400
-
12401
12434
  impl magnus::IntoValue for ContentPart {
12402
12435
  fn into_value_with(self, handle: &Ruby) -> magnus::Value {
12403
12436
  match serde_json::to_value(&self) {
@@ -12409,7 +12442,8 @@ impl magnus::IntoValue for ContentPart {
12409
12442
 
12410
12443
  impl magnus::TryConvert for ContentPart {
12411
12444
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
12412
- // For data enums with fields (e.g., PageAction), try to deserialize from JSON first.
12445
+ // Generated Data variants carry native DTOs, not JSON-compatible display strings.
12446
+ let class_name: Option<String> = val.class().funcall("name", ())?; // For data enums with fields (e.g., PageAction), try to deserialize from JSON first.
12413
12447
  // For unit enums or when passed as a string, fall back to string-based conversion.
12414
12448
  let json_str: String = if let Ok(s) = <String as magnus::TryConvert>::try_convert(val) {
12415
12449
  s
@@ -12441,6 +12475,7 @@ impl magnus::TryConvert for ContentPart {
12441
12475
 
12442
12476
  unsafe impl IntoValueFromNative for ContentPart {}
12443
12477
  unsafe impl TryConvertOwned for ContentPart {}
12478
+
12444
12479
  impl ContentPart {}
12445
12480
 
12446
12481
  #[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
@@ -12454,14 +12489,6 @@ pub enum EmbeddingContentPart {
12454
12489
  ImageBase64 { image_base64: String },
12455
12490
  }
12456
12491
 
12457
- impl Default for EmbeddingContentPart {
12458
- fn default() -> Self {
12459
- Self::Text {
12460
- text: Default::default(),
12461
- }
12462
- }
12463
- }
12464
-
12465
12492
  impl magnus::IntoValue for EmbeddingContentPart {
12466
12493
  fn into_value_with(self, handle: &Ruby) -> magnus::Value {
12467
12494
  match serde_json::to_value(&self) {
@@ -12473,7 +12500,8 @@ impl magnus::IntoValue for EmbeddingContentPart {
12473
12500
 
12474
12501
  impl magnus::TryConvert for EmbeddingContentPart {
12475
12502
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
12476
- // For data enums with fields (e.g., PageAction), try to deserialize from JSON first.
12503
+ // Generated Data variants carry native DTOs, not JSON-compatible display strings.
12504
+ let class_name: Option<String> = val.class().funcall("name", ())?; // For data enums with fields (e.g., PageAction), try to deserialize from JSON first.
12477
12505
  // For unit enums or when passed as a string, fall back to string-based conversion.
12478
12506
  let json_str: String = if let Ok(s) = <String as magnus::TryConvert>::try_convert(val) {
12479
12507
  s
@@ -12505,9 +12533,10 @@ impl magnus::TryConvert for EmbeddingContentPart {
12505
12533
 
12506
12534
  unsafe impl IntoValueFromNative for EmbeddingContentPart {}
12507
12535
  unsafe impl TryConvertOwned for EmbeddingContentPart {}
12536
+
12508
12537
  impl EmbeddingContentPart {}
12509
12538
 
12510
- #[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
12539
+ #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, serde::Serialize, serde::Deserialize)]
12511
12540
  #[serde(rename_all = "lowercase")]
12512
12541
  pub enum EmbeddingFormat {
12513
12542
  Float,
@@ -12532,7 +12561,14 @@ impl magnus::IntoValue for EmbeddingFormat {
12532
12561
 
12533
12562
  impl magnus::TryConvert for EmbeddingFormat {
12534
12563
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
12535
- let s: String = magnus::TryConvert::try_convert(val)?;
12564
+ // IntoValue emits Symbols, including when this enum is a Hash key.
12565
+ // Accept that exact representation as well as String inputs; do not
12566
+ // coerce arbitrary objects through to_s.
12567
+ let s: String = if let Some(symbol) = magnus::Symbol::from_value(val) {
12568
+ symbol.name()?.into_owned()
12569
+ } else {
12570
+ magnus::TryConvert::try_convert(val)?
12571
+ };
12536
12572
  // Accept the real serde wire value, the legacy always-snake_case symbol Magnus used to
12537
12573
  // emit unconditionally, and the verbatim PascalCase Rust variant name, so fixtures and
12538
12574
  // existing consumer code written in any of those styles keep working.
@@ -12558,12 +12594,6 @@ pub enum EmbeddingInput {
12558
12594
  Multimodal(Vec<EmbeddingContentPart>),
12559
12595
  }
12560
12596
 
12561
- impl Default for EmbeddingInput {
12562
- fn default() -> Self {
12563
- Self::Single(Default::default())
12564
- }
12565
- }
12566
-
12567
12597
  impl magnus::IntoValue for EmbeddingInput {
12568
12598
  fn into_value_with(self, handle: &Ruby) -> magnus::Value {
12569
12599
  match serde_json::to_value(&self) {
@@ -12607,7 +12637,7 @@ impl magnus::TryConvert for EmbeddingInput {
12607
12637
  unsafe impl IntoValueFromNative for EmbeddingInput {}
12608
12638
  unsafe impl TryConvertOwned for EmbeddingInput {}
12609
12639
 
12610
- #[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
12640
+ #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, serde::Serialize, serde::Deserialize)]
12611
12641
  pub enum Enforcement {
12612
12642
  Hard,
12613
12643
  Soft,
@@ -12631,7 +12661,14 @@ impl magnus::IntoValue for Enforcement {
12631
12661
 
12632
12662
  impl magnus::TryConvert for Enforcement {
12633
12663
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
12634
- let s: String = magnus::TryConvert::try_convert(val)?;
12664
+ // IntoValue emits Symbols, including when this enum is a Hash key.
12665
+ // Accept that exact representation as well as String inputs; do not
12666
+ // coerce arbitrary objects through to_s.
12667
+ let s: String = if let Some(symbol) = magnus::Symbol::from_value(val) {
12668
+ symbol.name()?.into_owned()
12669
+ } else {
12670
+ magnus::TryConvert::try_convert(val)?
12671
+ };
12635
12672
  // Accept the real serde wire value, the legacy always-snake_case symbol Magnus used to
12636
12673
  // emit unconditionally, and the verbatim PascalCase Rust variant name, so fixtures and
12637
12674
  // existing consumer code written in any of those styles keep working.
@@ -12649,7 +12686,7 @@ impl magnus::TryConvert for Enforcement {
12649
12686
  unsafe impl IntoValueFromNative for Enforcement {}
12650
12687
  unsafe impl TryConvertOwned for Enforcement {}
12651
12688
 
12652
- #[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
12689
+ #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, serde::Serialize, serde::Deserialize)]
12653
12690
  #[serde(rename_all = "kebab-case")]
12654
12691
  pub enum FilePurpose {
12655
12692
  Assistants,
@@ -12678,7 +12715,14 @@ impl magnus::IntoValue for FilePurpose {
12678
12715
 
12679
12716
  impl magnus::TryConvert for FilePurpose {
12680
12717
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
12681
- let s: String = magnus::TryConvert::try_convert(val)?;
12718
+ // IntoValue emits Symbols, including when this enum is a Hash key.
12719
+ // Accept that exact representation as well as String inputs; do not
12720
+ // coerce arbitrary objects through to_s.
12721
+ let s: String = if let Some(symbol) = magnus::Symbol::from_value(val) {
12722
+ symbol.name()?.into_owned()
12723
+ } else {
12724
+ magnus::TryConvert::try_convert(val)?
12725
+ };
12682
12726
  // Accept the real serde wire value, the legacy always-snake_case symbol Magnus used to
12683
12727
  // emit unconditionally, and the verbatim PascalCase Rust variant name, so fixtures and
12684
12728
  // existing consumer code written in any of those styles keep working.
@@ -12698,7 +12742,7 @@ impl magnus::TryConvert for FilePurpose {
12698
12742
  unsafe impl IntoValueFromNative for FilePurpose {}
12699
12743
  unsafe impl TryConvertOwned for FilePurpose {}
12700
12744
 
12701
- #[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
12745
+ #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, serde::Serialize, serde::Deserialize)]
12702
12746
  #[serde(rename_all = "snake_case")]
12703
12747
  pub enum FinishReason {
12704
12748
  Stop,
@@ -12732,7 +12776,14 @@ impl magnus::IntoValue for FinishReason {
12732
12776
 
12733
12777
  impl magnus::TryConvert for FinishReason {
12734
12778
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
12735
- let s: String = magnus::TryConvert::try_convert(val)?;
12779
+ // IntoValue emits Symbols, including when this enum is a Hash key.
12780
+ // Accept that exact representation as well as String inputs; do not
12781
+ // coerce arbitrary objects through to_s.
12782
+ let s: String = if let Some(symbol) = magnus::Symbol::from_value(val) {
12783
+ symbol.name()?.into_owned()
12784
+ } else {
12785
+ magnus::TryConvert::try_convert(val)?
12786
+ };
12736
12787
  // Accept the real serde wire value, the legacy always-snake_case symbol Magnus used to
12737
12788
  // emit unconditionally, and the verbatim PascalCase Rust variant name, so fixtures and
12738
12789
  // existing consumer code written in any of those styles keep working.
@@ -12754,7 +12805,7 @@ impl magnus::TryConvert for FinishReason {
12754
12805
  unsafe impl IntoValueFromNative for FinishReason {}
12755
12806
  unsafe impl TryConvertOwned for FinishReason {}
12756
12807
 
12757
- #[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
12808
+ #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, serde::Serialize, serde::Deserialize)]
12758
12809
  pub enum HealthStatus {
12759
12810
  Healthy,
12760
12811
  Unhealthy,
@@ -12778,7 +12829,14 @@ impl magnus::IntoValue for HealthStatus {
12778
12829
 
12779
12830
  impl magnus::TryConvert for HealthStatus {
12780
12831
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
12781
- let s: String = magnus::TryConvert::try_convert(val)?;
12832
+ // IntoValue emits Symbols, including when this enum is a Hash key.
12833
+ // Accept that exact representation as well as String inputs; do not
12834
+ // coerce arbitrary objects through to_s.
12835
+ let s: String = if let Some(symbol) = magnus::Symbol::from_value(val) {
12836
+ symbol.name()?.into_owned()
12837
+ } else {
12838
+ magnus::TryConvert::try_convert(val)?
12839
+ };
12782
12840
  // Accept the real serde wire value, the legacy always-snake_case symbol Magnus used to
12783
12841
  // emit unconditionally, and the verbatim PascalCase Rust variant name, so fixtures and
12784
12842
  // existing consumer code written in any of those styles keep working.
@@ -12796,7 +12854,7 @@ impl magnus::TryConvert for HealthStatus {
12796
12854
  unsafe impl IntoValueFromNative for HealthStatus {}
12797
12855
  unsafe impl TryConvertOwned for HealthStatus {}
12798
12856
 
12799
- #[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
12857
+ #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, serde::Serialize, serde::Deserialize)]
12800
12858
  #[serde(rename_all = "lowercase")]
12801
12859
  pub enum ImageDetail {
12802
12860
  Low,
@@ -12823,7 +12881,14 @@ impl magnus::IntoValue for ImageDetail {
12823
12881
 
12824
12882
  impl magnus::TryConvert for ImageDetail {
12825
12883
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
12826
- let s: String = magnus::TryConvert::try_convert(val)?;
12884
+ // IntoValue emits Symbols, including when this enum is a Hash key.
12885
+ // Accept that exact representation as well as String inputs; do not
12886
+ // coerce arbitrary objects through to_s.
12887
+ let s: String = if let Some(symbol) = magnus::Symbol::from_value(val) {
12888
+ symbol.name()?.into_owned()
12889
+ } else {
12890
+ magnus::TryConvert::try_convert(val)?
12891
+ };
12827
12892
  // Accept the real serde wire value, the legacy always-snake_case symbol Magnus used to
12828
12893
  // emit unconditionally, and the verbatim PascalCase Rust variant name, so fixtures and
12829
12894
  // existing consumer code written in any of those styles keep working.
@@ -12877,12 +12942,6 @@ pub enum Message {
12877
12942
  },
12878
12943
  }
12879
12944
 
12880
- impl Default for Message {
12881
- fn default() -> Self {
12882
- Self::System { _0: Default::default() }
12883
- }
12884
- }
12885
-
12886
12945
  impl magnus::IntoValue for Message {
12887
12946
  fn into_value_with(self, handle: &Ruby) -> magnus::Value {
12888
12947
  match serde_json::to_value(&self) {
@@ -12894,7 +12953,32 @@ impl magnus::IntoValue for Message {
12894
12953
 
12895
12954
  impl magnus::TryConvert for Message {
12896
12955
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
12897
- // For data enums with fields (e.g., PageAction), try to deserialize from JSON first.
12956
+ // Generated Data variants carry native DTOs, not JSON-compatible display strings.
12957
+ let class_name: Option<String> = val.class().funcall("name", ())?;
12958
+ if class_name.as_deref() == Some("LiterLlm::MessageSystem") {
12959
+ let payload: SystemMessage = val.funcall("value", ())?;
12960
+ return Ok(Self::System { _0: payload });
12961
+ }
12962
+ if class_name.as_deref() == Some("LiterLlm::MessageUser") {
12963
+ let payload: UserMessage = val.funcall("value", ())?;
12964
+ return Ok(Self::User { _0: payload });
12965
+ }
12966
+ if class_name.as_deref() == Some("LiterLlm::MessageAssistant") {
12967
+ let payload: AssistantMessage = val.funcall("value", ())?;
12968
+ return Ok(Self::Assistant { _0: payload });
12969
+ }
12970
+ if class_name.as_deref() == Some("LiterLlm::MessageTool") {
12971
+ let payload: ToolMessage = val.funcall("value", ())?;
12972
+ return Ok(Self::Tool { _0: payload });
12973
+ }
12974
+ if class_name.as_deref() == Some("LiterLlm::MessageDeveloper") {
12975
+ let payload: DeveloperMessage = val.funcall("value", ())?;
12976
+ return Ok(Self::Developer { _0: payload });
12977
+ }
12978
+ if class_name.as_deref() == Some("LiterLlm::MessageFunction") {
12979
+ let payload: FunctionMessage = val.funcall("value", ())?;
12980
+ return Ok(Self::Function { _0: payload });
12981
+ } // For data enums with fields (e.g., PageAction), try to deserialize from JSON first.
12898
12982
  // For unit enums or when passed as a string, fall back to string-based conversion.
12899
12983
  let json_str: String = if let Ok(s) = <String as magnus::TryConvert>::try_convert(val) {
12900
12984
  s
@@ -12926,6 +13010,7 @@ impl magnus::TryConvert for Message {
12926
13010
 
12927
13011
  unsafe impl IntoValueFromNative for Message {}
12928
13012
  unsafe impl TryConvertOwned for Message {}
13013
+
12929
13014
  impl Message {
12930
13015
  pub fn system(&self) -> Option<&SystemMessage> {
12931
13016
  match self {
@@ -12965,7 +13050,7 @@ impl Message {
12965
13050
  }
12966
13051
  }
12967
13052
 
12968
- #[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
13053
+ #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, serde::Serialize, serde::Deserialize)]
12969
13054
  #[serde(rename_all = "snake_case")]
12970
13055
  pub enum Modality {
12971
13056
  Text,
@@ -12992,7 +13077,14 @@ impl magnus::IntoValue for Modality {
12992
13077
 
12993
13078
  impl magnus::TryConvert for Modality {
12994
13079
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
12995
- let s: String = magnus::TryConvert::try_convert(val)?;
13080
+ // IntoValue emits Symbols, including when this enum is a Hash key.
13081
+ // Accept that exact representation as well as String inputs; do not
13082
+ // coerce arbitrary objects through to_s.
13083
+ let s: String = if let Some(symbol) = magnus::Symbol::from_value(val) {
13084
+ symbol.name()?.into_owned()
13085
+ } else {
13086
+ magnus::TryConvert::try_convert(val)?
13087
+ };
12996
13088
  // Accept the real serde wire value, the legacy always-snake_case symbol Magnus used to
12997
13089
  // emit unconditionally, and the verbatim PascalCase Rust variant name, so fixtures and
12998
13090
  // existing consumer code written in any of those styles keep working.
@@ -13018,12 +13110,6 @@ pub enum ModerationInput {
13018
13110
  Multiple(Vec<String>),
13019
13111
  }
13020
13112
 
13021
- impl Default for ModerationInput {
13022
- fn default() -> Self {
13023
- Self::Single(Default::default())
13024
- }
13025
- }
13026
-
13027
13113
  impl magnus::IntoValue for ModerationInput {
13028
13114
  fn into_value_with(self, handle: &Ruby) -> magnus::Value {
13029
13115
  match serde_json::to_value(&self) {
@@ -13076,14 +13162,6 @@ pub enum OcrDocument {
13076
13162
  Base64 { data: String, media_type: String },
13077
13163
  }
13078
13164
 
13079
- impl Default for OcrDocument {
13080
- fn default() -> Self {
13081
- Self::Url {
13082
- url: Default::default(),
13083
- }
13084
- }
13085
- }
13086
-
13087
13165
  impl magnus::IntoValue for OcrDocument {
13088
13166
  fn into_value_with(self, handle: &Ruby) -> magnus::Value {
13089
13167
  match serde_json::to_value(&self) {
@@ -13095,7 +13173,8 @@ impl magnus::IntoValue for OcrDocument {
13095
13173
 
13096
13174
  impl magnus::TryConvert for OcrDocument {
13097
13175
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
13098
- // For data enums with fields (e.g., PageAction), try to deserialize from JSON first.
13176
+ // Generated Data variants carry native DTOs, not JSON-compatible display strings.
13177
+ let class_name: Option<String> = val.class().funcall("name", ())?; // For data enums with fields (e.g., PageAction), try to deserialize from JSON first.
13099
13178
  // For unit enums or when passed as a string, fall back to string-based conversion.
13100
13179
  let json_str: String = if let Ok(s) = <String as magnus::TryConvert>::try_convert(val) {
13101
13180
  s
@@ -13127,9 +13206,10 @@ impl magnus::TryConvert for OcrDocument {
13127
13206
 
13128
13207
  unsafe impl IntoValueFromNative for OcrDocument {}
13129
13208
  unsafe impl TryConvertOwned for OcrDocument {}
13209
+
13130
13210
  impl OcrDocument {}
13131
13211
 
13132
- #[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
13212
+ #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, serde::Serialize, serde::Deserialize)]
13133
13213
  #[serde(rename_all = "lowercase")]
13134
13214
  pub enum ReasoningEffort {
13135
13215
  Low,
@@ -13160,7 +13240,14 @@ impl magnus::IntoValue for ReasoningEffort {
13160
13240
 
13161
13241
  impl magnus::TryConvert for ReasoningEffort {
13162
13242
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
13163
- let s: String = magnus::TryConvert::try_convert(val)?;
13243
+ // IntoValue emits Symbols, including when this enum is a Hash key.
13244
+ // Accept that exact representation as well as String inputs; do not
13245
+ // coerce arbitrary objects through to_s.
13246
+ let s: String = if let Some(symbol) = magnus::Symbol::from_value(val) {
13247
+ symbol.name()?.into_owned()
13248
+ } else {
13249
+ magnus::TryConvert::try_convert(val)?
13250
+ };
13164
13251
  // Accept the real serde wire value, the legacy always-snake_case symbol Magnus used to
13165
13252
  // emit unconditionally, and the verbatim PascalCase Rust variant name, so fixtures and
13166
13253
  // existing consumer code written in any of those styles keep working.
@@ -13181,7 +13268,7 @@ impl magnus::TryConvert for ReasoningEffort {
13181
13268
  unsafe impl IntoValueFromNative for ReasoningEffort {}
13182
13269
  unsafe impl TryConvertOwned for ReasoningEffort {}
13183
13270
 
13184
- #[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
13271
+ #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, serde::Serialize, serde::Deserialize)]
13185
13272
  pub enum RefreshOutcome {
13186
13273
  Disabled,
13187
13274
  FromCache,
@@ -13207,7 +13294,14 @@ impl magnus::IntoValue for RefreshOutcome {
13207
13294
 
13208
13295
  impl magnus::TryConvert for RefreshOutcome {
13209
13296
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
13210
- let s: String = magnus::TryConvert::try_convert(val)?;
13297
+ // IntoValue emits Symbols, including when this enum is a Hash key.
13298
+ // Accept that exact representation as well as String inputs; do not
13299
+ // coerce arbitrary objects through to_s.
13300
+ let s: String = if let Some(symbol) = magnus::Symbol::from_value(val) {
13301
+ symbol.name()?.into_owned()
13302
+ } else {
13303
+ magnus::TryConvert::try_convert(val)?
13304
+ };
13211
13305
  // Accept the real serde wire value, the legacy always-snake_case symbol Magnus used to
13212
13306
  // emit unconditionally, and the verbatim PascalCase Rust variant name, so fixtures and
13213
13307
  // existing consumer code written in any of those styles keep working.
@@ -13233,12 +13327,6 @@ pub enum RerankDocument {
13233
13327
  Object { text: String },
13234
13328
  }
13235
13329
 
13236
- impl Default for RerankDocument {
13237
- fn default() -> Self {
13238
- Self::Text(Default::default())
13239
- }
13240
- }
13241
-
13242
13330
  impl magnus::IntoValue for RerankDocument {
13243
13331
  fn into_value_with(self, handle: &Ruby) -> magnus::Value {
13244
13332
  match serde_json::to_value(&self) {
@@ -13316,7 +13404,8 @@ impl magnus::IntoValue for ResponseFormat {
13316
13404
 
13317
13405
  impl magnus::TryConvert for ResponseFormat {
13318
13406
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
13319
- // For data enums with fields (e.g., PageAction), try to deserialize from JSON first.
13407
+ // Generated Data variants carry native DTOs, not JSON-compatible display strings.
13408
+ let class_name: Option<String> = val.class().funcall("name", ())?; // For data enums with fields (e.g., PageAction), try to deserialize from JSON first.
13320
13409
  // For unit enums or when passed as a string, fall back to string-based conversion.
13321
13410
  let json_str: String = if let Ok(s) = <String as magnus::TryConvert>::try_convert(val) {
13322
13411
  s
@@ -13348,6 +13437,7 @@ impl magnus::TryConvert for ResponseFormat {
13348
13437
 
13349
13438
  unsafe impl IntoValueFromNative for ResponseFormat {}
13350
13439
  unsafe impl TryConvertOwned for ResponseFormat {}
13440
+
13351
13441
  impl ResponseFormat {}
13352
13442
 
13353
13443
  #[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
@@ -13357,12 +13447,6 @@ pub enum StopSequence {
13357
13447
  Multiple(Vec<String>),
13358
13448
  }
13359
13449
 
13360
- impl Default for StopSequence {
13361
- fn default() -> Self {
13362
- Self::Single(Default::default())
13363
- }
13364
- }
13365
-
13366
13450
  impl magnus::IntoValue for StopSequence {
13367
13451
  fn into_value_with(self, handle: &Ruby) -> magnus::Value {
13368
13452
  match serde_json::to_value(&self) {
@@ -13406,7 +13490,7 @@ impl magnus::TryConvert for StopSequence {
13406
13490
  unsafe impl IntoValueFromNative for StopSequence {}
13407
13491
  unsafe impl TryConvertOwned for StopSequence {}
13408
13492
 
13409
- #[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
13493
+ #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, serde::Serialize, serde::Deserialize)]
13410
13494
  #[serde(rename_all = "snake_case")]
13411
13495
  pub enum StreamFormat {
13412
13496
  Sse,
@@ -13431,7 +13515,14 @@ impl magnus::IntoValue for StreamFormat {
13431
13515
 
13432
13516
  impl magnus::TryConvert for StreamFormat {
13433
13517
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
13434
- let s: String = magnus::TryConvert::try_convert(val)?;
13518
+ // IntoValue emits Symbols, including when this enum is a Hash key.
13519
+ // Accept that exact representation as well as String inputs; do not
13520
+ // coerce arbitrary objects through to_s.
13521
+ let s: String = if let Some(symbol) = magnus::Symbol::from_value(val) {
13522
+ symbol.name()?.into_owned()
13523
+ } else {
13524
+ magnus::TryConvert::try_convert(val)?
13525
+ };
13435
13526
  // Accept the real serde wire value, the legacy always-snake_case symbol Magnus used to
13436
13527
  // emit unconditionally, and the verbatim PascalCase Rust variant name, so fixtures and
13437
13528
  // existing consumer code written in any of those styles keep working.
@@ -13450,62 +13541,44 @@ unsafe impl IntoValueFromNative for StreamFormat {}
13450
13541
  unsafe impl TryConvertOwned for StreamFormat {}
13451
13542
 
13452
13543
  #[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
13544
+ #[magnus::wrap(class = "LiterLlm::ToolChoice")]
13453
13545
  #[serde(untagged)]
13454
13546
  pub enum ToolChoice {
13455
13547
  Mode(ToolChoiceMode),
13456
13548
  Specific(SpecificToolChoice),
13457
13549
  }
13458
13550
 
13459
- impl Default for ToolChoice {
13460
- fn default() -> Self {
13461
- Self::Mode(Default::default())
13462
- }
13463
- }
13464
-
13465
- impl magnus::IntoValue for ToolChoice {
13466
- fn into_value_with(self, handle: &Ruby) -> magnus::Value {
13467
- match serde_json::to_value(&self) {
13468
- Ok(v) => json_to_ruby(handle, v),
13469
- Err(_) => handle.qnil().into_value_with(handle),
13470
- }
13471
- }
13472
- }
13473
-
13474
13551
  impl magnus::TryConvert for ToolChoice {
13475
13552
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
13476
- // For data enums with fields (e.g., PageAction), try to deserialize from JSON first.
13477
- // For unit enums or when passed as a string, fall back to string-based conversion.
13478
- let json_str: String = if let Ok(s) = <String as magnus::TryConvert>::try_convert(val) {
13479
- s
13480
- } else {
13481
- val.funcall::<_, _, String>("to_json", ()).map_err(|e| {
13482
- magnus::Error::new(
13483
- unsafe { Ruby::get_unchecked() }.exception_type_error(),
13484
- format!("no implicit conversion into ToolChoice: {}", e),
13485
- )
13486
- })?
13487
- };
13488
- // Try deserializing as JSON first (handles JSON strings like "\"markdown\"" or "{\"click\":{\"selector\":\"...\"}}\"")
13489
- // For internally-tagged enums, a bare variant string is wrapped as {"<tag>": value}.
13490
- // If that fails, try treating it as a plain string value and wrap in quotes
13491
- // If both fail, try as Custom variant (for untagged enum support)
13492
- serde_json::from_str(&json_str)
13493
- .or_else(|_| serde_json::from_str(&format!("\"{json_str}\"")))
13494
- .or_else(|_| {
13495
- // Try as a JSON string for Custom variant (untagged enums accept any remaining value)
13496
- match serde_json::to_value(&json_str) {
13497
- Ok(val) => serde_json::from_value(val),
13498
- Err(e) => Err(e),
13499
- }
13500
- })
13501
- .map_err(|e| magnus::Error::new(unsafe { Ruby::get_unchecked() }.exception_type_error(), e.to_string()))
13553
+ <&Self as magnus::TryConvert>::try_convert(val).cloned()
13502
13554
  }
13503
13555
  }
13504
13556
 
13505
13557
  unsafe impl IntoValueFromNative for ToolChoice {}
13506
13558
  unsafe impl TryConvertOwned for ToolChoice {}
13507
13559
 
13508
- #[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
13560
+ impl ToolChoice {
13561
+ pub fn from_mode(value: ToolChoiceMode) -> Self {
13562
+ Self::Mode(value)
13563
+ }
13564
+ pub fn mode(&self) -> Option<ToolChoiceMode> {
13565
+ match self {
13566
+ Self::Mode(value) => Some(value.clone()),
13567
+ _ => None,
13568
+ }
13569
+ }
13570
+ pub fn from_specific(value: SpecificToolChoice) -> Self {
13571
+ Self::Specific(value)
13572
+ }
13573
+ pub fn specific(&self) -> Option<SpecificToolChoice> {
13574
+ match self {
13575
+ Self::Specific(value) => Some(value.clone()),
13576
+ _ => None,
13577
+ }
13578
+ }
13579
+ }
13580
+
13581
+ #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, serde::Serialize, serde::Deserialize)]
13509
13582
  #[serde(rename_all = "lowercase")]
13510
13583
  pub enum ToolChoiceMode {
13511
13584
  Auto,
@@ -13532,7 +13605,14 @@ impl magnus::IntoValue for ToolChoiceMode {
13532
13605
 
13533
13606
  impl magnus::TryConvert for ToolChoiceMode {
13534
13607
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
13535
- let s: String = magnus::TryConvert::try_convert(val)?;
13608
+ // IntoValue emits Symbols, including when this enum is a Hash key.
13609
+ // Accept that exact representation as well as String inputs; do not
13610
+ // coerce arbitrary objects through to_s.
13611
+ let s: String = if let Some(symbol) = magnus::Symbol::from_value(val) {
13612
+ symbol.name()?.into_owned()
13613
+ } else {
13614
+ magnus::TryConvert::try_convert(val)?
13615
+ };
13536
13616
  // Accept the real serde wire value, the legacy always-snake_case symbol Magnus used to
13537
13617
  // emit unconditionally, and the verbatim PascalCase Rust variant name, so fixtures and
13538
13618
  // existing consumer code written in any of those styles keep working.
@@ -13551,7 +13631,7 @@ impl magnus::TryConvert for ToolChoiceMode {
13551
13631
  unsafe impl IntoValueFromNative for ToolChoiceMode {}
13552
13632
  unsafe impl TryConvertOwned for ToolChoiceMode {}
13553
13633
 
13554
- #[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
13634
+ #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, serde::Serialize, serde::Deserialize)]
13555
13635
  pub enum ToolType {
13556
13636
  #[serde(rename = "function")]
13557
13637
  Function,
@@ -13574,7 +13654,14 @@ impl magnus::IntoValue for ToolType {
13574
13654
 
13575
13655
  impl magnus::TryConvert for ToolType {
13576
13656
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
13577
- let s: String = magnus::TryConvert::try_convert(val)?;
13657
+ // IntoValue emits Symbols, including when this enum is a Hash key.
13658
+ // Accept that exact representation as well as String inputs; do not
13659
+ // coerce arbitrary objects through to_s.
13660
+ let s: String = if let Some(symbol) = magnus::Symbol::from_value(val) {
13661
+ symbol.name()?.into_owned()
13662
+ } else {
13663
+ magnus::TryConvert::try_convert(val)?
13664
+ };
13578
13665
  // Accept the real serde wire value, the legacy always-snake_case symbol Magnus used to
13579
13666
  // emit unconditionally, and the verbatim PascalCase Rust variant name, so fixtures and
13580
13667
  // existing consumer code written in any of those styles keep working.
@@ -13598,12 +13685,6 @@ pub enum UserContent {
13598
13685
  Parts(Vec<ContentPart>),
13599
13686
  }
13600
13687
 
13601
- impl Default for UserContent {
13602
- fn default() -> Self {
13603
- Self::Text(Default::default())
13604
- }
13605
- }
13606
-
13607
13688
  impl magnus::IntoValue for UserContent {
13608
13689
  fn into_value_with(self, handle: &Ruby) -> magnus::Value {
13609
13690
  match serde_json::to_value(&self) {
@@ -14221,6 +14302,24 @@ impl From<liter_llm::cost::refresh::CatalogRefreshConfig> for CatalogRefreshConf
14221
14302
  }
14222
14303
  }
14223
14304
 
14305
+ #[allow(clippy::needless_update)]
14306
+ #[allow(clippy::useless_conversion)]
14307
+ impl From<ChatCompletionChunk> for liter_llm::types::ChatCompletionChunk {
14308
+ fn from(val: ChatCompletionChunk) -> Self {
14309
+ Self {
14310
+ id: val.id,
14311
+ object: val.object,
14312
+ created: val.created,
14313
+ model: val.model,
14314
+ choices: val.choices.into_iter().map(Into::into).collect(),
14315
+ usage: val.usage.map(Into::into),
14316
+ system_fingerprint: val.system_fingerprint,
14317
+ service_tier: val.service_tier,
14318
+ ..Default::default()
14319
+ }
14320
+ }
14321
+ }
14322
+
14224
14323
  #[allow(clippy::redundant_closure, clippy::useless_conversion)]
14225
14324
  impl From<liter_llm::types::ChatCompletionChunk> for ChatCompletionChunk {
14226
14325
  fn from(val: liter_llm::types::ChatCompletionChunk) -> Self {
@@ -15943,6 +16042,19 @@ impl From<liter_llm::types::SpecificToolChoice> for SpecificToolChoice {
15943
16042
  }
15944
16043
  }
15945
16044
 
16045
+ #[allow(clippy::needless_update)]
16046
+ #[allow(clippy::useless_conversion)]
16047
+ impl From<StreamChoice> for liter_llm::types::StreamChoice {
16048
+ fn from(val: StreamChoice) -> Self {
16049
+ Self {
16050
+ index: val.index,
16051
+ delta: val.delta.into(),
16052
+ finish_reason: val.finish_reason.map(Into::into),
16053
+ ..Default::default()
16054
+ }
16055
+ }
16056
+ }
16057
+
15946
16058
  #[allow(clippy::useless_conversion)]
15947
16059
  impl From<liter_llm::types::StreamChoice> for StreamChoice {
15948
16060
  fn from(val: liter_llm::types::StreamChoice) -> Self {
@@ -15954,6 +16066,22 @@ impl From<liter_llm::types::StreamChoice> for StreamChoice {
15954
16066
  }
15955
16067
  }
15956
16068
 
16069
+ #[allow(clippy::needless_update)]
16070
+ #[allow(clippy::redundant_closure, clippy::useless_conversion)]
16071
+ impl From<StreamDelta> for liter_llm::types::StreamDelta {
16072
+ fn from(val: StreamDelta) -> Self {
16073
+ Self {
16074
+ role: val.role,
16075
+ content: val.content,
16076
+ tool_calls: val.tool_calls.map(|v| v.into_iter().map(Into::into).collect()),
16077
+ function_call: val.function_call.map(Into::into),
16078
+ refusal: val.refusal,
16079
+ reasoning_content: val.reasoning_content,
16080
+ ..Default::default()
16081
+ }
16082
+ }
16083
+ }
16084
+
15957
16085
  #[allow(clippy::redundant_closure, clippy::useless_conversion)]
15958
16086
  impl From<liter_llm::types::StreamDelta> for StreamDelta {
15959
16087
  fn from(val: liter_llm::types::StreamDelta) -> Self {
@@ -15968,6 +16096,17 @@ impl From<liter_llm::types::StreamDelta> for StreamDelta {
15968
16096
  }
15969
16097
  }
15970
16098
 
16099
+ #[allow(clippy::needless_update)]
16100
+ impl From<StreamFunctionCall> for liter_llm::types::StreamFunctionCall {
16101
+ fn from(val: StreamFunctionCall) -> Self {
16102
+ Self {
16103
+ name: val.name,
16104
+ arguments: val.arguments,
16105
+ ..Default::default()
16106
+ }
16107
+ }
16108
+ }
16109
+
15971
16110
  #[allow(clippy::redundant_closure)]
15972
16111
  impl From<liter_llm::types::StreamFunctionCall> for StreamFunctionCall {
15973
16112
  fn from(val: liter_llm::types::StreamFunctionCall) -> Self {
@@ -15996,6 +16135,20 @@ impl From<liter_llm::types::StreamOptions> for StreamOptions {
15996
16135
  }
15997
16136
  }
15998
16137
 
16138
+ #[allow(clippy::needless_update)]
16139
+ #[allow(clippy::useless_conversion)]
16140
+ impl From<StreamToolCall> for liter_llm::types::StreamToolCall {
16141
+ fn from(val: StreamToolCall) -> Self {
16142
+ Self {
16143
+ index: val.index,
16144
+ id: val.id,
16145
+ call_type: val.call_type.map(Into::into),
16146
+ function: val.function.map(Into::into),
16147
+ ..Default::default()
16148
+ }
16149
+ }
16150
+ }
16151
+
15999
16152
  #[allow(clippy::redundant_closure, clippy::useless_conversion)]
16000
16153
  impl From<liter_llm::types::StreamToolCall> for StreamToolCall {
16001
16154
  fn from(val: liter_llm::types::StreamToolCall) -> Self {
@@ -16250,7 +16403,7 @@ impl From<AuthHeaderFormat> for liter_llm::provider::custom::AuthHeaderFormat {
16250
16403
  fn from(val: AuthHeaderFormat) -> Self {
16251
16404
  match val {
16252
16405
  AuthHeaderFormat::Bearer => Self::Bearer,
16253
- AuthHeaderFormat::ApiKey { _0 } => Self::ApiKey(_0),
16406
+ AuthHeaderFormat::ApiKey(_0) => Self::ApiKey(_0),
16254
16407
  AuthHeaderFormat::None => Self::None,
16255
16408
  }
16256
16409
  }
@@ -16260,7 +16413,7 @@ impl From<liter_llm::provider::custom::AuthHeaderFormat> for AuthHeaderFormat {
16260
16413
  fn from(val: liter_llm::provider::custom::AuthHeaderFormat) -> Self {
16261
16414
  match val {
16262
16415
  liter_llm::provider::custom::AuthHeaderFormat::Bearer => Self::Bearer,
16263
- liter_llm::provider::custom::AuthHeaderFormat::ApiKey(_0) => Self::ApiKey { _0: _0.to_string() },
16416
+ liter_llm::provider::custom::AuthHeaderFormat::ApiKey(_0) => Self::ApiKey(_0),
16264
16417
  liter_llm::provider::custom::AuthHeaderFormat::None => Self::None,
16265
16418
  }
16266
16419
  }
@@ -16525,6 +16678,16 @@ impl From<liter_llm::types::FinishReason> for FinishReason {
16525
16678
  }
16526
16679
  }
16527
16680
 
16681
+ #[cfg(feature = "tower")]
16682
+ impl From<HealthStatus> for liter_llm::tower::HealthStatus {
16683
+ fn from(val: HealthStatus) -> Self {
16684
+ match val {
16685
+ HealthStatus::Healthy => Self::Healthy,
16686
+ HealthStatus::Unhealthy => Self::Unhealthy,
16687
+ }
16688
+ }
16689
+ }
16690
+
16528
16691
  #[cfg(feature = "tower")]
16529
16692
  impl From<liter_llm::tower::HealthStatus> for HealthStatus {
16530
16693
  fn from(val: liter_llm::tower::HealthStatus) -> Self {
@@ -18374,6 +18537,12 @@ fn ruby_init(ruby: &Ruby) -> Result<(), Error> {
18374
18537
 
18375
18538
  class.define_singleton_method("object", function!(RerankDocument::_factory_object, 1))?;
18376
18539
 
18540
+ let class = module.define_class("ToolChoice", ruby.class_object())?;
18541
+ class.undef_default_alloc_func();
18542
+ class.define_singleton_method("from_mode", function!(ToolChoice::from_mode, 1))?;
18543
+ class.define_method("mode", method!(ToolChoice::mode, 0))?;
18544
+ class.define_singleton_method("from_specific", function!(ToolChoice::from_specific, 1))?;
18545
+ class.define_method("specific", method!(ToolChoice::specific, 0))?;
18377
18546
  let class = module.define_class("ChatStreamIterator", ruby.class_object())?;
18378
18547
  class.define_method("next_chunk", method!(ChatStreamIterator::next_chunk, 0))?;
18379
18548
  class.define_method("each", method!(ChatStreamIterator::each, 0))?;