39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/legion/llm/inventory.rb', line 39
def offerings(filters = {})
log.debug "[llm][inventory] action=offerings.enter filters=#{filters.keys}"
normalized_filters = normalize_filter_hash(filters)
provider_scope = normalized_filters[:provider]&.to_sym
list = []
providers_config.each do |provider_family, config|
next unless enabled_config?(config)
next if provider_scope && provider_family.to_sym != provider_scope
list.concat(provider_offerings(provider_family.to_sym, config))
end
native = native_provider_offerings(provider: provider_scope)
native_providers = native.map { |o| o[:provider_family]&.to_sym }.uniq
list.concat(native)
list.concat(discovery_offerings(provider: provider_scope, exclude_providers: native_providers))
list = dedupe_offerings(list)
result = filter_offerings(list, normalized_filters)
log.debug "[llm][inventory] action=offerings.complete total=#{result.size}"
result
rescue NameError, ArgumentError, TypeError => e
handle_exception(e, level: :error, handled: false, operation: 'llm.inventory.offerings')
raise
rescue StandardError => e
handle_exception(e, level: :warn, handled: true, operation: 'llm.inventory.offerings')
[]
end
|