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.
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 |
# File 'lib/legion/extensions/llm/routing/records.rb', line 249 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
246 247 248 |
# File 'lib/legion/extensions/llm/routing/records.rb', line 246 def disposition @disposition end |
#matched_blacklist ⇒ Object (readonly)
Returns the value of attribute matched_blacklist
246 247 248 |
# File 'lib/legion/extensions/llm/routing/records.rb', line 246 def matched_blacklist @matched_blacklist end |
#matched_whitelist ⇒ Object (readonly)
Returns the value of attribute matched_whitelist
246 247 248 |
# File 'lib/legion/extensions/llm/routing/records.rb', line 246 def matched_whitelist @matched_whitelist end |
#model_constraint ⇒ Object (readonly)
Returns the value of attribute model_constraint
246 247 248 |
# File 'lib/legion/extensions/llm/routing/records.rb', line 246 def model_constraint @model_constraint end |
#requested_model ⇒ Object (readonly)
Returns the value of attribute requested_model
246 247 248 |
# File 'lib/legion/extensions/llm/routing/records.rb', line 246 def requested_model @requested_model end |
#settings_generation ⇒ Object (readonly)
Returns the value of attribute settings_generation
246 247 248 |
# File 'lib/legion/extensions/llm/routing/records.rb', line 246 def settings_generation @settings_generation end |
Instance Method Details
#optional_text(value, field) ⇒ Object
271 272 273 274 275 |
# File 'lib/legion/extensions/llm/routing/records.rb', line 271 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
277 278 279 280 281 282 283 |
# File 'lib/legion/extensions/llm/routing/records.rb', line 277 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 |