bitfab 0.71.0 → 0.72.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/lib/bitfab/assertions.rb +13 -0
- data/lib/bitfab/baml.rb +11 -0
- data/lib/bitfab/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7e1f7e41d0dcac668a09e2c2bf57e1d1c928ba5943e51d526e83a43009987369
|
|
4
|
+
data.tar.gz: 80600ab8d5c6a7230799d08b70346de0a68e79beded3858f4321c66f061456c0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3d062220939f258721a0359f5cef0fecac374810b2203c8a74efafbe4f626b7e220249dd34beb5d91896154d6f560dc3a98347693e161f4615c51afb4464627c
|
|
7
|
+
data.tar.gz: b7d66ca98007fbdc7d6f0d334e909711be612ae9892316da02ad25e08dcc43cbb48853e110af5ec979edab56836ca5f4c67c72ec8d0c7121bbd27404dba43fac
|
data/lib/bitfab/assertions.rb
CHANGED
|
@@ -29,6 +29,19 @@ module Bitfab
|
|
|
29
29
|
# pass nil to clear it. The deprecated "category_assertion_id" is still
|
|
30
30
|
# accepted and sent as "category_id"; "category_id" wins when both are set.
|
|
31
31
|
#
|
|
32
|
+
# "kind" says who decides the assertion: "judge" (the LLM judge), "code"
|
|
33
|
+
# ("code" decides every replay), or "hybrid" ("code" decides what it can
|
|
34
|
+
# and returns "defer" for the rest). Send "code" or "hybrid" together with
|
|
35
|
+
# "code", {"source" => ..., "spanNames" => [...]}. "source" is the body of a
|
|
36
|
+
# TypeScript (or plain JavaScript) function called with spans (each
|
|
37
|
+
# {name, input, output, metadata}, in start order), input, and output,
|
|
38
|
+
# returning "pass", "fail", or "defer" (hybrid only), or {result, reason},
|
|
39
|
+
# within one second. "spanNames" lists every span a correct run is
|
|
40
|
+
# expected to produce. Code that cannot run on the trace, or that returns
|
|
41
|
+
# "defer" for a "code" assertion, is refused. Omit both to keep them, or
|
|
42
|
+
# pass "kind" => "judge" to remove the code. Returned assertions carry
|
|
43
|
+
# "kind", "code", and "codeBrokenReason".
|
|
44
|
+
#
|
|
32
45
|
# By default, after the save, Bitfab checks each assertion's text against its
|
|
33
46
|
# trace. When the text bundles two claims, adds a condition, points at a
|
|
34
47
|
# value instead of stating it, names an id from the recorded run, or cannot
|
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?
|
data/lib/bitfab/version.rb
CHANGED