Module: Legion::LLM::Router::RequiredCapabilities
- Extended by:
- Legion::Logging::Helper
- Includes:
- Legion::Logging::Helper
- Defined in:
- lib/legion/llm/router/required_capabilities.rb
Overview
Sole request-shape-to-capability derivation (SSOT v3 §9.2).
This is the ONLY place that maps a canonical Inference::Request to a set of routing capability requirements. No route handler, translator, payload builder, executor step, embedding helper, or provider adapter independently derives routing capabilities.
The HTTP dialect that produced the request (OpenAI, Anthropic, native) is invisible here. In particular, the OpenAI Responses dialect DOES NOT add a :responses capability — canonical chat/stream_chat operations flow through ordinary operation evidence.
Constant Summary collapse
- OPERATION_BASE =
Base capabilities required by each operation, independent of request shape.
{ chat: [].freeze, stream_chat: %i[streaming].freeze, embed: %i[embedding].freeze, image: %i[image].freeze, transcribe: %i[audio_transcription].freeze, translate: [].freeze, speak: %i[audio_speech].freeze, moderate: %i[moderation].freeze, count_tokens: [].freeze }.freeze
Class Method Summary collapse
-
.call(request:, operation:) ⇒ Array<Symbol>
Derive the complete frozen capability requirement set for a canonical request.
Class Method Details
.call(request:, operation:) ⇒ Array<Symbol>
Derive the complete frozen capability requirement set for a canonical request.
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/legion/llm/router/required_capabilities.rb', line 43 def call(request:, operation:) caps = OPERATION_BASE.fetch(operation, []).dup caps << :tools if tools_required?(request) caps << :thinking if thinking_required?(request) caps << :vision if vision_required?(request) caps << :structured_output if structured_output_required?(request) result = Legion::Extensions::Llm::Capabilities.normalize(caps) log.debug("[llm][required_capabilities] action=derive operation=#{operation} caps=#{result.inspect}") result end |