Module: RubyLLM::Providers::Azure::Models
- Included in:
- ChatCompletions
- Defined in:
- lib/ruby_llm/providers/azure/models.rb
Overview
Models methods of the Azure AI Foundry API integration
Instance Method Summary collapse
- #azure_inference_retired?(model_data) ⇒ Boolean
- #azure_modalities(capabilities) ⇒ Object
- #azure_model(model_data, slug) ⇒ Object
- #models_url ⇒ Object
-
#parse_list_models_response(response, slug) ⇒ Object
Azure reports the same id once per region it is offered in, and keeps returning models whose inference deprecation date has passed.
Instance Method Details
#azure_inference_retired?(model_data) ⇒ Boolean
21 22 23 24 |
# File 'lib/ruby_llm/providers/azure/models.rb', line 21 def azure_inference_retired?(model_data) retires_at = model_data.dig('deprecation', 'inference') retires_at.is_a?(Numeric) && Time.at(retires_at) < Time.now end |
#azure_modalities(capabilities) ⇒ Object
41 42 43 44 45 |
# File 'lib/ruby_llm/providers/azure/models.rb', line 41 def azure_modalities(capabilities) return { input: ['text'], output: ['embeddings'] } if capabilities['embeddings'] { input: ['text'], output: ['text'] } end |
#azure_model(model_data, slug) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ruby_llm/providers/azure/models.rb', line 26 def azure_model(model_data, slug) Model.new( id: model_data['id'], name: model_data['id'], provider: slug, created_at: model_data['created_at'] ? Time.at(model_data['created_at']) : nil, modalities: azure_modalities(model_data['capabilities'] || {}), metadata: { object: model_data['object'], lifecycle_status: model_data['lifecycle_status'], inference_retires_at: model_data.dig('deprecation', 'inference') }.compact ) end |
#models_url ⇒ Object
8 9 10 |
# File 'lib/ruby_llm/providers/azure/models.rb', line 8 def models_url azure_endpoint(:models) end |
#parse_list_models_response(response, slug) ⇒ Object
Azure reports the same id once per region it is offered in, and keeps returning models whose inference deprecation date has passed.
14 15 16 17 18 19 |
# File 'lib/ruby_llm/providers/azure/models.rb', line 14 def parse_list_models_response(response, slug) Array(response.body['data']) .uniq { |model_data| model_data['id'] } .reject { |model_data| azure_inference_retired?(model_data) } .map { |model_data| azure_model(model_data, slug) } end |