Class: Vellum::WorkflowExecutionSpan

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, events:, attributes:, usage_result: OMIT, span_id:, start_ts:, end_ts:, parent_span_id: OMIT, additional_properties: nil) ⇒ Vellum::WorkflowExecutionSpan



46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/vellum_ai/types/workflow_execution_span.rb', line 46

def initialize(name:, events:, attributes:, usage_result: OMIT, span_id:, start_ts:, end_ts:, parent_span_id: OMIT, additional_properties: nil)
  @name = name
  @events = events
  @attributes = attributes
  @usage_result = usage_result if usage_result != OMIT
  @span_id = span_id
  @start_ts = start_ts
  @end_ts = end_ts
  @parent_span_id = parent_span_id if parent_span_id != OMIT
  @additional_properties = additional_properties
  @_field_set = { "name": name, "events": events, "attributes": attributes, "usage_result": usage_result, "span_id": span_id, "start_ts": start_ts, "end_ts": end_ts, "parent_span_id": parent_span_id }.reject do | _k, v |
  v == OMIT
end
end

Instance Attribute Details

#additional_properties ⇒ OpenStruct (readonly)



29
30
31
# File 'lib/vellum_ai/types/workflow_execution_span.rb', line 29

def additional_properties
  @additional_properties
end

#attributes ⇒ Vellum::WorkflowExecutionSpanAttributes (readonly)



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

def attributes
  @attributes
end

#end_ts ⇒ DateTime (readonly)



25
26
27
# File 'lib/vellum_ai/types/workflow_execution_span.rb', line 25

def end_ts
  @end_ts
end

#events ⇒ Array<Vellum::VellumWorkflowExecutionEvent> (readonly)



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

def events
  @events
end

#name ⇒ String (readonly)



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

def name
  @name
end

#parent_span_id ⇒ String (readonly)



27
28
29
# File 'lib/vellum_ai/types/workflow_execution_span.rb', line 27

def parent_span_id
  @parent_span_id
end

#span_id ⇒ String (readonly)



21
22
23
# File 'lib/vellum_ai/types/workflow_execution_span.rb', line 21

def span_id
  @span_id
end

#start_ts ⇒ DateTime (readonly)



23
24
25
# File 'lib/vellum_ai/types/workflow_execution_span.rb', line 23

def start_ts
  @start_ts
end

#usage_result ⇒ Vellum::WorkflowExecutionUsageCalculationFulfilledBody (readonly)



19
20
21
# File 'lib/vellum_ai/types/workflow_execution_span.rb', line 19

def usage_result
  @usage_result
end

Class Method Details

.from_json(json_object:) ⇒ Vellum::WorkflowExecutionSpan



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/vellum_ai/types/workflow_execution_span.rb', line 64

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  name = parsed_json["name"]
  events = parsed_json["events"]&.map do | item |
  item = item.to_json
  Vellum::VellumWorkflowExecutionEvent.from_json(json_object: item)
end
  unless parsed_json["attributes"].nil?
    attributes = parsed_json["attributes"].to_json
    attributes = Vellum::WorkflowExecutionSpanAttributes.from_json(json_object: attributes)
  else
    attributes = nil
  end
  unless parsed_json["usage_result"].nil?
    usage_result = parsed_json["usage_result"].to_json
    usage_result = Vellum::WorkflowExecutionUsageCalculationFulfilledBody.from_json(json_object: usage_result)
  else
    usage_result = nil
  end
  span_id = parsed_json["span_id"]
  start_ts = unless parsed_json["start_ts"].nil?
  DateTime.parse(parsed_json["start_ts"])
else
  nil
end
  end_ts = unless parsed_json["end_ts"].nil?
  DateTime.parse(parsed_json["end_ts"])
else
  nil
end
  parent_span_id = parsed_json["parent_span_id"]
  new(
    name: name,
    events: events,
    attributes: attributes,
    usage_result: usage_result,
    span_id: span_id,
    start_ts: start_ts,
    end_ts: end_ts,
    parent_span_id: parent_span_id,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void



120
121
122
123
124
125
126
127
128
129
# File 'lib/vellum_ai/types/workflow_execution_span.rb', line 120

def self.validate_raw(obj:)
  obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
  obj.events.is_a?(Array) != false || raise("Passed value for field obj.events is not the expected type, validation failed.")
  Vellum::WorkflowExecutionSpanAttributes.validate_raw(obj: obj.attributes)
  obj.usage_result.nil? || Vellum::WorkflowExecutionUsageCalculationFulfilledBody.validate_raw(obj: obj.usage_result)
  obj.span_id.is_a?(String) != false || raise("Passed value for field obj.span_id is not the expected type, validation failed.")
  obj.start_ts.is_a?(DateTime) != false || raise("Passed value for field obj.start_ts is not the expected type, validation failed.")
  obj.end_ts.is_a?(DateTime) != false || raise("Passed value for field obj.end_ts is not the expected type, validation failed.")
  obj.parent_span_id&.is_a?(String) != false || raise("Passed value for field obj.parent_span_id is not the expected type, validation failed.")
end

Instance Method Details

#to_json ⇒ String



111
112
113
# File 'lib/vellum_ai/types/workflow_execution_span.rb', line 111

def to_json
  @_field_set&.to_json
end