lex-llm-azure-foundry 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 93b2b78c6462da9e924d9de921741cc21a406b68d47879a23c21d26df0478e88
4
- data.tar.gz: a91ed47ace39e1a38db76d35a0475fb9332a60213cbf2bd4816a31fe988c58a6
3
+ metadata.gz: 279b43dc868c44a7b0f39f737cfff512ee6f5383097b886c5ceb77da7cbb6367
4
+ data.tar.gz: 8c6d1c95608344743ae5ebbf181cd9eb016dc389ddb88efb9a338bf7590112a4
5
5
  SHA512:
6
- metadata.gz: 58ec3150d974660d8f573f282fbafa1c2d5716c817453da7124fa2f1125852dacac0d388e34e406535a43178da29c20e3b5ccd00f54d39c3581bde2bc949cd19
7
- data.tar.gz: 1f53bccbe6444087c3269de7ad8d1a82ee00681dd4bf0670477b144dfb4994fe3a9f22c1738e067d38c0dcd4e1fe011ca243d6095adbeb28dc50ec9480d4a693
6
+ metadata.gz: 98254832116e7e04fc487d0477a791f0aac57fa2123035b87d8ca73d6e88c4691706f0ee23c95fdd8833db77898646ec21378d4eaf6faa799b46840d695732a4
7
+ data.tar.gz: fc8551e98c53413ad263b0e78903a24c2d1e2ee49822bba32a5a2e183d5a205af5e1fc00af80cd8f1b6501b02638f5a22286741ea800caf2267ad200438040f7
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.6] - 2026-05-01
4
+
5
+ - Require lex-llm >= 0.1.9 for the shared base contract
6
+ - Replace local RegistryPublisher and RegistryEventBuilder with base classes from lex-llm
7
+ - Delete local transport/ directory (exchange and message classes now live in lex-llm)
8
+ - Remove deprecated Provider.register call; use Configuration.register_provider_options directly
9
+ - Simplify default_settings to flat provider hash (no provider_settings builder)
10
+ - Fix Model::Info construction to use modalities_input/modalities_output keywords
11
+
3
12
  ## [0.1.5] - 2026-04-30
4
13
 
5
14
  - Audit all rescue blocks for handle_exception compliance across Provider, RegistryPublisher, and RegistryEventBuilder
@@ -26,5 +26,5 @@ Gem::Specification.new do |spec|
26
26
  spec.add_dependency 'legion-json', '>= 1.2.1'
27
27
  spec.add_dependency 'legion-logging', '>= 1.3.2'
28
28
  spec.add_dependency 'legion-settings', '>= 1.3.14'
29
- spec.add_dependency 'lex-llm', '>= 0.1.5'
29
+ spec.add_dependency 'lex-llm', '>= 0.2.0'
30
30
  end
@@ -17,8 +17,6 @@ module Legion
17
17
  OPENAI_V1_SURFACE = :openai_v1
18
18
 
19
19
  class << self
20
- attr_writer :registry_publisher
21
-
22
20
  def slug = 'azure_foundry'
23
21
  def configuration_requirements = %i[azure_foundry_endpoint]
24
22
 
@@ -36,7 +34,7 @@ module Legion
36
34
  def capabilities = Capabilities
37
35
 
38
36
  def registry_publisher
39
- @registry_publisher ||= RegistryPublisher.new
37
+ AzureFoundry.registry_publisher
40
38
  end
41
39
 
42
40
  def resolve_model_id(model_id, config: nil)
@@ -246,13 +244,15 @@ module Legion
246
244
 
247
245
  def model_info_from_offering(offering)
248
246
  capabilities = offering.capabilities.map(&:to_s)
247
+ modalities = modalities_for_capabilities(capabilities)
249
248
  Legion::Extensions::Llm::Model::Info.new(
250
249
  id: offering.model,
251
250
  name: offering.metadata[:canonical_model_alias] || offering.model,
252
251
  provider: :azure_foundry,
253
252
  family: offering.metadata[:model_family],
254
253
  capabilities: capabilities,
255
- modalities: modalities_for_capabilities(capabilities),
254
+ modalities_input: modalities[:input],
255
+ modalities_output: modalities[:output],
256
256
  metadata: offering.to_h
257
257
  )
258
258
  end
@@ -4,7 +4,7 @@ module Legion
4
4
  module Extensions
5
5
  module Llm
6
6
  module AzureFoundry
7
- VERSION = '0.1.5'
7
+ VERSION = '0.1.6'
8
8
  end
9
9
  end
10
10
  end
@@ -2,8 +2,6 @@
2
2
 
3
3
  require 'legion/extensions/llm'
4
4
  require 'legion/extensions/llm/azure_foundry/provider'
5
- require 'legion/extensions/llm/azure_foundry/registry_event_builder'
6
- require 'legion/extensions/llm/azure_foundry/registry_publisher'
7
5
  require 'legion/extensions/llm/azure_foundry/version'
8
6
 
9
7
  module Legion
@@ -17,34 +15,33 @@ module Legion
17
15
  PROVIDER_FAMILY = :azure_foundry
18
16
 
19
17
  def self.default_settings
20
- ::Legion::Extensions::Llm.provider_settings(
21
- family: PROVIDER_FAMILY,
22
- discovery: { enabled: true, live: false },
23
- instance: {
24
- endpoint: 'https://<resource>.services.ai.azure.com',
25
- api_version: '2024-05-01-preview',
26
- surface: :model_inference,
27
- tier: :frontier,
28
- transport: :http,
29
- credentials: {
30
- api_key: 'env://AZURE_INFERENCE_CREDENTIAL',
31
- bearer_token: 'env://AZURE_FOUNDRY_BEARER_TOKEN',
32
- entra_scope: 'https://cognitiveservices.azure.com/.default'
33
- },
34
- deployments: [],
35
- usage: { inference: true, embedding: true, token_counting: false },
36
- limits: { concurrency: 4 }
37
- }
38
- )
18
+ {
19
+ enabled: false,
20
+ default_model: nil,
21
+ endpoint: nil,
22
+ api_key: nil,
23
+ bearer_token: nil,
24
+ api_version: '2024-05-01-preview',
25
+ surface: nil,
26
+ deployments: [],
27
+ model_whitelist: [],
28
+ model_blacklist: [],
29
+ model_cache_ttl: 3600,
30
+ tls: { enabled: false, verify: :peer },
31
+ instances: {}
32
+ }
39
33
  end
40
34
 
41
35
  def self.provider_class
42
36
  Provider
43
37
  end
38
+
39
+ def self.registry_publisher
40
+ @registry_publisher ||= Legion::Extensions::Llm::RegistryPublisher.new(provider_family: PROVIDER_FAMILY)
41
+ end
42
+
43
+ Legion::Extensions::Llm::Configuration.register_provider_options(Provider.configuration_options)
44
44
  end
45
45
  end
46
46
  end
47
47
  end
48
-
49
- Legion::Extensions::Llm::Provider.register(Legion::Extensions::Llm::AzureFoundry::PROVIDER_FAMILY,
50
- Legion::Extensions::Llm::AzureFoundry::Provider)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lex-llm-azure-foundry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - LegionIO
@@ -57,14 +57,14 @@ dependencies:
57
57
  requirements:
58
58
  - - ">="
59
59
  - !ruby/object:Gem::Version
60
- version: 0.1.5
60
+ version: 0.2.0
61
61
  type: :runtime
62
62
  prerelease: false
63
63
  version_requirements: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - ">="
66
66
  - !ruby/object:Gem::Version
67
- version: 0.1.5
67
+ version: 0.2.0
68
68
  description: Azure AI Foundry and Azure OpenAI hosted provider integration for LegionIO
69
69
  LLM routing.
70
70
  email:
@@ -85,10 +85,6 @@ files:
85
85
  - lex-llm-azure-foundry.gemspec
86
86
  - lib/legion/extensions/llm/azure_foundry.rb
87
87
  - lib/legion/extensions/llm/azure_foundry/provider.rb
88
- - lib/legion/extensions/llm/azure_foundry/registry_event_builder.rb
89
- - lib/legion/extensions/llm/azure_foundry/registry_publisher.rb
90
- - lib/legion/extensions/llm/azure_foundry/transport/exchanges/llm_registry.rb
91
- - lib/legion/extensions/llm/azure_foundry/transport/messages/registry_event.rb
92
88
  - lib/legion/extensions/llm/azure_foundry/version.rb
93
89
  homepage: https://github.com/LegionIO/lex-llm-azure-foundry
94
90
  licenses:
@@ -1,129 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Legion
4
- module Extensions
5
- module Llm
6
- module AzureFoundry
7
- # Builds sanitized lex-llm registry envelopes for Azure Foundry provider state.
8
- class RegistryEventBuilder
9
- include Legion::Logging::Helper
10
-
11
- def readiness(readiness)
12
- registry_event_class.public_send(
13
- readiness[:ready] ? :available : :unavailable,
14
- provider_offering(readiness),
15
- runtime: runtime_metadata,
16
- health: readiness_health(readiness),
17
- metadata: readiness_metadata(readiness)
18
- )
19
- end
20
-
21
- def model_available(model, readiness:)
22
- registry_event_class.available(
23
- model_offering(model),
24
- runtime: runtime_metadata,
25
- health: model_health(readiness),
26
- metadata: model_metadata(model)
27
- )
28
- end
29
-
30
- private
31
-
32
- def provider_offering(readiness)
33
- {
34
- provider_family: :azure_foundry,
35
- provider_instance: provider_instance,
36
- transport: :http,
37
- model: 'provider-readiness',
38
- usage_type: :inference,
39
- capabilities: [],
40
- health: readiness_health(readiness),
41
- metadata: { lex: :llm_azure_foundry, provider_readiness: true }
42
- }
43
- end
44
-
45
- def model_offering(model)
46
- metadata = model.metadata if model.respond_to?(:metadata)
47
- return metadata if metadata.is_a?(Hash) && metadata[:provider_family]
48
-
49
- {
50
- provider_family: :azure_foundry,
51
- provider_instance: provider_instance,
52
- transport: :http,
53
- model: model.id,
54
- usage_type: usage_type_for(model),
55
- capabilities: Array(model.capabilities).map(&:to_sym),
56
- limits: model_limits(model),
57
- metadata: { lex: :llm_azure_foundry, model_name: model.name }.compact
58
- }
59
- end
60
-
61
- def readiness_health(readiness)
62
- health = {
63
- ready: readiness[:ready] == true,
64
- status: readiness[:ready] ? :available : :unavailable,
65
- checked: readiness.dig(:health, :checked) != false
66
- }
67
- add_readiness_error(health, readiness[:health])
68
- end
69
-
70
- def add_readiness_error(health, source)
71
- error = source.is_a?(Hash) ? source : {}
72
- error_class = error[:error] || error['error']
73
- error_message = error[:message] || error['message']
74
- health[:error_class] = error_class if error_class
75
- health[:error] = error_message if error_message
76
- health
77
- end
78
-
79
- def model_health(readiness)
80
- ready = readiness.fetch(:ready, true) == true
81
- { ready:, status: ready ? :available : :degraded }
82
- end
83
-
84
- def readiness_metadata(readiness)
85
- {
86
- extension: :lex_llm_azure_foundry,
87
- provider: :azure_foundry,
88
- configured: readiness[:configured] == true,
89
- live: readiness[:live] == true
90
- }
91
- end
92
-
93
- def model_metadata(model)
94
- { extension: :lex_llm_azure_foundry, provider: :azure_foundry, model_type: model.type }
95
- end
96
-
97
- def runtime_metadata
98
- { node: provider_instance }
99
- end
100
-
101
- def model_limits(model)
102
- {
103
- context_window: model.context_window,
104
- max_output_tokens: model.max_output_tokens
105
- }.compact
106
- end
107
-
108
- def usage_type_for(model)
109
- model.type == 'embedding' ? :embedding : :inference
110
- end
111
-
112
- def provider_instance
113
- configured_node = (::Legion::Settings.dig(:node, :canonical_name) if defined?(::Legion::Settings))
114
- value = configured_node.to_s.strip
115
- value.empty? ? :azure_foundry : value.to_sym
116
- rescue StandardError => e
117
- handle_exception(e, level: :debug, handled: true,
118
- operation: 'azure_foundry.registry.provider_instance')
119
- :azure_foundry
120
- end
121
-
122
- def registry_event_class
123
- ::Legion::Extensions::Llm::Routing::RegistryEvent
124
- end
125
- end
126
- end
127
- end
128
- end
129
- end
@@ -1,95 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Legion
4
- module Extensions
5
- module Llm
6
- module AzureFoundry
7
- # Best-effort publisher for Azure Foundry provider availability events.
8
- class RegistryPublisher
9
- include Legion::Logging::Helper
10
-
11
- APP_ID = 'lex-llm-azure-foundry'
12
-
13
- def initialize(builder: RegistryEventBuilder.new)
14
- @builder = builder
15
- end
16
-
17
- def publish_readiness_async(readiness)
18
- log.info { 'publishing readiness event to llm.registry' }
19
- schedule { publish_event(@builder.readiness(readiness)) }
20
- end
21
-
22
- def publish_models_async(models, readiness:)
23
- log.info { "publishing #{Array(models).size} model event(s) to llm.registry" }
24
- schedule do
25
- Array(models).each do |model|
26
- publish_event(@builder.model_available(model, readiness:))
27
- end
28
- end
29
- end
30
-
31
- private
32
-
33
- def schedule(&)
34
- return false unless publishing_available?
35
-
36
- Thread.new do
37
- Thread.current.abort_on_exception = false
38
- yield
39
- rescue StandardError => e
40
- handle_exception(e, level: :debug, handled: true, operation: 'azure_foundry.registry.schedule_thread')
41
- end
42
- rescue StandardError => e
43
- handle_exception(e, level: :debug, handled: true, operation: 'azure_foundry.registry.schedule')
44
- false
45
- end
46
-
47
- def publish_event(event)
48
- return false unless publishing_available?
49
-
50
- message_class.new(event:, app_id: APP_ID).publish(spool: false)
51
- rescue StandardError => e
52
- handle_exception(e, level: :warn, handled: true, operation: 'azure_foundry.registry.publish_event')
53
- false
54
- end
55
-
56
- def publishing_available?
57
- return false unless registry_event_available?
58
- return false unless transport_message_available?
59
- return true unless defined?(::Legion::Transport::Connection)
60
- return true unless ::Legion::Transport::Connection.respond_to?(:session_open?)
61
-
62
- ::Legion::Transport::Connection.session_open?
63
- rescue StandardError => e
64
- handle_exception(e, level: :debug, handled: true,
65
- operation: 'azure_foundry.registry.publishing_available?')
66
- false
67
- end
68
-
69
- def registry_event_available?
70
- defined?(::Legion::Extensions::Llm::Routing::RegistryEvent)
71
- end
72
-
73
- def transport_message_available?
74
- return true if message_class_defined?
75
- return false unless defined?(::Legion::Transport::Message) && defined?(::Legion::Transport::Exchange)
76
-
77
- require 'legion/extensions/llm/azure_foundry/transport/messages/registry_event'
78
- message_class_defined?
79
- rescue LoadError => e
80
- handle_exception(e, level: :debug, handled: true, operation: 'azure_foundry.registry.transport_load')
81
- false
82
- end
83
-
84
- def message_class_defined?
85
- defined?(::Legion::Extensions::Llm::AzureFoundry::Transport::Messages::RegistryEvent)
86
- end
87
-
88
- def message_class
89
- ::Legion::Extensions::Llm::AzureFoundry::Transport::Messages::RegistryEvent
90
- end
91
- end
92
- end
93
- end
94
- end
95
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Legion
4
- module Extensions
5
- module Llm
6
- module AzureFoundry
7
- module Transport
8
- module Exchanges
9
- # Topic exchange for Azure Foundry provider availability events.
10
- class LlmRegistry < ::Legion::Transport::Exchange
11
- def exchange_name
12
- 'llm.registry'
13
- end
14
-
15
- def default_type
16
- 'topic'
17
- end
18
- end
19
- end
20
- end
21
- end
22
- end
23
- end
24
- end
@@ -1,42 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'legion/extensions/llm/azure_foundry/transport/exchanges/llm_registry'
4
-
5
- module Legion
6
- module Extensions
7
- module Llm
8
- module AzureFoundry
9
- module Transport
10
- module Messages
11
- # Publishes lex-llm RegistryEvent envelopes to the llm.registry exchange.
12
- class RegistryEvent < ::Legion::Transport::Message
13
- def initialize(event:, **options)
14
- super(**event.to_h.merge(options))
15
- end
16
-
17
- def exchange
18
- Transport::Exchanges::LlmRegistry
19
- end
20
-
21
- def routing_key
22
- @options[:routing_key] || "llm.registry.#{@options.fetch(:event_type)}"
23
- end
24
-
25
- def type
26
- 'llm.registry.event'
27
- end
28
-
29
- def app_id
30
- @options[:app_id] || RegistryPublisher::APP_ID
31
- end
32
-
33
- def persistent # rubocop:disable Naming/PredicateMethod
34
- false
35
- end
36
- end
37
- end
38
- end
39
- end
40
- end
41
- end
42
- end