ruby_bots 0.0.4 → 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: d0b84559e01ae6822b1c0df25903afac6558afd2deeec3a9168dd432a43f02c8
4
- data.tar.gz: c7badfadd1f4281dcd83b813ff748203cb1618570eaab41929d8cc276cdeba56
3
+ metadata.gz: b09beb21193f74ab2940c6b117e245bc916a74aaf888d56d70d682aea97198e8
4
+ data.tar.gz: 7e72bb00d11cb236555a3b7cd187e850e68cdd62d3d44fefc2775b139df283f8
5
5
  SHA512:
6
- metadata.gz: 81d3ad8d09dbc3ec62bafac7a227d6cdf76c70250993750e4e43b823a1e980a7b98b0f8fdd0ae9e3fd49877e48c3d3881fe24004644b5a7d416241b5225bd623
7
- data.tar.gz: 34efdc886c8422f65e590d11a2071056c215d02f586bbf77d6e6f8e11bd364cc39be587a9e56db56e8d3e506453b5080fa2e66c4b3c212a021de000b0e3f4162
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.4".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
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.4
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Paulson