Class: Legion::Extensions::Llm::Vllm::Actor::DiscoveryRefresh
- Inherits:
-
Actors::Every
- Object
- Actors::Every
- Legion::Extensions::Llm::Vllm::Actor::DiscoveryRefresh
- Includes:
- Inventory::ScopedRefresher, Logging::Helper
- Defined in:
- lib/legion/extensions/llm/vllm/actors/discovery_refresh.rb
Overview
Periodic actor that refreshes the vLLM discovered model list.
Class Method Summary collapse
Instance Method Summary collapse
- #check_subtask? ⇒ Boolean
- #compute_lanes_for_scope ⇒ Object
- #credential_hash ⇒ Object
- #generate_task? ⇒ Boolean
- #manual ⇒ Object
- #offering_type(raw_type) ⇒ Object
- #run_now? ⇒ Boolean
- #runner_class ⇒ Object
- #runner_function ⇒ Object
- #scope_key ⇒ Object
- #time ⇒ Object
- #use_runner? ⇒ Boolean
- #vllm_cfg ⇒ Object
Class Method Details
.every_seconds ⇒ Object
32 |
# File 'lib/legion/extensions/llm/vllm/actors/discovery_refresh.rb', line 32 def self.every_seconds = 300 |
Instance Method Details
#check_subtask? ⇒ Boolean
38 |
# File 'lib/legion/extensions/llm/vllm/actors/discovery_refresh.rb', line 38 def check_subtask? = false |
#compute_lanes_for_scope ⇒ Object
57 58 59 60 61 62 63 64 |
# File 'lib/legion/extensions/llm/vllm/actors/discovery_refresh.rb', line 57 def compute_lanes_for_scope(**) return [] unless defined?(Legion::LLM::Call::Registry) vllm_instances.flat_map { |entry| lanes_from_instance(entry) } rescue StandardError => e handle_exception(e, level: :warn, handled: true, operation: 'vllm.actor.compute_lanes_for_scope') [] end |
#credential_hash ⇒ Object
66 67 68 69 70 71 |
# File 'lib/legion/extensions/llm/vllm/actors/discovery_refresh.rb', line 66 def credential_hash(**) cfg = vllm_cfg Digest::SHA256.hexdigest(cfg&.dig(:api_key).to_s + cfg&.dig(:instances).to_s)[0, 16] rescue StandardError 'unknown' end |
#generate_task? ⇒ Boolean
39 |
# File 'lib/legion/extensions/llm/vllm/actors/discovery_refresh.rb', line 39 def generate_task? = false |
#manual ⇒ Object
73 74 75 76 77 |
# File 'lib/legion/extensions/llm/vllm/actors/discovery_refresh.rb', line 73 def manual run_scoped_tick rescue StandardError => e handle_exception(e, level: :warn, handled: true, operation: 'vllm.actor.discovery_refresh') end |
#offering_type(raw_type) ⇒ Object
48 |
# File 'lib/legion/extensions/llm/vllm/actors/discovery_refresh.rb', line 48 def offering_type(raw_type) = %i[embed embedding].include?(raw_type) ? :embedding : :inference |
#run_now? ⇒ Boolean
36 |
# File 'lib/legion/extensions/llm/vllm/actors/discovery_refresh.rb', line 36 def run_now? = true |
#runner_class ⇒ Object
34 |
# File 'lib/legion/extensions/llm/vllm/actors/discovery_refresh.rb', line 34 def runner_class = self.class |
#runner_function ⇒ Object
35 |
# File 'lib/legion/extensions/llm/vllm/actors/discovery_refresh.rb', line 35 def runner_function = 'manual' |
#scope_key ⇒ Object
47 |
# File 'lib/legion/extensions/llm/vllm/actors/discovery_refresh.rb', line 47 def scope_key = { provider: :vllm } |
#time ⇒ Object
41 42 43 44 45 |
# File 'lib/legion/extensions/llm/vllm/actors/discovery_refresh.rb', line 41 def time return self.class.every_seconds unless defined?(Legion::Settings) Legion::Settings.dig(:extensions, :llm, :vllm, :discovery_interval) || self.class.every_seconds end |
#use_runner? ⇒ Boolean
37 |
# File 'lib/legion/extensions/llm/vllm/actors/discovery_refresh.rb', line 37 def use_runner? = false |