Module: Legion::LLM::API::ModelCatalog
- Extended by:
- Legion::Logging::Helper
- Includes:
- Legion::Logging::Helper
- Defined in:
- lib/legion/llm/api/model_catalog.rb
Overview
Snapshot-only model catalog — §17.3 / D19 Copilot compatibility.
.list → frozen Array
The catalog iterates the supplied snapshot once and NEVER calls Router.next_lane, Ranker, or any callable. Selection, lane weight, and availability do not determine which models appear in the compat view — only publication completion, supported-operation evidence, and the §9.5 model policy (from settings_snapshot.model_policy_for) do.
X-Legion-Model is intentionally exempt from the body-hint policy evaluated here. This module handles only compat-view construction; it does NOT re-apply D19 body-hint logic during GET /v1/models listing.
Class Method Summary collapse
-
.fetch(id:, snapshot:, settings_snapshot:, dialect:) ⇒ Object
Returns the frozen dialect model object for
id, or nil when: - compat dialect: the model is not catalog-visible (body hint would be ignored or not whitelisted); auto-routing alias returns nil when the compat set is empty. -
.list(snapshot:, settings_snapshot:, dialect:) ⇒ Object
Returns a frozen Array
of model objects for the requested dialect.
Class Method Details
.fetch(id:, snapshot:, settings_snapshot:, dialect:) ⇒ Object
Returns the frozen dialect model object for id, or nil when:
- compat dialect: the model is not catalog-visible (body hint would be ignored or not whitelisted); auto-routing alias returns nil when the compat set is empty.
- native dialect: the id does not match any offering in the snapshot.
56 57 58 59 60 |
# File 'lib/legion/llm/api/model_catalog.rb', line 56 def self.fetch(id:, snapshot:, settings_snapshot:, dialect:) validate_dialect!(dialect) list(snapshot: snapshot, settings_snapshot: settings_snapshot, dialect: dialect) .find { |m| m[:id] == id.to_s } end |
.list(snapshot:, settings_snapshot:, dialect:) ⇒ Object
Returns a frozen Array
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/legion/llm/api/model_catalog.rb', line 39 def self.list(snapshot:, settings_snapshot:, dialect:) validate_dialect!(dialect) log.debug("[llm][model_catalog] action=list dialect=#{dialect} " \ "snapshot_generation=#{snapshot.generation} " \ "settings_generation=#{settings_snapshot.generation}") case dialect when :native then native_list(snapshot: snapshot) when :openai then compat_list(snapshot: snapshot, settings_snapshot: settings_snapshot, dialect: :openai) when :anthropic then compat_list(snapshot: snapshot, settings_snapshot: settings_snapshot, dialect: :anthropic) end end |