boxcars 0.8.8 → 0.8.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/Gemfile.lock +43 -43
- data/lib/boxcars/boxcar/engine_boxcar.rb +7 -3
- data/lib/boxcars/engine/openai.rb +2 -1
- data/lib/boxcars/engine.rb +1 -1
- data/lib/boxcars/prompt.rb +6 -3
- data/lib/boxcars/result.rb +2 -1
- 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: bdc68194311ad4474d79a19542422630819c12e9e31e53492f124a2f68e4e289
|
|
4
|
+
data.tar.gz: 4af69cd36ea2cc96cbd08e6312620ae838382a9c1aca12ff0d11d3fdaa470987
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ba7608a0c52359113c7c52a516690b13fe0a0e6b91b93a306a71e193285ba785d384b82f1f62bf24ffccd1ac6f559c13ec8af60816fd0923c2aea91461f843b5
|
|
7
|
+
data.tar.gz: 6a593dc290f477f945622b52c621d301b27c2f42058ef9df682aeb5152886a1307dd31630ff07d9545f85fd6d49ce9340582b8e89513cd93c262d26796268211
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
boxcars (0.8.
|
|
4
|
+
boxcars (0.8.10)
|
|
5
5
|
faraday-retry (~> 2.0)
|
|
6
6
|
google_search_results (~> 2.2)
|
|
7
7
|
gpt4all (~> 0.0.5)
|
|
@@ -56,10 +56,10 @@ GEM
|
|
|
56
56
|
async (>= 1.25)
|
|
57
57
|
base64 (0.3.0)
|
|
58
58
|
benchmark (0.4.1)
|
|
59
|
-
bigdecimal (3.2.
|
|
59
|
+
bigdecimal (3.2.3)
|
|
60
60
|
concurrent-ruby (1.3.5)
|
|
61
|
-
connection_pool (2.5.
|
|
62
|
-
console (1.
|
|
61
|
+
connection_pool (2.5.4)
|
|
62
|
+
console (1.34.0)
|
|
63
63
|
fiber-annotation
|
|
64
64
|
fiber-local (~> 1.1)
|
|
65
65
|
json
|
|
@@ -77,7 +77,7 @@ GEM
|
|
|
77
77
|
dynamicschema (1.0.1)
|
|
78
78
|
erb (5.0.2)
|
|
79
79
|
event_stream_parser (1.0.0)
|
|
80
|
-
faraday (2.
|
|
80
|
+
faraday (2.14.0)
|
|
81
81
|
faraday-net_http (>= 2.0, < 3.5)
|
|
82
82
|
json
|
|
83
83
|
logger
|
|
@@ -107,10 +107,10 @@ GEM
|
|
|
107
107
|
faraday (~> 2.7)
|
|
108
108
|
os (~> 1.1)
|
|
109
109
|
tty-progressbar (~> 0.18.2)
|
|
110
|
-
hashdiff (1.2.
|
|
110
|
+
hashdiff (1.2.1)
|
|
111
111
|
hnswlib (0.9.0)
|
|
112
112
|
http-accept (1.7.0)
|
|
113
|
-
http-cookie (1.0
|
|
113
|
+
http-cookie (1.1.0)
|
|
114
114
|
domain_name (~> 0.5)
|
|
115
115
|
i18n (1.14.7)
|
|
116
116
|
concurrent-ruby (~> 1.0)
|
|
@@ -124,7 +124,7 @@ GEM
|
|
|
124
124
|
pp (>= 0.6.0)
|
|
125
125
|
rdoc (>= 4.0.0)
|
|
126
126
|
reline (>= 0.4.2)
|
|
127
|
-
json (2.
|
|
127
|
+
json (2.15.0)
|
|
128
128
|
json-repair (0.2.0)
|
|
129
129
|
language_server-protocol (3.17.0.5)
|
|
130
130
|
lint_roller (1.1.0)
|
|
@@ -132,7 +132,7 @@ GEM
|
|
|
132
132
|
mime-types (3.7.0)
|
|
133
133
|
logger
|
|
134
134
|
mime-types-data (~> 3.2025, >= 3.2025.0507)
|
|
135
|
-
mime-types-data (3.2025.
|
|
135
|
+
mime-types-data (3.2025.0924)
|
|
136
136
|
minitest (5.25.5)
|
|
137
137
|
multi_json (1.17.0)
|
|
138
138
|
multipart-post (2.4.1)
|
|
@@ -140,21 +140,21 @@ GEM
|
|
|
140
140
|
uri
|
|
141
141
|
netrc (0.11.0)
|
|
142
142
|
nio4r (2.7.4)
|
|
143
|
-
nokogiri (1.18.
|
|
143
|
+
nokogiri (1.18.10-aarch64-linux-gnu)
|
|
144
144
|
racc (~> 1.4)
|
|
145
|
-
nokogiri (1.18.
|
|
145
|
+
nokogiri (1.18.10-aarch64-linux-musl)
|
|
146
146
|
racc (~> 1.4)
|
|
147
|
-
nokogiri (1.18.
|
|
147
|
+
nokogiri (1.18.10-arm-linux-gnu)
|
|
148
148
|
racc (~> 1.4)
|
|
149
|
-
nokogiri (1.18.
|
|
149
|
+
nokogiri (1.18.10-arm-linux-musl)
|
|
150
150
|
racc (~> 1.4)
|
|
151
|
-
nokogiri (1.18.
|
|
151
|
+
nokogiri (1.18.10-arm64-darwin)
|
|
152
152
|
racc (~> 1.4)
|
|
153
|
-
nokogiri (1.18.
|
|
153
|
+
nokogiri (1.18.10-x86_64-darwin)
|
|
154
154
|
racc (~> 1.4)
|
|
155
|
-
nokogiri (1.18.
|
|
155
|
+
nokogiri (1.18.10-x86_64-linux-gnu)
|
|
156
156
|
racc (~> 1.4)
|
|
157
|
-
nokogiri (1.18.
|
|
157
|
+
nokogiri (1.18.10-x86_64-linux-musl)
|
|
158
158
|
racc (~> 1.4)
|
|
159
159
|
octokit (4.25.1)
|
|
160
160
|
faraday (>= 1, < 3)
|
|
@@ -164,20 +164,20 @@ GEM
|
|
|
164
164
|
parser (3.3.9.0)
|
|
165
165
|
ast (~> 2.4.1)
|
|
166
166
|
racc
|
|
167
|
-
pg (1.6.
|
|
168
|
-
pg (1.6.
|
|
169
|
-
pg (1.6.
|
|
170
|
-
pg (1.6.
|
|
171
|
-
pg (1.6.
|
|
172
|
-
pg (1.6.
|
|
173
|
-
pg (1.6.
|
|
167
|
+
pg (1.6.2)
|
|
168
|
+
pg (1.6.2-aarch64-linux)
|
|
169
|
+
pg (1.6.2-aarch64-linux-musl)
|
|
170
|
+
pg (1.6.2-arm64-darwin)
|
|
171
|
+
pg (1.6.2-x86_64-darwin)
|
|
172
|
+
pg (1.6.2-x86_64-linux)
|
|
173
|
+
pg (1.6.2-x86_64-linux-musl)
|
|
174
174
|
pgvector (0.2.2)
|
|
175
|
-
posthog-ruby (3.
|
|
175
|
+
posthog-ruby (3.3.2)
|
|
176
176
|
concurrent-ruby (~> 1)
|
|
177
177
|
pp (0.6.2)
|
|
178
178
|
prettyprint
|
|
179
179
|
prettyprint (0.2.0)
|
|
180
|
-
prism (1.
|
|
180
|
+
prism (1.5.1)
|
|
181
181
|
protocol-hpack (1.5.1)
|
|
182
182
|
protocol-http (0.26.8)
|
|
183
183
|
protocol-http1 (0.19.1)
|
|
@@ -195,7 +195,7 @@ GEM
|
|
|
195
195
|
rdoc (6.14.2)
|
|
196
196
|
erb
|
|
197
197
|
psych (>= 4.0.0)
|
|
198
|
-
regexp_parser (2.11.
|
|
198
|
+
regexp_parser (2.11.3)
|
|
199
199
|
reline (0.6.2)
|
|
200
200
|
io-console (~> 0.5)
|
|
201
201
|
rest-client (2.1.0)
|
|
@@ -203,7 +203,7 @@ GEM
|
|
|
203
203
|
http-cookie (>= 1.0.2, < 2.0)
|
|
204
204
|
mime-types (>= 1.16, < 4.0)
|
|
205
205
|
netrc (~> 0.8)
|
|
206
|
-
rexml (3.4.
|
|
206
|
+
rexml (3.4.4)
|
|
207
207
|
rspec (3.13.1)
|
|
208
208
|
rspec-core (~> 3.13.0)
|
|
209
209
|
rspec-expectations (~> 3.13.0)
|
|
@@ -216,8 +216,8 @@ GEM
|
|
|
216
216
|
rspec-mocks (3.13.5)
|
|
217
217
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
218
218
|
rspec-support (~> 3.13.0)
|
|
219
|
-
rspec-support (3.13.
|
|
220
|
-
rubocop (1.
|
|
219
|
+
rspec-support (3.13.6)
|
|
220
|
+
rubocop (1.81.1)
|
|
221
221
|
json (~> 2.3)
|
|
222
222
|
language_server-protocol (~> 3.17.0.2)
|
|
223
223
|
lint_roller (~> 1.1.0)
|
|
@@ -225,22 +225,22 @@ GEM
|
|
|
225
225
|
parser (>= 3.3.0.2)
|
|
226
226
|
rainbow (>= 2.2.2, < 4.0)
|
|
227
227
|
regexp_parser (>= 2.9.3, < 3.0)
|
|
228
|
-
rubocop-ast (>= 1.
|
|
228
|
+
rubocop-ast (>= 1.47.1, < 2.0)
|
|
229
229
|
ruby-progressbar (~> 1.7)
|
|
230
230
|
unicode-display_width (>= 2.4.0, < 4.0)
|
|
231
|
-
rubocop-ast (1.
|
|
231
|
+
rubocop-ast (1.47.1)
|
|
232
232
|
parser (>= 3.3.7.2)
|
|
233
233
|
prism (~> 1.4)
|
|
234
234
|
rubocop-rake (0.6.0)
|
|
235
235
|
rubocop (~> 1.0)
|
|
236
|
-
rubocop-rspec (3.
|
|
236
|
+
rubocop-rspec (3.7.0)
|
|
237
237
|
lint_roller (~> 1.1)
|
|
238
238
|
rubocop (~> 1.72, >= 1.72.1)
|
|
239
239
|
ruby-anthropic (0.4.2)
|
|
240
240
|
event_stream_parser (>= 0.3.0, < 2.0.0)
|
|
241
241
|
faraday (>= 1)
|
|
242
242
|
faraday-multipart (>= 1)
|
|
243
|
-
ruby-openai (8.
|
|
243
|
+
ruby-openai (8.3.0)
|
|
244
244
|
event_stream_parser (>= 0.3.0, < 2.0.0)
|
|
245
245
|
faraday (>= 1)
|
|
246
246
|
faraday-multipart (>= 1)
|
|
@@ -249,19 +249,19 @@ GEM
|
|
|
249
249
|
addressable (>= 2.3.5)
|
|
250
250
|
faraday (>= 0.17.3, < 3)
|
|
251
251
|
securerandom (0.4.1)
|
|
252
|
-
sqlite3 (2.7.
|
|
253
|
-
sqlite3 (2.7.
|
|
254
|
-
sqlite3 (2.7.
|
|
255
|
-
sqlite3 (2.7.
|
|
256
|
-
sqlite3 (2.7.
|
|
257
|
-
sqlite3 (2.7.
|
|
258
|
-
sqlite3 (2.7.
|
|
259
|
-
sqlite3 (2.7.
|
|
252
|
+
sqlite3 (2.7.4-aarch64-linux-gnu)
|
|
253
|
+
sqlite3 (2.7.4-aarch64-linux-musl)
|
|
254
|
+
sqlite3 (2.7.4-arm-linux-gnu)
|
|
255
|
+
sqlite3 (2.7.4-arm-linux-musl)
|
|
256
|
+
sqlite3 (2.7.4-arm64-darwin)
|
|
257
|
+
sqlite3 (2.7.4-x86_64-darwin)
|
|
258
|
+
sqlite3 (2.7.4-x86_64-linux-gnu)
|
|
259
|
+
sqlite3 (2.7.4-x86_64-linux-musl)
|
|
260
260
|
stringio (3.1.7)
|
|
261
261
|
strings-ansi (0.2.0)
|
|
262
262
|
timeout (0.4.3)
|
|
263
263
|
timers (4.4.0)
|
|
264
|
-
traces (0.
|
|
264
|
+
traces (0.18.2)
|
|
265
265
|
tty-cursor (0.7.1)
|
|
266
266
|
tty-progressbar (0.18.3)
|
|
267
267
|
strings-ansi (~> 0.2)
|
|
@@ -56,7 +56,7 @@ module Boxcars
|
|
|
56
56
|
def apply(input_list:, current_conversation: nil)
|
|
57
57
|
response = generate(input_list:, current_conversation:)
|
|
58
58
|
response.generations.to_h do |generation|
|
|
59
|
-
[output_key, generation[0].
|
|
59
|
+
[output_key, generation[0]&.text.to_s]
|
|
60
60
|
end
|
|
61
61
|
end
|
|
62
62
|
|
|
@@ -86,8 +86,12 @@ module Boxcars
|
|
|
86
86
|
conversation = nil
|
|
87
87
|
answer = nil
|
|
88
88
|
4.times do
|
|
89
|
-
text = predict(current_conversation: conversation, **prediction_variables(inputs)).strip
|
|
90
|
-
answer =
|
|
89
|
+
text = predict(current_conversation: conversation, **prediction_variables(inputs)).to_s.strip
|
|
90
|
+
answer = if text.empty?
|
|
91
|
+
Result.from_error("Empty response from engine")
|
|
92
|
+
else
|
|
93
|
+
get_answer(text)
|
|
94
|
+
end
|
|
91
95
|
if answer.status == :error
|
|
92
96
|
Boxcars.debug "have error, trying again: #{answer.answer}", :red
|
|
93
97
|
conversation ||= Conversation.new
|
|
@@ -116,7 +116,8 @@ module Boxcars
|
|
|
116
116
|
|
|
117
117
|
# -- Request construction ---------------------------------------------------
|
|
118
118
|
def build_api_request(prompt_object, inputs, params, chat:)
|
|
119
|
-
|
|
119
|
+
use_responses = params.delete(:use_responses_api) || gpt5_model?(params[:model])
|
|
120
|
+
if use_responses
|
|
120
121
|
build_responses_params(prompt_object, inputs, params.dup)
|
|
121
122
|
elsif chat
|
|
122
123
|
build_chat_params(prompt_object, inputs, params.dup)
|
data/lib/boxcars/engine.rb
CHANGED
|
@@ -36,7 +36,7 @@ module Boxcars
|
|
|
36
36
|
def generation_info(sub_choices)
|
|
37
37
|
sub_choices.map do |choice|
|
|
38
38
|
Generation.new(
|
|
39
|
-
text: choice.dig("message", "content") || choice["text"],
|
|
39
|
+
text: (choice.dig("message", "content") || choice["text"]).to_s,
|
|
40
40
|
generation_info: {
|
|
41
41
|
finish_reason: choice.fetch("finish_reason", nil),
|
|
42
42
|
logprobs: choice.fetch("logprobs", nil)
|
data/lib/boxcars/prompt.rb
CHANGED
|
@@ -36,9 +36,12 @@ module Boxcars
|
|
|
36
36
|
def with_conversation(conversation)
|
|
37
37
|
return self unless conversation
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
Prompt.new(
|
|
40
|
+
template: "#{template}\n\n#{conversation.message_text}",
|
|
41
|
+
input_variables: input_variables,
|
|
42
|
+
other_inputs: other_inputs,
|
|
43
|
+
output_variables: output_variables
|
|
44
|
+
)
|
|
42
45
|
end
|
|
43
46
|
|
|
44
47
|
def default_prefixes
|
data/lib/boxcars/result.rb
CHANGED
|
@@ -43,7 +43,8 @@ module Boxcars
|
|
|
43
43
|
# @param kwargs [Hash] Any additional kwargs to pass to the result
|
|
44
44
|
# @return [Boxcars::Result] The result
|
|
45
45
|
def self.from_text(text, **)
|
|
46
|
-
|
|
46
|
+
str = text.to_s
|
|
47
|
+
answer = str.delete_prefix('"').delete_suffix('"').strip
|
|
47
48
|
answer = Regexp.last_match(:answer) if answer =~ /^Answer:\s*(?<answer>.*)$/
|
|
48
49
|
explanation = "Answer: #{answer}"
|
|
49
50
|
new(status: :ok, answer:, explanation:, **)
|
data/lib/boxcars/version.rb
CHANGED