boxcars 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4c6fc81621333c6663dd04a49215f01a1fbd5fa247551b80b652676a4c06f155
4
- data.tar.gz: a956727b4b986d42cc9f7b2b609dba561473f1976cce5f16ce2db641de778dfc
3
+ metadata.gz: d42ec321ce559b15e1b9da6b7d0338f13ce1faca17a5c70dfc1b516eb51062f9
4
+ data.tar.gz: 2b8841ca63703ef49426bf004207e808267bc7a692a33188f45d34bdf02c54ea
5
5
  SHA512:
6
- metadata.gz: cac0c355836d68387a0fe66e7c65efe341c4ec746627eb275411198a0ba0092291e7add9cb8fbd93aee00da1d61420e36eaa1c90d97621629f3db5f56c0b134d
7
- data.tar.gz: 799149ab51920e7d95d136ad5b4e57ac98c7e344ce277bcbd6e0ee8d89e8cc0d8eea23f37d821712818b16eacf8f0b236bb8c5730633250dc02c209b647f7b8f
6
+ metadata.gz: e793cc40fd92d2ea1e249f3f613b4a4bd51954a794c02a201e171d6f38a84da95d851464feab60e11729813c80b90bf8091dfb4750fa4be0084439b94ee8d9a2
7
+ data.tar.gz: 147e84f7839647fe86ac26d3ed0c9be34a450540dc29d43bd86b6b2fac944718fecb6ba0be324048dd836999ae8f1f0ad83e6f1d50e5975f8510905b35ded432
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- boxcars (0.3.3)
4
+ boxcars (0.3.4)
5
5
  google_search_results (~> 2.2)
6
6
  gpt4all (~> 0.0.4)
7
7
  hnswlib (~> 0.8)
@@ -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 % inputs } } }
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| format("#{ln.first}: #{ln.last}", inputs) }.compact.join("\n\n")
105
+ no_history.map { |ln| cformat("#{ln.first}: #{ln.last}", inputs) }.compact.join("\n\n")
106
106
  else
107
- no_history.map { |ln| format(ln.last, inputs) }.compact.join("\n\n")
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].gsub!(/%(?!<)/, '%%') if args.length > 1
118
+ format(*args)
119
+ end
114
120
  end
115
121
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Boxcars
4
4
  # The current version of the gem.
5
- VERSION = "0.3.3"
5
+ VERSION = "0.3.4"
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.3.3
4
+ version: 0.3.4
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-10 00:00:00.000000000 Z
12
+ date: 2023-07-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: google_search_results