ruby_bots 0.0.1 → 0.0.2
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 +4 -4
- data/lib/ruby_bots/tool.rb +20 -6
- data/lib/ruby_bots/tools/openai_tool.rb +7 -1
- data/lib/ruby_bots/version.rb +1 -1
- data/lib/ruby_bots.rb +8 -5
- 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: 97bf25557fb288a1416c47c9e3e566e437c04c5d2c19fedab06ae83837e24408
|
4
|
+
data.tar.gz: 26bb0781e3d5c2580b385539ae041eda38fb6ce2d323df20e80260780df78b88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7cefa94ef3b53ea79d46d39fb8256a3d96e96db852f45ae51feed2c58e0826fd2ba536acb43a1c801fdae83de8694be7f30e9e6541c344228d4bda1cac4dcbf7
|
7
|
+
data.tar.gz: 2b2afd2c55c6878d52a5d9675bbcfc39b90a6df8374482fc06e762c68dec48afd88bf5282a36aa48859e77ec5697b7911e8a755fe5367d29734424225da701b7
|
data/lib/ruby_bots/tool.rb
CHANGED
@@ -1,23 +1,37 @@
|
|
1
1
|
module RubyBots
|
2
2
|
class Tool
|
3
|
-
attr_accessor :name, :description
|
3
|
+
attr_accessor :name, :description, :errors
|
4
4
|
|
5
5
|
def initialize(name:, description:)
|
6
6
|
@name = name
|
7
7
|
@description = description
|
8
|
+
@errors = []
|
9
|
+
@input_validators = []
|
10
|
+
@output_validators = []
|
8
11
|
end
|
9
12
|
|
10
|
-
def validate_inputs(
|
11
|
-
|
13
|
+
def validate_inputs(method)
|
14
|
+
@input_validators << method
|
15
|
+
end
|
16
|
+
|
17
|
+
def validate_outputs(method)
|
18
|
+
@output_validators << method
|
12
19
|
end
|
13
20
|
|
14
21
|
def run(inputs)
|
15
22
|
raise NotImplementedError
|
16
23
|
end
|
17
24
|
|
18
|
-
def response(
|
19
|
-
|
20
|
-
|
25
|
+
def response(input)
|
26
|
+
@input_validators.each do |validator|
|
27
|
+
validator.call(input)
|
28
|
+
end
|
29
|
+
|
30
|
+
output = run(input)
|
31
|
+
|
32
|
+
@output_validators.each do |validator|
|
33
|
+
validator.call(output)
|
34
|
+
end
|
21
35
|
end
|
22
36
|
end
|
23
37
|
end
|
@@ -2,7 +2,7 @@ require 'openai'
|
|
2
2
|
|
3
3
|
module RubyBots
|
4
4
|
class OpenAITool < Tool
|
5
|
-
|
5
|
+
validate_inputs :input_is_json
|
6
6
|
|
7
7
|
DEFAULT_DESCRIPTION = "This tool will use open ai to determine the output."
|
8
8
|
|
@@ -38,5 +38,11 @@ module RubyBots
|
|
38
38
|
|
39
39
|
response.dig("choices", 0, "message", "content")
|
40
40
|
end
|
41
|
+
|
42
|
+
def input_is_json(input)
|
43
|
+
JSON.parse(input)
|
44
|
+
rescue JSON::ParserError
|
45
|
+
errors.add(:input, "must be valid JSON")
|
46
|
+
end
|
41
47
|
end
|
42
48
|
end
|
data/lib/ruby_bots/version.rb
CHANGED
data/lib/ruby_bots.rb
CHANGED
@@ -9,12 +9,15 @@ module RubyBots
|
|
9
9
|
def self.tool
|
10
10
|
RubyBots::Tool
|
11
11
|
end
|
12
|
+
|
13
|
+
class Error < StandardError; end
|
14
|
+
class InvalidInputError < Error; end
|
15
|
+
class InvalidOutputError < Error; end
|
12
16
|
end
|
13
17
|
|
14
18
|
require "ruby_bots/tool"
|
15
19
|
require "ruby_bots/bot"
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
# require "ruby_bots/tools/openai_tool.rb"
|
20
|
+
require "ruby_bots/bots/openai_bot.rb"
|
21
|
+
require "ruby_bots/bots/pipeline_bot.rb"
|
22
|
+
require "ruby_bots/bots/router_bot.rb"
|
23
|
+
require "ruby_bots/tools/openai_tool.rb"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_bots
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Paulson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: debug
|