Class: Legion::Extensions::Llm::Routing::Exclusion
- Inherits:
-
Data
- Object
- Data
- Legion::Extensions::Llm::Routing::Exclusion
- Defined in:
- lib/legion/extensions/llm/routing/records.rb
Overview
A request-local or attempt-group exclusion of a typed target. See 15.3.
Instance Attribute Summary collapse
-
#evidence ⇒ Object
readonly
Returns the value of attribute evidence.
-
#lifetime ⇒ Object
readonly
Returns the value of attribute lifetime.
-
#reason ⇒ Object
readonly
Returns the value of attribute reason.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
-
#target_kind ⇒ Object
readonly
Returns the value of attribute target_kind.
Instance Method Summary collapse
-
#initialize(target_kind:, target:, reason:, evidence:, lifetime:) ⇒ Exclusion
constructor
A new instance of Exclusion.
- #normalize_target(target_kind, target) ⇒ Object
Constructor Details
#initialize(target_kind:, target:, reason:, evidence:, lifetime:) ⇒ Exclusion
Returns a new instance of Exclusion.
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/legion/extensions/llm/routing/records.rb', line 48 def initialize(target_kind:, target:, reason:, evidence:, lifetime:) raise Legion::Extensions::Llm::Inventory::Errors::ValidationError, 'invalid target_kind' unless Legion::Extensions::Llm::Taxonomies::EXCLUSION_TARGET_KINDS.include?(target_kind) raise Legion::Extensions::Llm::Inventory::Errors::ValidationError, 'invalid lifetime' unless Legion::Extensions::Llm::Taxonomies::EXCLUSION_LIFETIMES.include?(lifetime) super( target_kind: target_kind, target: normalize_target(target_kind, target), reason: Legion::Extensions::Llm::Inventory::RecordSupport.sanitized_reason(value: reason, field: :reason), evidence: Legion::Extensions::Llm::Inventory::ImmutableValue.copy_and_freeze(value: evidence, field: :evidence), lifetime: lifetime ) end |
Instance Attribute Details
#evidence ⇒ Object (readonly)
Returns the value of attribute evidence
47 48 49 |
# File 'lib/legion/extensions/llm/routing/records.rb', line 47 def evidence @evidence end |
#lifetime ⇒ Object (readonly)
Returns the value of attribute lifetime
47 48 49 |
# File 'lib/legion/extensions/llm/routing/records.rb', line 47 def lifetime @lifetime end |
#reason ⇒ Object (readonly)
Returns the value of attribute reason
47 48 49 |
# File 'lib/legion/extensions/llm/routing/records.rb', line 47 def reason @reason end |
#target ⇒ Object (readonly)
Returns the value of attribute target
47 48 49 |
# File 'lib/legion/extensions/llm/routing/records.rb', line 47 def target @target end |
#target_kind ⇒ Object (readonly)
Returns the value of attribute target_kind
47 48 49 |
# File 'lib/legion/extensions/llm/routing/records.rb', line 47 def target_kind @target_kind end |
Instance Method Details
#normalize_target(target_kind, target) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/legion/extensions/llm/routing/records.rb', line 61 def normalize_target(target_kind, target) errors = Legion::Extensions::Llm::Inventory::Errors case target_kind when :attempt_target raise errors::ValidationError, 'attempt_target target must be an AttemptTargetKey' unless target.is_a?(AttemptTargetKey) target when :instance raise errors::ValidationError, 'instance target must be an InstanceKey' unless target.is_a?(Legion::Extensions::Llm::Inventory::Identity::InstanceKey) target when :quota_domain raise errors::ValidationError, 'quota_domain target must be a QuotaDomainKey' unless target.is_a?(QuotaDomainKey) target when :provider Legion::Extensions::Llm::Inventory::RecordSupport.normalize_provider_family(value: target, field: :target) else # :lane, :offering, :model Legion::Extensions::Llm::Inventory::Identity.normalize_text(value: target, field: target_kind) end end |