Class: Nanobot::Agent::Tools::ScheduleAdd
- Inherits:
-
RubyLLM::Tool
- Object
- RubyLLM::Tool
- Nanobot::Agent::Tools::ScheduleAdd
- Defined in:
- lib/nanobot/agent/tools/schedule.rb
Overview
Tool for creating scheduled tasks
Instance Method Summary collapse
- #execute(kind:, expression:, prompt:, timezone: nil, deliver_channel: nil, deliver_chat_id: nil) ⇒ Object
-
#initialize(store:) ⇒ ScheduleAdd
constructor
A new instance of ScheduleAdd.
Constructor Details
#initialize(store:) ⇒ ScheduleAdd
Returns a new instance of ScheduleAdd.
24 25 26 27 |
# File 'lib/nanobot/agent/tools/schedule.rb', line 24 def initialize(store:) super() @store = store end |
Instance Method Details
#execute(kind:, expression:, prompt:, timezone: nil, deliver_channel: nil, deliver_chat_id: nil) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/nanobot/agent/tools/schedule.rb', line 29 def execute(kind:, expression:, prompt:, timezone: nil, deliver_channel: nil, deliver_chat_id: nil) deliver_to = { channel: deliver_channel, chat_id: deliver_chat_id } if deliver_channel && deliver_chat_id schedule = @store.add( kind: kind, expression: expression, prompt: prompt, timezone: timezone, deliver_to: deliver_to ) "Created schedule #{schedule.id} (#{schedule.kind}: #{schedule.expression}). " \ "Next run: #{schedule.next_run_at}" rescue ArgumentError => e "Error creating schedule: #{e.}" end |