Class: Vellum::WorkflowExecutionUsageResult
- Inherits:
-
Object
- Object
- Vellum::WorkflowExecutionUsageResult
- Defined in:
- lib/vellum_ai/types/workflow_execution_usage_result.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
- #cost ⇒ Array<Vellum::Price> readonly
- #error ⇒ Vellum::WorkflowExecutionUsageCalculationError readonly
- #usage ⇒ Array<Vellum::MlModelUsageWrapper> readonly
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(usage: OMIT, cost: OMIT, error: OMIT, additional_properties: nil) ⇒ Vellum::WorkflowExecutionUsageResult constructor
- #to_json ⇒ String
Constructor Details
#initialize(usage: OMIT, cost: OMIT, error: OMIT, additional_properties: nil) ⇒ Vellum::WorkflowExecutionUsageResult
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_properties ⇒ OpenStruct (readonly)
Returns 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 |
#cost ⇒ Array<Vellum::Price> (readonly)
13 14 15 |
# File 'lib/vellum_ai/types/workflow_execution_usage_result.rb', line 13 def cost @cost end |
#error ⇒ Vellum::WorkflowExecutionUsageCalculationError (readonly)
15 16 17 |
# File 'lib/vellum_ai/types/workflow_execution_usage_result.rb', line 15 def error @error end |
#usage ⇒ Array<Vellum::MlModelUsageWrapper> (readonly)
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
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
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_json ⇒ String
69 70 71 |
# File 'lib/vellum_ai/types/workflow_execution_usage_result.rb', line 69 def to_json @_field_set&.to_json end |