liter_llm 1.19.1 → 1.19.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b4b7b9d01b49d2090215dde076467f46d6e73db1070f01be1c29d7cc85067c03
4
- data.tar.gz: 46887b8a60479c74cdefeb48b789a2a3a64d480f56832ab9818f0260933edb06
3
+ metadata.gz: e0f4e7c263ad95365e3192a7b310cd4dc34e1c2ab36efae96f3e38b2f8fe15f7
4
+ data.tar.gz: 239d6cd89be3c4f77de79f671bfdc964fc96ca0fc0b24a90e5806652a41a793b
5
5
  SHA512:
6
- metadata.gz: cc4489ce5fe2d1e2917004c7ca293220390c56a067cdf1e37ec6b4a0f46c53d3932bd9d01db1122128a07ad1a5f361940cdc00587df71fb19ef8d495acfb96ad
7
- data.tar.gz: 669ec7886b2185f59343082514ca9762ff5d7b6892758cdc0c3c5b35599d36d34425021d5d05cb67e634216002016f467197d8c2947dd83127ec169a37ec6fec
6
+ metadata.gz: 79c5810d1195d623aa090792321084e3db586fabbee62eae9a8198b3d5fe617b2625384ce5626c1462545d4c1f74e7ca26e9a0bee48387d4cb6d60d36f7d0e63
7
+ data.tar.gz: e9a877730c34ec69d779028fddea0f0965257441f33c5ab76adf7d36be18b0132784540df880dda375e78b6d53e4481aab749fec4ad80190f9bee2f59e93f6d1
@@ -1795,9 +1795,9 @@ checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae"
1795
1795
 
1796
1796
  [[package]]
1797
1797
  name = "liter-llm"
1798
- version = "1.19.1"
1798
+ version = "1.19.2"
1799
1799
  source = "registry+https://github.com/rust-lang/crates.io-index"
1800
- checksum = "6e4bee60f599735a464cbc0cf869a0389a757fefbc4dcd717354b8cda01d1b46"
1800
+ checksum = "883a4704bafd86f33c011940adac5e9962614a0f5917738a91cf22e528b1a805"
1801
1801
  dependencies = [
1802
1802
  "ahash 0.8.12",
1803
1803
  "arc-swap",
@@ -1839,7 +1839,7 @@ dependencies = [
1839
1839
 
1840
1840
  [[package]]
1841
1841
  name = "liter-llm-rb"
1842
- version = "1.19.1"
1842
+ version = "1.19.2"
1843
1843
  dependencies = [
1844
1844
  "futures",
1845
1845
  "liter-llm",
@@ -1,11 +1,11 @@
1
1
  # This file is auto-generated by alef — DO NOT EDIT.
2
- # alef:hash:7369e831c2e890674db62b12c055a8b5c8cb7b6ee47481cda82b4b5cf9e43c53
2
+ # alef:hash:9cf41ac17e81157466dd1070f5e7bb4a84b4772b1236e711790a6921806c9f47
3
3
  # To regenerate: alef generate
4
4
  # To verify freshness: alef verify
5
5
 
6
6
  [package]
7
7
  name = "liter-llm-rb"
8
- version = "1.19.1"
8
+ version = "1.19.2"
9
9
  edition = "2024"
10
10
  license = "MIT"
11
11
  description = "Universal LLM API client with Rust-powered polyglot bindings."
@@ -31,7 +31,7 @@ wasm-http = ["liter-llm/wasm-http"]
31
31
 
32
32
  [dependencies]
33
33
  futures = "0.3"
34
- liter-llm = { version = "1.19.1", features = ["native-http", "full"] }
34
+ liter-llm = { version = "1.19.2", features = ["native-http", "full"] }
35
35
  magnus = "0.8"
36
36
  rb-sys = ">=0.9.130, <0.10"
37
37
  serde = { version = "1", features = ["derive"] }
@@ -1,5 +1,5 @@
1
1
  // This file is auto-generated by alef. DO NOT EDIT.
2
- // alef:hash:318631ff5a15c91ccae8da6c9f692ae94ab3ff4691e23e2a97487d9e3e88250e
2
+ // alef:hash:60474db2c50465cf1ec1b24f42d2ca1e4420ad603e55340ad7a4817ae4a65cae
3
3
  // Re-generate with: alef generate
4
4
  #![allow(dead_code, unused_imports, unused_variables)]
5
5
  #![allow(
@@ -30,6 +30,52 @@ use magnus::{Error, IntoValueFromNative, Ruby, function, method, prelude::*, try
30
30
  use std::collections::HashMap;
31
31
  use std::sync::Arc;
32
32
 
33
+ /// Run owned Rust work while the calling Ruby thread releases the GVL.
34
+ fn alef_magnus_run_without_gvl<F, T>(callback: F) -> T
35
+ where
36
+ F: FnOnce() -> T,
37
+ {
38
+ struct RunState<F, T> {
39
+ callback: Option<F>,
40
+ result: Option<std::thread::Result<T>>,
41
+ }
42
+
43
+ extern "C" fn run_without_gvl<F, T>(data: *mut std::ffi::c_void) -> *mut std::ffi::c_void
44
+ where
45
+ F: FnOnce() -> T,
46
+ {
47
+ // SAFETY: `data` points to the caller's RunState for the duration of this callback.
48
+ let state = unsafe { &mut *(data as *mut RunState<F, T>) };
49
+ let Some(callback) = state.callback.take() else {
50
+ state.result = Some(Err(Box::new("Alef Magnus callback already consumed")));
51
+ return std::ptr::null_mut();
52
+ };
53
+ state.result = Some(std::panic::catch_unwind(std::panic::AssertUnwindSafe(callback)));
54
+ std::ptr::null_mut()
55
+ }
56
+
57
+ extern "C" fn unblock_run(_data: *mut std::ffi::c_void) {}
58
+
59
+ let mut state = RunState {
60
+ callback: Some(callback),
61
+ result: None,
62
+ };
63
+ // SAFETY: Ruby invokes the callback synchronously, and `state` remains live until it returns.
64
+ unsafe {
65
+ rb_sys::rb_thread_call_without_gvl(
66
+ Some(run_without_gvl::<F, T>),
67
+ &mut state as *mut RunState<F, T> as *mut std::ffi::c_void,
68
+ Some(unblock_run),
69
+ std::ptr::null_mut(),
70
+ );
71
+ }
72
+
73
+ match state.result.expect("Alef Magnus callback did not run") {
74
+ Ok(result) => result,
75
+ Err(payload) => std::panic::resume_unwind(payload),
76
+ }
77
+ }
78
+
33
79
  fn json_to_ruby(handle: &Ruby, val: serde_json::Value) -> magnus::Value {
34
80
  use magnus::IntoValue;
35
81
  match val {
@@ -947,8 +993,10 @@ pub struct BudgetConfig {
947
993
  enforcement: Enforcement,
948
994
  }
949
995
 
996
+ #[cfg(feature = "tower")]
950
997
  unsafe impl IntoValueFromNative for BudgetConfig {}
951
998
 
999
+ #[cfg(feature = "tower")]
952
1000
  impl magnus::TryConvert for BudgetConfig {
953
1001
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
954
1002
  if let Ok(r) = <&BudgetConfig as magnus::TryConvert>::try_convert(val) {
@@ -973,6 +1021,7 @@ impl magnus::TryConvert for BudgetConfig {
973
1021
  }
974
1022
  }
975
1023
 
1024
+ #[cfg(feature = "tower")]
976
1025
  unsafe impl TryConvertOwned for BudgetConfig {}
977
1026
 
978
1027
  #[cfg(feature = "tower")]
@@ -1027,8 +1076,10 @@ pub struct CacheConfig {
1027
1076
  backend: CacheBackend,
1028
1077
  }
1029
1078
 
1079
+ #[cfg(feature = "tower")]
1030
1080
  unsafe impl IntoValueFromNative for CacheConfig {}
1031
1081
 
1082
+ #[cfg(feature = "tower")]
1032
1083
  impl magnus::TryConvert for CacheConfig {
1033
1084
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
1034
1085
  if let Ok(r) = <&CacheConfig as magnus::TryConvert>::try_convert(val) {
@@ -1053,6 +1104,7 @@ impl magnus::TryConvert for CacheConfig {
1053
1104
  }
1054
1105
  }
1055
1106
 
1107
+ #[cfg(feature = "tower")]
1056
1108
  unsafe impl TryConvertOwned for CacheConfig {}
1057
1109
 
1058
1110
  #[cfg(feature = "tower")]
@@ -2712,8 +2764,10 @@ pub struct DefaultClient {
2712
2764
  inner: Arc<liter_llm::client::DefaultClient>,
2713
2765
  }
2714
2766
 
2767
+ #[cfg(any(feature = "native-http", feature = "wasm-http"))]
2715
2768
  unsafe impl IntoValueFromNative for DefaultClient {}
2716
2769
 
2770
+ #[cfg(any(feature = "native-http", feature = "wasm-http"))]
2717
2771
  impl magnus::TryConvert for DefaultClient {
2718
2772
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
2719
2773
  let r: &DefaultClient = magnus::TryConvert::try_convert(val)?;
@@ -2721,6 +2775,7 @@ impl magnus::TryConvert for DefaultClient {
2721
2775
  }
2722
2776
  }
2723
2777
 
2778
+ #[cfg(any(feature = "native-http", feature = "wasm-http"))]
2724
2779
  unsafe impl TryConvertOwned for DefaultClient {}
2725
2780
 
2726
2781
  #[cfg(any(feature = "native-http", feature = "wasm-http"))]
@@ -4487,8 +4542,10 @@ pub struct InFlightLimitConfig {
4487
4542
  max_in_flight: Option<usize>,
4488
4543
  }
4489
4544
 
4545
+ #[cfg(feature = "tower")]
4490
4546
  unsafe impl IntoValueFromNative for InFlightLimitConfig {}
4491
4547
 
4548
+ #[cfg(feature = "tower")]
4492
4549
  impl magnus::TryConvert for InFlightLimitConfig {
4493
4550
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
4494
4551
  if let Ok(r) = <&InFlightLimitConfig as magnus::TryConvert>::try_convert(val) {
@@ -4513,6 +4570,7 @@ impl magnus::TryConvert for InFlightLimitConfig {
4513
4570
  }
4514
4571
  }
4515
4572
 
4573
+ #[cfg(feature = "tower")]
4516
4574
  unsafe impl TryConvertOwned for InFlightLimitConfig {}
4517
4575
 
4518
4576
  #[cfg(feature = "tower")]
@@ -4550,8 +4608,10 @@ pub struct IntentPrototype {
4550
4608
  model: String,
4551
4609
  }
4552
4610
 
4611
+ #[cfg(feature = "tower")]
4553
4612
  unsafe impl IntoValueFromNative for IntentPrototype {}
4554
4613
 
4614
+ #[cfg(feature = "tower")]
4555
4615
  impl magnus::TryConvert for IntentPrototype {
4556
4616
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
4557
4617
  if let Ok(r) = <&IntentPrototype as magnus::TryConvert>::try_convert(val) {
@@ -4576,6 +4636,7 @@ impl magnus::TryConvert for IntentPrototype {
4576
4636
  }
4577
4637
  }
4578
4638
 
4639
+ #[cfg(feature = "tower")]
4579
4640
  unsafe impl TryConvertOwned for IntentPrototype {}
4580
4641
 
4581
4642
  #[cfg(feature = "tower")]
@@ -7093,8 +7154,10 @@ pub struct RateLimitConfig {
7093
7154
  window: u64,
7094
7155
  }
7095
7156
 
7157
+ #[cfg(feature = "tower")]
7096
7158
  unsafe impl IntoValueFromNative for RateLimitConfig {}
7097
7159
 
7160
+ #[cfg(feature = "tower")]
7098
7161
  impl magnus::TryConvert for RateLimitConfig {
7099
7162
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
7100
7163
  if let Ok(r) = <&RateLimitConfig as magnus::TryConvert>::try_convert(val) {
@@ -7119,6 +7182,7 @@ impl magnus::TryConvert for RateLimitConfig {
7119
7182
  }
7120
7183
  }
7121
7184
 
7185
+ #[cfg(feature = "tower")]
7122
7186
  unsafe impl TryConvertOwned for RateLimitConfig {}
7123
7187
 
7124
7188
  #[cfg(feature = "tower")]
@@ -8117,8 +8181,10 @@ pub struct SingleflightResult {
8117
8181
  inner: Arc<liter_llm::tower::SingleflightResult>,
8118
8182
  }
8119
8183
 
8184
+ #[cfg(feature = "tower")]
8120
8185
  unsafe impl IntoValueFromNative for SingleflightResult {}
8121
8186
 
8187
+ #[cfg(feature = "tower")]
8122
8188
  impl magnus::TryConvert for SingleflightResult {
8123
8189
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
8124
8190
  let r: &SingleflightResult = magnus::TryConvert::try_convert(val)?;
@@ -8126,6 +8192,7 @@ impl magnus::TryConvert for SingleflightResult {
8126
8192
  }
8127
8193
  }
8128
8194
 
8195
+ #[cfg(feature = "tower")]
8129
8196
  unsafe impl TryConvertOwned for SingleflightResult {}
8130
8197
 
8131
8198
  #[cfg(feature = "tower")]
@@ -9285,8 +9352,10 @@ pub struct WaitForBatchConfig {
9285
9352
  timeout_secs: Option<f64>,
9286
9353
  }
9287
9354
 
9355
+ #[cfg(any(feature = "native-http", feature = "wasm-http"))]
9288
9356
  unsafe impl IntoValueFromNative for WaitForBatchConfig {}
9289
9357
 
9358
+ #[cfg(any(feature = "native-http", feature = "wasm-http"))]
9290
9359
  impl magnus::TryConvert for WaitForBatchConfig {
9291
9360
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
9292
9361
  if let Ok(r) = <&WaitForBatchConfig as magnus::TryConvert>::try_convert(val) {
@@ -9311,6 +9380,7 @@ impl magnus::TryConvert for WaitForBatchConfig {
9311
9380
  }
9312
9381
  }
9313
9382
 
9383
+ #[cfg(any(feature = "native-http", feature = "wasm-http"))]
9314
9384
  unsafe impl TryConvertOwned for WaitForBatchConfig {}
9315
9385
 
9316
9386
  #[cfg(any(feature = "native-http", feature = "wasm-http"))]
@@ -11216,20 +11286,16 @@ fn refresh_catalog(args: &[magnus::Value]) -> Result<RefreshOutcome, Error> {
11216
11286
  }
11217
11287
  _ => Default::default(),
11218
11288
  };
11219
- let rt = tokio::runtime::Runtime::new().map_err(|e| {
11220
- magnus::Error::new(
11221
- unsafe { Ruby::get_unchecked() }.exception_runtime_error(),
11222
- e.to_string(),
11223
- )
11224
- })?;
11225
- let result = rt
11226
- .block_on(async { liter_llm::cost::refresh::refresh_catalog(&config_core).await })
11227
- .map_err(|e| {
11228
- magnus::Error::new(
11229
- unsafe { Ruby::get_unchecked() }.exception_runtime_error(),
11230
- e.to_string(),
11231
- )
11232
- })?;
11289
+ let async_result = alef_magnus_run_without_gvl(move || -> Result<_, String> {
11290
+ let rt = tokio::runtime::Builder::new_current_thread()
11291
+ .enable_all()
11292
+ .build()
11293
+ .map_err(|e| e.to_string())?;
11294
+ rt.block_on(async { liter_llm::cost::refresh::refresh_catalog(&config_core).await })
11295
+ .map_err(|e| e.to_string())
11296
+ });
11297
+ let result = async_result
11298
+ .map_err(|message| magnus::Error::new(unsafe { Ruby::get_unchecked() }.exception_runtime_error(), message))?;
11233
11299
  Ok(result.into())
11234
11300
  }
11235
11301
 
@@ -11249,20 +11315,16 @@ fn refresh_catalog_async(args: &[magnus::Value]) -> Result<RefreshOutcome, Error
11249
11315
  }
11250
11316
  _ => Default::default(),
11251
11317
  };
11252
- let rt = tokio::runtime::Runtime::new().map_err(|e| {
11253
- magnus::Error::new(
11254
- unsafe { Ruby::get_unchecked() }.exception_runtime_error(),
11255
- e.to_string(),
11256
- )
11257
- })?;
11258
- let result = rt
11259
- .block_on(async { liter_llm::cost::refresh::refresh_catalog(&config_core).await })
11260
- .map_err(|e| {
11261
- magnus::Error::new(
11262
- unsafe { Ruby::get_unchecked() }.exception_runtime_error(),
11263
- e.to_string(),
11264
- )
11265
- })?;
11318
+ let async_result = alef_magnus_run_without_gvl(move || -> Result<_, String> {
11319
+ let rt = tokio::runtime::Builder::new_current_thread()
11320
+ .enable_all()
11321
+ .build()
11322
+ .map_err(|e| e.to_string())?;
11323
+ rt.block_on(async { liter_llm::cost::refresh::refresh_catalog(&config_core).await })
11324
+ .map_err(|e| e.to_string())
11325
+ });
11326
+ let result = async_result
11327
+ .map_err(|message| magnus::Error::new(unsafe { Ruby::get_unchecked() }.exception_runtime_error(), message))?;
11266
11328
  Ok(result.into())
11267
11329
  }
11268
11330
 
@@ -1,10 +1,10 @@
1
1
  # This file is auto-generated by alef — DO NOT EDIT.
2
- # alef:hash:8e14eecd5f0122432853429ade58c4809002ae5b39f8b93f8e7ce09ef6522dc6
2
+ # alef:hash:b6a87f16b65e649206568b5d448684b1a1ce181dca36445cd8b422a1a6dcf8c9
3
3
  # To regenerate: alef generate
4
4
  # To verify freshness: alef verify
5
5
  # frozen_string_literal: true
6
6
 
7
7
  module LiterLlm
8
8
  ## The version string for this package.
9
- VERSION = "1.19.1"
9
+ VERSION = "1.19.2"
10
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: liter_llm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.19.1
4
+ version: 1.19.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Na'aman Hirschfeld
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-09-01 00:00:00.000000000 Z
11
+ date: 2026-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rb_sys