liter_llm 2.1.4 → 2.2.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.
- checksums.yaml +4 -4
- data/ext/liter_llm_rb/native/Cargo.lock +3 -3
- data/ext/liter_llm_rb/native/Cargo.toml +3 -3
- data/ext/liter_llm_rb/src/lib.rs +125 -1
- data/lib/liter_llm/version.rb +2 -2
- data/sig/types.rbs +9 -2
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6b3dc0a9f183e0f7d2e468d519ad911720501e3633f68a67bd0940782e1ff018
|
|
4
|
+
data.tar.gz: 83bac628afe410dc0da63752c7ebae701cdd433b15b0e58522283d677d1e8a59
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9d83d1ae3756951a5c819cb6a15d46e6ec08def7161bd5810db59192b62ee875b0b10c459ba1c7f2339c58042ebb2dc53e18a557b5a9b248f564fc8ba0959168
|
|
7
|
+
data.tar.gz: ccdbd3742fa8e71e8b6fbe372a4ac7ff59a5879f240d91249575737e9f317fe28caeb336525f247026281457860cef4a0fa70400ba51627839cd8288b4b1a1be
|
|
@@ -1697,9 +1697,9 @@ checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae"
|
|
|
1697
1697
|
|
|
1698
1698
|
[[package]]
|
|
1699
1699
|
name = "liter-llm"
|
|
1700
|
-
version = "2.
|
|
1700
|
+
version = "2.2.0"
|
|
1701
1701
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1702
|
-
checksum = "
|
|
1702
|
+
checksum = "8638e8a77817d0debb8944de890ad736f80e1a46c2c53b8d75a303f59307fa68"
|
|
1703
1703
|
dependencies = [
|
|
1704
1704
|
"ahash",
|
|
1705
1705
|
"arc-swap",
|
|
@@ -1742,7 +1742,7 @@ dependencies = [
|
|
|
1742
1742
|
|
|
1743
1743
|
[[package]]
|
|
1744
1744
|
name = "liter-llm-rb"
|
|
1745
|
-
version = "2.
|
|
1745
|
+
version = "2.2.0"
|
|
1746
1746
|
dependencies = [
|
|
1747
1747
|
"futures",
|
|
1748
1748
|
"liter-llm",
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# This file is auto-generated by alef — DO NOT EDIT.
|
|
2
|
-
# alef:hash:
|
|
2
|
+
# alef:hash:c521ecc32356e04cfe9a166fa28268f2f087a83ad433544f00ab20701f293372
|
|
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 = "2.
|
|
8
|
+
version = "2.2.0"
|
|
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 = "2.
|
|
34
|
+
liter-llm = { version = "2.2.0", features = ["native-http", "full"] }
|
|
35
35
|
magnus = "0.9"
|
|
36
36
|
rb-sys = ">=0.9.130, <0.10"
|
|
37
37
|
serde = { version = "1", features = ["derive"] }
|
data/ext/liter_llm_rb/src/lib.rs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// This file is auto-generated by alef. DO NOT EDIT.
|
|
2
|
-
// alef:hash:
|
|
2
|
+
// alef:hash:a471cf0303320780d0a56e0d907d0c97856c0d95870f41e3b9e70df6bb9db85c
|
|
3
3
|
// Re-generate with: alef generate
|
|
4
4
|
#![allow(dead_code, unused_imports, unused_variables)]
|
|
5
5
|
#![allow(
|
|
@@ -2538,6 +2538,79 @@ impl Choice {
|
|
|
2538
2538
|
}
|
|
2539
2539
|
}
|
|
2540
2540
|
|
|
2541
|
+
#[derive(Clone, Debug, serde::Serialize)]
|
|
2542
|
+
#[serde(default)]
|
|
2543
|
+
#[magnus::wrap(class = "LiterLlm::CompletionTokensDetails")]
|
|
2544
|
+
pub struct CompletionTokensDetails {
|
|
2545
|
+
reasoning_tokens: u64,
|
|
2546
|
+
}
|
|
2547
|
+
|
|
2548
|
+
unsafe impl IntoValueFromNative for CompletionTokensDetails {}
|
|
2549
|
+
|
|
2550
|
+
impl magnus::TryConvert for CompletionTokensDetails {
|
|
2551
|
+
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
2552
|
+
if let Ok(r) = <&CompletionTokensDetails as magnus::TryConvert>::try_convert(val) {
|
|
2553
|
+
return Ok(r.clone());
|
|
2554
|
+
}
|
|
2555
|
+
let json_str: String = if let Ok(s) = <String as magnus::TryConvert>::try_convert(val) {
|
|
2556
|
+
s
|
|
2557
|
+
} else {
|
|
2558
|
+
val.funcall::<_, _, String>("to_json", ()).map_err(|e| {
|
|
2559
|
+
magnus::Error::new(
|
|
2560
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2561
|
+
format!("no implicit conversion into CompletionTokensDetails: {}", e),
|
|
2562
|
+
)
|
|
2563
|
+
})?
|
|
2564
|
+
};
|
|
2565
|
+
serde_json::from_str::<CompletionTokensDetails>(&json_str).map_err(|e| {
|
|
2566
|
+
magnus::Error::new(
|
|
2567
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2568
|
+
format!("failed to deserialize CompletionTokensDetails: {}", e),
|
|
2569
|
+
)
|
|
2570
|
+
})
|
|
2571
|
+
}
|
|
2572
|
+
}
|
|
2573
|
+
|
|
2574
|
+
unsafe impl TryConvertOwned for CompletionTokensDetails {}
|
|
2575
|
+
impl<'de> serde::Deserialize<'de> for CompletionTokensDetails {
|
|
2576
|
+
fn deserialize<D>(deserializer: D) -> ::core::result::Result<Self, D::Error>
|
|
2577
|
+
where
|
|
2578
|
+
D: serde::Deserializer<'de>,
|
|
2579
|
+
{
|
|
2580
|
+
<liter_llm::types::CompletionTokensDetails as serde::Deserialize>::deserialize(deserializer).map(Into::into)
|
|
2581
|
+
}
|
|
2582
|
+
}
|
|
2583
|
+
|
|
2584
|
+
impl Default for CompletionTokensDetails {
|
|
2585
|
+
fn default() -> Self {
|
|
2586
|
+
liter_llm::types::CompletionTokensDetails::default().into()
|
|
2587
|
+
}
|
|
2588
|
+
}
|
|
2589
|
+
|
|
2590
|
+
impl CompletionTokensDetails {
|
|
2591
|
+
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
2592
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
2593
|
+
let args = magnus::scan_args::scan_args::<(), (Option<magnus::RHash>,), (), (), (), ()>(args)?;
|
|
2594
|
+
let (kwargs_opt,) = args.optional;
|
|
2595
|
+
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
2596
|
+
Ok(Self {
|
|
2597
|
+
reasoning_tokens: match kwargs.get(ruby.to_symbol("reasoning_tokens")) {
|
|
2598
|
+
Some(v) => u64::try_convert(v).map_err(|e| {
|
|
2599
|
+
magnus::Error::new(
|
|
2600
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
2601
|
+
format!("invalid value for `reasoning_tokens`: {}", e),
|
|
2602
|
+
)
|
|
2603
|
+
})?,
|
|
2604
|
+
None => Default::default(),
|
|
2605
|
+
},
|
|
2606
|
+
})
|
|
2607
|
+
}
|
|
2608
|
+
|
|
2609
|
+
fn reasoning_tokens(&self) -> u64 {
|
|
2610
|
+
self.reasoning_tokens
|
|
2611
|
+
}
|
|
2612
|
+
}
|
|
2613
|
+
|
|
2541
2614
|
#[derive(Clone, Debug, serde::Serialize)]
|
|
2542
2615
|
#[serde(default)]
|
|
2543
2616
|
#[magnus::wrap(class = "LiterLlm::CreateBatchRequest")]
|
|
@@ -11703,6 +11776,7 @@ pub struct Usage {
|
|
|
11703
11776
|
completion_tokens: u64,
|
|
11704
11777
|
total_tokens: u64,
|
|
11705
11778
|
prompt_tokens_details: Option<PromptTokensDetails>,
|
|
11779
|
+
completion_tokens_details: Option<CompletionTokensDetails>,
|
|
11706
11780
|
}
|
|
11707
11781
|
|
|
11708
11782
|
unsafe impl IntoValueFromNative for Usage {}
|
|
@@ -11793,6 +11867,18 @@ impl Usage {
|
|
|
11793
11867
|
})?),
|
|
11794
11868
|
None => None,
|
|
11795
11869
|
},
|
|
11870
|
+
completion_tokens_details: match kwargs
|
|
11871
|
+
.get(ruby.to_symbol("completion_tokens_details"))
|
|
11872
|
+
.filter(|v| !v.is_nil())
|
|
11873
|
+
{
|
|
11874
|
+
Some(v) => Some(CompletionTokensDetails::try_convert(v).map_err(|e| {
|
|
11875
|
+
magnus::Error::new(
|
|
11876
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
11877
|
+
format!("invalid value for `completion_tokens_details`: {}", e),
|
|
11878
|
+
)
|
|
11879
|
+
})?),
|
|
11880
|
+
None => None,
|
|
11881
|
+
},
|
|
11796
11882
|
})
|
|
11797
11883
|
}
|
|
11798
11884
|
|
|
@@ -11811,6 +11897,10 @@ impl Usage {
|
|
|
11811
11897
|
fn prompt_tokens_details(&self) -> Option<PromptTokensDetails> {
|
|
11812
11898
|
self.prompt_tokens_details.clone()
|
|
11813
11899
|
}
|
|
11900
|
+
|
|
11901
|
+
fn completion_tokens_details(&self) -> Option<CompletionTokensDetails> {
|
|
11902
|
+
self.completion_tokens_details.clone()
|
|
11903
|
+
}
|
|
11814
11904
|
}
|
|
11815
11905
|
|
|
11816
11906
|
#[derive(Clone, Debug, serde::Serialize)]
|
|
@@ -14532,6 +14622,24 @@ impl From<liter_llm::types::Choice> for Choice {
|
|
|
14532
14622
|
}
|
|
14533
14623
|
}
|
|
14534
14624
|
|
|
14625
|
+
#[allow(clippy::needless_update)]
|
|
14626
|
+
impl From<CompletionTokensDetails> for liter_llm::types::CompletionTokensDetails {
|
|
14627
|
+
fn from(val: CompletionTokensDetails) -> Self {
|
|
14628
|
+
Self {
|
|
14629
|
+
reasoning_tokens: val.reasoning_tokens,
|
|
14630
|
+
..Default::default()
|
|
14631
|
+
}
|
|
14632
|
+
}
|
|
14633
|
+
}
|
|
14634
|
+
|
|
14635
|
+
impl From<liter_llm::types::CompletionTokensDetails> for CompletionTokensDetails {
|
|
14636
|
+
fn from(val: liter_llm::types::CompletionTokensDetails) -> Self {
|
|
14637
|
+
Self {
|
|
14638
|
+
reasoning_tokens: val.reasoning_tokens,
|
|
14639
|
+
}
|
|
14640
|
+
}
|
|
14641
|
+
}
|
|
14642
|
+
|
|
14535
14643
|
#[allow(clippy::needless_update)]
|
|
14536
14644
|
#[allow(clippy::redundant_closure)]
|
|
14537
14645
|
impl From<CreateBatchRequest> for liter_llm::types::CreateBatchRequest {
|
|
@@ -16319,6 +16427,7 @@ impl From<Usage> for liter_llm::types::Usage {
|
|
|
16319
16427
|
completion_tokens: val.completion_tokens,
|
|
16320
16428
|
total_tokens: val.total_tokens,
|
|
16321
16429
|
prompt_tokens_details: val.prompt_tokens_details.map(Into::into),
|
|
16430
|
+
completion_tokens_details: val.completion_tokens_details.map(Into::into),
|
|
16322
16431
|
..Default::default()
|
|
16323
16432
|
}
|
|
16324
16433
|
}
|
|
@@ -16332,6 +16441,7 @@ impl From<liter_llm::types::Usage> for Usage {
|
|
|
16332
16441
|
completion_tokens: val.completion_tokens,
|
|
16333
16442
|
total_tokens: val.total_tokens,
|
|
16334
16443
|
prompt_tokens_details: val.prompt_tokens_details.map(Into::into),
|
|
16444
|
+
completion_tokens_details: val.completion_tokens_details.map(Into::into),
|
|
16335
16445
|
}
|
|
16336
16446
|
}
|
|
16337
16447
|
}
|
|
@@ -17467,6 +17577,15 @@ fn ruby_init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
17467
17577
|
|
|
17468
17578
|
class.define_method("logprobs", method!(Choice::logprobs, 0))?;
|
|
17469
17579
|
|
|
17580
|
+
let class = module.define_class("CompletionTokensDetails", ruby.class_object())?;
|
|
17581
|
+
|
|
17582
|
+
class.define_singleton_method("new", function!(CompletionTokensDetails::new, -1))?;
|
|
17583
|
+
|
|
17584
|
+
class.define_method(
|
|
17585
|
+
"reasoning_tokens",
|
|
17586
|
+
method!(CompletionTokensDetails::reasoning_tokens, 0),
|
|
17587
|
+
)?;
|
|
17588
|
+
|
|
17470
17589
|
let class = module.define_class("CreateBatchRequest", ruby.class_object())?;
|
|
17471
17590
|
|
|
17472
17591
|
class.define_singleton_method("new", function!(CreateBatchRequest::new, -1))?;
|
|
@@ -18543,6 +18662,11 @@ fn ruby_init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
18543
18662
|
|
|
18544
18663
|
class.define_method("prompt_tokens_details", method!(Usage::prompt_tokens_details, 0))?;
|
|
18545
18664
|
|
|
18665
|
+
class.define_method(
|
|
18666
|
+
"completion_tokens_details",
|
|
18667
|
+
method!(Usage::completion_tokens_details, 0),
|
|
18668
|
+
)?;
|
|
18669
|
+
|
|
18546
18670
|
let class = module.define_class("UserMessage", ruby.class_object())?;
|
|
18547
18671
|
|
|
18548
18672
|
class.define_singleton_method("new", function!(UserMessage::new, -1))?;
|
data/lib/liter_llm/version.rb
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# This file is auto-generated by alef — DO NOT EDIT.
|
|
2
|
-
# alef:hash:
|
|
2
|
+
# alef:hash:88d843936a293d3dbc8d7b28247e23b849ade6bdaec311f512475702e7f6d5d3
|
|
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 = "2.
|
|
9
|
+
VERSION = "2.2.0"
|
|
10
10
|
end
|
data/sig/types.rbs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# This file is auto-generated by alef — DO NOT EDIT.
|
|
2
|
-
# alef:hash:
|
|
2
|
+
# alef:hash:d586cd0ed89b7c23a36a35404031b0152d6e4bb331734e021b41b776a7a22706
|
|
3
3
|
# To regenerate: alef generate
|
|
4
4
|
# To verify freshness: alef verify
|
|
5
5
|
|
|
@@ -195,6 +195,12 @@ module LiterLlm
|
|
|
195
195
|
def initialize: (?index: Integer, ?message: AssistantMessage, ?finish_reason: enum_FinishReason, ?logprobs: String) -> void
|
|
196
196
|
end
|
|
197
197
|
|
|
198
|
+
class CompletionTokensDetails
|
|
199
|
+
attr_reader reasoning_tokens: Integer
|
|
200
|
+
|
|
201
|
+
def initialize: (?reasoning_tokens: Integer) -> void
|
|
202
|
+
end
|
|
203
|
+
|
|
198
204
|
class CreateBatchRequest
|
|
199
205
|
attr_reader input_file_id: String
|
|
200
206
|
attr_reader endpoint: String
|
|
@@ -896,8 +902,9 @@ module LiterLlm
|
|
|
896
902
|
attr_reader completion_tokens: Integer
|
|
897
903
|
attr_reader total_tokens: Integer
|
|
898
904
|
attr_reader prompt_tokens_details: PromptTokensDetails?
|
|
905
|
+
attr_reader completion_tokens_details: CompletionTokensDetails?
|
|
899
906
|
|
|
900
|
-
def initialize: (?prompt_tokens: Integer, ?completion_tokens: Integer, ?total_tokens: Integer, ?prompt_tokens_details: PromptTokensDetails) -> void
|
|
907
|
+
def initialize: (?prompt_tokens: Integer, ?completion_tokens: Integer, ?total_tokens: Integer, ?prompt_tokens_details: PromptTokensDetails, ?completion_tokens_details: CompletionTokensDetails) -> void
|
|
901
908
|
end
|
|
902
909
|
|
|
903
910
|
class UserMessage
|
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: 2.
|
|
4
|
+
version: 2.2.0
|
|
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-10-
|
|
11
|
+
date: 2026-10-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rb_sys
|