Class: Legion::Extensions::Llm::RegistryPublisher
- Inherits:
-
Object
- Object
- Legion::Extensions::Llm::RegistryPublisher
- Includes:
- Logging::Helper
- Defined in:
- lib/legion/extensions/llm/registry_publisher.rb
Overview
Best-effort publisher for LLM provider availability events. Parameterized by ‘provider_family` so each lex-llm-* gem can reuse this class without defining its own copy.
Constant Summary collapse
- ASYNC_THREAD_POOL =
Concurrent::FixedThreadPool.new(1, fallback_policy: :caller_runs)
Instance Attribute Summary collapse
-
#provider_family ⇒ Object
readonly
Returns the value of attribute provider_family.
Instance Method Summary collapse
- #app_id ⇒ Object
-
#initialize(provider_family:, builder: nil) ⇒ RegistryPublisher
constructor
A new instance of RegistryPublisher.
- #publish_models_async(models, readiness:) ⇒ Object
- #publish_readiness_async(readiness) ⇒ Object
Constructor Details
#initialize(provider_family:, builder: nil) ⇒ RegistryPublisher
Returns a new instance of RegistryPublisher.
18 19 20 21 |
# File 'lib/legion/extensions/llm/registry_publisher.rb', line 18 def initialize(provider_family:, builder: nil) @provider_family = provider_family.to_s.downcase.to_sym @builder = builder || RegistryEventBuilder.new(provider_family: @provider_family) end |
Instance Attribute Details
#provider_family ⇒ Object (readonly)
Returns the value of attribute provider_family.
16 17 18 |
# File 'lib/legion/extensions/llm/registry_publisher.rb', line 16 def provider_family @provider_family end |
Instance Method Details
#app_id ⇒ Object
23 24 25 |
# File 'lib/legion/extensions/llm/registry_publisher.rb', line 23 def app_id "lex-llm-#{provider_family}" end |
#publish_models_async(models, readiness:) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/legion/extensions/llm/registry_publisher.rb', line 32 def publish_models_async(models, readiness:) log.debug { "publishing #{Array(models).size} model event(s) to llm.registry for #{provider_family}" } schedule do Array(models).each do |model| publish_event(@builder.model_available(model, readiness:)) end end end |
#publish_readiness_async(readiness) ⇒ Object
27 28 29 30 |
# File 'lib/legion/extensions/llm/registry_publisher.rb', line 27 def publish_readiness_async(readiness) log.debug { "publishing readiness event to llm.registry for #{provider_family}" } schedule { publish_event(@builder.readiness(readiness)) } end |