Class: SharedTools::Tools::SystemInfoTool
- Inherits:
-
RubyLLM::Tool
- Object
- RubyLLM::Tool
- SharedTools::Tools::SystemInfoTool
- Defined in:
- lib/shared_tools/tools/system_info_tool.rb
Overview
Returns OS, CPU, memory, disk, network, and Ruby runtime information.
Class Method Summary collapse
Instance Method Summary collapse
-
#execute(category: 'all') ⇒ Hash
System information.
-
#initialize(logger: nil) ⇒ SystemInfoTool
constructor
A new instance of SystemInfoTool.
Constructor Details
#initialize(logger: nil) ⇒ SystemInfoTool
Returns a new instance of SystemInfoTool.
36 37 38 |
# File 'lib/shared_tools/tools/system_info_tool.rb', line 36 def initialize(logger: nil) @logger = logger || RubyLLM.logger end |
Class Method Details
.name ⇒ Object
14 |
# File 'lib/shared_tools/tools/system_info_tool.rb', line 14 def self.name = 'system_info_tool' |
Instance Method Details
#execute(category: 'all') ⇒ Hash
Returns system information.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/shared_tools/tools/system_info_tool.rb', line 42 def execute(category: 'all') @logger.info("SystemInfoTool#execute category=#{category}") case category.to_s.downcase when 'os' then { success: true }.merge(os_info) when 'cpu' then { success: true }.merge(cpu_info) when 'memory' then { success: true }.merge(memory_info) when 'disk' then { success: true }.merge(disk_info) when 'network' then { success: true }.merge(network_info) when 'ruby' then { success: true }.merge(ruby_info) else { success: true } .merge(os_info) .merge(cpu_info) .merge(memory_info) .merge(disk_info) .merge(network_info) .merge(ruby_info) end rescue => e @logger.error("SystemInfoTool error: #{e.}") { success: false, error: e. } end |