Class: Legion::TTY::Background::LlmProbe

Inherits:
Object
  • Object
show all
Includes:
Logging::Helper
Defined in:
lib/legion/tty/background/llm_probe.rb

Constant Summary collapse

PROBE_PROMPT =
'Respond with only: pong'

Instance Method Summary collapse

Constructor Details

#initialize(logger: nil, wait_queue: nil) ⇒ LlmProbe

Returns a new instance of LlmProbe.



13
14
15
16
# File 'lib/legion/tty/background/llm_probe.rb', line 13

def initialize(logger: nil, wait_queue: nil)
  @boot_log = logger
  @wait_queue = wait_queue
end

Instance Method Details

#run_async(queue) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/legion/tty/background/llm_probe.rb', line 18

def run_async(queue)
  Thread.new do
    wait_for_bootstrap if @wait_queue
    result = probe_providers
    queue.push({ data: result })
  rescue StandardError => e
    @boot_log&.log('llm_probe', "error: #{e.message}")
    queue.push({ data: { providers: [], error: e.message } })
  end
end