ruby_bots 0.0.15 → 0.0.17

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: 92b2794d56c61fe3cd5572120168ded68cd36656bc21c819637f91093669cd3b
4
- data.tar.gz: a743fe0ba4e291e1c18de787f5139346f6d7db06aa65c5f05518f527a3181edf
3
+ metadata.gz: 5b39c819ac52b84e9dd2b380d63532df4ee08a0c668f5fcec2eaa59db2270652
4
+ data.tar.gz: 546368ae3240380c1017dbdd2d11f521e280284858d435f788ec183ecfcdcf4e
5
5
  SHA512:
6
- metadata.gz: c9c8d8aa5d7a1e7bc93874ebb30e7b98fae2f7cc514366fd3a6bdc61ca7dc852483b30d12f4cac1621d9c4f23319770cbf398af08944e3d21b1bb7cc97db37b4
7
- data.tar.gz: d3fda3396dca0c0f4ba26bb19e8c470cea16495f10869f53f394741a86e8632064b0c1a85196d3337b80820fe32a7c9d5ec6d46caf6a0154fc50162a1e017c7f
6
+ metadata.gz: 24e5d93a84405c5e7a57ffd1877bff805c52067f3152e14019302535750bbbce4760c2e0871cc9fef12e694ff311d109da65256c88bb9532532a79e884faa858
7
+ data.tar.gz: 932623e0f83638a893867f7559173672b2d25e4eb9554c6c177b07a02e5d34ee91d8826a6e9b6066d1239f5f6f6955106e2d64c77a506425ed6253c06e08b6c5
@@ -23,6 +23,7 @@ module RubyBots
23
23
  end
24
24
 
25
25
  def response(input)
26
+ @@input_validators ||= []
26
27
  @@input_validators.each do |validator|
27
28
  send(validator, input)
28
29
  end
@@ -33,6 +34,7 @@ module RubyBots
33
34
  raise RubyBots::Errors::InvalidInputError.new(errors: @errors)
34
35
  end
35
36
 
37
+ @@output_validators ||= []
36
38
  @@output_validators.each do |validator|
37
39
  send(validator, output)
38
40
  end
@@ -40,6 +42,8 @@ module RubyBots
40
42
  if @errors.any?
41
43
  raise RubyBots::Errors::InvalidOutputError.new(errors: @errors)
42
44
  end
45
+
46
+ output
43
47
  end
44
48
 
45
49
  private
@@ -47,5 +51,11 @@ module RubyBots
47
51
  def run(inputs)
48
52
  raise NotImplementedError
49
53
  end
54
+
55
+ def is_json(param)
56
+ JSON.parse(param)
57
+ rescue JSON::ParserError
58
+ errors << "invalid JSON"
59
+ end
50
60
  end
51
61
  end
@@ -2,8 +2,6 @@ require 'openai'
2
2
 
3
3
  module RubyBots
4
4
  class OpenAITool < Tool
5
- validate_inputs :input_is_json
6
-
7
5
  DEFAULT_DESCRIPTION = "This tool will use open ai to determine the output."
8
6
 
9
7
  def initialize(name: "OpenAI Tool", description: DEFAULT_DESCRIPTION)
@@ -39,11 +37,5 @@ module RubyBots
39
37
 
40
38
  response.dig("choices", 0, "message", "content")
41
39
  end
42
-
43
- def input_is_json(input)
44
- JSON.parse(input)
45
- rescue JSON::ParserError
46
- errors.add(:input, "must be valid JSON")
47
- end
48
40
  end
49
41
  end
@@ -1,3 +1,3 @@
1
1
  module RubyBots
2
- VERSION = "0.0.15".freeze
2
+ VERSION = "0.0.17".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_bots
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Paulson