Class: Vellum::WorkflowExecutionUsageCalculationFulfilledBody

Inherits:
Object
  • Object
show all
Defined in:
lib/vellum_ai/types/workflow_execution_usage_calculation_fulfilled_body.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(usage:, cost:, additional_properties: nil) ⇒ Vellum::WorkflowExecutionUsageCalculationFulfilledBody



25
26
27
28
29
30
# File 'lib/vellum_ai/types/workflow_execution_usage_calculation_fulfilled_body.rb', line 25

def initialize(usage:, cost:, additional_properties: nil)
  @usage = usage
  @cost = cost
  @additional_properties = additional_properties
  @_field_set = { "usage": usage, "cost": cost }
end

Instance Attribute Details

#additional_properties ⇒ OpenStruct (readonly)



14
15
16
# File 'lib/vellum_ai/types/workflow_execution_usage_calculation_fulfilled_body.rb', line 14

def additional_properties
  @additional_properties
end

#cost ⇒ Array<Vellum::Price> (readonly)



12
13
14
# File 'lib/vellum_ai/types/workflow_execution_usage_calculation_fulfilled_body.rb', line 12

def cost
  @cost
end

#usage ⇒ Array<Vellum::MlModelUsageWrapper> (readonly)



10
11
12
# File 'lib/vellum_ai/types/workflow_execution_usage_calculation_fulfilled_body.rb', line 10

def usage
  @usage
end

Class Method Details

.from_json(json_object:) ⇒ Vellum::WorkflowExecutionUsageCalculationFulfilledBody



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/vellum_ai/types/workflow_execution_usage_calculation_fulfilled_body.rb', line 36

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  usage = parsed_json["usage"]&.map do | item |
  item = item.to_json
  Vellum::MlModelUsageWrapper.from_json(json_object: item)
end
  cost = parsed_json["cost"]&.map do | item |
  item = item.to_json
  Vellum::Price.from_json(json_object: item)
end
  new(
    usage: usage,
    cost: cost,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void



66
67
68
69
# File 'lib/vellum_ai/types/workflow_execution_usage_calculation_fulfilled_body.rb', line 66

def self.validate_raw(obj:)
  obj.usage.is_a?(Array) != false || raise("Passed value for field obj.usage is not the expected type, validation failed.")
  obj.cost.is_a?(Array) != false || raise("Passed value for field obj.cost is not the expected type, validation failed.")
end

Instance Method Details

#to_json ⇒ String



57
58
59
# File 'lib/vellum_ai/types/workflow_execution_usage_calculation_fulfilled_body.rb', line 57

def to_json
  @_field_set&.to_json
end