func_bot 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/func_bot/bots/client.rb +1 -1
- data/lib/func_bot/functions/base_function.rb +4 -4
- data/lib/func_bot/functions/handler.rb +1 -1
- data/lib/func_bot/functions/list.rb +8 -4
- data/lib/func_bot/version.rb +1 -1
- data/lib/func_bot.rb +2 -1
- data/lib/generators/func_bot/templates/weather_function.rb +1 -0
- 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: e2642f560765801d53e14efe88c613738759eb83c5ea65bac70696987eb38783
|
4
|
+
data.tar.gz: fc5683415acbaed9f68013aad668dbb180d1059b1496c514bcbcd05d5be6044c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a17a9594c4a6ec3cdfbf31db3531afb2074e314fd092851c76d73fa41f221a3e03c35a183ef2a7a86618e15bbd20cd9ff7d642e5efb5dbb9c55e48495eef1165
|
7
|
+
data.tar.gz: 615b2b10f8c235b67dd7489ea3624a83c3b53a9b0eb57843d816d66dc1672a4c6692cfd615dd7c2238e3c62c5521093dfd32b8186c358fb595b7eedaca201499
|
data/lib/func_bot/bots/client.rb
CHANGED
@@ -3,15 +3,15 @@
|
|
3
3
|
module FuncBot
|
4
4
|
module Functions
|
5
5
|
class BaseFunction
|
6
|
-
attr_reader :
|
6
|
+
attr_reader :bot
|
7
7
|
|
8
|
-
def initialize(
|
9
|
-
@
|
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
|
@@ -3,11 +3,15 @@
|
|
3
3
|
module FuncBot
|
4
4
|
module Functions
|
5
5
|
class List
|
6
|
-
def self.call
|
7
|
-
if
|
8
|
-
|
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
|
-
|
14
|
+
[]
|
11
15
|
end
|
12
16
|
end
|
13
17
|
end
|
data/lib/func_bot/version.rb
CHANGED
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)
|