Class: SharedTools::Tools::CurrentDateTimeTool
- Inherits:
-
RubyLLM::Tool
- Object
- RubyLLM::Tool
- SharedTools::Tools::CurrentDateTimeTool
- Defined in:
- lib/shared_tools/tools/current_date_time_tool.rb
Overview
A tool that returns the current date, time, and timezone information. Useful for AI assistants that need to know the current time context.
Class Method Summary collapse
Instance Method Summary collapse
-
#execute(format: 'full') ⇒ Hash
Execute the date/time query.
-
#initialize(logger: nil) ⇒ CurrentDateTimeTool
constructor
A new instance of CurrentDateTimeTool.
Constructor Details
#initialize(logger: nil) ⇒ CurrentDateTimeTool
50 51 52 |
# File 'lib/shared_tools/tools/current_date_time_tool.rb', line 50 def initialize(logger: nil) @logger = logger || RubyLLM.logger end |
Class Method Details
.name ⇒ Object
18 |
# File 'lib/shared_tools/tools/current_date_time_tool.rb', line 18 def self.name = 'current_date_time' |
Instance Method Details
#execute(format: 'full') ⇒ Hash
Execute the date/time query
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/shared_tools/tools/current_date_time_tool.rb', line 58 def execute(format: 'full') @logger.info("DateTimeTool#execute format=#{format.inspect}") now = Time.now case format.to_s.downcase when 'date_only' date_only_response(now) when 'time_only' time_only_response(now) when 'iso8601' iso8601_response(now) else full_response(now) end end |