Class: Legion::CLI::Chat::Tools::WorkerStatus

Inherits:
RubyLLM::Tool
  • Object
show all
Defined in:
lib/legion/cli/chat/tools/worker_status.rb

Constant Summary collapse

DEFAULT_PORT =
4567
DEFAULT_HOST =
'127.0.0.1'

Instance Method Summary collapse

Instance Method Details

#execute(action: 'list', worker_id: nil, status_filter: nil) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/legion/cli/chat/tools/worker_status.rb', line 31

def execute(action: 'list', worker_id: nil, status_filter: nil)
  case action.to_s
  when 'show'
    return 'worker_id is required for the "show" action.' unless worker_id

    handle_show(worker_id.strip)
  when 'health'
    handle_health
  else
    handle_list(status_filter)
  end
rescue Errno::ECONNREFUSED
  'Legion daemon not running (cannot reach workers API).'
rescue StandardError => e
  Legion::Logging.warn("WorkerStatus#execute failed: #{e.message}") if defined?(Legion::Logging)
  "Error fetching worker data: #{e.message}"
end