Class: Legion::Extensions::Llm::Routing::BodyModelHintDecision
- Inherits:
-
Data
- Object
- Data
- Legion::Extensions::Llm::Routing::BodyModelHintDecision
- Defined in:
- lib/legion/extensions/llm/routing/records.rb
Overview
The disposition of a body-supplied model hint. The record performs no matching and cannot dispatch. See section 15.6.
Instance Attribute Summary collapse
-
#disposition ⇒ Object
readonly
Returns the value of attribute disposition.
-
#matched_blacklist ⇒ Object
readonly
Returns the value of attribute matched_blacklist.
-
#matched_whitelist ⇒ Object
readonly
Returns the value of attribute matched_whitelist.
-
#model_constraint ⇒ Object
readonly
Returns the value of attribute model_constraint.
-
#requested_model ⇒ Object
readonly
Returns the value of attribute requested_model.
-
#settings_generation ⇒ Object
readonly
Returns the value of attribute settings_generation.
Instance Method Summary collapse
-
#initialize(**kwargs) ⇒ BodyModelHintDecision
constructor
A new instance of BodyModelHintDecision.
- #optional_text(value, field) ⇒ Object
- #validate_disposition_rules!(disposition, requested_model, model_constraint) ⇒ Object
Constructor Details
#initialize(**kwargs) ⇒ BodyModelHintDecision
Returns a new instance of BodyModelHintDecision.
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 |
# File 'lib/legion/extensions/llm/routing/records.rb', line 266 def initialize(**kwargs) kwargs = { model_constraint: nil, matched_whitelist: nil, matched_blacklist: nil }.merge(kwargs) Legion::Extensions::Llm::Inventory::RecordSupport.check_unknown_kwargs!(kwargs: kwargs, members: self.class.members) support = Legion::Extensions::Llm::Inventory::RecordSupport errors = Legion::Extensions::Llm::Inventory::Errors disposition = kwargs[:disposition] raise errors::ValidationError, 'invalid disposition' unless Legion::Extensions::Llm::Taxonomies::BODY_MODEL_HINT_DISPOSITIONS.include?(disposition) normalized_requested = optional_text(kwargs[:requested_model], :requested_model) normalized_constraint = optional_text(kwargs[:model_constraint], :model_constraint) validate_disposition_rules!(disposition, normalized_requested, normalized_constraint) super( requested_model: normalized_requested, disposition: disposition, model_constraint: normalized_constraint, matched_whitelist: optional_text(kwargs[:matched_whitelist], :matched_whitelist), matched_blacklist: optional_text(kwargs[:matched_blacklist], :matched_blacklist), settings_generation: support.nonnegative_integer(value: kwargs[:settings_generation], field: :settings_generation) ) end |
Instance Attribute Details
#disposition ⇒ Object (readonly)
Returns the value of attribute disposition
263 264 265 |
# File 'lib/legion/extensions/llm/routing/records.rb', line 263 def disposition @disposition end |
#matched_blacklist ⇒ Object (readonly)
Returns the value of attribute matched_blacklist
263 264 265 |
# File 'lib/legion/extensions/llm/routing/records.rb', line 263 def matched_blacklist @matched_blacklist end |
#matched_whitelist ⇒ Object (readonly)
Returns the value of attribute matched_whitelist
263 264 265 |
# File 'lib/legion/extensions/llm/routing/records.rb', line 263 def matched_whitelist @matched_whitelist end |
#model_constraint ⇒ Object (readonly)
Returns the value of attribute model_constraint
263 264 265 |
# File 'lib/legion/extensions/llm/routing/records.rb', line 263 def model_constraint @model_constraint end |
#requested_model ⇒ Object (readonly)
Returns the value of attribute requested_model
263 264 265 |
# File 'lib/legion/extensions/llm/routing/records.rb', line 263 def requested_model @requested_model end |
#settings_generation ⇒ Object (readonly)
Returns the value of attribute settings_generation
263 264 265 |
# File 'lib/legion/extensions/llm/routing/records.rb', line 263 def settings_generation @settings_generation end |
Instance Method Details
#optional_text(value, field) ⇒ Object
288 289 290 291 292 |
# File 'lib/legion/extensions/llm/routing/records.rb', line 288 def optional_text(value, field) return nil if value.nil? Legion::Extensions::Llm::Inventory::Identity.normalize_text(value: value, field: field) end |
#validate_disposition_rules!(disposition, requested_model, model_constraint) ⇒ Object
294 295 296 297 298 299 300 |
# File 'lib/legion/extensions/llm/routing/records.rb', line 294 def validate_disposition_rules!(disposition, requested_model, model_constraint) errors = Legion::Extensions::Llm::Inventory::Errors raise errors::ValidationError, 'only honored may carry a model_constraint' if disposition != :honored && !model_constraint.nil? return unless disposition == :absent && !requested_model.nil? raise errors::ValidationError, 'absent must carry a nil requested_model' end |