func_bot 0.1.1 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 68e7cc778676e7b037cff5572cd69c2f61559763fd57b8e31328f487fa839148
4
- data.tar.gz: cb9ca4334b4c08384216a03988e7b3343809cf7d0ee9e0ba69706b17a3c91e48
3
+ metadata.gz: e2642f560765801d53e14efe88c613738759eb83c5ea65bac70696987eb38783
4
+ data.tar.gz: fc5683415acbaed9f68013aad668dbb180d1059b1496c514bcbcd05d5be6044c
5
5
  SHA512:
6
- metadata.gz: b22ff1a5ebedc9261dc022bed342d8272b1bd15ed73c749038c4c2711f7785fa9dae7452fe0e8a40337dc46ae43daa2df7bc7ba7b4af28a8fa3f0844aff9efe3
7
- data.tar.gz: 45ac6d18634f9615dcbd3807726543bab58409a7c6e20d80c8a0ad039a5f9bbcccf1c2e801c6b1070bce3aaf4632d435538aa6313f468e22dfe889efca24c156
6
+ metadata.gz: a17a9594c4a6ec3cdfbf31db3531afb2074e314fd092851c76d73fa41f221a3e03c35a183ef2a7a86618e15bbd20cd9ff7d642e5efb5dbb9c55e48495eef1165
7
+ data.tar.gz: 615b2b10f8c235b67dd7489ea3624a83c3b53a9b0eb57843d816d66dc1672a4c6692cfd615dd7c2238e3c62c5521093dfd32b8186c358fb595b7eedaca201499
@@ -15,7 +15,7 @@ module FuncBot
15
15
  model: "gpt-3.5-turbo-0613",
16
16
  messages: bot.history.payload,
17
17
  temperature: 0.7,
18
- functions: FuncBot::Functions::List.call
18
+ functions: FuncBot::Functions::List.call(bot)
19
19
  }
20
20
  )
21
21
  end
@@ -3,15 +3,15 @@
3
3
  module FuncBot
4
4
  module Functions
5
5
  class BaseFunction
6
- attr_reader :response
6
+ attr_reader :bot
7
7
 
8
- def initialize(response)
9
- @response = response
8
+ def initialize(bot)
9
+ @bot = bot
10
10
  end
11
11
 
12
12
  def parsed_response
13
13
  JSON.parse(
14
- response.dig("choices", 0, "message", "function_call", "arguments")
14
+ bot.response.dig("choices", 0, "message", "function_call", "arguments")
15
15
  )
16
16
  end
17
17
  end
@@ -17,7 +17,7 @@ module FuncBot
17
17
  private
18
18
 
19
19
  def function_data
20
- constantize_function.new(bot.response).execute
20
+ constantize_function.new(bot).execute
21
21
  end
22
22
 
23
23
  def constantize_function
@@ -3,11 +3,15 @@
3
3
  module FuncBot
4
4
  module Functions
5
5
  class List
6
- def self.call
7
- if File.exist?(Rails.root.join("app", "lib", "func_bot", "functions", "list.yml"))
8
- YAML.load_file(Rails.root.join("app", "lib", "func_bot", "functions", "list.yml"))["functions"]
6
+ def self.call(bot)
7
+ if bot.include_functions
8
+ if File.exist?(Rails.root.join("app", "lib", "func_bot", "functions", "list.yml"))
9
+ YAML.load_file(Rails.root.join("app", "lib", "func_bot", "functions", "list.yml"))["functions"]
10
+ else
11
+ raise "app/lib/func_bot/functions/list.yml file not found. Please create it by running rails func_bot:install."
12
+ end
9
13
  else
10
- raise "app/lib/func_bot/functions/list.yml file not found. Please create it by running rails func_bot:install."
14
+ []
11
15
  end
12
16
  end
13
17
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FuncBot
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
data/lib/func_bot.rb CHANGED
@@ -12,12 +12,13 @@ require_relative "func_bot/functions/list"
12
12
 
13
13
  module FuncBot
14
14
  class Bot
15
- attr_accessor :response
15
+ attr_accessor :response, :include_functions
16
16
  attr_reader :client, :history
17
17
 
18
18
  def initialize
19
19
  @history = Bots::History.new
20
20
  @client = Bots::Client.new(self)
21
+ @include_functions = true
21
22
  end
22
23
 
23
24
  def ask(prompt)
@@ -7,6 +7,7 @@ module FuncBot
7
7
  module Functions
8
8
  class WeatherFunction < BaseFunction
9
9
  def execute
10
+ bot.include_functions = false
10
11
  weather_info = {
11
12
  location: parsed_response["location"],
12
13
  temperature: 98,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: func_bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - lbp