bitfab 0.76.2 → 0.76.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 +4 -4
- data/lib/bitfab/assertions.rb +3 -3
- data/lib/bitfab/baml.rb +30 -1
- 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: 99143cec76387e336a55ce05cf5d971026a2861c3f7ff0d4d8b960de2f06b5eb
|
|
4
|
+
data.tar.gz: '080f2fee8ac925c38c1a05b417718b61ac99aa4e285791efeeac897ea7981c24'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: be0a213a0a8600e3ed1eb8aa3f0e3a8d5d8d60b85439b51ceecb2ef84185c9a469a0e8b2e2ff606e2c8baa9a44166de69110d34173514ea0d959601dcaaabf0b
|
|
7
|
+
data.tar.gz: 198b044448bafe78bcde28186539fca6bb2d648d18467dd14782b754e5cc391a0d8b4c9141c501f305658e206848ad0a65e37d1249d74835f600191a578572ed
|
data/lib/bitfab/assertions.rb
CHANGED
|
@@ -32,9 +32,9 @@ module Bitfab
|
|
|
32
32
|
# "code" is optional code that decides the assertion on a replay without
|
|
33
33
|
# the LLM judge: {"source" => ..., "spanNames" => [...]}. Send a "code"
|
|
34
34
|
# hash to set it, "code" => nil to remove it, or omit "code" to keep the
|
|
35
|
-
# current code. "source" is the body of an async
|
|
36
|
-
#
|
|
37
|
-
#
|
|
35
|
+
# current code. "source" is the body of an async JavaScript function called
|
|
36
|
+
# with spans (each {name, index, hasData}, in start order, without its
|
|
37
|
+
# data), input, and output. It reads span data
|
|
38
38
|
# with await named("span name") or await span.data(), with one second of
|
|
39
39
|
# compute and the data of at most 50 spans loaded within ten seconds. It
|
|
40
40
|
# returns "pass" or "fail", which decides the verdict with no judge call,
|
data/lib/bitfab/baml.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "json"
|
|
4
|
+
require "uri"
|
|
4
5
|
|
|
5
6
|
module Bitfab
|
|
6
7
|
module BAML
|
|
@@ -120,6 +121,34 @@ module Bitfab
|
|
|
120
121
|
nil
|
|
121
122
|
end
|
|
122
123
|
|
|
124
|
+
MODEL_IN_URL = %r{/models?/([^/:?]+)}
|
|
125
|
+
|
|
126
|
+
def response_body(call)
|
|
127
|
+
body = call&.http_response&.body&.json
|
|
128
|
+
body.is_a?(Hash) ? body : {}
|
|
129
|
+
rescue
|
|
130
|
+
{}
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def model_from_url(url)
|
|
134
|
+
match = url.is_a?(String) ? url.match(MODEL_IN_URL) : nil
|
|
135
|
+
match && URI.decode_www_form_component(match[1])
|
|
136
|
+
rescue
|
|
137
|
+
match&.[](1)
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def present_string(value)
|
|
141
|
+
(value.is_a?(String) && !value.empty?) ? value : nil
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
def model_of(call, body)
|
|
145
|
+
response = response_body(call)
|
|
146
|
+
present_string(body["model"]) ||
|
|
147
|
+
present_string(response["model"]) ||
|
|
148
|
+
present_string(response["modelVersion"]) ||
|
|
149
|
+
model_from_url(call&.http_request&.url)
|
|
150
|
+
end
|
|
151
|
+
|
|
123
152
|
def enrich_span(collector)
|
|
124
153
|
log = collector.last
|
|
125
154
|
calls = log&.calls || []
|
|
@@ -137,7 +166,7 @@ module Bitfab
|
|
|
137
166
|
usage = collector.usage
|
|
138
167
|
metadata = {
|
|
139
168
|
provider: call&.provider,
|
|
140
|
-
model: body
|
|
169
|
+
model: model_of(call, body),
|
|
141
170
|
inputTokens: usage&.input_tokens || call&.usage&.input_tokens,
|
|
142
171
|
outputTokens: usage&.output_tokens || call&.usage&.output_tokens,
|
|
143
172
|
cachedInputTokens: usage&.cached_input_tokens || call&.usage&.cached_input_tokens,
|
data/lib/bitfab/version.rb
CHANGED