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

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

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of LlmProbe.



11
12
13
14
# File 'lib/legion/tty/background/llm_probe.rb', line 11

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

Instance Method Details

#run_async(queue) ⇒ Object



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

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