Class: Legion::CLI::Chat::Tools::SchedulingStatus
- Inherits:
-
Tools::Base
- Object
- Tools::Base
- Legion::CLI::Chat::Tools::SchedulingStatus
show all
- Defined in:
- lib/legion/cli/chat/tools/scheduling_status.rb
Class Method Summary
collapse
Methods inherited from Tools::Base
deferred, deferred?, description, error_response, extension, handle_exception, input_schema, log, mcp_category, mcp_tier, runner, sticky, tags, text_response, tool_name, trigger_words
Class Method Details
.batch_available? ⇒ Boolean
94
95
96
|
# File 'lib/legion/cli/chat/tools/scheduling_status.rb', line 94
def self.batch_available?
defined?(Legion::LLM::Batch)
end
|
.call(action: 'overview') ⇒ Object
19
20
21
22
23
24
25
|
# File 'lib/legion/cli/chat/tools/scheduling_status.rb', line 19
def self.call(action: 'overview')
case action.to_s
when 'scheduling' then format_scheduling
when 'batch' then format_batch
else format_overview
end
end
|
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/legion/cli/chat/tools/scheduling_status.rb', line 67
def self.format_batch
return 'Batch module not available.' unless batch_available?
b = Legion::LLM::Batch.status
lines = ["LLM Batch Queue Detail:\n"]
lines << format(' Enabled: %<v>s', v: b[:enabled])
lines << format(' Queue Size: %<v>d', v: b[:queue_size])
lines << format(' Max Batch Size: %<v>d', v: b[:max_batch_size])
lines << format(' Window (sec): %<v>d', v: b[:window_seconds])
lines << format(' Oldest Queued: %<v>s', v: b[:oldest_queued]) if b[:oldest_queued]
unless (b[:by_priority] || {}).empty?
lines << ''
lines << ' By Priority:'
b[:by_priority].each do |priority, count|
lines << format(' %<p>-10s %<c>d', p: priority, c: count)
end
end
lines.join("\n")
end
|
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/legion/cli/chat/tools/scheduling_status.rb', line 27
def self.format_overview
lines = ["LLM Scheduling & Batch Overview:\n"]
if scheduling_available?
s = Legion::LLM::Scheduling.status
lines << format(' Scheduling: %<v>s', v: s[:enabled] ? 'enabled' : 'disabled')
lines << format(' Peak Hours: %<v>s (%<r>s UTC)',
v: s[:peak_hours] ? 'YES (peak now)' : 'no (off-peak)',
r: s[:peak_range])
else
lines << ' Scheduling: not available'
end
lines << ''
if batch_available?
b = Legion::LLM::Batch.status
lines << format(' Batch Queue: %<v>s', v: b[:enabled] ? 'enabled' : 'disabled')
lines << format(' Queue Depth: %<v>d', v: b[:queue_size])
else
lines << ' Batch Queue: not available'
end
lines.join("\n")
end
|
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/legion/cli/chat/tools/scheduling_status.rb', line 53
def self.format_scheduling
return 'Scheduling module not available.' unless scheduling_available?
s = Legion::LLM::Scheduling.status
lines = ["LLM Scheduling Detail:\n"]
lines << format(' Enabled: %<v>s', v: s[:enabled])
lines << format(' Peak Hours Now: %<v>s', v: s[:peak_hours])
lines << format(' Peak Range (UTC): %<v>s', v: s[:peak_range])
lines << format(' Next Off-Peak: %<v>s', v: s[:next_off_peak])
lines << format(' Max Defer Hours: %<v>d', v: s[:max_defer_hours])
lines << format(' Defer Intents: %<v>s', v: Array(s[:defer_intents]).join(', '))
lines.join("\n")
end
|
.scheduling_available? ⇒ Boolean
90
91
92
|
# File 'lib/legion/cli/chat/tools/scheduling_status.rb', line 90
def self.scheduling_available?
defined?(Legion::LLM::Scheduling)
end
|