boxcars 0.10.9 → 0.10.10
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 +6 -0
- data/Gemfile.lock +1 -1
- data/lib/boxcars/engine/anthropic.rb +38 -8
- data/lib/boxcars/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: 8d767d4ab5ffda00912f46c865922bbe971fd2c338cde5af54ccfbeffe5f1e70
|
|
4
|
+
data.tar.gz: c24a5d73b1597ee71ef5643740891e3641cd180658e2177d285fcb86d2f0deb2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 950f1737c92124bacb12ad99ab0baf29a800205c2fbd048b8629340bededc3615436cfd6b7ed93d9e379fcbfd6628428127144cd84cfae30ab75b9c18fd59e71
|
|
7
|
+
data.tar.gz: e67b18640bdb04014a173c84ff84b75f5e761c2d56d32b1fce531f94de0039eb474f23c7b01faf62f7c4b29a1904190c91abe5618f98a04fa798600c1363f8f7
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.10.10] - 2026-05-07
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- Anthropic responses now extract and join all text-bearing content blocks, including Claude responses where `thinking` blocks precede the final text block.
|
|
10
|
+
|
|
5
11
|
## [0.10.9] - 2026-04-30
|
|
6
12
|
|
|
7
13
|
### Fixed
|
data/Gemfile.lock
CHANGED
|
@@ -118,18 +118,21 @@ module Boxcars
|
|
|
118
118
|
response_data[:parsed_json] = normalized_response
|
|
119
119
|
|
|
120
120
|
if normalized_response && !normalized_response["error"]
|
|
121
|
-
response_data[:success] = true
|
|
122
121
|
response_data[:status_code] = 200 # Inferred
|
|
122
|
+
normalize_anthropic_usage!(normalized_response)
|
|
123
|
+
|
|
123
124
|
# Transform response to match expected format
|
|
124
|
-
normalized_response["completion"] = normalized_response
|
|
125
|
+
normalized_response["completion"] = extract_anthropic_completion(normalized_response)
|
|
126
|
+
|
|
127
|
+
if normalized_response["completion"].empty?
|
|
128
|
+
response_data[:success] = false
|
|
129
|
+
response_data[:error] ||= Error.new("Anthropic response contained no text content")
|
|
130
|
+
return
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
response_data[:success] = true
|
|
125
134
|
normalized_response["choices"] ||= [{ "text" => normalized_response["completion"],
|
|
126
135
|
"finish_reason" => normalized_response["stop_reason"] }]
|
|
127
|
-
if normalized_response["usage"].is_a?(Hash)
|
|
128
|
-
normalized_response["usage"]["prompt_tokens"] ||= normalized_response["usage"]["input_tokens"]
|
|
129
|
-
normalized_response["usage"]["completion_tokens"] ||= normalized_response["usage"]["output_tokens"]
|
|
130
|
-
normalized_response["usage"]["total_tokens"] ||= normalized_response["usage"]["prompt_tokens"].to_i +
|
|
131
|
-
normalized_response["usage"]["completion_tokens"].to_i
|
|
132
|
-
end
|
|
133
136
|
normalized_response.delete("content")
|
|
134
137
|
else
|
|
135
138
|
response_data[:success] = false
|
|
@@ -139,6 +142,33 @@ module Boxcars
|
|
|
139
142
|
end
|
|
140
143
|
end
|
|
141
144
|
|
|
145
|
+
def extract_anthropic_completion(normalized_response)
|
|
146
|
+
content = normalized_response["content"]
|
|
147
|
+
blocks = content.is_a?(Array) ? content : [content]
|
|
148
|
+
|
|
149
|
+
blocks.filter_map { |block| extract_anthropic_text_block(block) }.join("\n").strip
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def extract_anthropic_text_block(block)
|
|
153
|
+
case block
|
|
154
|
+
when String
|
|
155
|
+
block
|
|
156
|
+
when Hash
|
|
157
|
+
block["text"] || block[:text]
|
|
158
|
+
else
|
|
159
|
+
block.text if block.respond_to?(:text)
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
def normalize_anthropic_usage!(normalized_response)
|
|
164
|
+
return unless normalized_response["usage"].is_a?(Hash)
|
|
165
|
+
|
|
166
|
+
normalized_response["usage"]["prompt_tokens"] ||= normalized_response["usage"]["input_tokens"]
|
|
167
|
+
normalized_response["usage"]["completion_tokens"] ||= normalized_response["usage"]["output_tokens"]
|
|
168
|
+
normalized_response["usage"]["total_tokens"] ||= normalized_response["usage"]["prompt_tokens"].to_i +
|
|
169
|
+
normalized_response["usage"]["completion_tokens"].to_i
|
|
170
|
+
end
|
|
171
|
+
|
|
142
172
|
# Handle errors from Anthropic API calls
|
|
143
173
|
def handle_anthropic_error(error, response_data)
|
|
144
174
|
response_data[:error] = error
|
data/lib/boxcars/version.rb
CHANGED