Class: Smith::Workflow::UsageEntry

Inherits:
Struct
  • Object
show all
Defined in:
lib/smith/workflow/usage_entry.rb

Overview

One row per agent provider call. usage_id is a UUID generated at recording time and stable across persist/restore so hosts can use it as an idempotency anchor. rubocop:disable Style/RedundantStructKeywordInit

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#agent_nameObject

Returns the value of attribute agent_name

Returns:

  • (Object)

    the current value of agent_name



9
10
11
# File 'lib/smith/workflow/usage_entry.rb', line 9

def agent_name
  @agent_name
end

#attempt_kindObject

Returns the value of attribute attempt_kind

Returns:

  • (Object)

    the current value of attempt_kind



9
10
11
# File 'lib/smith/workflow/usage_entry.rb', line 9

def attempt_kind
  @attempt_kind
end

#costObject

Returns the value of attribute cost

Returns:

  • (Object)

    the current value of cost



9
10
11
# File 'lib/smith/workflow/usage_entry.rb', line 9

def cost
  @cost
end

#input_tokensObject

Returns the value of attribute input_tokens

Returns:

  • (Object)

    the current value of input_tokens



9
10
11
# File 'lib/smith/workflow/usage_entry.rb', line 9

def input_tokens
  @input_tokens
end

#modelObject

Returns the value of attribute model

Returns:

  • (Object)

    the current value of model



9
10
11
# File 'lib/smith/workflow/usage_entry.rb', line 9

def model
  @model
end

#output_tokensObject

Returns the value of attribute output_tokens

Returns:

  • (Object)

    the current value of output_tokens



9
10
11
# File 'lib/smith/workflow/usage_entry.rb', line 9

def output_tokens
  @output_tokens
end

#recorded_atObject

Returns the value of attribute recorded_at

Returns:

  • (Object)

    the current value of recorded_at



9
10
11
# File 'lib/smith/workflow/usage_entry.rb', line 9

def recorded_at
  @recorded_at
end

#usage_idObject

Returns the value of attribute usage_id

Returns:

  • (Object)

    the current value of usage_id



9
10
11
# File 'lib/smith/workflow/usage_entry.rb', line 9

def usage_id
  @usage_id
end

Class Method Details

.from_h(hash) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/smith/workflow/usage_entry.rb', line 20

def self.from_h(hash)
  sym = hash.transform_keys(&:to_sym)
  filtered = sym.slice(*members)
  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