shared_tools 0.1.2 → 0.1.3
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/CHANGELOG.md +2 -0
- data/lib/shared_tools/llm_rb.rb +2 -0
- data/lib/shared_tools/omniai.rb +2 -0
- data/lib/shared_tools/raix/what_is_the_weather.rb +18 -0
- data/lib/shared_tools/raix.rb +9 -0
- data/lib/shared_tools/ruby_llm/python_eval.rb +3 -8
- data/lib/shared_tools/ruby_llm/ruby_eval.rb +3 -8
- data/lib/shared_tools/ruby_llm/run_shell_command.rb +2 -4
- data/lib/shared_tools/ruby_llm.rb +2 -0
- data/lib/shared_tools/version.rb +1 -1
- data/lib/shared_tools.rb +26 -2
- metadata +17 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6c52f4b0cd9b70b60f1e0a9ed50c752d440f17c4d3a638932976cb4796a64e6
|
4
|
+
data.tar.gz: 8c15bd8b3c71f42265f4ef4b7dbc98fae5297dde626d510f43a02cd952e2a069
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aad7b1f18772c7b4407f86fd811141ee5c9c0cc4cddf1a5ca312a27c2f7096cb4502a6295d8c16ec0e5bfa740949faeb7f2d1106cf828f9445b5c80f31e4d2c1
|
7
|
+
data.tar.gz: 394c9b6b1d3f22320b3c151d8477912c34fa4e86c9e3a46a023983581d0325886a2abb6a5df536ba11c165a6d4e9454097528794122cd842cabb9a03111d75be
|
data/CHANGELOG.md
CHANGED
data/lib/shared_tools/llm_rb.rb
CHANGED
data/lib/shared_tools/omniai.rb
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../../shared_tools"
|
4
|
+
|
5
|
+
module SharedTools
|
6
|
+
verify_gem :ruby_llm
|
7
|
+
|
8
|
+
class WhatIsTheWeather
|
9
|
+
include Raix::ChatCompletion
|
10
|
+
include Raix::FunctionDispatch
|
11
|
+
|
12
|
+
function :check_weather,
|
13
|
+
"Check the weather for a location",
|
14
|
+
location: { type: "string", required: true } do |arguments|
|
15
|
+
"The weather in #{arguments[:location]} is hot and sunny"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -29,14 +29,9 @@ module SharedTools
|
|
29
29
|
end
|
30
30
|
|
31
31
|
# Show user the code and ask for confirmation
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
puts "=" * 50
|
36
|
-
print "Do you want to execute it? (y/n) "
|
37
|
-
response = gets.chomp.downcase
|
38
|
-
|
39
|
-
unless response == "y"
|
32
|
+
allowed = SharedTools.execute?(tool: self.class.name, stuff: code)
|
33
|
+
|
34
|
+
unless allowed
|
40
35
|
RubyLLM.logger.warn("User declined to execute the Python code")
|
41
36
|
return { error: "User declined to execute the Python code" }
|
42
37
|
end
|
@@ -27,14 +27,9 @@ module SharedTools
|
|
27
27
|
end
|
28
28
|
|
29
29
|
# Show user the code and ask for confirmation
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
puts "=" * 50
|
34
|
-
print "Do you want to execute it? (y/n) "
|
35
|
-
response = gets.chomp.downcase
|
36
|
-
|
37
|
-
unless response == "y"
|
30
|
+
allowed = SharedTools.execute?(tool: self.class.name, stuff: code)
|
31
|
+
|
32
|
+
unless allowed
|
38
33
|
RubyLLM.logger.warn("User declined to execute the Ruby code")
|
39
34
|
return { error: "User declined to execute the Ruby code" }
|
40
35
|
end
|
@@ -20,11 +20,9 @@ module SharedTools
|
|
20
20
|
end
|
21
21
|
|
22
22
|
# Show user the command and ask for confirmation
|
23
|
-
|
24
|
-
print "Do you want to execute it? (y/n) "
|
25
|
-
response = gets.chomp.downcase
|
23
|
+
allowed = SharedTools.execute?(tool: self.class.name, stuff: command)
|
26
24
|
|
27
|
-
unless
|
25
|
+
unless allowed
|
28
26
|
RubyLLM.logger.warn("User declined to execute the command: '#{command}'")
|
29
27
|
return { error: "User declined to execute the command" }
|
30
28
|
end
|
data/lib/shared_tools/version.rb
CHANGED
data/lib/shared_tools.rb
CHANGED
@@ -1,21 +1,45 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'io/console'
|
4
|
+
|
3
5
|
require "zeitwerk"
|
4
6
|
loader = Zeitwerk::Loader.for_gem
|
5
7
|
# Ignore aggregate loader files that don't define constants
|
6
8
|
loader.ignore("#{__dir__}/shared_tools/ruby_llm.rb")
|
7
9
|
loader.ignore("#{__dir__}/shared_tools/llm_rb.rb")
|
8
10
|
loader.ignore("#{__dir__}/shared_tools/omniai.rb")
|
11
|
+
loader.ignore("#{__dir__}/shared_tools/raix.rb")
|
9
12
|
loader.setup
|
10
13
|
|
11
14
|
module SharedTools
|
12
|
-
|
15
|
+
SUPPORTED_GEMS = %i(ruby_llm llm_rb omniai raix)
|
16
|
+
@auto_execute = false # Human in the loop
|
13
17
|
|
14
18
|
class << self
|
19
|
+
def auto_execute(wildwest=true)
|
20
|
+
@auto_execute = wildwest
|
21
|
+
end
|
22
|
+
|
23
|
+
def execute?(tool: 'unknown', stuff: '')
|
24
|
+
# Return true if auto_execute is explicitly enabled
|
25
|
+
return true if @auto_execute == true
|
26
|
+
|
27
|
+
puts "\n\nThe AI (tool: #{tool}) wants to do the following ..."
|
28
|
+
puts "="*42
|
29
|
+
puts(stuff.empty? ? "unknown strange and mysterious things" : stuff)
|
30
|
+
puts "="*42
|
31
|
+
|
32
|
+
sleep 0.2 if defined?(AIA) # Allows CLI spinner to recycle
|
33
|
+
print "\nIs it okay to proceed? (y/N"
|
34
|
+
STDIN.getch == "y"
|
35
|
+
end
|
36
|
+
|
37
|
+
|
15
38
|
def detected_gem
|
16
39
|
return :ruby_llm if defined?(::RubyLLM::Tool)
|
17
40
|
return :llm_rb if defined?(::LLM) || defined?(::Llm)
|
18
41
|
return :omniai if defined?(::OmniAI) || defined?(::Omniai)
|
42
|
+
return :raix if defined?(::Raix::FunctionDispatch)
|
19
43
|
nil
|
20
44
|
end
|
21
45
|
|
@@ -27,6 +51,6 @@ module SharedTools
|
|
27
51
|
end
|
28
52
|
|
29
53
|
if detected_gem.nil?
|
30
|
-
warn "⚠️ SharedTools: No supported
|
54
|
+
warn "⚠️ SharedTools: No supported gem detected. Supported gems are: #{SUPPORTED_GEMS.join(', ')}"
|
31
55
|
end
|
32
56
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shared_tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MadBomber Team
|
@@ -65,6 +65,20 @@ dependencies:
|
|
65
65
|
- - "~>"
|
66
66
|
- !ruby/object:Gem::Version
|
67
67
|
version: '2.0'
|
68
|
+
- !ruby/object:Gem::Dependency
|
69
|
+
name: raix
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
type: :development
|
76
|
+
prerelease: false
|
77
|
+
version_requirements: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
68
82
|
- !ruby/object:Gem::Dependency
|
69
83
|
name: ruby_llm
|
70
84
|
requirement: !ruby/object:Gem::Requirement
|
@@ -151,6 +165,8 @@ files:
|
|
151
165
|
- lib/shared_tools/llm_rb.rb
|
152
166
|
- lib/shared_tools/llm_rb/run_shell_command.rb
|
153
167
|
- lib/shared_tools/omniai.rb
|
168
|
+
- lib/shared_tools/raix.rb
|
169
|
+
- lib/shared_tools/raix/what_is_the_weather.rb
|
154
170
|
- lib/shared_tools/ruby_llm.rb
|
155
171
|
- lib/shared_tools/ruby_llm/edit_file.rb
|
156
172
|
- lib/shared_tools/ruby_llm/list_files.rb
|