Class: Vellum::WorkflowNodeResultData

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(member:, discriminant:) ⇒ WorkflowNodeResultData

Parameters:

  • member (Object)
  • discriminant (String)


22
23
24
25
26
27
# File 'lib/vellum_ai/types/workflow_node_result_data.rb', line 22

def initialize(member:, discriminant:)
  # @type [Object]
  @member = member
  # @type [String]
  @discriminant = discriminant
end

Instance Attribute Details

#discriminantObject (readonly)

Returns the value of attribute discriminant.



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

def discriminant
  @discriminant
end

#memberObject (readonly)

Returns the value of attribute member.



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

def member
  @member
end

Class Method Details

.api(member:) ⇒ WorkflowNodeResultData

Parameters:

Returns:



152
153
154
# File 'lib/vellum_ai/types/workflow_node_result_data.rb', line 152

def self.api(member:)
  new(member: member, discriminant: "API")
end

.code_execution(member:) ⇒ WorkflowNodeResultData

Parameters:

Returns:



140
141
142
# File 'lib/vellum_ai/types/workflow_node_result_data.rb', line 140

def self.code_execution(member:)
  new(member: member, discriminant: "CODE_EXECUTION")
end

.conditional(member:) ⇒ WorkflowNodeResultData

Parameters:

Returns:



146
147
148
# File 'lib/vellum_ai/types/workflow_node_result_data.rb', line 146

def self.conditional(member:)
  new(member: member, discriminant: "CONDITIONAL")
end

.from_json(json_object:) ⇒ WorkflowNodeResultData

Deserialize a JSON object to an instance of WorkflowNodeResultData

Parameters:

  • json_object (JSON)

Returns:



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/vellum_ai/types/workflow_node_result_data.rb', line 33

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  member = case struct.type
           when "PROMPT"
             PromptNodeResult.from_json(json_object: json_object)
           when "SEARCH"
             SearchNodeResult.from_json(json_object: json_object)
           when "TEMPLATING"
             TemplatingNodeResult.from_json(json_object: json_object)
           when "CODE_EXECUTION"
             CodeExecutionNodeResult.from_json(json_object: json_object)
           when "CONDITIONAL"
             ConditionalNodeResult.from_json(json_object: json_object)
           when "API"
             ApiNodeResult.from_json(json_object: json_object)
           when "TERMINAL"
             TerminalNodeResult.from_json(json_object: json_object)
           when "SUBWORKFLOW"
             SubworkflowNodeResult.from_json(json_object: json_object)
           else
             PromptNodeResult.from_json(json_object: json_object)
           end
  new(member: member, discriminant: struct.type)
end

.prompt(member:) ⇒ WorkflowNodeResultData

Parameters:

Returns:



122
123
124
# File 'lib/vellum_ai/types/workflow_node_result_data.rb', line 122

def self.prompt(member:)
  new(member: member, discriminant: "PROMPT")
end

.search(member:) ⇒ WorkflowNodeResultData

Parameters:

Returns:



128
129
130
# File 'lib/vellum_ai/types/workflow_node_result_data.rb', line 128

def self.search(member:)
  new(member: member, discriminant: "SEARCH")
end

.subworkflow(member:) ⇒ WorkflowNodeResultData

Parameters:

Returns:



164
165
166
# File 'lib/vellum_ai/types/workflow_node_result_data.rb', line 164

def self.subworkflow(member:)
  new(member: member, discriminant: "SUBWORKFLOW")
end

.templating(member:) ⇒ WorkflowNodeResultData

Parameters:

Returns:



134
135
136
# File 'lib/vellum_ai/types/workflow_node_result_data.rb', line 134

def self.templating(member:)
  new(member: member, discriminant: "TEMPLATING")
end

.terminal(member:) ⇒ WorkflowNodeResultData

Parameters:

Returns:



158
159
160
# File 'lib/vellum_ai/types/workflow_node_result_data.rb', line 158

def self.terminal(member:)
  new(member: member, discriminant: "TERMINAL")
end

.validate_raw(obj:) ⇒ Void

Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.

Parameters:

  • obj (Object)

Returns:

  • (Void)


89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/vellum_ai/types/workflow_node_result_data.rb', line 89

def self.validate_raw(obj:)
  case obj.type
  when "PROMPT"
    PromptNodeResult.validate_raw(obj: obj)
  when "SEARCH"
    SearchNodeResult.validate_raw(obj: obj)
  when "TEMPLATING"
    TemplatingNodeResult.validate_raw(obj: obj)
  when "CODE_EXECUTION"
    CodeExecutionNodeResult.validate_raw(obj: obj)
  when "CONDITIONAL"
    ConditionalNodeResult.validate_raw(obj: obj)
  when "API"
    ApiNodeResult.validate_raw(obj: obj)
  when "TERMINAL"
    TerminalNodeResult.validate_raw(obj: obj)
  when "SUBWORKFLOW"
    SubworkflowNodeResult.validate_raw(obj: obj)
  else
    raise("Passed value matched no type within the union, validation failed.")
  end
end

Instance Method Details

#is_a?(obj) ⇒ Boolean

For Union Types, is_a? functionality is delegated to the wrapped member.

Parameters:

  • obj (Object)

Returns:

  • (Boolean)


116
117
118
# File 'lib/vellum_ai/types/workflow_node_result_data.rb', line 116

def is_a?(obj)
  @member.is_a?(obj)
end

#kind_of?Object



18
# File 'lib/vellum_ai/types/workflow_node_result_data.rb', line 18

alias kind_of? is_a?

#to_json(*_args) ⇒ JSON

For Union Types, to_json functionality is delegated to the wrapped member.

Returns:

  • (JSON)


61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/vellum_ai/types/workflow_node_result_data.rb', line 61

def to_json(*_args)
  case @discriminant
  when "PROMPT"
    { **@member.to_json, type: @discriminant }.to_json
  when "SEARCH"
    { **@member.to_json, type: @discriminant }.to_json
  when "TEMPLATING"
    { **@member.to_json, type: @discriminant }.to_json
  when "CODE_EXECUTION"
    { **@member.to_json, type: @discriminant }.to_json
  when "CONDITIONAL"
    { **@member.to_json, type: @discriminant }.to_json
  when "API"
    { **@member.to_json, type: @discriminant }.to_json
  when "TERMINAL"
    { **@member.to_json, type: @discriminant }.to_json
  when "SUBWORKFLOW"
    { **@member.to_json, type: @discriminant }.to_json
  else
    { "type": @discriminant, value: @member }.to_json
  end
  @member.to_json
end