boxcars 0.3.3 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/boxcars/boxcar.rb +1 -1
- data/lib/boxcars/conversation.rb +9 -3
- data/lib/boxcars/engine/openai.rb +1 -1
- data/lib/boxcars/train.rb +1 -1
- data/lib/boxcars/version.rb +1 -1
- 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: f1a16f4a38b33df747173cfabb27c183b95eccdcf35b4b8167db16fec1ecc913
|
4
|
+
data.tar.gz: cdbc64c7a8d71c9bd2812a07ed022f25c08f2bd68e34d2a3bc8686dafde486d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba80d07797ef09b43012048e52cb7181a707595f848b9a1b3f62890442e0355f190219301467bb51aecb9b6581d81908e8d1995b2b707ded618287bb50f10db6
|
7
|
+
data.tar.gz: 41c28b0fdca5dfb4da99c19963cd014bcdd1f3a582c0efdd0446f612bfdafae4c6a22303c0bcff4e5c1da02fae355a782651000802c90f20ca2c66b53d07b683
|
data/Gemfile.lock
CHANGED
data/lib/boxcars/boxcar.rb
CHANGED
@@ -165,7 +165,7 @@ module Boxcars
|
|
165
165
|
begin
|
166
166
|
output = call(inputs: inputs)
|
167
167
|
rescue StandardError => e
|
168
|
-
Boxcars.error "Error in #{name} boxcar#call: #{e}", :red
|
168
|
+
Boxcars.error "Error in #{name} boxcar#call: #{e}\nbt:#{caller[0..5].join("\n ")}", :red
|
169
169
|
raise e
|
170
170
|
end
|
171
171
|
validate_outputs(outputs: output.keys)
|
data/lib/boxcars/conversation.rb
CHANGED
@@ -90,7 +90,7 @@ module Boxcars
|
|
90
90
|
# @param inputs [Hash] The inputs to use for the prompt.
|
91
91
|
# @return [Hash] The formatted prompt { messages: ...}
|
92
92
|
def as_messages(inputs = nil)
|
93
|
-
{ messages: no_history.map { |ln| { role: ln.first, content: ln.last
|
93
|
+
{ messages: no_history.map { |ln| { role: ln.first, content: cformat(ln.last, inputs) } } }
|
94
94
|
rescue ::KeyError => e
|
95
95
|
first_line = e.message.to_s.split("\n").first
|
96
96
|
Boxcars.error "Missing prompt input key: #{first_line}"
|
@@ -102,14 +102,20 @@ module Boxcars
|
|
102
102
|
# @return [Hash] The formatted prompt { prompt: "..."}
|
103
103
|
def as_prompt(inputs = nil)
|
104
104
|
if show_roles
|
105
|
-
no_history.map { |ln|
|
105
|
+
no_history.map { |ln| cformat("#{ln.first}: #{ln.last}", inputs) }.compact.join("\n\n")
|
106
106
|
else
|
107
|
-
no_history.map { |ln|
|
107
|
+
no_history.map { |ln| cformat(ln.last, inputs) }.compact.join("\n\n")
|
108
108
|
end
|
109
109
|
rescue ::KeyError => e
|
110
110
|
first_line = e.message.to_s.split("\n").first
|
111
111
|
Boxcars.error "Missing prompt input key: #{first_line}"
|
112
112
|
raise KeyError, "Prompt format error: #{first_line}"
|
113
113
|
end
|
114
|
+
|
115
|
+
# special format that replaces lone percent signs with double percent signs
|
116
|
+
def cformat(*args)
|
117
|
+
args[0] = args[0].dup.gsub(/%(?!<)/, '%%') if args.length > 1
|
118
|
+
format(*args)
|
119
|
+
end
|
114
120
|
end
|
115
121
|
end
|
@@ -59,7 +59,7 @@ module Boxcars
|
|
59
59
|
prompt = prompt.first if prompt.is_a?(Array)
|
60
60
|
params = prompt.as_messages(inputs).merge(params)
|
61
61
|
if Boxcars.configuration.log_prompts
|
62
|
-
Boxcars.debug(params[:messages].map { |p| ">>>>>> Role: #{p[:role]} <<<<<<\n#{p[:content]}" }.join("\n"), :cyan)
|
62
|
+
Boxcars.debug(params[:messages].last(2).map { |p| ">>>>>> Role: #{p[:role]} <<<<<<\n#{p[:content]}" }.join("\n"), :cyan)
|
63
63
|
end
|
64
64
|
clnt.chat(parameters: params)
|
65
65
|
else
|
data/lib/boxcars/train.rb
CHANGED
@@ -214,7 +214,7 @@ module Boxcars
|
|
214
214
|
rescue Boxcars::ConfigurationError, Boxcars::SecurityError => e
|
215
215
|
raise e
|
216
216
|
rescue StandardError => e
|
217
|
-
Boxcars.error "Error in #{boxcar.name}
|
217
|
+
Boxcars.error "Error in #{boxcar.name} train#call: #{e}\nbt:#{caller[0..5].join("\n ")}", :red
|
218
218
|
observation = Observation.err("Error - #{e}, correct and try again.")
|
219
219
|
end
|
220
220
|
elsif output.boxcar == :error
|
data/lib/boxcars/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: boxcars
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Francis Sullivan
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-07-
|
12
|
+
date: 2023-07-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: google_search_results
|