Module: Legion::LLM::Capabilities
- Defined in:
- lib/legion/llm/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
35 36 37 38 39 40 41 42 43 |
# File 'lib/legion/llm/capabilities.rb', line 35 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
31 32 33 |
# File 'lib/legion/llm/capabilities.rb', line 31 def merge(*sets) sets.flat_map { |set| normalize(set) }.uniq end |
.normalize(capabilities) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/legion/llm/capabilities.rb', line 19 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 |