boxcars 0.2.14 → 0.2.15

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: 1039f86c58712c10143cc26438da14571013081bcff08aed3d9fcac4b1e84060
4
- data.tar.gz: fca9f08855cae8e4e8a4171c043e92884e245582b049b4cc75bfa4d2cd98e51a
3
+ metadata.gz: 94f8c86ef9a5d967f854447e0e2807d116ca95c2ebfe40fc624162144fbf77a3
4
+ data.tar.gz: 1230243ce0c1d6fb37855d093202daa65584df540f306bea57a1ed3daf331c45
5
5
  SHA512:
6
- metadata.gz: 5f24a578f4004d99a0d71c05f4a0ed520dda2e562d1327ec68bdf8682a927b741e870ed348a1a273319003f515521ef8a12c8778b70994764a945e31f906f807
7
- data.tar.gz: be067a2ba1ba2e032a58d32f46071f5510a5ce0f15fbc89a06fe84f4fd854ec825a0ea0c786a90ba87c20bb1893ff59512170ac2e338080e25f85b2474b6fb64
6
+ metadata.gz: 50d40ff9d3e5bd80f65dee223bd5f4de6c90d681b797f973f665a770bfc64f761acc4c2f22ef39f59731064c1350af56a47525d867acfc223a79635ded27906d
7
+ data.tar.gz: b574a4f7f27f2f24e2ca13577b51cdaf609a00a5372d3f8b112c724412c66f08242a7853abe1e8c7ae542ecc28854c07a01be803606c27cba87153a4a21086a7
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.2.2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## [v0.2.14](https://github.com/BoxcarsAI/boxcars/tree/v0.2.14) (2023-06-06)
4
+
5
+ [Full Changelog](https://github.com/BoxcarsAI/boxcars/compare/v0.2.13...v0.2.14)
6
+
7
+ **Closed issues:**
8
+
9
+ - VectorAnswer always return error "Query must a string" [\#90](https://github.com/BoxcarsAI/boxcars/issues/90)
10
+ - Readme vector search example 404 [\#86](https://github.com/BoxcarsAI/boxcars/issues/86)
11
+ - Add Boxcar similar to LLMChain [\#85](https://github.com/BoxcarsAI/boxcars/issues/85)
12
+
13
+ **Merged pull requests:**
14
+
15
+ - Chore/refactored vector stores [\#92](https://github.com/BoxcarsAI/boxcars/pull/92) ([jaigouk](https://github.com/jaigouk))
16
+ - Fix the issue of calling the wrong method in vector\_answer.rb. [\#91](https://github.com/BoxcarsAI/boxcars/pull/91) ([xleotranx](https://github.com/xleotranx))
17
+ - issue\_83 Fix readme 404 [\#87](https://github.com/BoxcarsAI/boxcars/pull/87) ([beouk](https://github.com/beouk))
18
+
3
19
  ## [v0.2.13](https://github.com/BoxcarsAI/boxcars/tree/v0.2.13) (2023-05-24)
4
20
 
5
21
  [Full Changelog](https://github.com/BoxcarsAI/boxcars/compare/v0.2.12...v0.2.13)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- boxcars (0.2.14)
4
+ boxcars (0.2.15)
5
5
  google_search_results (~> 2.2)
6
6
  gpt4all (~> 0.0.4)
7
7
  hnswlib (~> 0.8)
@@ -88,9 +88,11 @@ GEM
88
88
  i18n (1.13.0)
89
89
  concurrent-ruby (~> 1.0)
90
90
  io-console (0.6.0)
91
+ io-console (0.6.0-java)
91
92
  irb (1.6.4)
92
93
  reline (>= 0.3.0)
93
94
  json (2.6.3)
95
+ json (2.6.3-java)
94
96
  mime-types (3.4.1)
95
97
  mime-types-data (~> 3.2015)
96
98
  mime-types-data (3.2023.0218.1)
@@ -100,6 +102,7 @@ GEM
100
102
  multipart-post (2.3.0)
101
103
  netrc (0.11.0)
102
104
  nio4r (2.5.9)
105
+ nio4r (2.5.9-java)
103
106
  octokit (4.25.1)
104
107
  faraday (>= 1, < 3)
105
108
  sawyer (~> 0.9)
@@ -173,6 +176,9 @@ GEM
173
176
  faraday (>= 0.17.3, < 3)
174
177
  sqlite3 (1.6.3)
175
178
  mini_portile2 (~> 2.8.0)
179
+ sqlite3 (1.6.3-arm64-darwin)
180
+ sqlite3 (1.6.3-x86_64-darwin)
181
+ sqlite3 (1.6.3-x86_64-linux)
176
182
  strings-ansi (0.2.0)
177
183
  timers (4.3.5)
178
184
  traces (0.9.1)
@@ -187,6 +193,7 @@ GEM
187
193
  concurrent-ruby (~> 1.0)
188
194
  unf (0.1.4)
189
195
  unf_ext
196
+ unf (0.1.4-java)
190
197
  unf_ext (0.0.8.2)
191
198
  unicode-display_width (2.4.2)
192
199
  vcr (6.1.0)
@@ -56,7 +56,7 @@ module Boxcars
56
56
  def apply(input_list:, current_conversation: nil)
57
57
  response = generate(input_list: input_list, current_conversation: current_conversation)
58
58
  response.generations.to_h do |generation|
59
- [output_keys.first, generation[0].text]
59
+ [output_key, generation[0].text]
60
60
  end
61
61
  end
62
62
 
@@ -65,7 +65,7 @@ module Boxcars
65
65
  # @param kwargs [Hash] A hash of input values to use for the prompt.
66
66
  # @return [String] The output value.
67
67
  def predict(current_conversation: nil, **kwargs)
68
- prediction = apply(current_conversation: current_conversation, input_list: [kwargs])[output_keys.first]
68
+ prediction = apply(current_conversation: current_conversation, input_list: [kwargs])[output_key]
69
69
  Boxcars.debug(prediction, :white) if Boxcars.configuration.log_generated
70
70
  prediction
71
71
  end
@@ -95,7 +95,7 @@ module Boxcars
95
95
  conversation.add_user(answer.answer)
96
96
  else
97
97
  Boxcars.debug answer.to_json, :magenta
98
- return { output_keys.first => answer }
98
+ return { output_key => answer }
99
99
  end
100
100
  end
101
101
  Boxcars.error answer.to_json, :red
@@ -5,22 +5,25 @@ module Boxcars
5
5
  # A Train using the zero-shot react method.
6
6
  class ZeroShot < Train
7
7
  attr_reader :boxcars, :observation_prefix, :engine_prefix
8
+ attr_accessor :wants_next_actions
8
9
 
9
10
  # @param boxcars [Array<Boxcars::Boxcar>] The boxcars to run.
10
11
  # @param engine [Boxcars::Engine] The engine to use for this train.
11
12
  # @param name [String] The name of the train. Defaults to 'Zero Shot'.
12
13
  # @param description [String] The description of the train. Defaults to 'Zero Shot Train'.
13
14
  # @param prompt [Boxcars::Prompt] The prompt to use. Defaults to the built-in prompt.
14
- def initialize(boxcars:, engine: nil, name: 'Zero Shot', description: 'Zero Shot Train', prompt: nil)
15
+ # @param kwargs [Hash] Additional arguments to pass to the train. wants_next_actions: true
16
+ def initialize(boxcars:, engine: nil, name: 'Zero Shot', description: 'Zero Shot Train', prompt: nil, **kwargs)
15
17
  @observation_prefix = 'Observation: '
16
18
  @engine_prefix = 'Thought:'
19
+ @wants_next_actions = kwargs.fetch(:wants_next_actions, false)
17
20
  prompt ||= my_prompt
18
21
  super(engine: engine, boxcars: boxcars, prompt: prompt, name: name, description: description)
19
22
  end
20
23
 
21
24
  # @return Hash The additional variables for this boxcar.
22
25
  def prediction_additional(_inputs)
23
- { boxcar_names: boxcar_names, boxcar_descriptions: boxcar_descriptions }.merge super
26
+ { boxcar_names: boxcar_names, boxcar_descriptions: boxcar_descriptions, next_actions: next_actions }.merge super
24
27
  end
25
28
 
26
29
  # Extract the boxcar and input from the engine output.
@@ -72,13 +75,14 @@ module Boxcars
72
75
  "Question: the input question you must answer\n",
73
76
  "Thought: you should always think about what to do\n",
74
77
  "Action: the action to take, should be one from this list: %<boxcar_names>s\n",
75
- "Action Input: the input to the action\n",
78
+ "Action Input: an input question to the action\n",
76
79
  "Observation: the result of the action\n",
77
80
  "... (this Thought/Action/Action Input/Observation sequence can repeat N times)\n",
78
81
  "Thought: I know the final answer\n",
79
82
  "Final Answer: the final answer to the original input question\n",
80
- "Next Actions: Up to 3 logical suggested next questions for the user to ask after getting this answer.\n",
83
+ "%<next_actions>s\n",
81
84
  "Remember to start a line with \"Final Answer:\" to give me the final answer.\n",
85
+ "Also make sure to specify a question for the Action Input.\n",
82
86
  "Begin!"),
83
87
  user("Question: %<input>s"),
84
88
  assi("Thought: %<agent_scratchpad>s")
@@ -92,13 +96,21 @@ module Boxcars
92
96
  @boxcar_descriptions ||= boxcars.map { |boxcar| "#{boxcar.name}: #{boxcar.description}" }.join("\n")
93
97
  end
94
98
 
99
+ def next_actions
100
+ if wants_next_actions
101
+ "Next Actions: Up to 3 logical suggested next questions for the user to ask after getting this answer.\n"
102
+ else
103
+ ""
104
+ end
105
+ end
106
+
95
107
  # The prompt to use for the train.
96
108
  def my_prompt
97
109
  @conversation ||= Conversation.new(lines: CTEMPLATE)
98
110
  @my_prompt ||= ConversationPrompt.new(
99
111
  conversation: @conversation,
100
112
  input_variables: [:input],
101
- other_inputs: [:boxcar_names, :boxcar_descriptions, :agent_scratchpad],
113
+ other_inputs: [:boxcar_names, :boxcar_descriptions, :next_actions, :agent_scratchpad],
102
114
  output_variables: [:answer])
103
115
  end
104
116
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Boxcars
4
4
  # The current version of the gem.
5
- VERSION = "0.2.14"
5
+ VERSION = "0.2.15"
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.2.14
4
+ version: 0.2.15
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-06-06 00:00:00.000000000 Z
12
+ date: 2023-06-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: google_search_results
@@ -92,6 +92,7 @@ files:
92
92
  - ".env_sample"
93
93
  - ".rspec"
94
94
  - ".rubocop.yml"
95
+ - ".ruby-version"
95
96
  - CHANGELOG.md
96
97
  - CODE_OF_CONDUCT.md
97
98
  - Gemfile
@@ -167,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
168
  - !ruby/object:Gem::Version
168
169
  version: '0'
169
170
  requirements: []
170
- rubygems_version: 3.2.32
171
+ rubygems_version: 3.4.10
171
172
  signing_key:
172
173
  specification_version: 4
173
174
  summary: Boxcars is a gem that enables you to create new systems with AI composability.