Module: Legion::Extensions::Llm::AzureFoundry::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)


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

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

.critical_capabilities_for(model) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/legion/extensions/llm/azure_foundry/provider.rb', line 26

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)


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

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

.functions?(model) ⇒ Boolean

Returns:

  • (Boolean)


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

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

.hash_model_id(model) ⇒ Object



41
42
43
44
45
46
# File 'lib/legion/extensions/llm/azure_foundry/provider.rb', line 41

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



35
36
37
38
39
# File 'lib/legion/extensions/llm/azure_foundry/provider.rb', line 35

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)


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

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

.usage_type(model) ⇒ Object



48
49
50
51
52
53
# File 'lib/legion/extensions/llm/azure_foundry/provider.rb', line 48

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)


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

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