Module: Legion::LLM::Inventory::Capabilities
- Defined in:
- lib/legion/llm/inventory/capabilities.rb
Constant Summary collapse
- ALIASES =
{ function_calling: :tools, functions: :tools, tool: :tools, tool_use: :tools, tool_calls: :tools, stream: :streaming, stream_chat: :streaming, responses_api: :responses }.freeze
Class Method Summary collapse
- .include_all?(available, required) ⇒ Boolean
- .merge(*sets) ⇒ Object
- .normalize(capabilities) ⇒ Object
Class Method Details
.include_all?(available, required) ⇒ Boolean
36 37 38 39 40 41 42 43 44 |
# File 'lib/legion/llm/inventory/capabilities.rb', line 36 def include_all?(available, required) required = normalize(required) return true if required.empty? normalized = normalize(available) return false if normalized.empty? required.all? { |capability| normalized.include?(capability) } end |
.merge(*sets) ⇒ Object
32 33 34 |
# File 'lib/legion/llm/inventory/capabilities.rb', line 32 def merge(*sets) sets.flat_map { |set| normalize(set) }.uniq end |
.normalize(capabilities) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/legion/llm/inventory/capabilities.rb', line 20 def normalize(capabilities) Array(capabilities).compact.each_with_object([]) do |capability, normalized| next unless capability.respond_to?(:to_s) sym = capability.to_s.downcase.strip.tr('-', '_').to_sym next if sym.to_s.empty? normalized << sym normalized << ALIASES[sym] if ALIASES[sym] end.uniq end |