Class: Smith::Workflow::UsageEntry
- Inherits:
-
Struct
- Object
- Struct
- Smith::Workflow::UsageEntry
- Defined in:
- lib/smith/workflow.rb
Overview
One row per agent provider call. ‘usage_id` is a UUID generated at recording time and stable across persist/restore — hadithi uses it as the idempotency anchor on `usage_events.smith_usage_id`. Includes `to_h`/`from_h` for JSON serialization (plain Struct JSON-encodes to `“#<struct …>”` — useless).
keyword_init: true gives forward/backward compatibility:
-
Adding a new field: old persisted hashes restore cleanly (new field defaults to nil).
-
Reading new persisted hashes with an older Smith version: from_h slices to known members (unknown keys silently dropped).
Instance Attribute Summary collapse
-
#agent_name ⇒ Object
Returns the value of attribute agent_name.
-
#attempt_kind ⇒ Object
Returns the value of attribute attempt_kind.
-
#cost ⇒ Object
Returns the value of attribute cost.
-
#input_tokens ⇒ Object
Returns the value of attribute input_tokens.
-
#model ⇒ Object
Returns the value of attribute model.
-
#output_tokens ⇒ Object
Returns the value of attribute output_tokens.
-
#recorded_at ⇒ Object
Returns the value of attribute recorded_at.
-
#usage_id ⇒ Object
Returns the value of attribute usage_id.
Class Method Summary collapse
Instance Attribute Details
#agent_name ⇒ Object
Returns the value of attribute agent_name
109 110 111 |
# File 'lib/smith/workflow.rb', line 109 def agent_name @agent_name end |
#attempt_kind ⇒ Object
Returns the value of attribute attempt_kind
109 110 111 |
# File 'lib/smith/workflow.rb', line 109 def attempt_kind @attempt_kind end |
#cost ⇒ Object
Returns the value of attribute cost
109 110 111 |
# File 'lib/smith/workflow.rb', line 109 def cost @cost end |
#input_tokens ⇒ Object
Returns the value of attribute input_tokens
109 110 111 |
# File 'lib/smith/workflow.rb', line 109 def input_tokens @input_tokens end |
#model ⇒ Object
Returns the value of attribute model
109 110 111 |
# File 'lib/smith/workflow.rb', line 109 def model @model end |
#output_tokens ⇒ Object
Returns the value of attribute output_tokens
109 110 111 |
# File 'lib/smith/workflow.rb', line 109 def output_tokens @output_tokens end |
#recorded_at ⇒ Object
Returns the value of attribute recorded_at
109 110 111 |
# File 'lib/smith/workflow.rb', line 109 def recorded_at @recorded_at end |
#usage_id ⇒ Object
Returns the value of attribute usage_id
109 110 111 |
# File 'lib/smith/workflow.rb', line 109 def usage_id @usage_id end |
Class Method Details
.from_h(hash) ⇒ Object
120 121 122 123 124 125 126 127 128 |
# File 'lib/smith/workflow.rb', line 120 def self.from_h(hash) sym = hash.transform_keys(&:to_sym) filtered = sym.slice(*members) # Symbolize :agent_name and :attempt_kind for backward compat # with callers that consume the field as Symbol. filtered[:agent_name] = filtered[:agent_name].to_sym if filtered[:agent_name].is_a?(String) filtered[:attempt_kind] = filtered[:attempt_kind].to_sym if filtered[:attempt_kind].is_a?(String) new(**filtered) end |