nitro_intelligence 4.3.1 → 4.3.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: 7257a5598a1874c82985d7ad53c510630324d188fb0b8357b9cbd0f2bd2a2a01
4
- data.tar.gz: 257cf46ad150fdf356ffb18163d632f78e4c1cf83ada368fb821bac28af12e7a
3
+ metadata.gz: 7cbb853c952d95a2f7daf43fe1b24e6fdc22a86037a521c90c35d6d15a3101a2
4
+ data.tar.gz: a7f86718cdc8408cf2a87011214ce9e4cf4cce904eaac9560f24decec840f89c
5
5
  SHA512:
6
- metadata.gz: 57af436d4123e3f5ebe01c00e035d41bcc7a6de019c0318d8621b07db6dc25e780548414aaa3ce0975938ac686503db9b2ed942e9ebc2d0c3ef6fb3c41ad49a3
7
- data.tar.gz: fbe0b679170af183511c157dd59fad3ed5e9fd13cc38bb9dfac19fa6a3fe17b7868a71181ed7dcf8cfe2ad82f38d71e8daecf48f113e96e0971741f32fd0171b
6
+ metadata.gz: 239ee2221ce1120a1ff04b0a68316a8fb762086aebcf57ec2e7fc72302de51ae2b1cf30ea8cca40ab79c2cceb3af8e649cd23584192bc4547eec63b6730d13cb
7
+ data.tar.gz: 38b82841af416d45a904e3e8fbd63b50056dcbbb20e3d33fadb0b02fef7618b201c9c3e302dc217f06eeb8944c2c5a0a1a56fcf4ee9c7aa8023dae887a1e7dbd
data/docs/CHANGELOG.md CHANGED
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [4.3.2](https://github.com/powerhome/nitro-intelligence.rb/compare/v4.3.1...v4.3.2) (2026-11-23)
9
+
10
+
11
+ ### Fixed
12
+
13
+ * **embeddings:** stop Cerebro double-counting embedding usage ([#222](https://github.com/powerhome/nitro-intelligence.rb/issues/222)) ([93e076c](https://github.com/powerhome/nitro-intelligence.rb/commit/93e076c681d54e3d1baa789f4d74ada24637a3d1))
14
+
8
15
  ## [4.3.1](https://github.com/powerhome/nitro-intelligence.rb/compare/v4.3.0...v4.3.1) (2026-11-11)
9
16
 
10
17
 
data/docs/README.md CHANGED
@@ -297,7 +297,7 @@ client.embed_query(query: "How do I request time off?", parameters: { dimensions
297
297
 
298
298
  A model's `query_prefix` and `document_prefix` in `config.model_config` are what it expects before a query's text and before a document's, in the form it was trained on. Qwen3-Embedding takes an instruction before each query and nothing before a document, as in the configuration above; E5 takes `"query: "` and `"passage: "`. Leave both out for a model that embeds queries and documents the same way, such as OpenAI's. Switching to another embeddings model only means changing its `model_config` entry, but vectors from different models cannot be compared, so it also means embedding your stored documents again.
299
299
 
300
- `embeddings.usage` holds `prompt_tokens` and `total_tokens` summed over every request, and `embeddings.responses` the gateway's responses, one per batch, each with its `last_response`. With observability enabled, each call is recorded in Cerebro as an embedding observation named `embed-query` or `embed-documents`, with the input as the model received it, prefix included, the gateway's cost added up over every batch, and the number and size of the vectors as output. The vectors themselves are never recorded. If the gateway did not price every batch, the cost is left unset rather than undercounted. If a batch fails after others succeeded, the failed call still records what those cost before the error is raised.
300
+ `embeddings.usage` holds `prompt_tokens` and `total_tokens` summed over every request, and `embeddings.responses` the gateway's responses, one per batch, each with its `last_response`. With observability enabled, each call is recorded in Cerebro as an embedding observation named `embed-query` or `embed-documents`, with the input as the model received it, prefix included, the input tokens as usage, the gateway's cost added up over every batch, and the number and size of the vectors as output. The vectors themselves are never recorded. If the gateway did not price every batch, the cost is left unset rather than undercounted. If a batch fails after others succeeded, the failed call still records what those cost before the error is raised.
301
301
 
302
302
  Embeddings take no managed prompt: `prompt_name` and `prompt_variables` are ignored.
303
303
 
@@ -44,7 +44,7 @@ module NitroIntelligence
44
44
  trace_attributes = {
45
45
  model: embeddings.model,
46
46
  output: { count: embeddings.vectors.size, dimensions: embeddings.vector&.size },
47
- usage_details: embeddings.usage.to_h.symbolize_keys.presence,
47
+ usage_details: usage_details(embeddings.usage),
48
48
  cost_details: @base_handler.cost_details(embeddings),
49
49
  }
50
50
 
@@ -61,11 +61,18 @@ module NitroIntelligence
61
61
 
62
62
  billed = Embeddings.new(responses)
63
63
  attributes = {
64
- usage_details: billed.usage.to_h.symbolize_keys.presence,
64
+ usage_details: usage_details(billed.usage),
65
65
  cost_details: @base_handler.cost_details(billed),
66
66
  }.compact
67
67
  embedding.update(attributes) if attributes.any?
68
68
  end
69
+
70
+ # Recorded under Langfuse's own `input` and `total` keys. OpenAI's names are only recognised
71
+ # alongside `completion_tokens`, which an embedding has none of, so Langfuse would otherwise
72
+ # keep `prompt_tokens` and `total_tokens` as two counters and total them, doubling the count.
73
+ def usage_details(usage)
74
+ { input: usage[:prompt_tokens], total: usage[:total_tokens] }.compact.presence
75
+ end
69
76
  end
70
77
  end
71
78
  end
@@ -1,4 +1,4 @@
1
1
  module NitroIntelligence
2
2
  # The gem's version.
3
- VERSION = "4.3.1".freeze
3
+ VERSION = "4.3.2".freeze
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nitro_intelligence
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.1
4
+ version: 4.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Artemenko