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

Parameters:



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_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



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

def additional_properties
  @additional_properties
end

#costArray<Vellum::Price> (readonly)

Returns:



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

def cost
  @cost
end

#usageArray<Vellum::MlModelUsageWrapper> (readonly)

Returns:



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

Parameters:

  • json_object (String)

Returns:



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

Parameters:

  • obj (Object)

Returns:

  • (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_jsonString

Returns:

  • (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