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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bef20237112478305bf9cdb8e787ac9f71b9e3c32c3349e27f5e5bfead02e182
4
- data.tar.gz: b14559042c705dede19698e6cd0a77eaaa95e7e8c098027e7965688f5135588f
3
+ metadata.gz: b6c52f4b0cd9b70b60f1e0a9ed50c752d440f17c4d3a638932976cb4796a64e6
4
+ data.tar.gz: 8c15bd8b3c71f42265f4ef4b7dbc98fae5297dde626d510f43a02cd952e2a069
5
5
  SHA512:
6
- metadata.gz: 12d20678d2c41ad9c5c2a27bf6a6fbe57cee1e70f68554c0f13fcf20ceb5b5fadee5762a9f4099db282cdd005df2d657b4e8dce16cbfcc5a39e51847731d7cda
7
- data.tar.gz: 7c4e14b09e87cf4ff7a2e6f7f679e19c6a62dc3be368c842959a683eafa6ea7d8ce73cc3f02311bb645a53a72c40cb8b7f3a9a8507f11dec3fe3fd259f90cc17
6
+ metadata.gz: aad7b1f18772c7b4407f86fd811141ee5c9c0cc4cddf1a5ca312a27c2f7096cb4502a6295d8c16ec0e5bfa740949faeb7f2d1106cf828f9445b5c80f31e4d2c1
7
+ data.tar.gz: 394c9b6b1d3f22320b3c151d8477912c34fa4e86c9e3a46a023983581d0325886a2abb6a5df536ba11c165a6d4e9454097528794122cd842cabb9a03111d75be
data/CHANGELOG.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Changelog
2
2
 
3
3
  ## Unreleased
4
+ ### [0.1.3] 2025-06-18
5
+ - tweaking the load all tools process
4
6
 
5
7
  ## Released
6
8
 
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative '../shared_tools'
4
+
3
5
  SharedTools.verify_gem :llm_rb
4
6
 
5
7
  Dir.glob(File.join(__dir__, "llm_rb", "*.rb")).each do |file|
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative '../shared_tools'
4
+
3
5
  SharedTools.verify_gem :omniai
4
6
 
5
7
  Dir.glob(File.join(__dir__, "omniai", "*.rb")).each do |file|
@@ -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
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../shared_tools'
4
+
5
+ SharedTools.verify_gem :raix
6
+
7
+ Dir.glob(File.join(__dir__, "raix", "*.rb")).each do |file|
8
+ require file
9
+ end
@@ -29,14 +29,9 @@ module SharedTools
29
29
  end
30
30
 
31
31
  # Show user the code and ask for confirmation
32
- puts "AI wants to execute the following Python code:"
33
- puts "=" * 50
34
- puts code
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
- puts "AI wants to execute the following Ruby code:"
31
- puts "=" * 50
32
- puts code
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
- puts "AI wants to execute the following shell command: '#{command}'"
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 response == "y"
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
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative '../shared_tools'
4
+
3
5
  SharedTools.verify_gem :ruby_llm
4
6
 
5
7
  Dir.glob(File.join(__dir__, "ruby_llm", "*.rb")).each do |file|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SharedTools
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
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
- @st_supported_gems = [:ruby_llm, :llm_rb, :omniai]
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 LLM provider API gem detected. Please require one of: #{@st_supported_gems.join(', ')} before requiring shared_tools."
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.2
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