Class: Vellum::WorkflowExecutionUsageResult

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(usage: OMIT, cost: OMIT, error: OMIT, additional_properties: nil) ⇒ Vellum::WorkflowExecutionUsageResult

Parameters:



29
30
31
32
33
34
35
36
37
# File 'lib/vellum_ai/types/workflow_execution_usage_result.rb', line 29

def initialize(usage: OMIT, cost: OMIT, error: OMIT, additional_properties: nil)
  @usage = usage if usage != OMIT
  @cost = cost if cost != OMIT
  @error = error if error != OMIT
  @additional_properties = additional_properties
  @_field_set = { "usage": usage, "cost": cost, "error": error }.reject do | _k, v |
  v == OMIT
end
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



17
18
19
# File 'lib/vellum_ai/types/workflow_execution_usage_result.rb', line 17

def additional_properties
  @additional_properties
end

#costArray<Vellum::Price> (readonly)

Returns:



13
14
15
# File 'lib/vellum_ai/types/workflow_execution_usage_result.rb', line 13

def cost
  @cost
end

#errorVellum::WorkflowExecutionUsageCalculationError (readonly)



15
16
17
# File 'lib/vellum_ai/types/workflow_execution_usage_result.rb', line 15

def error
  @error
end

#usageArray<Vellum::MlModelUsageWrapper> (readonly)

Returns:



11
12
13
# File 'lib/vellum_ai/types/workflow_execution_usage_result.rb', line 11

def usage
  @usage
end

Class Method Details

.from_json(json_object:) ⇒ Vellum::WorkflowExecutionUsageResult

Parameters:

  • json_object (String)

Returns:



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/vellum_ai/types/workflow_execution_usage_result.rb', line 42

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
  unless parsed_json["error"].nil?
    error = parsed_json["error"].to_json
    error = Vellum::WorkflowExecutionUsageCalculationError.from_json(json_object: error)
  else
    error = nil
  end
  new(
    usage: usage,
    cost: cost,
    error: error,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


78
79
80
81
82
# File 'lib/vellum_ai/types/workflow_execution_usage_result.rb', line 78

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.")
  obj.error.nil? || Vellum::WorkflowExecutionUsageCalculationError.validate_raw(obj: obj.error)
end

Instance Method Details

#to_jsonString

Returns:

  • (String)


69
70
71
# File 'lib/vellum_ai/types/workflow_execution_usage_result.rb', line 69

def to_json
  @_field_set&.to_json
end