ruby_bots 0.0.3 → 0.0.6

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: 656073bfe550e5be358a7189a137acd2fab90279f46a1d9c44899dddd022f844
4
- data.tar.gz: 28bf1c1005c95aed8cb5f319c012a6ea4c54c8c1e2b5d9941af88bc6841eb9e3
3
+ metadata.gz: b09beb21193f74ab2940c6b117e245bc916a74aaf888d56d70d682aea97198e8
4
+ data.tar.gz: 7e72bb00d11cb236555a3b7cd187e850e68cdd62d3d44fefc2775b139df283f8
5
5
  SHA512:
6
- metadata.gz: 3338bbd983626a62f6448ba4631a940932c2639abb00fb4e109ef47b2ad7b5f777371321f94b42f1ee6be510964a951f8ac8d181c6f953023ae2fb34c1ab334c
7
- data.tar.gz: 1fb67357ceac7f6ceafeb0737a54e138e25350b79fc2aefc08278a9d1b83c4db391e4da669c53a390928cf56289c200ad943a86b8482a6362735857c8e04eb9b
6
+ metadata.gz: ab42068df4967ba2c05c9e4a9869a09e95ec09c633690873242ed157adba7beb798111a45a03d3eedfa45f28f8ce433ef5c148a1528c3cd72fcc578c3963154f
7
+ data.tar.gz: 59a8a478faa42a654a3abc9f37cd4ff6d103dc3e8049783b8bc0bf4748a99824f6b0f38bb6621361b16fd3c67aec66bb9f9e67ff6b5ff7219612b6dbcd7b59bc
data/lib/ruby_bots/bot.rb CHANGED
@@ -7,7 +7,7 @@ module RubyBots
7
7
  super(**kwargs)
8
8
  end
9
9
 
10
- def operate(inputs)
10
+ def run(inputs)
11
11
  raise NotImplementedError
12
12
  end
13
13
  end
@@ -10,7 +10,7 @@ module RubyBots
10
10
  @tools = tools
11
11
  end
12
12
 
13
- def operate(inputs)
13
+ def run(inputs)
14
14
  params = {
15
15
  messages: [
16
16
  { role: :system, content: system_instructions },
@@ -8,9 +8,9 @@ module RubyBots
8
8
  @tools = tools
9
9
  end
10
10
 
11
- def operate(inputs)
11
+ def run(inputs)
12
12
  tools.each do |tool|
13
- inputs = tool.operate(inputs)
13
+ inputs = tool.run(inputs)
14
14
  end
15
15
 
16
16
  inputs
@@ -19,7 +19,7 @@ module RubyBots
19
19
  PROMPT
20
20
  end
21
21
 
22
- def operate(inputs)
22
+ def run(inputs)
23
23
  params = {
24
24
  messages: [
25
25
  { role: :system, content: system_instructions },
@@ -32,7 +32,7 @@ module RubyBots
32
32
  response_text = response.dig("choices", 0, "message", "content")
33
33
  selected_tool = tools.find{|t| t.name == response_text}
34
34
  if selected_tool
35
- selected_tool.operate(inputs)
35
+ selected_tool.response(inputs)
36
36
  else
37
37
  response_text
38
38
  end
@@ -1,20 +1,22 @@
1
1
  module RubyBots
2
2
  class Tool
3
3
  attr_accessor :name, :description, :errors
4
-
4
+
5
5
  def initialize(name:, description:)
6
6
  @name = name
7
7
  @description = description
8
8
  @errors = []
9
- @input_validators = []
10
- @output_validators = []
9
+ @input_validators ||= []
10
+ @output_validators ||= []
11
11
  end
12
12
 
13
- def validate_inputs(method)
13
+ def self.validate_inputs(method)
14
+ @input_validators ||= []
14
15
  @input_validators << method
15
16
  end
16
17
 
17
- def validate_outputs(method)
18
+ def self.validate_outputs(method)
19
+ @output_validators ||= []
18
20
  @output_validators << method
19
21
  end
20
22
 
@@ -7,12 +7,11 @@ module RubyBots
7
7
  DEFAULT_DESCRIPTION = "This tool will use open ai to determine the output."
8
8
 
9
9
  def initialize(name: "OpenAI Tool", description: DEFAULT_DESCRIPTION)
10
- @name = name
11
- @description = description
10
+ super(name: name, description: description)
12
11
  end
13
12
 
14
13
  def client
15
- @client ||= OpenAI::Client.new(access_token: ENV["OPENAI_ACCESS_TOKEN"])
14
+ @client ||= OpenAI::Client.new(access_token: RubyBots.config.openai_api_key)
16
15
  end
17
16
 
18
17
  def default_params
@@ -26,7 +25,7 @@ module RubyBots
26
25
  "You are a helpful assistant."
27
26
  end
28
27
 
29
- def operate(inputs)
28
+ def run(inputs)
30
29
  params = {
31
30
  messages: [
32
31
  { role: :system, content: system_instructions },
@@ -1,3 +1,3 @@
1
1
  module RubyBots
2
- VERSION = "0.0.3".freeze
2
+ VERSION = "0.0.6".freeze
3
3
  end
data/lib/ruby_bots.rb CHANGED
@@ -1,5 +1,19 @@
1
1
  module RubyBots
2
2
  class << self
3
+ def config
4
+ @config ||= Configuration.new
5
+ end
6
+
7
+ def configure
8
+ yield config
9
+ end
10
+ end
11
+
12
+ class Configuration
13
+ attr_accessor :openai_api_key
14
+ def initialize()
15
+ @openai_api_key = ENV["OPENAI_ACCESS_TOKEN"]
16
+ end
3
17
  end
4
18
 
5
19
  def self.bot
@@ -17,7 +31,7 @@ end
17
31
 
18
32
  require "ruby_bots/tool"
19
33
  require "ruby_bots/bot"
34
+ require "ruby_bots/tools/openai_tool.rb"
20
35
  require "ruby_bots/bots/openai_bot.rb"
21
36
  require "ruby_bots/bots/pipeline_bot.rb"
22
- require "ruby_bots/bots/router_bot.rb"
23
- require "ruby_bots/tools/openai_tool.rb"
37
+ require "ruby_bots/bots/router_bot.rb"
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.3
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Paulson