Class: Legion::Extensions::Llm::AzureFoundry::Actor::DiscoveryRefresh
- Inherits:
-
Actors::Every
- Object
- Actors::Every
- Legion::Extensions::Llm::AzureFoundry::Actor::DiscoveryRefresh
- Includes:
- Inventory::ScopedRefresher, Logging::Helper
- Defined in:
- lib/legion/extensions/llm/azure_foundry/actors/discovery_refresh.rb
Overview
rubocop:disable Style/Documentation,Metrics/ClassLength
Constant Summary collapse
- EMBED_TYPES =
%i[embed embedding].freeze
Class Method Summary collapse
Instance Method Summary collapse
- #check_subtask? ⇒ Boolean
- #compute_lanes_for_scope ⇒ Object
- #credential_hash ⇒ Object
- #generate_task? ⇒ Boolean
-
#manual ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity.
- #run_now? ⇒ Boolean
- #runner_class ⇒ Object
- #runner_function ⇒ Object
- #scope_key ⇒ Object
- #time ⇒ Object
- #use_runner? ⇒ Boolean
Class Method Details
.every_seconds ⇒ Object
33 |
# File 'lib/legion/extensions/llm/azure_foundry/actors/discovery_refresh.rb', line 33 def self.every_seconds = 3600 |
Instance Method Details
#check_subtask? ⇒ Boolean
39 |
# File 'lib/legion/extensions/llm/azure_foundry/actors/discovery_refresh.rb', line 39 def check_subtask? = false |
#compute_lanes_for_scope ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/legion/extensions/llm/azure_foundry/actors/discovery_refresh.rb', line 70 def compute_lanes_for_scope(**) return [] unless defined?(Legion::LLM::Call::Registry) instances = Legion::LLM::Call::Registry.all_instances.select do |e| (e[:provider] || '').to_sym == :azure_foundry end lanes = [] instances.each { |entry| collect_instance_lanes(entry, lanes) } lanes rescue StandardError => e handle_exception(e, level: :warn, handled: true, operation: 'azure_foundry.compute_lanes_for_scope') [] end |
#credential_hash ⇒ Object
86 87 88 89 90 91 |
# File 'lib/legion/extensions/llm/azure_foundry/actors/discovery_refresh.rb', line 86 def credential_hash(**) settings = Legion::Settings.dig(:extensions, :llm, :azure_foundry) || {} ::Digest::SHA256.hexdigest(settings[:api_key].to_s + settings[:instances].to_s)[0, 16] rescue StandardError 'unknown' end |
#generate_task? ⇒ Boolean
40 |
# File 'lib/legion/extensions/llm/azure_foundry/actors/discovery_refresh.rb', line 40 def generate_task? = false |
#manual ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/legion/extensions/llm/azure_foundry/actors/discovery_refresh.rb', line 48 def manual # rubocop:disable Metrics/CyclomaticComplexity log.debug('[azure_foundry][discovery_refresh] refreshing model list') tick if respond_to?(:tick) return unless defined?(Legion::LLM::Discovery) Legion::LLM::Discovery.refresh_discovered_models!(provider: :azure_foundry) if defined?(Legion::LLM::Router) && Legion::LLM::Router.respond_to?(:populate_auto_rules) Legion::LLM::Router.populate_auto_rules(Legion::LLM::Discovery.discovered_instances) end if defined?(Legion::LLM::Inventory) && Legion::LLM::Inventory.respond_to?(:invalidate_offerings_cache!) Legion::LLM::Inventory.invalidate_offerings_cache! end rescue StandardError => e handle_exception(e, level: :warn, handled: true, operation: 'azure_foundry.actor.discovery_refresh') end |
#run_now? ⇒ Boolean
37 |
# File 'lib/legion/extensions/llm/azure_foundry/actors/discovery_refresh.rb', line 37 def run_now? = true |
#runner_class ⇒ Object
35 |
# File 'lib/legion/extensions/llm/azure_foundry/actors/discovery_refresh.rb', line 35 def runner_class = self.class |
#runner_function ⇒ Object
36 |
# File 'lib/legion/extensions/llm/azure_foundry/actors/discovery_refresh.rb', line 36 def runner_function = 'manual' |
#scope_key ⇒ Object
66 67 68 |
# File 'lib/legion/extensions/llm/azure_foundry/actors/discovery_refresh.rb', line 66 def scope_key(**) { provider: :azure_foundry } end |
#time ⇒ Object
42 43 44 45 46 |
# File 'lib/legion/extensions/llm/azure_foundry/actors/discovery_refresh.rb', line 42 def time return self.class.every_seconds unless defined?(Legion::Settings) Legion::Settings.dig(:extensions, :llm, :azure_foundry, :discovery_interval) || self.class.every_seconds end |
#use_runner? ⇒ Boolean
38 |
# File 'lib/legion/extensions/llm/azure_foundry/actors/discovery_refresh.rb', line 38 def use_runner? = false |