ruby_bots 0.0.4 → 0.0.7

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: d0b84559e01ae6822b1c0df25903afac6558afd2deeec3a9168dd432a43f02c8
4
- data.tar.gz: c7badfadd1f4281dcd83b813ff748203cb1618570eaab41929d8cc276cdeba56
3
+ metadata.gz: 9ae9e0cefac2b636d7dcb5e1627638ba1dd0a65193001cbe6ed143cca929bf86
4
+ data.tar.gz: e86443e3e76810dfb478f04f1727854aa4c698fdcae7d449c2181546ab4c0c3f
5
5
  SHA512:
6
- metadata.gz: 81d3ad8d09dbc3ec62bafac7a227d6cdf76c70250993750e4e43b823a1e980a7b98b0f8fdd0ae9e3fd49877e48c3d3881fe24004644b5a7d416241b5225bd623
7
- data.tar.gz: 34efdc886c8422f65e590d11a2071056c215d02f586bbf77d6e6f8e11bd364cc39be587a9e56db56e8d3e506453b5080fa2e66c4b3c212a021de000b0e3f4162
6
+ metadata.gz: e7f38b981264422dfedab32092b4afe7ccf11fcf3beffe281d96e1f946d2737ed72b502d7fbd1fc3486430158d54298e97546f1676944209c85b6e4ec824c540
7
+ data.tar.gz: 2b7067d0f1638c7553b062d94362354d59082c4c5fd545005e1e47f80a21d8d4159c18a4688816b43b71e614043ced82dfea82af308560996e7cad4e2ec21fd1
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 },
@@ -2,15 +2,15 @@ module RubyBots
2
2
  class PipelineBot < Bot
3
3
  DEFAULT_DESCRIPTION = "This bot will utilize all of its tools in a syncronouse pipeline based on the order the tools are provided."
4
4
 
5
- def initialize(name: "Pipeline bot", decription: DEFAULT_DESCRIPTION, tools:)
5
+ def initialize(name: "Pipeline bot", description: DEFAULT_DESCRIPTION, tools:)
6
6
  @name = name
7
7
  @description = description
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.7".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.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Paulson