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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8261b5fd1cf581d141ae39fd3d567abd9751a98c6227c3f56c3d221275eb08d1
4
- data.tar.gz: 5bb1a1f94a6076fa9f72542aa7117bd981d7f5191781cea917822109e93ace6c
3
+ metadata.gz: 1809b25de376f58babd70eda5795a6f757ed570b62b44fbebe8d8caec92c8c81
4
+ data.tar.gz: 9c77d377b6c8e2ebaa9b9376885a78bcdf61bd1bb9067d01ff8c8a4230a6fc24
5
5
  SHA512:
6
- metadata.gz: b763fabf8eb07f1d52dc558d51af423ebd96761fece00850862c41fefa1c342524ace6a733e097e4cd6696b80d3b6baabfb043a81c3734fa2f4b8f8f45b58a07
7
- data.tar.gz: 264fcc8c5ba7e064a5f295ee1b8427ffaeccb072eb8bf89ac64e146214ce3485a317ba9a92ed8a874ae62dc86b5f973b1cea6d71f0361e8300c46ae956bd2151
6
+ metadata.gz: 73c859810559e64f6cc33b092cea6a0ee34ba50cff65f1224c82e85f17dee54c064b1b62e1f2ed824003e2d6c7a4992b434e6370807d77b09324ba06eb509abb
7
+ data.tar.gz: c5e5ddcf6b4e2599acdf8ba77f3011bc97920a450801b9c3d992edf502b156633830805e62b78a7e5fbe371b52ef16c7e02de4a09de23b538ece47b71af8e0ea
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- boxcars (0.8.8)
4
+ boxcars (0.8.9)
5
5
  faraday-retry (~> 2.0)
6
6
  google_search_results (~> 2.2)
7
7
  gpt4all (~> 0.0.5)
@@ -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].text]
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 = get_answer(text)
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
@@ -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)
@@ -36,9 +36,12 @@ module Boxcars
36
36
  def with_conversation(conversation)
37
37
  return self unless conversation
38
38
 
39
- new_prompt = dup
40
- new_prompt.template += "\n\n#{conversation.message_text}"
41
- new_prompt
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
@@ -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
- answer = text.delete_prefix('"').delete_suffix('"').strip
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:, **)
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Boxcars
4
4
  # The current version of the gem.
5
- VERSION = "0.8.8"
5
+ VERSION = "0.8.9"
6
6
  end
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.8.8
4
+ version: 0.8.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francis Sullivan