lex-xai 0.1.3 → 0.1.4

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: 12eb444e9136e46f0734f9a6e89dd976582746194f2fb19e9d911e75e810644e
4
- data.tar.gz: 346af921176e50c420ddf9b685439453fdf3ba79a971401cbdcd03fef03ad80c
3
+ metadata.gz: f122be7885c3d5f79b22015679579e69bbf8ccbb841a4e5f903688e2ae2d1221
4
+ data.tar.gz: 7738c16fc492d2f975702b535d9b1d54ca370bbe8013a0d03946b7203070386b
5
5
  SHA512:
6
- metadata.gz: fd63e18d3f814c311020ad7137aeddf3ef51b9697a5fae70d8cb553ee2cf550ce39d611da511356c5d39fcef6d39c29ab069d6140ab6bd4301e184f034c96a72
7
- data.tar.gz: 56332345d7420caff6d052f3e7ddb1c94aa36910089350a24ef8396d8fe2b2e1769e9e6ff78df0d3e10c608808127ea588676f7179d677b117ae74bc0dc06969
6
+ metadata.gz: 6b39da9f13c8445ca28b69402162d9323fc280eb84770c96040a0979f4890eae53c7acc1017ed7f07c4db8e140a57b38c51abb065cee872b82423e5c59b77aec
7
+ data.tar.gz: 9aea0da6fc20892bad4346e9c72d27c25244987b10d650b79f273fc0db53b313f965b4f605b4e00960c11d34f893a77e0fc85b1cef28c4651c082d6c8d2b8fea
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.4] - 2026-03-31
4
+
5
+ ### Added
6
+ - Standardized `usage:` key in `Runners::Chat#create` and `Runners::Embeddings#create` return hashes with `input_tokens`, `output_tokens`, `cache_read_tokens`, and `cache_write_tokens` fields for consumption by legion-llm's CostEstimator and metering
7
+
3
8
  ## [0.1.3] - 2026-03-30
4
9
 
5
10
  ### Changed
@@ -16,7 +16,16 @@ module Legion
16
16
  body[:temperature] = temperature if temperature
17
17
 
18
18
  response = client(api_key: api_key, **).post('/v1/chat/completions', body)
19
- { result: response.body }
19
+ body = response.body
20
+ {
21
+ result: body,
22
+ usage: {
23
+ input_tokens: body.dig('usage', 'prompt_tokens') || 0,
24
+ output_tokens: body.dig('usage', 'completion_tokens') || 0,
25
+ cache_read_tokens: 0,
26
+ cache_write_tokens: 0
27
+ }
28
+ }
20
29
  end
21
30
 
22
31
  include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers, false) &&
@@ -13,7 +13,16 @@ module Legion
13
13
  body = { model: model, input: input }
14
14
 
15
15
  response = client(api_key: api_key, **).post('/v1/embeddings', body)
16
- { result: response.body }
16
+ body = response.body
17
+ {
18
+ result: body,
19
+ usage: {
20
+ input_tokens: body.dig('usage', 'prompt_tokens') || 0,
21
+ output_tokens: body.dig('usage', 'completion_tokens') || 0,
22
+ cache_read_tokens: 0,
23
+ cache_write_tokens: 0
24
+ }
25
+ }
17
26
  end
18
27
 
19
28
  include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers, false) &&
@@ -3,7 +3,7 @@
3
3
  module Legion
4
4
  module Extensions
5
5
  module Xai
6
- VERSION = '0.1.3'
6
+ VERSION = '0.1.4'
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lex-xai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity