Module: Legion::Extensions::Llm::AzureFoundry::Provider::Capabilities

Defined in:
lib/legion/extensions/llm/azure_foundry/provider.rb

Overview

Capability predicates inferred from deployment metadata and model naming.

Class Method Summary collapse

Class Method Details

.chat?(model) ⇒ Boolean

Returns:

  • (Boolean)


81
# File 'lib/legion/extensions/llm/azure_foundry/provider.rb', line 81

def chat?(model) = !embeddings?(model)

.critical_capabilities_for(model) ⇒ Object



87
88
89
90
91
92
93
94
# File 'lib/legion/extensions/llm/azure_foundry/provider.rb', line 87

def critical_capabilities_for(model)
  [
    ('streaming' if streaming?(model)),
    ('function_calling' if functions?(model)),
    ('vision' if vision?(model)),
    ('embeddings' if embeddings?(model))
  ].compact
end

.embeddings?(model) ⇒ Boolean

Returns:

  • (Boolean)


85
# File 'lib/legion/extensions/llm/azure_foundry/provider.rb', line 85

def embeddings?(model) = usage_type(model) == :embedding || model_id(model).match?(/embed/i)

.functions?(model) ⇒ Boolean

Returns:

  • (Boolean)


83
# File 'lib/legion/extensions/llm/azure_foundry/provider.rb', line 83

def functions?(model) = chat?(model)

.hash_model_id(model) ⇒ Object



102
103
104
105
106
107
# File 'lib/legion/extensions/llm/azure_foundry/provider.rb', line 102

def hash_model_id(model)
  %i[canonical_model_alias model deployment].each do |key|
    value = model[key] || model[key.to_s]
    return value.to_s if value
  end
end

.model_id(model) ⇒ Object



96
97
98
99
100
# File 'lib/legion/extensions/llm/azure_foundry/provider.rb', line 96

def model_id(model)
  return hash_model_id(model) if model.is_a?(Hash)

  model.respond_to?(:id) ? model.id.to_s : model.to_s
end

.streaming?(model) ⇒ Boolean

Returns:

  • (Boolean)


82
# File 'lib/legion/extensions/llm/azure_foundry/provider.rb', line 82

def streaming?(model) = chat?(model)

.usage_type(model) ⇒ Object



109
110
111
112
113
114
# File 'lib/legion/extensions/llm/azure_foundry/provider.rb', line 109

def usage_type(model)
  return nil unless model.is_a?(Hash)

  value = model[:usage_type] || model['usage_type'] || model[:type] || model['type']
  value&.to_sym
end

.vision?(model) ⇒ Boolean

Returns:

  • (Boolean)


84
# File 'lib/legion/extensions/llm/azure_foundry/provider.rb', line 84

def vision?(model) = chat?(model) && model_id(model).match?(/(gpt-4|gpt-5|llava|vision|phi-3.5)/i)