liter_llm 1.15.0 → 1.16.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 +2 -2
- data/ext/liter_llm_rb/src/lib.rs +927 -74
- data/lib/liter_llm/native.rb +1 -1
- data/lib/liter_llm/version.rb +2 -2
- data/lib/liter_llm.rb +1 -1
- data/sig/types.rbs +70 -3
- 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: 583c166965b777229367242f38ad821d1342f0fcd49327c33c436252bde4d3d3
|
|
4
|
+
data.tar.gz: bb2286dcf26095bd41dd72f2bf1622554af0c3306b389aab386999366291a76a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6372e35d3c8bd6887310037de0e0ad3727af77696f2d5f547dd83f6323b2be6e9bd887cbaab6fb4f77d63849b7ad81a85a10a179e7e999985c765cf6372ff266
|
|
7
|
+
data.tar.gz: 5427806e8ae63d9104cab65932168403aaa0a27c344184b3d950a87271c03cefa3587a0b0080580557bed113f7515664777cc2666d1496be7b1f61b7be930099
|
|
@@ -1783,9 +1783,9 @@ checksum = "92daf443525c4cce67b150400bc2316076100ce0b3686209eb8cf3c31612e6f0"
|
|
|
1783
1783
|
|
|
1784
1784
|
[[package]]
|
|
1785
1785
|
name = "liter-llm"
|
|
1786
|
-
version = "1.
|
|
1786
|
+
version = "1.16.0"
|
|
1787
1787
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1788
|
-
checksum = "
|
|
1788
|
+
checksum = "9c5ed2a6c80abf59ecef2990a20369c171349160738a652a50c26b9c202a81d7"
|
|
1789
1789
|
dependencies = [
|
|
1790
1790
|
"ahash 0.8.12",
|
|
1791
1791
|
"arc-swap",
|
|
@@ -1826,7 +1826,7 @@ dependencies = [
|
|
|
1826
1826
|
|
|
1827
1827
|
[[package]]
|
|
1828
1828
|
name = "liter-llm-rb"
|
|
1829
|
-
version = "1.
|
|
1829
|
+
version = "1.16.0"
|
|
1830
1830
|
dependencies = [
|
|
1831
1831
|
"futures",
|
|
1832
1832
|
"liter-llm",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "liter-llm-rb"
|
|
3
|
-
version = "1.
|
|
3
|
+
version = "1.16.0"
|
|
4
4
|
edition = "2024"
|
|
5
5
|
license = "MIT"
|
|
6
6
|
description = "Universal LLM API client with Rust-powered polyglot bindings."
|
|
@@ -24,7 +24,7 @@ wasm-http = ["liter-llm/wasm-http"]
|
|
|
24
24
|
|
|
25
25
|
[dependencies]
|
|
26
26
|
futures = "0.3"
|
|
27
|
-
liter-llm = { version = "1.
|
|
27
|
+
liter-llm = { version = "1.16.0", features = ["native-http", "full"] }
|
|
28
28
|
magnus = "0.8"
|
|
29
29
|
rb-sys = ">=0.9, <0.9.128"
|
|
30
30
|
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:938b8ffd93c3e30d74875f875188c728addee9d4b80a97a7ac22716b3154c7c5
|
|
3
3
|
// Re-generate with: alef generate
|
|
4
4
|
#![allow(dead_code, unused_imports, unused_variables)]
|
|
5
5
|
#![allow(
|
|
@@ -609,7 +609,7 @@ impl AssistantMessage {
|
|
|
609
609
|
#[serde(default)]
|
|
610
610
|
#[magnus::wrap(class = "LiterLlm::ToolMessage")]
|
|
611
611
|
pub struct ToolMessage {
|
|
612
|
-
content:
|
|
612
|
+
content: UserContent,
|
|
613
613
|
tool_call_id: String,
|
|
614
614
|
name: Option<String>,
|
|
615
615
|
}
|
|
@@ -657,7 +657,7 @@ impl ToolMessage {
|
|
|
657
657
|
Ok(Self {
|
|
658
658
|
content: kwargs
|
|
659
659
|
.get(ruby.to_symbol("content"))
|
|
660
|
-
.and_then(|v|
|
|
660
|
+
.and_then(|v| UserContent::try_convert(v).ok())
|
|
661
661
|
.unwrap_or_default(),
|
|
662
662
|
tool_call_id: kwargs
|
|
663
663
|
.get(ruby.to_symbol("tool_call_id"))
|
|
@@ -669,7 +669,7 @@ impl ToolMessage {
|
|
|
669
669
|
})
|
|
670
670
|
}
|
|
671
671
|
|
|
672
|
-
fn content(&self) ->
|
|
672
|
+
fn content(&self) -> UserContent {
|
|
673
673
|
self.content.clone()
|
|
674
674
|
}
|
|
675
675
|
|
|
@@ -680,11 +680,6 @@ impl ToolMessage {
|
|
|
680
680
|
fn name(&self) -> Option<String> {
|
|
681
681
|
self.name.clone()
|
|
682
682
|
}
|
|
683
|
-
|
|
684
|
-
#[allow(clippy::should_implement_trait)]
|
|
685
|
-
fn to_s(&self) -> String {
|
|
686
|
-
self.content.clone()
|
|
687
|
-
}
|
|
688
683
|
}
|
|
689
684
|
|
|
690
685
|
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
@@ -6201,32 +6196,606 @@ impl ResponseObject {
|
|
|
6201
6196
|
self.status.clone()
|
|
6202
6197
|
}
|
|
6203
6198
|
|
|
6204
|
-
fn output(&self) -> Vec<ResponseOutputItem> {
|
|
6205
|
-
self.output.clone()
|
|
6199
|
+
fn output(&self) -> Vec<ResponseOutputItem> {
|
|
6200
|
+
self.output.clone()
|
|
6201
|
+
}
|
|
6202
|
+
|
|
6203
|
+
fn usage(&self) -> Option<ResponseUsage> {
|
|
6204
|
+
self.usage.clone()
|
|
6205
|
+
}
|
|
6206
|
+
|
|
6207
|
+
fn error(&self) -> Option<String> {
|
|
6208
|
+
self.error.clone()
|
|
6209
|
+
}
|
|
6210
|
+
}
|
|
6211
|
+
|
|
6212
|
+
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
6213
|
+
#[serde(default)]
|
|
6214
|
+
#[magnus::wrap(class = "LiterLlm::ResponseOutputItem")]
|
|
6215
|
+
pub struct ResponseOutputItem {
|
|
6216
|
+
item_type: String,
|
|
6217
|
+
content: String,
|
|
6218
|
+
}
|
|
6219
|
+
|
|
6220
|
+
unsafe impl IntoValueFromNative for ResponseOutputItem {}
|
|
6221
|
+
|
|
6222
|
+
impl magnus::TryConvert for ResponseOutputItem {
|
|
6223
|
+
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
6224
|
+
if let Ok(r) = <&ResponseOutputItem as magnus::TryConvert>::try_convert(val) {
|
|
6225
|
+
return Ok(r.clone());
|
|
6226
|
+
}
|
|
6227
|
+
let json_str: String = if let Ok(s) = <String as magnus::TryConvert>::try_convert(val) {
|
|
6228
|
+
s
|
|
6229
|
+
} else {
|
|
6230
|
+
val.funcall::<_, _, String>("to_json", ()).map_err(|e| {
|
|
6231
|
+
magnus::Error::new(
|
|
6232
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
6233
|
+
format!("no implicit conversion into ResponseOutputItem: {}", e),
|
|
6234
|
+
)
|
|
6235
|
+
})?
|
|
6236
|
+
};
|
|
6237
|
+
serde_json::from_str::<ResponseOutputItem>(&json_str).map_err(|e| {
|
|
6238
|
+
magnus::Error::new(
|
|
6239
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
6240
|
+
format!("failed to deserialize ResponseOutputItem: {}", e),
|
|
6241
|
+
)
|
|
6242
|
+
})
|
|
6243
|
+
}
|
|
6244
|
+
}
|
|
6245
|
+
|
|
6246
|
+
unsafe impl TryConvertOwned for ResponseOutputItem {}
|
|
6247
|
+
|
|
6248
|
+
impl Default for ResponseOutputItem {
|
|
6249
|
+
fn default() -> Self {
|
|
6250
|
+
liter_llm::types::ResponseOutputItem::default().into()
|
|
6251
|
+
}
|
|
6252
|
+
}
|
|
6253
|
+
|
|
6254
|
+
impl ResponseOutputItem {
|
|
6255
|
+
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
6256
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
6257
|
+
let args = magnus::scan_args::scan_args::<(), (Option<magnus::RHash>,), (), (), (), ()>(args)?;
|
|
6258
|
+
let (kwargs_opt,) = args.optional;
|
|
6259
|
+
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
6260
|
+
Ok(Self {
|
|
6261
|
+
item_type: kwargs
|
|
6262
|
+
.get(ruby.to_symbol("item_type"))
|
|
6263
|
+
.and_then(|v| String::try_convert(v).ok())
|
|
6264
|
+
.unwrap_or_default(),
|
|
6265
|
+
content: kwargs
|
|
6266
|
+
.get(ruby.to_symbol("content"))
|
|
6267
|
+
.and_then(|v| String::try_convert(v).ok())
|
|
6268
|
+
.unwrap_or_default(),
|
|
6269
|
+
})
|
|
6270
|
+
}
|
|
6271
|
+
|
|
6272
|
+
fn item_type(&self) -> String {
|
|
6273
|
+
self.item_type.clone()
|
|
6274
|
+
}
|
|
6275
|
+
|
|
6276
|
+
fn content(&self) -> String {
|
|
6277
|
+
self.content.clone()
|
|
6278
|
+
}
|
|
6279
|
+
}
|
|
6280
|
+
|
|
6281
|
+
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
6282
|
+
#[serde(default)]
|
|
6283
|
+
#[magnus::wrap(class = "LiterLlm::ResponseUsage")]
|
|
6284
|
+
pub struct ResponseUsage {
|
|
6285
|
+
input_tokens: u64,
|
|
6286
|
+
output_tokens: u64,
|
|
6287
|
+
total_tokens: u64,
|
|
6288
|
+
}
|
|
6289
|
+
|
|
6290
|
+
unsafe impl IntoValueFromNative for ResponseUsage {}
|
|
6291
|
+
|
|
6292
|
+
impl magnus::TryConvert for ResponseUsage {
|
|
6293
|
+
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
6294
|
+
if let Ok(r) = <&ResponseUsage as magnus::TryConvert>::try_convert(val) {
|
|
6295
|
+
return Ok(r.clone());
|
|
6296
|
+
}
|
|
6297
|
+
let json_str: String = if let Ok(s) = <String as magnus::TryConvert>::try_convert(val) {
|
|
6298
|
+
s
|
|
6299
|
+
} else {
|
|
6300
|
+
val.funcall::<_, _, String>("to_json", ()).map_err(|e| {
|
|
6301
|
+
magnus::Error::new(
|
|
6302
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
6303
|
+
format!("no implicit conversion into ResponseUsage: {}", e),
|
|
6304
|
+
)
|
|
6305
|
+
})?
|
|
6306
|
+
};
|
|
6307
|
+
serde_json::from_str::<ResponseUsage>(&json_str).map_err(|e| {
|
|
6308
|
+
magnus::Error::new(
|
|
6309
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
6310
|
+
format!("failed to deserialize ResponseUsage: {}", e),
|
|
6311
|
+
)
|
|
6312
|
+
})
|
|
6313
|
+
}
|
|
6314
|
+
}
|
|
6315
|
+
|
|
6316
|
+
unsafe impl TryConvertOwned for ResponseUsage {}
|
|
6317
|
+
|
|
6318
|
+
impl Default for ResponseUsage {
|
|
6319
|
+
fn default() -> Self {
|
|
6320
|
+
liter_llm::types::ResponseUsage::default().into()
|
|
6321
|
+
}
|
|
6322
|
+
}
|
|
6323
|
+
|
|
6324
|
+
impl ResponseUsage {
|
|
6325
|
+
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
6326
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
6327
|
+
let args = magnus::scan_args::scan_args::<(), (Option<magnus::RHash>,), (), (), (), ()>(args)?;
|
|
6328
|
+
let (kwargs_opt,) = args.optional;
|
|
6329
|
+
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
6330
|
+
Ok(Self {
|
|
6331
|
+
input_tokens: kwargs
|
|
6332
|
+
.get(ruby.to_symbol("input_tokens"))
|
|
6333
|
+
.and_then(|v| u64::try_convert(v).ok())
|
|
6334
|
+
.unwrap_or_default(),
|
|
6335
|
+
output_tokens: kwargs
|
|
6336
|
+
.get(ruby.to_symbol("output_tokens"))
|
|
6337
|
+
.and_then(|v| u64::try_convert(v).ok())
|
|
6338
|
+
.unwrap_or_default(),
|
|
6339
|
+
total_tokens: kwargs
|
|
6340
|
+
.get(ruby.to_symbol("total_tokens"))
|
|
6341
|
+
.and_then(|v| u64::try_convert(v).ok())
|
|
6342
|
+
.unwrap_or_default(),
|
|
6343
|
+
})
|
|
6344
|
+
}
|
|
6345
|
+
|
|
6346
|
+
fn input_tokens(&self) -> u64 {
|
|
6347
|
+
self.input_tokens
|
|
6348
|
+
}
|
|
6349
|
+
|
|
6350
|
+
fn output_tokens(&self) -> u64 {
|
|
6351
|
+
self.output_tokens
|
|
6352
|
+
}
|
|
6353
|
+
|
|
6354
|
+
fn total_tokens(&self) -> u64 {
|
|
6355
|
+
self.total_tokens
|
|
6356
|
+
}
|
|
6357
|
+
}
|
|
6358
|
+
|
|
6359
|
+
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
6360
|
+
#[serde(default)]
|
|
6361
|
+
#[magnus::wrap(class = "LiterLlm::LlmConfig")]
|
|
6362
|
+
pub struct LlmConfig {
|
|
6363
|
+
model: String,
|
|
6364
|
+
api_key: Option<String>,
|
|
6365
|
+
base_url: Option<String>,
|
|
6366
|
+
timeout_secs: Option<u64>,
|
|
6367
|
+
max_retries: Option<u32>,
|
|
6368
|
+
temperature: Option<f64>,
|
|
6369
|
+
max_tokens: Option<u64>,
|
|
6370
|
+
load_env: Option<bool>,
|
|
6371
|
+
headers: Option<HashMap<String, String>>,
|
|
6372
|
+
providers: Option<Vec<LlmProviderConfig>>,
|
|
6373
|
+
cache: Option<LlmCacheConfig>,
|
|
6374
|
+
budget: Option<LlmBudgetConfig>,
|
|
6375
|
+
rate_limit: Option<LlmRateLimitConfig>,
|
|
6376
|
+
cost_tracking: Option<bool>,
|
|
6377
|
+
tracing: Option<bool>,
|
|
6378
|
+
cooldown_secs: Option<u64>,
|
|
6379
|
+
health_check_secs: Option<u64>,
|
|
6380
|
+
bedrock: Option<BedrockConfig>,
|
|
6381
|
+
}
|
|
6382
|
+
|
|
6383
|
+
unsafe impl IntoValueFromNative for LlmConfig {}
|
|
6384
|
+
|
|
6385
|
+
impl magnus::TryConvert for LlmConfig {
|
|
6386
|
+
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
6387
|
+
if let Ok(r) = <&LlmConfig as magnus::TryConvert>::try_convert(val) {
|
|
6388
|
+
return Ok(r.clone());
|
|
6389
|
+
}
|
|
6390
|
+
let json_str: String = if let Ok(s) = <String as magnus::TryConvert>::try_convert(val) {
|
|
6391
|
+
s
|
|
6392
|
+
} else {
|
|
6393
|
+
val.funcall::<_, _, String>("to_json", ()).map_err(|e| {
|
|
6394
|
+
magnus::Error::new(
|
|
6395
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
6396
|
+
format!("no implicit conversion into LlmConfig: {}", e),
|
|
6397
|
+
)
|
|
6398
|
+
})?
|
|
6399
|
+
};
|
|
6400
|
+
serde_json::from_str::<LlmConfig>(&json_str).map_err(|e| {
|
|
6401
|
+
magnus::Error::new(
|
|
6402
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
6403
|
+
format!("failed to deserialize LlmConfig: {}", e),
|
|
6404
|
+
)
|
|
6405
|
+
})
|
|
6406
|
+
}
|
|
6407
|
+
}
|
|
6408
|
+
|
|
6409
|
+
unsafe impl TryConvertOwned for LlmConfig {}
|
|
6410
|
+
|
|
6411
|
+
impl Default for LlmConfig {
|
|
6412
|
+
fn default() -> Self {
|
|
6413
|
+
liter_llm::client::LlmConfig::default().into()
|
|
6414
|
+
}
|
|
6415
|
+
}
|
|
6416
|
+
|
|
6417
|
+
impl LlmConfig {
|
|
6418
|
+
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
6419
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
6420
|
+
let args = magnus::scan_args::scan_args::<(), (Option<magnus::RHash>,), (), (), (), ()>(args)?;
|
|
6421
|
+
let (kwargs_opt,) = args.optional;
|
|
6422
|
+
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
6423
|
+
Ok(Self {
|
|
6424
|
+
model: kwargs
|
|
6425
|
+
.get(ruby.to_symbol("model"))
|
|
6426
|
+
.and_then(|v| String::try_convert(v).ok())
|
|
6427
|
+
.unwrap_or_default(),
|
|
6428
|
+
api_key: kwargs
|
|
6429
|
+
.get(ruby.to_symbol("api_key"))
|
|
6430
|
+
.and_then(|v| String::try_convert(v).ok()),
|
|
6431
|
+
base_url: kwargs
|
|
6432
|
+
.get(ruby.to_symbol("base_url"))
|
|
6433
|
+
.and_then(|v| String::try_convert(v).ok()),
|
|
6434
|
+
timeout_secs: kwargs
|
|
6435
|
+
.get(ruby.to_symbol("timeout_secs"))
|
|
6436
|
+
.and_then(|v| u64::try_convert(v).ok()),
|
|
6437
|
+
max_retries: kwargs
|
|
6438
|
+
.get(ruby.to_symbol("max_retries"))
|
|
6439
|
+
.and_then(|v| u32::try_convert(v).ok()),
|
|
6440
|
+
temperature: kwargs
|
|
6441
|
+
.get(ruby.to_symbol("temperature"))
|
|
6442
|
+
.and_then(|v| f64::try_convert(v).ok()),
|
|
6443
|
+
max_tokens: kwargs
|
|
6444
|
+
.get(ruby.to_symbol("max_tokens"))
|
|
6445
|
+
.and_then(|v| u64::try_convert(v).ok()),
|
|
6446
|
+
load_env: kwargs
|
|
6447
|
+
.get(ruby.to_symbol("load_env"))
|
|
6448
|
+
.and_then(|v| bool::try_convert(v).ok()),
|
|
6449
|
+
headers: kwargs
|
|
6450
|
+
.get(ruby.to_symbol("headers"))
|
|
6451
|
+
.and_then(|v| <HashMap<String, String>>::try_convert(v).ok()),
|
|
6452
|
+
providers: kwargs
|
|
6453
|
+
.get(ruby.to_symbol("providers"))
|
|
6454
|
+
.and_then(|v| <Vec<LlmProviderConfig>>::try_convert(v).ok()),
|
|
6455
|
+
cache: kwargs
|
|
6456
|
+
.get(ruby.to_symbol("cache"))
|
|
6457
|
+
.and_then(|v| LlmCacheConfig::try_convert(v).ok()),
|
|
6458
|
+
budget: kwargs
|
|
6459
|
+
.get(ruby.to_symbol("budget"))
|
|
6460
|
+
.and_then(|v| LlmBudgetConfig::try_convert(v).ok()),
|
|
6461
|
+
rate_limit: kwargs
|
|
6462
|
+
.get(ruby.to_symbol("rate_limit"))
|
|
6463
|
+
.and_then(|v| LlmRateLimitConfig::try_convert(v).ok()),
|
|
6464
|
+
cost_tracking: kwargs
|
|
6465
|
+
.get(ruby.to_symbol("cost_tracking"))
|
|
6466
|
+
.and_then(|v| bool::try_convert(v).ok()),
|
|
6467
|
+
tracing: kwargs
|
|
6468
|
+
.get(ruby.to_symbol("tracing"))
|
|
6469
|
+
.and_then(|v| bool::try_convert(v).ok()),
|
|
6470
|
+
cooldown_secs: kwargs
|
|
6471
|
+
.get(ruby.to_symbol("cooldown_secs"))
|
|
6472
|
+
.and_then(|v| u64::try_convert(v).ok()),
|
|
6473
|
+
health_check_secs: kwargs
|
|
6474
|
+
.get(ruby.to_symbol("health_check_secs"))
|
|
6475
|
+
.and_then(|v| u64::try_convert(v).ok()),
|
|
6476
|
+
bedrock: kwargs
|
|
6477
|
+
.get(ruby.to_symbol("bedrock"))
|
|
6478
|
+
.and_then(|v| BedrockConfig::try_convert(v).ok()),
|
|
6479
|
+
})
|
|
6480
|
+
}
|
|
6481
|
+
|
|
6482
|
+
fn model(&self) -> String {
|
|
6483
|
+
self.model.clone()
|
|
6484
|
+
}
|
|
6485
|
+
|
|
6486
|
+
fn api_key(&self) -> Option<String> {
|
|
6487
|
+
self.api_key.clone()
|
|
6488
|
+
}
|
|
6489
|
+
|
|
6490
|
+
fn base_url(&self) -> Option<String> {
|
|
6491
|
+
self.base_url.clone()
|
|
6492
|
+
}
|
|
6493
|
+
|
|
6494
|
+
fn timeout_secs(&self) -> Option<u64> {
|
|
6495
|
+
self.timeout_secs
|
|
6496
|
+
}
|
|
6497
|
+
|
|
6498
|
+
fn max_retries(&self) -> Option<u32> {
|
|
6499
|
+
self.max_retries
|
|
6500
|
+
}
|
|
6501
|
+
|
|
6502
|
+
fn temperature(&self) -> Option<f64> {
|
|
6503
|
+
self.temperature
|
|
6504
|
+
}
|
|
6505
|
+
|
|
6506
|
+
fn max_tokens(&self) -> Option<u64> {
|
|
6507
|
+
self.max_tokens
|
|
6508
|
+
}
|
|
6509
|
+
|
|
6510
|
+
fn load_env(&self) -> Option<bool> {
|
|
6511
|
+
self.load_env
|
|
6512
|
+
}
|
|
6513
|
+
|
|
6514
|
+
fn headers(&self) -> Option<HashMap<String, String>> {
|
|
6515
|
+
self.headers.clone()
|
|
6516
|
+
}
|
|
6517
|
+
|
|
6518
|
+
fn providers(&self) -> Option<Vec<LlmProviderConfig>> {
|
|
6519
|
+
self.providers.clone()
|
|
6520
|
+
}
|
|
6521
|
+
|
|
6522
|
+
fn cache(&self) -> Option<LlmCacheConfig> {
|
|
6523
|
+
self.cache.clone()
|
|
6524
|
+
}
|
|
6525
|
+
|
|
6526
|
+
fn budget(&self) -> Option<LlmBudgetConfig> {
|
|
6527
|
+
self.budget.clone()
|
|
6528
|
+
}
|
|
6529
|
+
|
|
6530
|
+
fn rate_limit(&self) -> Option<LlmRateLimitConfig> {
|
|
6531
|
+
self.rate_limit.clone()
|
|
6532
|
+
}
|
|
6533
|
+
|
|
6534
|
+
fn cost_tracking(&self) -> Option<bool> {
|
|
6535
|
+
self.cost_tracking
|
|
6536
|
+
}
|
|
6537
|
+
|
|
6538
|
+
fn tracing(&self) -> Option<bool> {
|
|
6539
|
+
self.tracing
|
|
6540
|
+
}
|
|
6541
|
+
|
|
6542
|
+
fn cooldown_secs(&self) -> Option<u64> {
|
|
6543
|
+
self.cooldown_secs
|
|
6544
|
+
}
|
|
6545
|
+
|
|
6546
|
+
fn health_check_secs(&self) -> Option<u64> {
|
|
6547
|
+
self.health_check_secs
|
|
6548
|
+
}
|
|
6549
|
+
|
|
6550
|
+
fn bedrock(&self) -> Option<BedrockConfig> {
|
|
6551
|
+
self.bedrock.clone()
|
|
6552
|
+
}
|
|
6553
|
+
}
|
|
6554
|
+
|
|
6555
|
+
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
6556
|
+
#[serde(default)]
|
|
6557
|
+
#[magnus::wrap(class = "LiterLlm::LlmCacheConfig")]
|
|
6558
|
+
pub struct LlmCacheConfig {
|
|
6559
|
+
max_entries: Option<usize>,
|
|
6560
|
+
ttl_seconds: Option<u64>,
|
|
6561
|
+
backend: Option<String>,
|
|
6562
|
+
backend_config: Option<HashMap<String, String>>,
|
|
6563
|
+
}
|
|
6564
|
+
|
|
6565
|
+
unsafe impl IntoValueFromNative for LlmCacheConfig {}
|
|
6566
|
+
|
|
6567
|
+
impl magnus::TryConvert for LlmCacheConfig {
|
|
6568
|
+
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
6569
|
+
if let Ok(r) = <&LlmCacheConfig as magnus::TryConvert>::try_convert(val) {
|
|
6570
|
+
return Ok(r.clone());
|
|
6571
|
+
}
|
|
6572
|
+
let json_str: String = if let Ok(s) = <String as magnus::TryConvert>::try_convert(val) {
|
|
6573
|
+
s
|
|
6574
|
+
} else {
|
|
6575
|
+
val.funcall::<_, _, String>("to_json", ()).map_err(|e| {
|
|
6576
|
+
magnus::Error::new(
|
|
6577
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
6578
|
+
format!("no implicit conversion into LlmCacheConfig: {}", e),
|
|
6579
|
+
)
|
|
6580
|
+
})?
|
|
6581
|
+
};
|
|
6582
|
+
serde_json::from_str::<LlmCacheConfig>(&json_str).map_err(|e| {
|
|
6583
|
+
magnus::Error::new(
|
|
6584
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
6585
|
+
format!("failed to deserialize LlmCacheConfig: {}", e),
|
|
6586
|
+
)
|
|
6587
|
+
})
|
|
6588
|
+
}
|
|
6589
|
+
}
|
|
6590
|
+
|
|
6591
|
+
unsafe impl TryConvertOwned for LlmCacheConfig {}
|
|
6592
|
+
|
|
6593
|
+
impl Default for LlmCacheConfig {
|
|
6594
|
+
fn default() -> Self {
|
|
6595
|
+
liter_llm::client::LlmCacheConfig::default().into()
|
|
6596
|
+
}
|
|
6597
|
+
}
|
|
6598
|
+
|
|
6599
|
+
impl LlmCacheConfig {
|
|
6600
|
+
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
6601
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
6602
|
+
let args = magnus::scan_args::scan_args::<(), (Option<magnus::RHash>,), (), (), (), ()>(args)?;
|
|
6603
|
+
let (kwargs_opt,) = args.optional;
|
|
6604
|
+
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
6605
|
+
Ok(Self {
|
|
6606
|
+
max_entries: kwargs
|
|
6607
|
+
.get(ruby.to_symbol("max_entries"))
|
|
6608
|
+
.and_then(|v| usize::try_convert(v).ok()),
|
|
6609
|
+
ttl_seconds: kwargs
|
|
6610
|
+
.get(ruby.to_symbol("ttl_seconds"))
|
|
6611
|
+
.and_then(|v| u64::try_convert(v).ok()),
|
|
6612
|
+
backend: kwargs
|
|
6613
|
+
.get(ruby.to_symbol("backend"))
|
|
6614
|
+
.and_then(|v| String::try_convert(v).ok()),
|
|
6615
|
+
backend_config: kwargs
|
|
6616
|
+
.get(ruby.to_symbol("backend_config"))
|
|
6617
|
+
.and_then(|v| <HashMap<String, String>>::try_convert(v).ok()),
|
|
6618
|
+
})
|
|
6619
|
+
}
|
|
6620
|
+
|
|
6621
|
+
fn max_entries(&self) -> Option<usize> {
|
|
6622
|
+
self.max_entries
|
|
6623
|
+
}
|
|
6624
|
+
|
|
6625
|
+
fn ttl_seconds(&self) -> Option<u64> {
|
|
6626
|
+
self.ttl_seconds
|
|
6627
|
+
}
|
|
6628
|
+
|
|
6629
|
+
fn backend(&self) -> Option<String> {
|
|
6630
|
+
self.backend.clone()
|
|
6631
|
+
}
|
|
6632
|
+
|
|
6633
|
+
fn backend_config(&self) -> Option<HashMap<String, String>> {
|
|
6634
|
+
self.backend_config.clone()
|
|
6635
|
+
}
|
|
6636
|
+
}
|
|
6637
|
+
|
|
6638
|
+
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
6639
|
+
#[serde(default)]
|
|
6640
|
+
#[magnus::wrap(class = "LiterLlm::LlmBudgetConfig")]
|
|
6641
|
+
pub struct LlmBudgetConfig {
|
|
6642
|
+
global_limit: Option<f64>,
|
|
6643
|
+
model_limits: Option<HashMap<String, f64>>,
|
|
6644
|
+
enforcement: Option<String>,
|
|
6645
|
+
}
|
|
6646
|
+
|
|
6647
|
+
unsafe impl IntoValueFromNative for LlmBudgetConfig {}
|
|
6648
|
+
|
|
6649
|
+
impl magnus::TryConvert for LlmBudgetConfig {
|
|
6650
|
+
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
6651
|
+
if let Ok(r) = <&LlmBudgetConfig as magnus::TryConvert>::try_convert(val) {
|
|
6652
|
+
return Ok(r.clone());
|
|
6653
|
+
}
|
|
6654
|
+
let json_str: String = if let Ok(s) = <String as magnus::TryConvert>::try_convert(val) {
|
|
6655
|
+
s
|
|
6656
|
+
} else {
|
|
6657
|
+
val.funcall::<_, _, String>("to_json", ()).map_err(|e| {
|
|
6658
|
+
magnus::Error::new(
|
|
6659
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
6660
|
+
format!("no implicit conversion into LlmBudgetConfig: {}", e),
|
|
6661
|
+
)
|
|
6662
|
+
})?
|
|
6663
|
+
};
|
|
6664
|
+
serde_json::from_str::<LlmBudgetConfig>(&json_str).map_err(|e| {
|
|
6665
|
+
magnus::Error::new(
|
|
6666
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
6667
|
+
format!("failed to deserialize LlmBudgetConfig: {}", e),
|
|
6668
|
+
)
|
|
6669
|
+
})
|
|
6670
|
+
}
|
|
6671
|
+
}
|
|
6672
|
+
|
|
6673
|
+
unsafe impl TryConvertOwned for LlmBudgetConfig {}
|
|
6674
|
+
|
|
6675
|
+
impl Default for LlmBudgetConfig {
|
|
6676
|
+
fn default() -> Self {
|
|
6677
|
+
liter_llm::client::LlmBudgetConfig::default().into()
|
|
6678
|
+
}
|
|
6679
|
+
}
|
|
6680
|
+
|
|
6681
|
+
impl LlmBudgetConfig {
|
|
6682
|
+
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
6683
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
6684
|
+
let args = magnus::scan_args::scan_args::<(), (Option<magnus::RHash>,), (), (), (), ()>(args)?;
|
|
6685
|
+
let (kwargs_opt,) = args.optional;
|
|
6686
|
+
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
6687
|
+
Ok(Self {
|
|
6688
|
+
global_limit: kwargs
|
|
6689
|
+
.get(ruby.to_symbol("global_limit"))
|
|
6690
|
+
.and_then(|v| f64::try_convert(v).ok()),
|
|
6691
|
+
model_limits: kwargs
|
|
6692
|
+
.get(ruby.to_symbol("model_limits"))
|
|
6693
|
+
.and_then(|v| <HashMap<String, f64>>::try_convert(v).ok()),
|
|
6694
|
+
enforcement: kwargs
|
|
6695
|
+
.get(ruby.to_symbol("enforcement"))
|
|
6696
|
+
.and_then(|v| String::try_convert(v).ok()),
|
|
6697
|
+
})
|
|
6698
|
+
}
|
|
6699
|
+
|
|
6700
|
+
fn global_limit(&self) -> Option<f64> {
|
|
6701
|
+
self.global_limit
|
|
6702
|
+
}
|
|
6703
|
+
|
|
6704
|
+
fn model_limits(&self) -> Option<HashMap<String, f64>> {
|
|
6705
|
+
self.model_limits.clone()
|
|
6706
|
+
}
|
|
6707
|
+
|
|
6708
|
+
fn enforcement(&self) -> Option<String> {
|
|
6709
|
+
self.enforcement.clone()
|
|
6710
|
+
}
|
|
6711
|
+
}
|
|
6712
|
+
|
|
6713
|
+
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
6714
|
+
#[serde(default)]
|
|
6715
|
+
#[magnus::wrap(class = "LiterLlm::LlmRateLimitConfig")]
|
|
6716
|
+
pub struct LlmRateLimitConfig {
|
|
6717
|
+
rpm: Option<u32>,
|
|
6718
|
+
tpm: Option<u64>,
|
|
6719
|
+
window_seconds: Option<u64>,
|
|
6720
|
+
}
|
|
6721
|
+
|
|
6722
|
+
unsafe impl IntoValueFromNative for LlmRateLimitConfig {}
|
|
6723
|
+
|
|
6724
|
+
impl magnus::TryConvert for LlmRateLimitConfig {
|
|
6725
|
+
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
6726
|
+
if let Ok(r) = <&LlmRateLimitConfig as magnus::TryConvert>::try_convert(val) {
|
|
6727
|
+
return Ok(r.clone());
|
|
6728
|
+
}
|
|
6729
|
+
let json_str: String = if let Ok(s) = <String as magnus::TryConvert>::try_convert(val) {
|
|
6730
|
+
s
|
|
6731
|
+
} else {
|
|
6732
|
+
val.funcall::<_, _, String>("to_json", ()).map_err(|e| {
|
|
6733
|
+
magnus::Error::new(
|
|
6734
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
6735
|
+
format!("no implicit conversion into LlmRateLimitConfig: {}", e),
|
|
6736
|
+
)
|
|
6737
|
+
})?
|
|
6738
|
+
};
|
|
6739
|
+
serde_json::from_str::<LlmRateLimitConfig>(&json_str).map_err(|e| {
|
|
6740
|
+
magnus::Error::new(
|
|
6741
|
+
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
6742
|
+
format!("failed to deserialize LlmRateLimitConfig: {}", e),
|
|
6743
|
+
)
|
|
6744
|
+
})
|
|
6745
|
+
}
|
|
6746
|
+
}
|
|
6747
|
+
|
|
6748
|
+
unsafe impl TryConvertOwned for LlmRateLimitConfig {}
|
|
6749
|
+
|
|
6750
|
+
impl Default for LlmRateLimitConfig {
|
|
6751
|
+
fn default() -> Self {
|
|
6752
|
+
liter_llm::client::LlmRateLimitConfig::default().into()
|
|
6753
|
+
}
|
|
6754
|
+
}
|
|
6755
|
+
|
|
6756
|
+
impl LlmRateLimitConfig {
|
|
6757
|
+
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
6758
|
+
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
6759
|
+
let args = magnus::scan_args::scan_args::<(), (Option<magnus::RHash>,), (), (), (), ()>(args)?;
|
|
6760
|
+
let (kwargs_opt,) = args.optional;
|
|
6761
|
+
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
6762
|
+
Ok(Self {
|
|
6763
|
+
rpm: kwargs.get(ruby.to_symbol("rpm")).and_then(|v| u32::try_convert(v).ok()),
|
|
6764
|
+
tpm: kwargs.get(ruby.to_symbol("tpm")).and_then(|v| u64::try_convert(v).ok()),
|
|
6765
|
+
window_seconds: kwargs
|
|
6766
|
+
.get(ruby.to_symbol("window_seconds"))
|
|
6767
|
+
.and_then(|v| u64::try_convert(v).ok()),
|
|
6768
|
+
})
|
|
6769
|
+
}
|
|
6770
|
+
|
|
6771
|
+
fn rpm(&self) -> Option<u32> {
|
|
6772
|
+
self.rpm
|
|
6206
6773
|
}
|
|
6207
6774
|
|
|
6208
|
-
fn
|
|
6209
|
-
self.
|
|
6775
|
+
fn tpm(&self) -> Option<u64> {
|
|
6776
|
+
self.tpm
|
|
6210
6777
|
}
|
|
6211
6778
|
|
|
6212
|
-
fn
|
|
6213
|
-
self.
|
|
6779
|
+
fn window_seconds(&self) -> Option<u64> {
|
|
6780
|
+
self.window_seconds
|
|
6214
6781
|
}
|
|
6215
6782
|
}
|
|
6216
6783
|
|
|
6217
6784
|
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
6218
6785
|
#[serde(default)]
|
|
6219
|
-
#[magnus::wrap(class = "LiterLlm::
|
|
6220
|
-
pub struct
|
|
6221
|
-
|
|
6222
|
-
|
|
6786
|
+
#[magnus::wrap(class = "LiterLlm::LlmProviderConfig")]
|
|
6787
|
+
pub struct LlmProviderConfig {
|
|
6788
|
+
name: String,
|
|
6789
|
+
base_url: String,
|
|
6790
|
+
auth_header: Option<String>,
|
|
6791
|
+
model_prefixes: Vec<String>,
|
|
6223
6792
|
}
|
|
6224
6793
|
|
|
6225
|
-
unsafe impl IntoValueFromNative for
|
|
6794
|
+
unsafe impl IntoValueFromNative for LlmProviderConfig {}
|
|
6226
6795
|
|
|
6227
|
-
impl magnus::TryConvert for
|
|
6796
|
+
impl magnus::TryConvert for LlmProviderConfig {
|
|
6228
6797
|
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
6229
|
-
if let Ok(r) = <&
|
|
6798
|
+
if let Ok(r) = <&LlmProviderConfig as magnus::TryConvert>::try_convert(val) {
|
|
6230
6799
|
return Ok(r.clone());
|
|
6231
6800
|
}
|
|
6232
6801
|
let json_str: String = if let Ok(s) = <String as magnus::TryConvert>::try_convert(val) {
|
|
@@ -6235,68 +6804,85 @@ impl magnus::TryConvert for ResponseOutputItem {
|
|
|
6235
6804
|
val.funcall::<_, _, String>("to_json", ()).map_err(|e| {
|
|
6236
6805
|
magnus::Error::new(
|
|
6237
6806
|
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
6238
|
-
format!("no implicit conversion into
|
|
6807
|
+
format!("no implicit conversion into LlmProviderConfig: {}", e),
|
|
6239
6808
|
)
|
|
6240
6809
|
})?
|
|
6241
6810
|
};
|
|
6242
|
-
serde_json::from_str::<
|
|
6811
|
+
serde_json::from_str::<LlmProviderConfig>(&json_str).map_err(|e| {
|
|
6243
6812
|
magnus::Error::new(
|
|
6244
6813
|
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
6245
|
-
format!("failed to deserialize
|
|
6814
|
+
format!("failed to deserialize LlmProviderConfig: {}", e),
|
|
6246
6815
|
)
|
|
6247
6816
|
})
|
|
6248
6817
|
}
|
|
6249
6818
|
}
|
|
6250
6819
|
|
|
6251
|
-
unsafe impl TryConvertOwned for
|
|
6820
|
+
unsafe impl TryConvertOwned for LlmProviderConfig {}
|
|
6252
6821
|
|
|
6253
|
-
impl Default for
|
|
6822
|
+
impl Default for LlmProviderConfig {
|
|
6254
6823
|
fn default() -> Self {
|
|
6255
|
-
liter_llm::
|
|
6824
|
+
liter_llm::client::LlmProviderConfig::default().into()
|
|
6256
6825
|
}
|
|
6257
6826
|
}
|
|
6258
6827
|
|
|
6259
|
-
impl
|
|
6828
|
+
impl LlmProviderConfig {
|
|
6260
6829
|
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
6261
6830
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
6262
6831
|
let args = magnus::scan_args::scan_args::<(), (Option<magnus::RHash>,), (), (), (), ()>(args)?;
|
|
6263
6832
|
let (kwargs_opt,) = args.optional;
|
|
6264
6833
|
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
6265
6834
|
Ok(Self {
|
|
6266
|
-
|
|
6267
|
-
.get(ruby.to_symbol("
|
|
6835
|
+
name: kwargs
|
|
6836
|
+
.get(ruby.to_symbol("name"))
|
|
6268
6837
|
.and_then(|v| String::try_convert(v).ok())
|
|
6269
6838
|
.unwrap_or_default(),
|
|
6270
|
-
|
|
6271
|
-
.get(ruby.to_symbol("
|
|
6839
|
+
base_url: kwargs
|
|
6840
|
+
.get(ruby.to_symbol("base_url"))
|
|
6272
6841
|
.and_then(|v| String::try_convert(v).ok())
|
|
6273
6842
|
.unwrap_or_default(),
|
|
6843
|
+
auth_header: kwargs
|
|
6844
|
+
.get(ruby.to_symbol("auth_header"))
|
|
6845
|
+
.and_then(|v| String::try_convert(v).ok()),
|
|
6846
|
+
model_prefixes: kwargs
|
|
6847
|
+
.get(ruby.to_symbol("model_prefixes"))
|
|
6848
|
+
.and_then(|v| <Vec<String>>::try_convert(v).ok())
|
|
6849
|
+
.unwrap_or_default(),
|
|
6274
6850
|
})
|
|
6275
6851
|
}
|
|
6276
6852
|
|
|
6277
|
-
fn
|
|
6278
|
-
self.
|
|
6853
|
+
fn name(&self) -> String {
|
|
6854
|
+
self.name.clone()
|
|
6279
6855
|
}
|
|
6280
6856
|
|
|
6281
|
-
fn
|
|
6282
|
-
self.
|
|
6857
|
+
fn base_url(&self) -> String {
|
|
6858
|
+
self.base_url.clone()
|
|
6859
|
+
}
|
|
6860
|
+
|
|
6861
|
+
fn auth_header(&self) -> Option<String> {
|
|
6862
|
+
self.auth_header.clone()
|
|
6863
|
+
}
|
|
6864
|
+
|
|
6865
|
+
fn model_prefixes(&self) -> Vec<String> {
|
|
6866
|
+
self.model_prefixes.clone()
|
|
6283
6867
|
}
|
|
6284
6868
|
}
|
|
6285
6869
|
|
|
6286
6870
|
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
|
6287
6871
|
#[serde(default)]
|
|
6288
|
-
#[magnus::wrap(class = "LiterLlm::
|
|
6289
|
-
pub struct
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
|
|
6872
|
+
#[magnus::wrap(class = "LiterLlm::BedrockConfig")]
|
|
6873
|
+
pub struct BedrockConfig {
|
|
6874
|
+
region: Option<String>,
|
|
6875
|
+
cross_region_prefix: Option<String>,
|
|
6876
|
+
access_key_id: Option<String>,
|
|
6877
|
+
secret_access_key: Option<String>,
|
|
6878
|
+
session_token: Option<String>,
|
|
6293
6879
|
}
|
|
6294
6880
|
|
|
6295
|
-
unsafe impl IntoValueFromNative for
|
|
6881
|
+
unsafe impl IntoValueFromNative for BedrockConfig {}
|
|
6296
6882
|
|
|
6297
|
-
impl magnus::TryConvert for
|
|
6883
|
+
impl magnus::TryConvert for BedrockConfig {
|
|
6298
6884
|
fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
|
|
6299
|
-
if let Ok(r) = <&
|
|
6885
|
+
if let Ok(r) = <&BedrockConfig as magnus::TryConvert>::try_convert(val) {
|
|
6300
6886
|
return Ok(r.clone());
|
|
6301
6887
|
}
|
|
6302
6888
|
let json_str: String = if let Ok(s) = <String as magnus::TryConvert>::try_convert(val) {
|
|
@@ -6305,59 +6891,70 @@ impl magnus::TryConvert for ResponseUsage {
|
|
|
6305
6891
|
val.funcall::<_, _, String>("to_json", ()).map_err(|e| {
|
|
6306
6892
|
magnus::Error::new(
|
|
6307
6893
|
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
6308
|
-
format!("no implicit conversion into
|
|
6894
|
+
format!("no implicit conversion into BedrockConfig: {}", e),
|
|
6309
6895
|
)
|
|
6310
6896
|
})?
|
|
6311
6897
|
};
|
|
6312
|
-
serde_json::from_str::<
|
|
6898
|
+
serde_json::from_str::<BedrockConfig>(&json_str).map_err(|e| {
|
|
6313
6899
|
magnus::Error::new(
|
|
6314
6900
|
unsafe { magnus::Ruby::get_unchecked() }.exception_type_error(),
|
|
6315
|
-
format!("failed to deserialize
|
|
6901
|
+
format!("failed to deserialize BedrockConfig: {}", e),
|
|
6316
6902
|
)
|
|
6317
6903
|
})
|
|
6318
6904
|
}
|
|
6319
6905
|
}
|
|
6320
6906
|
|
|
6321
|
-
unsafe impl TryConvertOwned for
|
|
6907
|
+
unsafe impl TryConvertOwned for BedrockConfig {}
|
|
6322
6908
|
|
|
6323
|
-
impl Default for
|
|
6909
|
+
impl Default for BedrockConfig {
|
|
6324
6910
|
fn default() -> Self {
|
|
6325
|
-
liter_llm::
|
|
6911
|
+
liter_llm::client::BedrockConfig::default().into()
|
|
6326
6912
|
}
|
|
6327
6913
|
}
|
|
6328
6914
|
|
|
6329
|
-
impl
|
|
6915
|
+
impl BedrockConfig {
|
|
6330
6916
|
fn new(args: &[magnus::Value]) -> Result<Self, magnus::Error> {
|
|
6331
6917
|
let ruby = unsafe { magnus::Ruby::get_unchecked() };
|
|
6332
6918
|
let args = magnus::scan_args::scan_args::<(), (Option<magnus::RHash>,), (), (), (), ()>(args)?;
|
|
6333
6919
|
let (kwargs_opt,) = args.optional;
|
|
6334
6920
|
let kwargs = kwargs_opt.unwrap_or_else(|| ruby.hash_new());
|
|
6335
6921
|
Ok(Self {
|
|
6336
|
-
|
|
6337
|
-
.get(ruby.to_symbol("
|
|
6338
|
-
.and_then(|v|
|
|
6339
|
-
|
|
6340
|
-
|
|
6341
|
-
.
|
|
6342
|
-
|
|
6343
|
-
.
|
|
6344
|
-
|
|
6345
|
-
|
|
6346
|
-
.
|
|
6347
|
-
.
|
|
6922
|
+
region: kwargs
|
|
6923
|
+
.get(ruby.to_symbol("region"))
|
|
6924
|
+
.and_then(|v| String::try_convert(v).ok()),
|
|
6925
|
+
cross_region_prefix: kwargs
|
|
6926
|
+
.get(ruby.to_symbol("cross_region_prefix"))
|
|
6927
|
+
.and_then(|v| String::try_convert(v).ok()),
|
|
6928
|
+
access_key_id: kwargs
|
|
6929
|
+
.get(ruby.to_symbol("access_key_id"))
|
|
6930
|
+
.and_then(|v| String::try_convert(v).ok()),
|
|
6931
|
+
secret_access_key: kwargs
|
|
6932
|
+
.get(ruby.to_symbol("secret_access_key"))
|
|
6933
|
+
.and_then(|v| String::try_convert(v).ok()),
|
|
6934
|
+
session_token: kwargs
|
|
6935
|
+
.get(ruby.to_symbol("session_token"))
|
|
6936
|
+
.and_then(|v| String::try_convert(v).ok()),
|
|
6348
6937
|
})
|
|
6349
6938
|
}
|
|
6350
6939
|
|
|
6351
|
-
fn
|
|
6352
|
-
self.
|
|
6940
|
+
fn region(&self) -> Option<String> {
|
|
6941
|
+
self.region.clone()
|
|
6353
6942
|
}
|
|
6354
6943
|
|
|
6355
|
-
fn
|
|
6356
|
-
self.
|
|
6944
|
+
fn cross_region_prefix(&self) -> Option<String> {
|
|
6945
|
+
self.cross_region_prefix.clone()
|
|
6357
6946
|
}
|
|
6358
6947
|
|
|
6359
|
-
fn
|
|
6360
|
-
self.
|
|
6948
|
+
fn access_key_id(&self) -> Option<String> {
|
|
6949
|
+
self.access_key_id.clone()
|
|
6950
|
+
}
|
|
6951
|
+
|
|
6952
|
+
fn secret_access_key(&self) -> Option<String> {
|
|
6953
|
+
self.secret_access_key.clone()
|
|
6954
|
+
}
|
|
6955
|
+
|
|
6956
|
+
fn session_token(&self) -> Option<String> {
|
|
6957
|
+
self.session_token.clone()
|
|
6361
6958
|
}
|
|
6362
6959
|
}
|
|
6363
6960
|
|
|
@@ -10028,7 +10625,7 @@ impl From<liter_llm::types::AssistantMessage> for AssistantMessage {
|
|
|
10028
10625
|
impl From<ToolMessage> for liter_llm::types::ToolMessage {
|
|
10029
10626
|
fn from(val: ToolMessage) -> Self {
|
|
10030
10627
|
Self {
|
|
10031
|
-
content: val.content,
|
|
10628
|
+
content: val.content.into(),
|
|
10032
10629
|
tool_call_id: val.tool_call_id,
|
|
10033
10630
|
name: val.name,
|
|
10034
10631
|
..Default::default()
|
|
@@ -10040,7 +10637,7 @@ impl From<ToolMessage> for liter_llm::types::ToolMessage {
|
|
|
10040
10637
|
impl From<liter_llm::types::ToolMessage> for ToolMessage {
|
|
10041
10638
|
fn from(val: liter_llm::types::ToolMessage) -> Self {
|
|
10042
10639
|
Self {
|
|
10043
|
-
content: val.content.
|
|
10640
|
+
content: val.content.into(),
|
|
10044
10641
|
tool_call_id: val.tool_call_id.to_string(),
|
|
10045
10642
|
name: val.name.map(|v| v.to_string()),
|
|
10046
10643
|
}
|
|
@@ -11656,6 +12253,166 @@ impl From<liter_llm::types::ResponseUsage> for ResponseUsage {
|
|
|
11656
12253
|
}
|
|
11657
12254
|
}
|
|
11658
12255
|
|
|
12256
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
12257
|
+
impl From<liter_llm::client::LlmConfig> for LlmConfig {
|
|
12258
|
+
fn from(val: liter_llm::client::LlmConfig) -> Self {
|
|
12259
|
+
Self {
|
|
12260
|
+
model: val.model.to_string(),
|
|
12261
|
+
api_key: val.api_key.map(|v| v.to_string()),
|
|
12262
|
+
base_url: val.base_url.map(|v| v.to_string()),
|
|
12263
|
+
timeout_secs: val.timeout_secs,
|
|
12264
|
+
max_retries: val.max_retries,
|
|
12265
|
+
temperature: val.temperature,
|
|
12266
|
+
max_tokens: val.max_tokens,
|
|
12267
|
+
load_env: val.load_env,
|
|
12268
|
+
headers: val
|
|
12269
|
+
.headers
|
|
12270
|
+
.map(|m| m.into_iter().map(|(k, v)| (k.into(), v.into())).collect()),
|
|
12271
|
+
providers: val.providers.map(|v| v.into_iter().map(Into::into).collect()),
|
|
12272
|
+
cache: val.cache.map(Into::into),
|
|
12273
|
+
budget: val.budget.map(Into::into),
|
|
12274
|
+
rate_limit: val.rate_limit.map(Into::into),
|
|
12275
|
+
cost_tracking: val.cost_tracking,
|
|
12276
|
+
tracing: val.tracing,
|
|
12277
|
+
cooldown_secs: val.cooldown_secs,
|
|
12278
|
+
health_check_secs: val.health_check_secs,
|
|
12279
|
+
bedrock: val.bedrock.map(Into::into),
|
|
12280
|
+
}
|
|
12281
|
+
}
|
|
12282
|
+
}
|
|
12283
|
+
|
|
12284
|
+
#[allow(clippy::needless_update)]
|
|
12285
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
12286
|
+
impl From<LlmCacheConfig> for liter_llm::client::LlmCacheConfig {
|
|
12287
|
+
fn from(val: LlmCacheConfig) -> Self {
|
|
12288
|
+
Self {
|
|
12289
|
+
max_entries: val.max_entries,
|
|
12290
|
+
ttl_seconds: val.ttl_seconds,
|
|
12291
|
+
backend: val.backend,
|
|
12292
|
+
backend_config: val
|
|
12293
|
+
.backend_config
|
|
12294
|
+
.map(|m| m.into_iter().map(|(k, v)| (k.into(), v.into())).collect()),
|
|
12295
|
+
..Default::default()
|
|
12296
|
+
}
|
|
12297
|
+
}
|
|
12298
|
+
}
|
|
12299
|
+
|
|
12300
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
12301
|
+
impl From<liter_llm::client::LlmCacheConfig> for LlmCacheConfig {
|
|
12302
|
+
fn from(val: liter_llm::client::LlmCacheConfig) -> Self {
|
|
12303
|
+
Self {
|
|
12304
|
+
max_entries: val.max_entries,
|
|
12305
|
+
ttl_seconds: val.ttl_seconds,
|
|
12306
|
+
backend: val.backend.map(|v| v.to_string()),
|
|
12307
|
+
backend_config: val
|
|
12308
|
+
.backend_config
|
|
12309
|
+
.map(|m| m.into_iter().map(|(k, v)| (k.into(), v.into())).collect()),
|
|
12310
|
+
}
|
|
12311
|
+
}
|
|
12312
|
+
}
|
|
12313
|
+
|
|
12314
|
+
#[allow(clippy::needless_update)]
|
|
12315
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
12316
|
+
impl From<LlmBudgetConfig> for liter_llm::client::LlmBudgetConfig {
|
|
12317
|
+
fn from(val: LlmBudgetConfig) -> Self {
|
|
12318
|
+
Self {
|
|
12319
|
+
global_limit: val.global_limit,
|
|
12320
|
+
model_limits: val.model_limits.map(|m| m.into_iter().collect()),
|
|
12321
|
+
enforcement: val.enforcement,
|
|
12322
|
+
..Default::default()
|
|
12323
|
+
}
|
|
12324
|
+
}
|
|
12325
|
+
}
|
|
12326
|
+
|
|
12327
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
12328
|
+
impl From<liter_llm::client::LlmBudgetConfig> for LlmBudgetConfig {
|
|
12329
|
+
fn from(val: liter_llm::client::LlmBudgetConfig) -> Self {
|
|
12330
|
+
Self {
|
|
12331
|
+
global_limit: val.global_limit,
|
|
12332
|
+
model_limits: val.model_limits.map(|m| m.into_iter().collect()),
|
|
12333
|
+
enforcement: val.enforcement.map(|v| v.to_string()),
|
|
12334
|
+
}
|
|
12335
|
+
}
|
|
12336
|
+
}
|
|
12337
|
+
|
|
12338
|
+
#[allow(clippy::needless_update)]
|
|
12339
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
12340
|
+
impl From<LlmRateLimitConfig> for liter_llm::client::LlmRateLimitConfig {
|
|
12341
|
+
fn from(val: LlmRateLimitConfig) -> Self {
|
|
12342
|
+
Self {
|
|
12343
|
+
rpm: val.rpm,
|
|
12344
|
+
tpm: val.tpm,
|
|
12345
|
+
window_seconds: val.window_seconds,
|
|
12346
|
+
..Default::default()
|
|
12347
|
+
}
|
|
12348
|
+
}
|
|
12349
|
+
}
|
|
12350
|
+
|
|
12351
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
12352
|
+
impl From<liter_llm::client::LlmRateLimitConfig> for LlmRateLimitConfig {
|
|
12353
|
+
fn from(val: liter_llm::client::LlmRateLimitConfig) -> Self {
|
|
12354
|
+
Self {
|
|
12355
|
+
rpm: val.rpm,
|
|
12356
|
+
tpm: val.tpm,
|
|
12357
|
+
window_seconds: val.window_seconds,
|
|
12358
|
+
}
|
|
12359
|
+
}
|
|
12360
|
+
}
|
|
12361
|
+
|
|
12362
|
+
#[allow(clippy::needless_update)]
|
|
12363
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
12364
|
+
impl From<LlmProviderConfig> for liter_llm::client::LlmProviderConfig {
|
|
12365
|
+
fn from(val: LlmProviderConfig) -> Self {
|
|
12366
|
+
Self {
|
|
12367
|
+
name: val.name,
|
|
12368
|
+
base_url: val.base_url,
|
|
12369
|
+
auth_header: val.auth_header,
|
|
12370
|
+
model_prefixes: val.model_prefixes.into_iter().collect(),
|
|
12371
|
+
..Default::default()
|
|
12372
|
+
}
|
|
12373
|
+
}
|
|
12374
|
+
}
|
|
12375
|
+
|
|
12376
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
12377
|
+
impl From<liter_llm::client::LlmProviderConfig> for LlmProviderConfig {
|
|
12378
|
+
fn from(val: liter_llm::client::LlmProviderConfig) -> Self {
|
|
12379
|
+
Self {
|
|
12380
|
+
name: val.name.to_string(),
|
|
12381
|
+
base_url: val.base_url.to_string(),
|
|
12382
|
+
auth_header: val.auth_header.map(|v| v.to_string()),
|
|
12383
|
+
model_prefixes: val.model_prefixes.into_iter().collect(),
|
|
12384
|
+
}
|
|
12385
|
+
}
|
|
12386
|
+
}
|
|
12387
|
+
|
|
12388
|
+
#[allow(clippy::needless_update)]
|
|
12389
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
12390
|
+
impl From<BedrockConfig> for liter_llm::client::BedrockConfig {
|
|
12391
|
+
fn from(val: BedrockConfig) -> Self {
|
|
12392
|
+
Self {
|
|
12393
|
+
region: val.region,
|
|
12394
|
+
cross_region_prefix: val.cross_region_prefix,
|
|
12395
|
+
access_key_id: val.access_key_id,
|
|
12396
|
+
secret_access_key: val.secret_access_key,
|
|
12397
|
+
session_token: val.session_token,
|
|
12398
|
+
..Default::default()
|
|
12399
|
+
}
|
|
12400
|
+
}
|
|
12401
|
+
}
|
|
12402
|
+
|
|
12403
|
+
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
12404
|
+
impl From<liter_llm::client::BedrockConfig> for BedrockConfig {
|
|
12405
|
+
fn from(val: liter_llm::client::BedrockConfig) -> Self {
|
|
12406
|
+
Self {
|
|
12407
|
+
region: val.region.map(|v| v.to_string()),
|
|
12408
|
+
cross_region_prefix: val.cross_region_prefix.map(|v| v.to_string()),
|
|
12409
|
+
access_key_id: val.access_key_id.map(|v| v.to_string()),
|
|
12410
|
+
secret_access_key: val.secret_access_key.map(|v| v.to_string()),
|
|
12411
|
+
session_token: val.session_token.map(|v| v.to_string()),
|
|
12412
|
+
}
|
|
12413
|
+
}
|
|
12414
|
+
}
|
|
12415
|
+
|
|
11659
12416
|
#[allow(clippy::needless_update)]
|
|
11660
12417
|
#[allow(clippy::redundant_closure, clippy::useless_conversion)]
|
|
11661
12418
|
impl From<WaitForBatchConfig> for liter_llm::client::WaitForBatchConfig {
|
|
@@ -12796,8 +13553,6 @@ fn ruby_init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
12796
13553
|
|
|
12797
13554
|
class.define_method("name", method!(ToolMessage::name, 0))?;
|
|
12798
13555
|
|
|
12799
|
-
class.define_method("to_s", method!(ToolMessage::to_s, 0))?;
|
|
12800
|
-
|
|
12801
13556
|
let class = module.define_class("DeveloperMessage", ruby.class_object())?;
|
|
12802
13557
|
|
|
12803
13558
|
class.define_singleton_method("new", function!(DeveloperMessage::new, -1))?;
|
|
@@ -13651,6 +14406,104 @@ fn ruby_init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
13651
14406
|
|
|
13652
14407
|
class.define_method("total_tokens", method!(ResponseUsage::total_tokens, 0))?;
|
|
13653
14408
|
|
|
14409
|
+
let class = module.define_class("LlmConfig", ruby.class_object())?;
|
|
14410
|
+
|
|
14411
|
+
class.define_singleton_method("new", function!(LlmConfig::new, -1))?;
|
|
14412
|
+
|
|
14413
|
+
class.define_method("model", method!(LlmConfig::model, 0))?;
|
|
14414
|
+
|
|
14415
|
+
class.define_method("api_key", method!(LlmConfig::api_key, 0))?;
|
|
14416
|
+
|
|
14417
|
+
class.define_method("base_url", method!(LlmConfig::base_url, 0))?;
|
|
14418
|
+
|
|
14419
|
+
class.define_method("timeout_secs", method!(LlmConfig::timeout_secs, 0))?;
|
|
14420
|
+
|
|
14421
|
+
class.define_method("max_retries", method!(LlmConfig::max_retries, 0))?;
|
|
14422
|
+
|
|
14423
|
+
class.define_method("temperature", method!(LlmConfig::temperature, 0))?;
|
|
14424
|
+
|
|
14425
|
+
class.define_method("max_tokens", method!(LlmConfig::max_tokens, 0))?;
|
|
14426
|
+
|
|
14427
|
+
class.define_method("load_env", method!(LlmConfig::load_env, 0))?;
|
|
14428
|
+
|
|
14429
|
+
class.define_method("headers", method!(LlmConfig::headers, 0))?;
|
|
14430
|
+
|
|
14431
|
+
class.define_method("providers", method!(LlmConfig::providers, 0))?;
|
|
14432
|
+
|
|
14433
|
+
class.define_method("cache", method!(LlmConfig::cache, 0))?;
|
|
14434
|
+
|
|
14435
|
+
class.define_method("budget", method!(LlmConfig::budget, 0))?;
|
|
14436
|
+
|
|
14437
|
+
class.define_method("rate_limit", method!(LlmConfig::rate_limit, 0))?;
|
|
14438
|
+
|
|
14439
|
+
class.define_method("cost_tracking", method!(LlmConfig::cost_tracking, 0))?;
|
|
14440
|
+
|
|
14441
|
+
class.define_method("tracing", method!(LlmConfig::tracing, 0))?;
|
|
14442
|
+
|
|
14443
|
+
class.define_method("cooldown_secs", method!(LlmConfig::cooldown_secs, 0))?;
|
|
14444
|
+
|
|
14445
|
+
class.define_method("health_check_secs", method!(LlmConfig::health_check_secs, 0))?;
|
|
14446
|
+
|
|
14447
|
+
class.define_method("bedrock", method!(LlmConfig::bedrock, 0))?;
|
|
14448
|
+
|
|
14449
|
+
let class = module.define_class("LlmCacheConfig", ruby.class_object())?;
|
|
14450
|
+
|
|
14451
|
+
class.define_singleton_method("new", function!(LlmCacheConfig::new, -1))?;
|
|
14452
|
+
|
|
14453
|
+
class.define_method("max_entries", method!(LlmCacheConfig::max_entries, 0))?;
|
|
14454
|
+
|
|
14455
|
+
class.define_method("ttl_seconds", method!(LlmCacheConfig::ttl_seconds, 0))?;
|
|
14456
|
+
|
|
14457
|
+
class.define_method("backend", method!(LlmCacheConfig::backend, 0))?;
|
|
14458
|
+
|
|
14459
|
+
class.define_method("backend_config", method!(LlmCacheConfig::backend_config, 0))?;
|
|
14460
|
+
|
|
14461
|
+
let class = module.define_class("LlmBudgetConfig", ruby.class_object())?;
|
|
14462
|
+
|
|
14463
|
+
class.define_singleton_method("new", function!(LlmBudgetConfig::new, -1))?;
|
|
14464
|
+
|
|
14465
|
+
class.define_method("global_limit", method!(LlmBudgetConfig::global_limit, 0))?;
|
|
14466
|
+
|
|
14467
|
+
class.define_method("model_limits", method!(LlmBudgetConfig::model_limits, 0))?;
|
|
14468
|
+
|
|
14469
|
+
class.define_method("enforcement", method!(LlmBudgetConfig::enforcement, 0))?;
|
|
14470
|
+
|
|
14471
|
+
let class = module.define_class("LlmRateLimitConfig", ruby.class_object())?;
|
|
14472
|
+
|
|
14473
|
+
class.define_singleton_method("new", function!(LlmRateLimitConfig::new, -1))?;
|
|
14474
|
+
|
|
14475
|
+
class.define_method("rpm", method!(LlmRateLimitConfig::rpm, 0))?;
|
|
14476
|
+
|
|
14477
|
+
class.define_method("tpm", method!(LlmRateLimitConfig::tpm, 0))?;
|
|
14478
|
+
|
|
14479
|
+
class.define_method("window_seconds", method!(LlmRateLimitConfig::window_seconds, 0))?;
|
|
14480
|
+
|
|
14481
|
+
let class = module.define_class("LlmProviderConfig", ruby.class_object())?;
|
|
14482
|
+
|
|
14483
|
+
class.define_singleton_method("new", function!(LlmProviderConfig::new, -1))?;
|
|
14484
|
+
|
|
14485
|
+
class.define_method("name", method!(LlmProviderConfig::name, 0))?;
|
|
14486
|
+
|
|
14487
|
+
class.define_method("base_url", method!(LlmProviderConfig::base_url, 0))?;
|
|
14488
|
+
|
|
14489
|
+
class.define_method("auth_header", method!(LlmProviderConfig::auth_header, 0))?;
|
|
14490
|
+
|
|
14491
|
+
class.define_method("model_prefixes", method!(LlmProviderConfig::model_prefixes, 0))?;
|
|
14492
|
+
|
|
14493
|
+
let class = module.define_class("BedrockConfig", ruby.class_object())?;
|
|
14494
|
+
|
|
14495
|
+
class.define_singleton_method("new", function!(BedrockConfig::new, -1))?;
|
|
14496
|
+
|
|
14497
|
+
class.define_method("region", method!(BedrockConfig::region, 0))?;
|
|
14498
|
+
|
|
14499
|
+
class.define_method("cross_region_prefix", method!(BedrockConfig::cross_region_prefix, 0))?;
|
|
14500
|
+
|
|
14501
|
+
class.define_method("access_key_id", method!(BedrockConfig::access_key_id, 0))?;
|
|
14502
|
+
|
|
14503
|
+
class.define_method("secret_access_key", method!(BedrockConfig::secret_access_key, 0))?;
|
|
14504
|
+
|
|
14505
|
+
class.define_method("session_token", method!(BedrockConfig::session_token, 0))?;
|
|
14506
|
+
|
|
13654
14507
|
let class = module.define_class("WaitForBatchConfig", ruby.class_object())?;
|
|
13655
14508
|
|
|
13656
14509
|
class.define_singleton_method("new", function!(WaitForBatchConfig::new, -1))?;
|
data/lib/liter_llm/native.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# This file is auto-generated by alef — DO NOT EDIT.
|
|
2
|
-
# alef:hash:
|
|
2
|
+
# alef:hash:938b8ffd93c3e30d74875f875188c728addee9d4b80a97a7ac22716b3154c7c5
|
|
3
3
|
# To regenerate: alef generate
|
|
4
4
|
# To verify freshness: alef verify --exit-code
|
|
5
5
|
# frozen_string_literal: true
|
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:938b8ffd93c3e30d74875f875188c728addee9d4b80a97a7ac22716b3154c7c5
|
|
3
3
|
# To regenerate: alef generate
|
|
4
4
|
# To verify freshness: alef verify --exit-code
|
|
5
5
|
# frozen_string_literal: true
|
|
6
6
|
|
|
7
7
|
module LiterLlm
|
|
8
8
|
## The version string for this package.
|
|
9
|
-
VERSION = "1.
|
|
9
|
+
VERSION = "1.16.0"
|
|
10
10
|
end
|
data/lib/liter_llm.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# This file is auto-generated by alef — DO NOT EDIT.
|
|
2
|
-
# alef:hash:
|
|
2
|
+
# alef:hash:938b8ffd93c3e30d74875f875188c728addee9d4b80a97a7ac22716b3154c7c5
|
|
3
3
|
# To regenerate: alef generate
|
|
4
4
|
# To verify freshness: alef verify --exit-code
|
|
5
5
|
# frozen_string_literal: true
|
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:938b8ffd93c3e30d74875f875188c728addee9d4b80a97a7ac22716b3154c7c5
|
|
3
3
|
# To regenerate: alef generate
|
|
4
4
|
# To verify freshness: alef verify --exit-code
|
|
5
5
|
|
|
@@ -61,11 +61,11 @@ module LiterLlm
|
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
class ToolMessage
|
|
64
|
-
attr_accessor content:
|
|
64
|
+
attr_accessor content: UserContent?
|
|
65
65
|
attr_accessor tool_call_id: String?
|
|
66
66
|
attr_accessor name: String?
|
|
67
67
|
|
|
68
|
-
def initialize: (?content:
|
|
68
|
+
def initialize: (?content: UserContent, ?tool_call_id: String, ?name: String) -> void
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
class DeveloperMessage
|
|
@@ -667,6 +667,73 @@ module LiterLlm
|
|
|
667
667
|
def initialize: (?input_tokens: Integer, ?output_tokens: Integer, ?total_tokens: Integer) -> void
|
|
668
668
|
end
|
|
669
669
|
|
|
670
|
+
class LlmConfig
|
|
671
|
+
attr_accessor model: String?
|
|
672
|
+
attr_accessor api_key: String?
|
|
673
|
+
attr_accessor base_url: String?
|
|
674
|
+
attr_accessor timeout_secs: Integer?
|
|
675
|
+
attr_accessor max_retries: Integer?
|
|
676
|
+
attr_accessor temperature: Float?
|
|
677
|
+
attr_accessor max_tokens: Integer?
|
|
678
|
+
attr_accessor load_env: bool?
|
|
679
|
+
attr_accessor headers: Hash[String, String]?
|
|
680
|
+
attr_accessor providers: Array[LlmProviderConfig]?
|
|
681
|
+
attr_accessor cache: LlmCacheConfig?
|
|
682
|
+
attr_accessor budget: LlmBudgetConfig?
|
|
683
|
+
attr_accessor rate_limit: LlmRateLimitConfig?
|
|
684
|
+
attr_accessor cost_tracking: bool?
|
|
685
|
+
attr_accessor tracing: bool?
|
|
686
|
+
attr_accessor cooldown_secs: Integer?
|
|
687
|
+
attr_accessor health_check_secs: Integer?
|
|
688
|
+
attr_accessor bedrock: BedrockConfig?
|
|
689
|
+
|
|
690
|
+
def initialize: (?model: String, ?api_key: String, ?base_url: String, ?timeout_secs: Integer, ?max_retries: Integer, ?temperature: Float, ?max_tokens: Integer, ?load_env: bool, ?headers: Hash[String, String], ?providers: Array[LlmProviderConfig], ?cache: LlmCacheConfig, ?budget: LlmBudgetConfig, ?rate_limit: LlmRateLimitConfig, ?cost_tracking: bool, ?tracing: bool, ?cooldown_secs: Integer, ?health_check_secs: Integer, ?bedrock: BedrockConfig) -> void
|
|
691
|
+
end
|
|
692
|
+
|
|
693
|
+
class LlmCacheConfig
|
|
694
|
+
attr_accessor max_entries: Integer?
|
|
695
|
+
attr_accessor ttl_seconds: Integer?
|
|
696
|
+
attr_accessor backend: String?
|
|
697
|
+
attr_accessor backend_config: Hash[String, String]?
|
|
698
|
+
|
|
699
|
+
def initialize: (?max_entries: Integer, ?ttl_seconds: Integer, ?backend: String, ?backend_config: Hash[String, String]) -> void
|
|
700
|
+
end
|
|
701
|
+
|
|
702
|
+
class LlmBudgetConfig
|
|
703
|
+
attr_accessor global_limit: Float?
|
|
704
|
+
attr_accessor model_limits: Hash[String, Float]?
|
|
705
|
+
attr_accessor enforcement: String?
|
|
706
|
+
|
|
707
|
+
def initialize: (?global_limit: Float, ?model_limits: Hash[String, Float], ?enforcement: String) -> void
|
|
708
|
+
end
|
|
709
|
+
|
|
710
|
+
class LlmRateLimitConfig
|
|
711
|
+
attr_accessor rpm: Integer?
|
|
712
|
+
attr_accessor tpm: Integer?
|
|
713
|
+
attr_accessor window_seconds: Integer?
|
|
714
|
+
|
|
715
|
+
def initialize: (?rpm: Integer, ?tpm: Integer, ?window_seconds: Integer) -> void
|
|
716
|
+
end
|
|
717
|
+
|
|
718
|
+
class LlmProviderConfig
|
|
719
|
+
attr_accessor name: String?
|
|
720
|
+
attr_accessor base_url: String?
|
|
721
|
+
attr_accessor auth_header: String?
|
|
722
|
+
attr_accessor model_prefixes: Array[String]?
|
|
723
|
+
|
|
724
|
+
def initialize: (?name: String, ?base_url: String, ?auth_header: String, ?model_prefixes: Array[String]) -> void
|
|
725
|
+
end
|
|
726
|
+
|
|
727
|
+
class BedrockConfig
|
|
728
|
+
attr_accessor region: String?
|
|
729
|
+
attr_accessor cross_region_prefix: String?
|
|
730
|
+
attr_accessor access_key_id: String?
|
|
731
|
+
attr_accessor secret_access_key: String?
|
|
732
|
+
attr_accessor session_token: String?
|
|
733
|
+
|
|
734
|
+
def initialize: (?region: String, ?cross_region_prefix: String, ?access_key_id: String, ?secret_access_key: String, ?session_token: String) -> void
|
|
735
|
+
end
|
|
736
|
+
|
|
670
737
|
class WaitForBatchConfig
|
|
671
738
|
attr_accessor initial_interval_secs: Float?
|
|
672
739
|
attr_accessor max_interval_secs: Float?
|
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.
|
|
4
|
+
version: 1.16.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-08-
|
|
11
|
+
date: 2026-08-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rb_sys
|