Class: Smith::Workflow::Composite::Effects
- Inherits:
-
Payload
- Object
- Dry::Struct
- Payload
- Smith::Workflow::Composite::Effects
- Defined in:
- lib/smith/workflow/composite/effects.rb
Overview
Length is fail-closed value validation, not logic: every key the contract admits gets a bounded value check beside the contract that admits it. Splitting the checks away from the payload they guard would trade cohesion for a metric.
Constant Summary
Constants inherited from Payload
Instance Attribute Summary collapse
-
#total_cost ⇒ Object
readonly
rubocop:disable Metrics/ClassLength.
-
#total_tokens ⇒ Object
readonly
rubocop:disable Metrics/ClassLength.
Instance Method Summary collapse
-
#initialize(attributes) ⇒ Effects
constructor
A new instance of Effects.
Constructor Details
#initialize(attributes) ⇒ Effects
Returns a new instance of Effects.
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/smith/workflow/composite/effects.rb', line 38 def initialize(attributes) owned = self.class.normalize_attributes(attributes) normalized = MessageValueNormalizer.new(owned, label: "composite effects").call usage_entries, tool_results, budget_consumed = normalized.values_at("usage_entries", "tool_results", "budget_consumed") @total_tokens, @total_cost = validate_usage_entries!(usage_entries) validate_tool_results!(tool_results) validate_budget!(budget_consumed) super(usage_entries:, tool_results:, budget_consumed:) end |
Instance Attribute Details
#total_cost ⇒ Object (readonly)
rubocop:disable Metrics/ClassLength
18 19 20 |
# File 'lib/smith/workflow/composite/effects.rb', line 18 def total_cost @total_cost end |
#total_tokens ⇒ Object (readonly)
rubocop:disable Metrics/ClassLength
18 19 20 |
# File 'lib/smith/workflow/composite/effects.rb', line 18 def total_tokens @total_tokens end |