bynn-decisionnode 0.4.1 → 0.5.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 +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +5 -3
- data/lib/decisionnode/results.rb +29 -2
- data/lib/decisionnode/version.rb +2 -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: 24de1dc3913b47a0710454ad0e4af3f9cf3b4d7b03049b6dd0bb98e3040ea968
|
|
4
|
+
data.tar.gz: 52f88fa99e13dcf1312a4f4f0a971ebb728adf3222e26e50f1c7925b300edb50
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7c1f27797c6d56fe7759d1b40e900e855184fdced5a4da809e43ceaab5c657dd1c8fbabd1cb12f7104cc69c072ab03664e5eeff67ed94597b363b363dd7178ea
|
|
7
|
+
data.tar.gz: 7278b88e634c83e09196c60c73daf6d4815a9efebe502a52f689d63ef412d14665d322b4cd6695aa0cf0b5e2efc0c8045c110944ad746af2ace1a770b6d1ff46
|
data/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,18 @@ All notable changes to this gem are listed here. The format follows
|
|
|
4
4
|
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the gem uses
|
|
5
5
|
[Semantic Versioning](https://semver.org/).
|
|
6
6
|
|
|
7
|
+
## [0.5.0] - Unreleased
|
|
8
|
+
|
|
9
|
+
Implements version 1.5 of the DecisionNode SDK surface (`DecisionNode::SPEC_VERSION` is `"1.5"`): the image and video shares of the input tokens, so callers can bill or budget vision tokens at their own price. Passes conformance suite 1.28.
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- `Usage#image_tokens` and `Usage#video_tokens` (an Integer or `nil`): the share of `usage.input_tokens` that came from images and from videos, read from the `x-decisionnode-image-tokens` and `x-decisionnode-video-tokens` response headers on every call that returns a `Decision`. Each is `nil` when its header is absent (the server sends it only for a request with images or videos), empty, or not a whole number from 0 to 2^31 - 1 after trimming spaces; such a header never fails the decision. Both are read as sent, never added to or taken from another count and never priced. A batch result's decision reads `nil`, since its line carries no such headers. `raw` is unchanged. Both are new members at the end of the `Usage` struct, so existing positional use is unchanged.
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
- `SPEC_VERSION` is `"1.5"`.
|
|
18
|
+
|
|
7
19
|
## [0.4.1] - Unreleased
|
|
8
20
|
|
|
9
21
|
Implements version 1.4 of the DecisionNode SDK surface (`DecisionNode::SPEC_VERSION` is `"1.4"`): knowledge.
|
data/README.md
CHANGED
|
@@ -165,7 +165,7 @@ end
|
|
|
165
165
|
|
|
166
166
|
| Class | Fields |
|
|
167
167
|
|---|---|
|
|
168
|
-
| `Decision` | `answers` (by question id, also `decision["id"]`), `model` (the resolved version), `usage.input_tokens`, `usage.output_tokens`, `usage.video_frames`, `usage.video_seconds`, `usage.booster_tokens`, `usage.boosters`, `usage.cost`, `evidence` (see "Boosters"), `fallback` (see "Fallback"), `warnings`, `request_id`, `latency_ms`, `safety`, `raw` |
|
|
168
|
+
| `Decision` | `answers` (by question id, also `decision["id"]`), `model` (the resolved version), `usage.input_tokens`, `usage.image_tokens`, `usage.video_tokens`, `usage.output_tokens`, `usage.video_frames`, `usage.video_seconds`, `usage.booster_tokens`, `usage.boosters`, `usage.cost`, `evidence` (see "Boosters"), `fallback` (see "Fallback"), `warnings`, `request_id`, `latency_ms`, `safety`, `raw` |
|
|
169
169
|
| `TruthAnswer` | `truth` |
|
|
170
170
|
| `ChoiceAnswer` | `choice`, `confidence`, `probabilities` (by option name, exactly as sent) |
|
|
171
171
|
| `ScoreAnswer` | `score`, `confidence`, `probabilities` (by level index, an Integer), `legend` (level index to the level as sent) |
|
|
@@ -178,6 +178,8 @@ Answers are read by question id. An answer of a type this version does not know
|
|
|
178
178
|
|
|
179
179
|
A token count or `latency_ms` the server did not send is `nil`, never 0. So are `usage.video_frames` and `usage.video_seconds` for a request without videos (`warnings` is then an empty Array), and `evidence`, `usage.booster_tokens` and `usage.boosters` for a request without boosters. `fallback` is `nil` on an ordinary answer.
|
|
180
180
|
|
|
181
|
+
`usage.image_tokens` and `usage.video_tokens` are the shares of `usage.input_tokens` that came from images and from videos (Integers), read from the `x-decisionnode-image-tokens` and `x-decisionnode-video-tokens` headers, so you can bill or budget vision tokens at your own price. `image_tokens` is `nil` for a request without images and `video_tokens` is `nil` for a request without videos (the server sends each header only when its share is above 0), and either is `nil` when its header is not a whole number from 0 to 2^31 - 1. They are read as sent: the gem never adds them to, or takes them from, another count, and never prices them. A batch result's decision reads `nil` for both.
|
|
182
|
+
|
|
181
183
|
`usage.cost` is what the answer cost, a `DecisionNode::Cost` with `usd`, `model_usd` and `boosters_usd` in USD and `free_tier` (true when the free tier paid for it). It is read as sent, never summed by the SDK, and `nil` when the response has none. A batch result's decision and a session frame's reply carry it too.
|
|
182
184
|
|
|
183
185
|
## Images
|
|
@@ -899,9 +901,9 @@ bundle exec rake test
|
|
|
899
901
|
DECISIONNODE_CONFORMANCE_DIR=/path/to/decision-node-conformance bundle exec rake conformance
|
|
900
902
|
```
|
|
901
903
|
|
|
902
|
-
The conformance tests run the language-neutral DecisionNode conformance suite (version 1.
|
|
904
|
+
The conformance tests run the language-neutral DecisionNode conformance suite (version 1.28) against its mock server. They need `DECISIONNODE_CONFORMANCE_DIR`: without it, they fail rather than skip.
|
|
903
905
|
|
|
904
|
-
This gem implements version 1.
|
|
906
|
+
This gem implements version 1.5 of the DecisionNode SDK surface (`DecisionNode::SPEC_VERSION`).
|
|
905
907
|
|
|
906
908
|
## License
|
|
907
909
|
|
data/lib/decisionnode/results.rb
CHANGED
|
@@ -295,8 +295,16 @@ class DecisionNode
|
|
|
295
295
|
# of `input_tokens` the boosters' readings take) and `boosters` (the booster
|
|
296
296
|
# calls billed); `cost`, what the answer cost (a Cost). Each is nil when the
|
|
297
297
|
# response has none.
|
|
298
|
+
#
|
|
299
|
+
# `image_tokens` and `video_tokens` are the shares of `input_tokens` that
|
|
300
|
+
# came from images and from videos (Integers), read from the
|
|
301
|
+
# `x-decisionnode-image-tokens` and `x-decisionnode-video-tokens` headers as
|
|
302
|
+
# sent: never added to or taken from another count. Each is nil for a
|
|
303
|
+
# request without images (or videos), since the server sends the header only
|
|
304
|
+
# when the share is above 0, and when the header is not a whole number from 0
|
|
305
|
+
# to 2^31 - 1.
|
|
298
306
|
Usage = Struct.new(:input_tokens, :output_tokens, :video_frames, :video_seconds, :booster_tokens, :boosters,
|
|
299
|
-
:cost)
|
|
307
|
+
:cost, :image_tokens, :video_tokens)
|
|
300
308
|
|
|
301
309
|
# What an answer cost, Usage#cost: `usd` in all, `model_usd` for the model,
|
|
302
310
|
# `boosters_usd` for the boosters (each the JSON number as received, in USD)
|
|
@@ -442,7 +450,9 @@ class DecisionNode
|
|
|
442
450
|
usage["video_seconds"].is_a?(Numeric) ? usage["video_seconds"] : nil,
|
|
443
451
|
usage["booster_tokens"].is_a?(Integer) ? usage["booster_tokens"] : nil,
|
|
444
452
|
usage["boosters"].is_a?(Integer) ? usage["boosters"] : nil,
|
|
445
|
-
Cost.parse(usage["cost"])
|
|
453
|
+
Cost.parse(usage["cost"]),
|
|
454
|
+
parse_token_header(headers["x-decisionnode-image-tokens"]),
|
|
455
|
+
parse_token_header(headers["x-decisionnode-video-tokens"]))
|
|
446
456
|
@evidence = Evidence.map(body["evidence"])
|
|
447
457
|
@warnings = body["warnings"].is_a?(Array) ? body["warnings"].grep(String).freeze : [].freeze
|
|
448
458
|
@request_id = headers["x-request-id"]
|
|
@@ -463,6 +473,23 @@ class DecisionNode
|
|
|
463
473
|
|
|
464
474
|
private
|
|
465
475
|
|
|
476
|
+
# The largest token count a header may carry, 2^31 - 1.
|
|
477
|
+
MAX_HEADER_TOKENS = (2**31) - 1
|
|
478
|
+
private_constant :MAX_HEADER_TOKENS
|
|
479
|
+
|
|
480
|
+
# A token count from a header: ASCII digits only after trimming spaces,
|
|
481
|
+
# from 0 to 2^31 - 1. Anything else (absent, empty, a sign, a fraction,
|
|
482
|
+
# too large) is nil, never an error and never 0.
|
|
483
|
+
def parse_token_header(value)
|
|
484
|
+
return nil unless value.is_a?(String)
|
|
485
|
+
|
|
486
|
+
digits = value.gsub(/\A[ \t]+|[ \t]+\z/, "")
|
|
487
|
+
return nil unless digits.match?(/\A[0-9]+\z/)
|
|
488
|
+
|
|
489
|
+
n = Integer(digits, 10)
|
|
490
|
+
n <= MAX_HEADER_TOKENS ? n : nil
|
|
491
|
+
end
|
|
492
|
+
|
|
466
493
|
def parse_latency(value)
|
|
467
494
|
return nil if value.nil?
|
|
468
495
|
|
data/lib/decisionnode/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bynn-decisionnode
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.5.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Bynn Intelligence, Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-11-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: websocket-driver
|