ruby_bots 0.0.14 → 0.0.16

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: 2e32a5d383a859aa90ab9908c848ec2752ca7bb461437c3043998705639015b4
4
- data.tar.gz: 5e0d061582106a990017ae4f39aa636babe9bc27a43b192b0cc01ca7d1294f6d
3
+ metadata.gz: 8edabf893242432d5b0a513a2fdac99ea2799a504e06a5b3e1fa02b39c701a64
4
+ data.tar.gz: 149731352ba25091b61fa16ac1cf70069a0f21fd355e8a2c261c10916ce900e6
5
5
  SHA512:
6
- metadata.gz: ca81bccad08abbc9d99cddf8e265c4a614796c9cd698acda3acb6499abacd313285df62d2dfe7e2a5401cd5512ad4e9e46e847b5ad56bc78ff463cf37c938843
7
- data.tar.gz: 62c5ab9bdd5a7cc179cc543eea4454885cd6f8812d835d0ccdc157ee76e70e0556d46bb22d9dbf80d42ccc729790da593c8130eee5b700f02785b51b6f1102f2
6
+ metadata.gz: e77831c3296c2913280c7c31f24a62a911f9b046deef425afc959fbcd7a5291ff35255fc81b21ce0f222b707f4015a5fbd41e599fcb2ea55f456e8d3263b111b
7
+ data.tar.gz: dd4e5b2ac95e560f744397ba84d2b2e43b1e5d9857e2c9e28d7ac3d96f2c5810ca98063ae537c448cb82bb66eec250e6bc25a3b1aa7609c7b6badde661c99589
@@ -24,13 +24,21 @@ module RubyBots
24
24
 
25
25
  def response(input)
26
26
  @@input_validators.each do |validator|
27
- validator.call(input)
27
+ send(validator, input)
28
28
  end
29
29
 
30
- output = run(input)
30
+ if @errors.empty?
31
+ output = run(input)
32
+ else
33
+ raise RubyBots::Errors::InvalidInputError.new(errors: @errors)
34
+ end
31
35
 
32
36
  @@output_validators.each do |validator|
33
- validator.call(output)
37
+ send(validator, output)
38
+ end
39
+
40
+ if @errors.any?
41
+ raise RubyBots::Errors::InvalidOutputError.new(errors: @errors)
34
42
  end
35
43
  end
36
44
 
@@ -39,5 +47,11 @@ module RubyBots
39
47
  def run(inputs)
40
48
  raise NotImplementedError
41
49
  end
50
+
51
+ def is_json(param)
52
+ JSON.parse(param)
53
+ rescue JSON::ParserError
54
+ errors << "invalid JSON"
55
+ end
42
56
  end
43
57
  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.14".freeze
2
+ VERSION = "0.0.16".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.14
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Paulson