bitfab 0.71.0 → 0.71.1

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: a84477fef0e70e513ab93e7ef81a0ef9021d5f09adefe8021075d89fbb26a64d
4
- data.tar.gz: 39795db6575ecc859004b3db5af4d35b13747234d8fafd43f444819c4e2425dc
3
+ metadata.gz: 6a9158d8ba5528a0445a8a84471b6556f1c068b9e34d1b11d9a7759e2a339dae
4
+ data.tar.gz: 1c00b3b0e7de1d47c34598752047772fc604f045715dd14b28a3d9c191986e21
5
5
  SHA512:
6
- metadata.gz: 0327c9092bb7b6d9071546c6a54ae5f64e49083518c6e35c3049eb04455b32eed4fa976df0c35a7d59d9231d0107cff212eca5a8287f5d4d043d1e566b5e1a58
7
- data.tar.gz: bab39d209b61f795eb681bafdf7e5e19b6707977864e6c7a5b72d5ee02af449a8c1f0a3b8c29a06229ef32f099326dfe3c6ba1890156cdf9a37308daab137bf9
6
+ metadata.gz: ef4585c3380e0ae2370fbb9f9e7a736bad89e7c04c7d2526e1f758a6583fcf82ae6ba84dd0720e99b7525dac11fa0331aa58e13606648f9ef288b1fae2b129de
7
+ data.tar.gz: ab972e7e48cb60881d62fe597513ae46f6e1649d7ee950d81fe79b7d0d5f523e43761f5381eca2222ec54fc75f940961d0e6d2b9e451fd39a293c9791c9e749a
data/lib/bitfab/baml.rb CHANGED
@@ -111,6 +111,15 @@ module Bitfab
111
111
  nil
112
112
  end
113
113
 
114
+ def reported_cost(call)
115
+ body = call&.http_response&.body&.json
116
+ usage = body["usage"] if body.is_a?(Hash)
117
+ cost = usage["cost"] if usage.is_a?(Hash)
118
+ (cost.is_a?(Numeric) && cost.finite?) ? cost : nil
119
+ rescue
120
+ nil
121
+ end
122
+
114
123
  def enrich_span(collector)
115
124
  log = collector.last
116
125
  calls = log&.calls || []
@@ -131,6 +140,8 @@ module Bitfab
131
140
  model: body["model"] || call&.http_request&.url&.match(%r{/models/([^/:]+)})&.[](1),
132
141
  inputTokens: usage&.input_tokens || call&.usage&.input_tokens,
133
142
  outputTokens: usage&.output_tokens || call&.usage&.output_tokens,
143
+ cachedInputTokens: usage&.cached_input_tokens || call&.usage&.cached_input_tokens,
144
+ costUsd: reported_cost(call),
134
145
  durationMs: log&.timing&.duration_ms
135
146
  }.compact
136
147
  Bitfab.current_span.add_context(metadata) unless metadata.empty?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bitfab
4
- VERSION = "0.71.0"
4
+ VERSION = "0.71.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bitfab
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.71.0
4
+ version: 0.71.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harvest Team