Class: Legion::Extensions::Llm::AzureFoundry::Provider
Overview
Azure AI Foundry and Azure OpenAI hosted provider surface.
Offerings are produced ONLY by the discovery actor's writer path
(OfferingDraft + Registry publication, 07 C1-C5); the base read
path discover_offerings serves the activated inventory offerings
from the Registry snapshot (07 C5). The legacy offering
production path (and its capability-policy cascade) is gone.
Constant Summary
collapse
- DEFAULT_API_VERSION =
'2024-05-01-preview'
- MODEL_INFERENCE_SURFACE =
:model_inference
- OPENAI_V1_SURFACE =
:openai_v1
Instance Method Summary
collapse
capabilities, configuration_options, configuration_requirements, default_tier, default_transport, slug
#chat, #embed, #stream
Instance Method Details
#api_base ⇒ Object
116
117
118
119
120
121
122
|
# File 'lib/legion/extensions/llm/azure_foundry/provider.rb', line 116
def api_base
endpoint = config.azure_foundry_endpoint.to_s.sub(%r{/*\z}, '')
return "#{endpoint}/openai/v1" if surface == OPENAI_V1_SURFACE && !endpoint.end_with?('/openai/v1')
return endpoint.delete_suffix('/models') if surface == MODEL_INFERENCE_SURFACE
endpoint
end
|
#chat_url ⇒ Object
130
|
# File 'lib/legion/extensions/llm/azure_foundry/provider.rb', line 130
def chat_url = completion_url
|
#completion_url ⇒ Object
129
|
# File 'lib/legion/extensions/llm/azure_foundry/provider.rb', line 129
def completion_url = path_for('chat/completions')
|
#embedding_url ⇒ Object
133
|
# File 'lib/legion/extensions/llm/azure_foundry/provider.rb', line 133
def embedding_url(**) = path_for('embeddings')
|
124
125
126
127
|
# File 'lib/legion/extensions/llm/azure_foundry/provider.rb', line 124
def
.merge({ 'api-key' => config.azure_foundry_api_key,
'Authorization' => }.compact)
end
|
#health(live: false) ⇒ Object
136
137
138
139
140
141
142
143
144
145
146
147
|
# File 'lib/legion/extensions/llm/azure_foundry/provider.rb', line 136
def health(live: false)
log.info { "checking health live=#{live} at #{api_base}" }
baseline = health_baseline(live)
return baseline.merge(checked: false) unless live
response = connection.get(health_url)
baseline.merge(checked: true, ready: true, status: 'healthy', raw: response.body)
rescue StandardError => e
handle_exception(e, level: :warn, handled: true, operation: 'azure_foundry.health')
baseline.merge(checked: true, ready: false, status: 'unhealthy',
error: e.class.name, message: e.message)
end
|
#health_url ⇒ Object
134
|
# File 'lib/legion/extensions/llm/azure_foundry/provider.rb', line 134
def health_url = models_url
|
#model_id(model) ⇒ Object
154
155
156
|
# File 'lib/legion/extensions/llm/azure_foundry/provider.rb', line 154
def model_id(model)
model.respond_to?(:id) ? model.id : model.to_s
end
|
#models_url ⇒ Object
132
|
# File 'lib/legion/extensions/llm/azure_foundry/provider.rb', line 132
def models_url = surface == MODEL_INFERENCE_SURFACE ? path_for('info') : path_for('models')
|
#readiness(live: false) ⇒ Object
149
150
151
152
|
# File 'lib/legion/extensions/llm/azure_foundry/provider.rb', line 149
def readiness(live: false)
log.info { "checking readiness live=#{live} at #{api_base}" }
health(live: live).merge(local: false, remote: true, endpoints: endpoint_manifest)
end
|
#stream_url ⇒ Object
131
|
# File 'lib/legion/extensions/llm/azure_foundry/provider.rb', line 131
def stream_url = completion_url
|
#stream_usage_supported? ⇒ Boolean
114
|
# File 'lib/legion/extensions/llm/azure_foundry/provider.rb', line 114
def stream_usage_supported? = true
|