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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/boxcars/conversation.rb +9 -3
- 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: d42ec321ce559b15e1b9da6b7d0338f13ce1faca17a5c70dfc1b516eb51062f9
|
4
|
+
data.tar.gz: 2b8841ca63703ef49426bf004207e808267bc7a692a33188f45d34bdf02c54ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e793cc40fd92d2ea1e249f3f613b4a4bd51954a794c02a201e171d6f38a84da95d851464feab60e11729813c80b90bf8091dfb4750fa4be0084439b94ee8d9a2
|
7
|
+
data.tar.gz: 147e84f7839647fe86ac26d3ed0c9be34a450540dc29d43bd86b6b2fac944718fecb6ba0be324048dd836999ae8f1f0ad83e6f1d50e5975f8510905b35ded432
|
data/Gemfile.lock
CHANGED
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].gsub!(/%(?!<)/, '%%') if args.length > 1
|
118
|
+
format(*args)
|
119
|
+
end
|
114
120
|
end
|
115
121
|
end
|
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.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-
|
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
|