ruby_bots 0.0.3 → 0.0.6
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/bot.rb +1 -1
- data/lib/ruby_bots/bots/openai_bot.rb +1 -1
- data/lib/ruby_bots/bots/pipeline_bot.rb +2 -2
- data/lib/ruby_bots/bots/router_bot.rb +2 -2
- data/lib/ruby_bots/tool.rb +7 -5
- data/lib/ruby_bots/tools/openai_tool.rb +3 -4
- data/lib/ruby_bots/version.rb +1 -1
- data/lib/ruby_bots.rb +16 -2
- metadata +1 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: b09beb21193f74ab2940c6b117e245bc916a74aaf888d56d70d682aea97198e8
         | 
| 4 | 
            +
              data.tar.gz: 7e72bb00d11cb236555a3b7cd187e850e68cdd62d3d44fefc2775b139df283f8
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: ab42068df4967ba2c05c9e4a9869a09e95ec09c633690873242ed157adba7beb798111a45a03d3eedfa45f28f8ce433ef5c148a1528c3cd72fcc578c3963154f
         | 
| 7 | 
            +
              data.tar.gz: 59a8a478faa42a654a3abc9f37cd4ff6d103dc3e8049783b8bc0bf4748a99824f6b0f38bb6621361b16fd3c67aec66bb9f9e67ff6b5ff7219612b6dbcd7b59bc
         | 
    
        data/lib/ruby_bots/bot.rb
    CHANGED
    
    
| @@ -19,7 +19,7 @@ module RubyBots | |
| 19 19 | 
             
                  PROMPT
         | 
| 20 20 | 
             
                end
         | 
| 21 21 |  | 
| 22 | 
            -
                def  | 
| 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. | 
| 35 | 
            +
                    selected_tool.response(inputs)
         | 
| 36 36 | 
             
                  else
         | 
| 37 37 | 
             
                    response_text
         | 
| 38 38 | 
             
                  end
         | 
    
        data/lib/ruby_bots/tool.rb
    CHANGED
    
    | @@ -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 | 
            -
                   | 
| 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:  | 
| 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  | 
| 28 | 
            +
                def run(inputs)
         | 
| 30 29 | 
             
                  params = {
         | 
| 31 30 | 
             
                    messages: [
         | 
| 32 31 | 
             
                      { role: :system, content: system_instructions },
         | 
    
        data/lib/ruby_bots/version.rb
    CHANGED
    
    
    
        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"
         |