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.
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.
14 15 16 17 |
# File 'lib/legion/extensions/llm/registry_publisher.rb', line 14 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.
12 13 14 |
# File 'lib/legion/extensions/llm/registry_publisher.rb', line 12 def provider_family @provider_family end |
Instance Method Details
#app_id ⇒ Object
19 20 21 |
# File 'lib/legion/extensions/llm/registry_publisher.rb', line 19 def app_id "lex-llm-#{provider_family}" end |
#publish_models_async(models, readiness:) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/legion/extensions/llm/registry_publisher.rb', line 28 def publish_models_async(models, readiness:) log.info { "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
23 24 25 26 |
# File 'lib/legion/extensions/llm/registry_publisher.rb', line 23 def publish_readiness_async(readiness) log.info { "publishing readiness event to llm.registry for #{provider_family}" } schedule { publish_event(@builder.readiness(readiness)) } end |