boxcars 0.8.8 → 0.8.9
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 +1 -1
- data/lib/boxcars/boxcar/engine_boxcar.rb +7 -3
- 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: 1809b25de376f58babd70eda5795a6f757ed570b62b44fbebe8d8caec92c8c81
|
4
|
+
data.tar.gz: 9c77d377b6c8e2ebaa9b9376885a78bcdf61bd1bb9067d01ff8c8a4230a6fc24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73c859810559e64f6cc33b092cea6a0ee34ba50cff65f1224c82e85f17dee54c064b1b62e1f2ed824003e2d6c7a4992b434e6370807d77b09324ba06eb509abb
|
7
|
+
data.tar.gz: c5e5ddcf6b4e2599acdf8ba77f3011bc97920a450801b9c3d992edf502b156633830805e62b78a7e5fbe371b52ef16c7e02de4a09de23b538ece47b71af8e0ea
|
data/Gemfile.lock
CHANGED
@@ -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
|
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