vellum_ai 0.3.10 → 0.3.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/requests.rb +2 -2
- data/lib/types_export.rb +10 -0
- data/lib/vellum_ai/deployments/client.rb +10 -4
- data/lib/vellum_ai/document_indexes/client.rb +150 -0
- data/lib/vellum_ai/types/array_variable_value_item.rb +13 -0
- data/lib/vellum_ai/types/chat_message.rb +9 -4
- data/lib/vellum_ai/types/chat_message_request.rb +9 -4
- data/lib/vellum_ai/types/execution_array_vellum_value.rb +59 -0
- data/lib/vellum_ai/types/execution_chat_history_vellum_value.rb +59 -0
- data/lib/vellum_ai/types/execution_error_vellum_value.rb +61 -0
- data/lib/vellum_ai/types/execution_function_call_vellum_value.rb +61 -0
- data/lib/vellum_ai/types/execution_json_vellum_value.rb +55 -0
- data/lib/vellum_ai/types/execution_number_vellum_value.rb +55 -0
- data/lib/vellum_ai/types/execution_search_results_vellum_value.rb +59 -0
- data/lib/vellum_ai/types/execution_string_vellum_value.rb +55 -0
- data/lib/vellum_ai/types/execution_vellum_value.rb +168 -0
- data/lib/vellum_ai/types/fulfilled_workflow_node_result_event.rb +19 -5
- data/lib/vellum_ai/types/generate_request.rb +2 -2
- data/lib/vellum_ai/types/image_variable_value.rb +52 -0
- data/lib/vellum_ai/types/initiated_workflow_node_result_event.rb +11 -4
- data/lib/vellum_ai/types/prompt_template_block_properties.rb +10 -4
- data/lib/vellum_ai/types/prompt_template_block_properties_request.rb +10 -4
- data/lib/vellum_ai/types/rejected_workflow_node_result_event.rb +11 -4
- data/lib/vellum_ai/types/streaming_workflow_node_result_event.rb +12 -5
- data/lib/vellum_ai/types/workflow_execution_event_error_code.rb +1 -0
- data/lib/vellum_ai/types/workflow_result_event.rb +15 -4
- data/lib/vellum_ai.rb +6 -6
- metadata +12 -2
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
module Vellum
|
6
|
+
class ExecutionJsonVellumValue
|
7
|
+
attr_reader :id, :name, :value, :additional_properties
|
8
|
+
|
9
|
+
# @param id [String] The variable's uniquely identifying internal id.
|
10
|
+
# @param name [String]
|
11
|
+
# @param value [Hash{String => String}]
|
12
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
13
|
+
# @return [ExecutionJsonVellumValue]
|
14
|
+
def initialize(id:, name:, value: nil, additional_properties: nil)
|
15
|
+
# @type [String] The variable's uniquely identifying internal id.
|
16
|
+
@id = id
|
17
|
+
# @type [String]
|
18
|
+
@name = name
|
19
|
+
# @type [Hash{String => String}]
|
20
|
+
@value = value
|
21
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
22
|
+
@additional_properties = additional_properties
|
23
|
+
end
|
24
|
+
|
25
|
+
# Deserialize a JSON object to an instance of ExecutionJsonVellumValue
|
26
|
+
#
|
27
|
+
# @param json_object [JSON]
|
28
|
+
# @return [ExecutionJsonVellumValue]
|
29
|
+
def self.from_json(json_object:)
|
30
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
31
|
+
JSON.parse(json_object)
|
32
|
+
id = struct.id
|
33
|
+
name = struct.name
|
34
|
+
value = struct.value
|
35
|
+
new(id: id, name: name, value: value, additional_properties: struct)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Serialize an instance of ExecutionJsonVellumValue to a JSON object
|
39
|
+
#
|
40
|
+
# @return [JSON]
|
41
|
+
def to_json(*_args)
|
42
|
+
{ "id": @id, "name": @name, "value": @value }.to_json
|
43
|
+
end
|
44
|
+
|
45
|
+
# 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.
|
46
|
+
#
|
47
|
+
# @param obj [Object]
|
48
|
+
# @return [Void]
|
49
|
+
def self.validate_raw(obj:)
|
50
|
+
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
51
|
+
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
52
|
+
obj.value&.is_a?(Hash) != false || raise("Passed value for field obj.value is not the expected type, validation failed.")
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
module Vellum
|
6
|
+
class ExecutionNumberVellumValue
|
7
|
+
attr_reader :id, :name, :value, :additional_properties
|
8
|
+
|
9
|
+
# @param id [String] The variable's uniquely identifying internal id.
|
10
|
+
# @param name [String]
|
11
|
+
# @param value [Float]
|
12
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
13
|
+
# @return [ExecutionNumberVellumValue]
|
14
|
+
def initialize(id:, name:, value: nil, additional_properties: nil)
|
15
|
+
# @type [String] The variable's uniquely identifying internal id.
|
16
|
+
@id = id
|
17
|
+
# @type [String]
|
18
|
+
@name = name
|
19
|
+
# @type [Float]
|
20
|
+
@value = value
|
21
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
22
|
+
@additional_properties = additional_properties
|
23
|
+
end
|
24
|
+
|
25
|
+
# Deserialize a JSON object to an instance of ExecutionNumberVellumValue
|
26
|
+
#
|
27
|
+
# @param json_object [JSON]
|
28
|
+
# @return [ExecutionNumberVellumValue]
|
29
|
+
def self.from_json(json_object:)
|
30
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
31
|
+
JSON.parse(json_object)
|
32
|
+
id = struct.id
|
33
|
+
name = struct.name
|
34
|
+
value = struct.value
|
35
|
+
new(id: id, name: name, value: value, additional_properties: struct)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Serialize an instance of ExecutionNumberVellumValue to a JSON object
|
39
|
+
#
|
40
|
+
# @return [JSON]
|
41
|
+
def to_json(*_args)
|
42
|
+
{ "id": @id, "name": @name, "value": @value }.to_json
|
43
|
+
end
|
44
|
+
|
45
|
+
# 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.
|
46
|
+
#
|
47
|
+
# @param obj [Object]
|
48
|
+
# @return [Void]
|
49
|
+
def self.validate_raw(obj:)
|
50
|
+
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
51
|
+
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
52
|
+
obj.value&.is_a?(Float) != false || raise("Passed value for field obj.value is not the expected type, validation failed.")
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "search_result"
|
4
|
+
require "json"
|
5
|
+
|
6
|
+
module Vellum
|
7
|
+
class ExecutionSearchResultsVellumValue
|
8
|
+
attr_reader :id, :name, :value, :additional_properties
|
9
|
+
|
10
|
+
# @param id [String] The variable's uniquely identifying internal id.
|
11
|
+
# @param name [String]
|
12
|
+
# @param value [Array<SearchResult>]
|
13
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
14
|
+
# @return [ExecutionSearchResultsVellumValue]
|
15
|
+
def initialize(id:, name:, value: nil, additional_properties: nil)
|
16
|
+
# @type [String] The variable's uniquely identifying internal id.
|
17
|
+
@id = id
|
18
|
+
# @type [String]
|
19
|
+
@name = name
|
20
|
+
# @type [Array<SearchResult>]
|
21
|
+
@value = value
|
22
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
23
|
+
@additional_properties = additional_properties
|
24
|
+
end
|
25
|
+
|
26
|
+
# Deserialize a JSON object to an instance of ExecutionSearchResultsVellumValue
|
27
|
+
#
|
28
|
+
# @param json_object [JSON]
|
29
|
+
# @return [ExecutionSearchResultsVellumValue]
|
30
|
+
def self.from_json(json_object:)
|
31
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
32
|
+
parsed_json = JSON.parse(json_object)
|
33
|
+
id = struct.id
|
34
|
+
name = struct.name
|
35
|
+
value = parsed_json["value"].map do |v|
|
36
|
+
v = v.to_json
|
37
|
+
SearchResult.from_json(json_object: v)
|
38
|
+
end
|
39
|
+
new(id: id, name: name, value: value, additional_properties: struct)
|
40
|
+
end
|
41
|
+
|
42
|
+
# Serialize an instance of ExecutionSearchResultsVellumValue to a JSON object
|
43
|
+
#
|
44
|
+
# @return [JSON]
|
45
|
+
def to_json(*_args)
|
46
|
+
{ "id": @id, "name": @name, "value": @value }.to_json
|
47
|
+
end
|
48
|
+
|
49
|
+
# 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.
|
50
|
+
#
|
51
|
+
# @param obj [Object]
|
52
|
+
# @return [Void]
|
53
|
+
def self.validate_raw(obj:)
|
54
|
+
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
55
|
+
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
56
|
+
obj.value&.is_a?(Array) != false || raise("Passed value for field obj.value is not the expected type, validation failed.")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
module Vellum
|
6
|
+
class ExecutionStringVellumValue
|
7
|
+
attr_reader :id, :name, :value, :additional_properties
|
8
|
+
|
9
|
+
# @param id [String] The variable's uniquely identifying internal id.
|
10
|
+
# @param name [String]
|
11
|
+
# @param value [String]
|
12
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
13
|
+
# @return [ExecutionStringVellumValue]
|
14
|
+
def initialize(id:, name:, value: nil, additional_properties: nil)
|
15
|
+
# @type [String] The variable's uniquely identifying internal id.
|
16
|
+
@id = id
|
17
|
+
# @type [String]
|
18
|
+
@name = name
|
19
|
+
# @type [String]
|
20
|
+
@value = value
|
21
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
22
|
+
@additional_properties = additional_properties
|
23
|
+
end
|
24
|
+
|
25
|
+
# Deserialize a JSON object to an instance of ExecutionStringVellumValue
|
26
|
+
#
|
27
|
+
# @param json_object [JSON]
|
28
|
+
# @return [ExecutionStringVellumValue]
|
29
|
+
def self.from_json(json_object:)
|
30
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
31
|
+
JSON.parse(json_object)
|
32
|
+
id = struct.id
|
33
|
+
name = struct.name
|
34
|
+
value = struct.value
|
35
|
+
new(id: id, name: name, value: value, additional_properties: struct)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Serialize an instance of ExecutionStringVellumValue to a JSON object
|
39
|
+
#
|
40
|
+
# @return [JSON]
|
41
|
+
def to_json(*_args)
|
42
|
+
{ "id": @id, "name": @name, "value": @value }.to_json
|
43
|
+
end
|
44
|
+
|
45
|
+
# 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.
|
46
|
+
#
|
47
|
+
# @param obj [Object]
|
48
|
+
# @return [Void]
|
49
|
+
def self.validate_raw(obj:)
|
50
|
+
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
51
|
+
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
52
|
+
obj.value&.is_a?(String) != false || raise("Passed value for field obj.value is not the expected type, validation failed.")
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,168 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
require_relative "execution_string_vellum_value"
|
5
|
+
require_relative "execution_number_vellum_value"
|
6
|
+
require_relative "execution_json_vellum_value"
|
7
|
+
require_relative "execution_chat_history_vellum_value"
|
8
|
+
require_relative "execution_search_results_vellum_value"
|
9
|
+
require_relative "execution_error_vellum_value"
|
10
|
+
require_relative "execution_array_vellum_value"
|
11
|
+
require_relative "execution_function_call_vellum_value"
|
12
|
+
|
13
|
+
module Vellum
|
14
|
+
class ExecutionVellumValue
|
15
|
+
attr_reader :member, :discriminant
|
16
|
+
|
17
|
+
private_class_method :new
|
18
|
+
alias kind_of? is_a?
|
19
|
+
# @param member [Object]
|
20
|
+
# @param discriminant [String]
|
21
|
+
# @return [ExecutionVellumValue]
|
22
|
+
def initialize(member:, discriminant:)
|
23
|
+
# @type [Object]
|
24
|
+
@member = member
|
25
|
+
# @type [String]
|
26
|
+
@discriminant = discriminant
|
27
|
+
end
|
28
|
+
|
29
|
+
# Deserialize a JSON object to an instance of ExecutionVellumValue
|
30
|
+
#
|
31
|
+
# @param json_object [JSON]
|
32
|
+
# @return [ExecutionVellumValue]
|
33
|
+
def self.from_json(json_object:)
|
34
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
35
|
+
member = case struct.type
|
36
|
+
when "STRING"
|
37
|
+
ExecutionStringVellumValue.from_json(json_object: json_object)
|
38
|
+
when "NUMBER"
|
39
|
+
ExecutionNumberVellumValue.from_json(json_object: json_object)
|
40
|
+
when "JSON"
|
41
|
+
ExecutionJsonVellumValue.from_json(json_object: json_object)
|
42
|
+
when "CHAT_HISTORY"
|
43
|
+
ExecutionChatHistoryVellumValue.from_json(json_object: json_object)
|
44
|
+
when "SEARCH_RESULTS"
|
45
|
+
ExecutionSearchResultsVellumValue.from_json(json_object: json_object)
|
46
|
+
when "ERROR"
|
47
|
+
ExecutionErrorVellumValue.from_json(json_object: json_object)
|
48
|
+
when "ARRAY"
|
49
|
+
ExecutionArrayVellumValue.from_json(json_object: json_object)
|
50
|
+
when "FUNCTION_CALL"
|
51
|
+
ExecutionFunctionCallVellumValue.from_json(json_object: json_object)
|
52
|
+
else
|
53
|
+
ExecutionStringVellumValue.from_json(json_object: json_object)
|
54
|
+
end
|
55
|
+
new(member: member, discriminant: struct.type)
|
56
|
+
end
|
57
|
+
|
58
|
+
# For Union Types, to_json functionality is delegated to the wrapped member.
|
59
|
+
#
|
60
|
+
# @return [JSON]
|
61
|
+
def to_json(*_args)
|
62
|
+
case @discriminant
|
63
|
+
when "STRING"
|
64
|
+
{ **@member.to_json, type: @discriminant }.to_json
|
65
|
+
when "NUMBER"
|
66
|
+
{ **@member.to_json, type: @discriminant }.to_json
|
67
|
+
when "JSON"
|
68
|
+
{ **@member.to_json, type: @discriminant }.to_json
|
69
|
+
when "CHAT_HISTORY"
|
70
|
+
{ **@member.to_json, type: @discriminant }.to_json
|
71
|
+
when "SEARCH_RESULTS"
|
72
|
+
{ **@member.to_json, type: @discriminant }.to_json
|
73
|
+
when "ERROR"
|
74
|
+
{ **@member.to_json, type: @discriminant }.to_json
|
75
|
+
when "ARRAY"
|
76
|
+
{ **@member.to_json, type: @discriminant }.to_json
|
77
|
+
when "FUNCTION_CALL"
|
78
|
+
{ **@member.to_json, type: @discriminant }.to_json
|
79
|
+
else
|
80
|
+
{ "type": @discriminant, value: @member }.to_json
|
81
|
+
end
|
82
|
+
@member.to_json
|
83
|
+
end
|
84
|
+
|
85
|
+
# 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.
|
86
|
+
#
|
87
|
+
# @param obj [Object]
|
88
|
+
# @return [Void]
|
89
|
+
def self.validate_raw(obj:)
|
90
|
+
case obj.type
|
91
|
+
when "STRING"
|
92
|
+
ExecutionStringVellumValue.validate_raw(obj: obj)
|
93
|
+
when "NUMBER"
|
94
|
+
ExecutionNumberVellumValue.validate_raw(obj: obj)
|
95
|
+
when "JSON"
|
96
|
+
ExecutionJsonVellumValue.validate_raw(obj: obj)
|
97
|
+
when "CHAT_HISTORY"
|
98
|
+
ExecutionChatHistoryVellumValue.validate_raw(obj: obj)
|
99
|
+
when "SEARCH_RESULTS"
|
100
|
+
ExecutionSearchResultsVellumValue.validate_raw(obj: obj)
|
101
|
+
when "ERROR"
|
102
|
+
ExecutionErrorVellumValue.validate_raw(obj: obj)
|
103
|
+
when "ARRAY"
|
104
|
+
ExecutionArrayVellumValue.validate_raw(obj: obj)
|
105
|
+
when "FUNCTION_CALL"
|
106
|
+
ExecutionFunctionCallVellumValue.validate_raw(obj: obj)
|
107
|
+
else
|
108
|
+
raise("Passed value matched no type within the union, validation failed.")
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
# For Union Types, is_a? functionality is delegated to the wrapped member.
|
113
|
+
#
|
114
|
+
# @param obj [Object]
|
115
|
+
# @return [Boolean]
|
116
|
+
def is_a?(obj)
|
117
|
+
@member.is_a?(obj)
|
118
|
+
end
|
119
|
+
|
120
|
+
# @param member [ExecutionStringVellumValue]
|
121
|
+
# @return [ExecutionVellumValue]
|
122
|
+
def self.string(member:)
|
123
|
+
new(member: member, discriminant: "STRING")
|
124
|
+
end
|
125
|
+
|
126
|
+
# @param member [ExecutionNumberVellumValue]
|
127
|
+
# @return [ExecutionVellumValue]
|
128
|
+
def self.number(member:)
|
129
|
+
new(member: member, discriminant: "NUMBER")
|
130
|
+
end
|
131
|
+
|
132
|
+
# @param member [ExecutionJsonVellumValue]
|
133
|
+
# @return [ExecutionVellumValue]
|
134
|
+
def self.json(member:)
|
135
|
+
new(member: member, discriminant: "JSON")
|
136
|
+
end
|
137
|
+
|
138
|
+
# @param member [ExecutionChatHistoryVellumValue]
|
139
|
+
# @return [ExecutionVellumValue]
|
140
|
+
def self.chat_history(member:)
|
141
|
+
new(member: member, discriminant: "CHAT_HISTORY")
|
142
|
+
end
|
143
|
+
|
144
|
+
# @param member [ExecutionSearchResultsVellumValue]
|
145
|
+
# @return [ExecutionVellumValue]
|
146
|
+
def self.search_results(member:)
|
147
|
+
new(member: member, discriminant: "SEARCH_RESULTS")
|
148
|
+
end
|
149
|
+
|
150
|
+
# @param member [ExecutionErrorVellumValue]
|
151
|
+
# @return [ExecutionVellumValue]
|
152
|
+
def self.error(member:)
|
153
|
+
new(member: member, discriminant: "ERROR")
|
154
|
+
end
|
155
|
+
|
156
|
+
# @param member [ExecutionArrayVellumValue]
|
157
|
+
# @return [ExecutionVellumValue]
|
158
|
+
def self.array(member:)
|
159
|
+
new(member: member, discriminant: "ARRAY")
|
160
|
+
end
|
161
|
+
|
162
|
+
# @param member [ExecutionFunctionCallVellumValue]
|
163
|
+
# @return [ExecutionVellumValue]
|
164
|
+
def self.function_call(member:)
|
165
|
+
new(member: member, discriminant: "FUNCTION_CALL")
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
@@ -8,17 +8,21 @@ require "json"
|
|
8
8
|
module Vellum
|
9
9
|
# An event that indicates that the node has fulfilled its execution.
|
10
10
|
class FulfilledWorkflowNodeResultEvent
|
11
|
-
attr_reader :id, :node_id, :node_result_id, :ts, :data, :output_values, :
|
11
|
+
attr_reader :id, :node_id, :node_result_id, :ts, :data, :source_execution_id, :output_values, :mocked,
|
12
|
+
:additional_properties
|
12
13
|
|
13
14
|
# @param id [String]
|
14
15
|
# @param node_id [String]
|
15
16
|
# @param node_result_id [String]
|
16
17
|
# @param ts [DateTime]
|
17
18
|
# @param data [WorkflowNodeResultData]
|
19
|
+
# @param source_execution_id [String]
|
18
20
|
# @param output_values [Array<NodeOutputCompiledValue>]
|
21
|
+
# @param mocked [Boolean]
|
19
22
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
20
23
|
# @return [FulfilledWorkflowNodeResultEvent]
|
21
|
-
def initialize(id:, node_id:, node_result_id:, ts: nil, data: nil,
|
24
|
+
def initialize(id:, node_id:, node_result_id:, ts: nil, data: nil, source_execution_id: nil, output_values: nil,
|
25
|
+
mocked: nil, additional_properties: nil)
|
22
26
|
# @type [String]
|
23
27
|
@id = id
|
24
28
|
# @type [String]
|
@@ -29,8 +33,12 @@ module Vellum
|
|
29
33
|
@ts = ts
|
30
34
|
# @type [WorkflowNodeResultData]
|
31
35
|
@data = data
|
36
|
+
# @type [String]
|
37
|
+
@source_execution_id = source_execution_id
|
32
38
|
# @type [Array<NodeOutputCompiledValue>]
|
33
39
|
@output_values = output_values
|
40
|
+
# @type [Boolean]
|
41
|
+
@mocked = mocked
|
34
42
|
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
35
43
|
@additional_properties = additional_properties
|
36
44
|
end
|
@@ -52,12 +60,14 @@ module Vellum
|
|
52
60
|
data = parsed_json["data"].to_json
|
53
61
|
data = WorkflowNodeResultData.from_json(json_object: data)
|
54
62
|
end
|
63
|
+
source_execution_id = struct.source_execution_id
|
55
64
|
output_values = parsed_json["output_values"].map do |v|
|
56
65
|
v = v.to_json
|
57
66
|
NodeOutputCompiledValue.from_json(json_object: v)
|
58
67
|
end
|
59
|
-
|
60
|
-
|
68
|
+
mocked = struct.mocked
|
69
|
+
new(id: id, node_id: node_id, node_result_id: node_result_id, ts: ts, data: data,
|
70
|
+
source_execution_id: source_execution_id, output_values: output_values, mocked: mocked, additional_properties: struct)
|
61
71
|
end
|
62
72
|
|
63
73
|
# Serialize an instance of FulfilledWorkflowNodeResultEvent to a JSON object
|
@@ -70,7 +80,9 @@ module Vellum
|
|
70
80
|
"node_result_id": @node_result_id,
|
71
81
|
"ts": @ts,
|
72
82
|
"data": @data,
|
73
|
-
"
|
83
|
+
"source_execution_id": @source_execution_id,
|
84
|
+
"output_values": @output_values,
|
85
|
+
"mocked": @mocked
|
74
86
|
}.to_json
|
75
87
|
end
|
76
88
|
|
@@ -84,7 +96,9 @@ module Vellum
|
|
84
96
|
obj.node_result_id.is_a?(String) != false || raise("Passed value for field obj.node_result_id is not the expected type, validation failed.")
|
85
97
|
obj.ts&.is_a?(DateTime) != false || raise("Passed value for field obj.ts is not the expected type, validation failed.")
|
86
98
|
obj.data.nil? || WorkflowNodeResultData.validate_raw(obj: obj.data)
|
99
|
+
obj.source_execution_id&.is_a?(String) != false || raise("Passed value for field obj.source_execution_id is not the expected type, validation failed.")
|
87
100
|
obj.output_values&.is_a?(Array) != false || raise("Passed value for field obj.output_values is not the expected type, validation failed.")
|
101
|
+
obj.mocked&.is_a?(Boolean) != false || raise("Passed value for field obj.mocked is not the expected type, validation failed.")
|
88
102
|
end
|
89
103
|
end
|
90
104
|
end
|
@@ -8,14 +8,14 @@ module Vellum
|
|
8
8
|
attr_reader :input_values, :chat_history, :external_ids, :additional_properties
|
9
9
|
|
10
10
|
# @param input_values [Hash{String => String}] Key/value pairs for each template variable defined in the deployment's prompt.
|
11
|
-
# @param chat_history [Array<ChatMessageRequest>] Optionally provide a list of chat messages that'll be used in place of the special
|
11
|
+
# @param chat_history [Array<ChatMessageRequest>] Optionally provide a list of chat messages that'll be used in place of the special chat_history variable, if included in the prompt.
|
12
12
|
# @param external_ids [Array<String>] Optionally include a unique identifier for each generation, as represented outside of Vellum. Note that this should generally be a list of length one.
|
13
13
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
14
14
|
# @return [GenerateRequest]
|
15
15
|
def initialize(input_values:, chat_history: nil, external_ids: nil, additional_properties: nil)
|
16
16
|
# @type [Hash{String => String}] Key/value pairs for each template variable defined in the deployment's prompt.
|
17
17
|
@input_values = input_values
|
18
|
-
# @type [Array<ChatMessageRequest>] Optionally provide a list of chat messages that'll be used in place of the special
|
18
|
+
# @type [Array<ChatMessageRequest>] Optionally provide a list of chat messages that'll be used in place of the special chat_history variable, if included in the prompt.
|
19
19
|
@chat_history = chat_history
|
20
20
|
# @type [Array<String>] Optionally include a unique identifier for each generation, as represented outside of Vellum. Note that this should generally be a list of length one.
|
21
21
|
@external_ids = external_ids
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "vellum_image"
|
4
|
+
require "json"
|
5
|
+
|
6
|
+
module Vellum
|
7
|
+
# A base Vellum primitive value representing an image.
|
8
|
+
class ImageVariableValue
|
9
|
+
attr_reader :value, :additional_properties
|
10
|
+
|
11
|
+
# @param value [VellumImage]
|
12
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
13
|
+
# @return [ImageVariableValue]
|
14
|
+
def initialize(value: nil, additional_properties: nil)
|
15
|
+
# @type [VellumImage]
|
16
|
+
@value = value
|
17
|
+
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
18
|
+
@additional_properties = additional_properties
|
19
|
+
end
|
20
|
+
|
21
|
+
# Deserialize a JSON object to an instance of ImageVariableValue
|
22
|
+
#
|
23
|
+
# @param json_object [JSON]
|
24
|
+
# @return [ImageVariableValue]
|
25
|
+
def self.from_json(json_object:)
|
26
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
27
|
+
parsed_json = JSON.parse(json_object)
|
28
|
+
if parsed_json["value"].nil?
|
29
|
+
value = nil
|
30
|
+
else
|
31
|
+
value = parsed_json["value"].to_json
|
32
|
+
value = VellumImage.from_json(json_object: value)
|
33
|
+
end
|
34
|
+
new(value: value, additional_properties: struct)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Serialize an instance of ImageVariableValue to a JSON object
|
38
|
+
#
|
39
|
+
# @return [JSON]
|
40
|
+
def to_json(*_args)
|
41
|
+
{ "value": @value }.to_json
|
42
|
+
end
|
43
|
+
|
44
|
+
# 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.
|
45
|
+
#
|
46
|
+
# @param obj [Object]
|
47
|
+
# @return [Void]
|
48
|
+
def self.validate_raw(obj:)
|
49
|
+
obj.value.nil? || VellumImage.validate_raw(obj: obj.value)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -8,17 +8,19 @@ require "json"
|
|
8
8
|
module Vellum
|
9
9
|
# An event that indicates that the node has initiated its execution.
|
10
10
|
class InitiatedWorkflowNodeResultEvent
|
11
|
-
attr_reader :id, :node_id, :node_result_id, :ts, :data, :input_values, :additional_properties
|
11
|
+
attr_reader :id, :node_id, :node_result_id, :ts, :data, :source_execution_id, :input_values, :additional_properties
|
12
12
|
|
13
13
|
# @param id [String]
|
14
14
|
# @param node_id [String]
|
15
15
|
# @param node_result_id [String]
|
16
16
|
# @param ts [DateTime]
|
17
17
|
# @param data [WorkflowNodeResultData]
|
18
|
+
# @param source_execution_id [String]
|
18
19
|
# @param input_values [Array<NodeInputVariableCompiledValue>]
|
19
20
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
20
21
|
# @return [InitiatedWorkflowNodeResultEvent]
|
21
|
-
def initialize(id:, node_id:, node_result_id:, ts: nil, data: nil,
|
22
|
+
def initialize(id:, node_id:, node_result_id:, ts: nil, data: nil, source_execution_id: nil, input_values: nil,
|
23
|
+
additional_properties: nil)
|
22
24
|
# @type [String]
|
23
25
|
@id = id
|
24
26
|
# @type [String]
|
@@ -29,6 +31,8 @@ module Vellum
|
|
29
31
|
@ts = ts
|
30
32
|
# @type [WorkflowNodeResultData]
|
31
33
|
@data = data
|
34
|
+
# @type [String]
|
35
|
+
@source_execution_id = source_execution_id
|
32
36
|
# @type [Array<NodeInputVariableCompiledValue>]
|
33
37
|
@input_values = input_values
|
34
38
|
# @type [OpenStruct] Additional properties unmapped to the current class definition
|
@@ -52,12 +56,13 @@ module Vellum
|
|
52
56
|
data = parsed_json["data"].to_json
|
53
57
|
data = WorkflowNodeResultData.from_json(json_object: data)
|
54
58
|
end
|
59
|
+
source_execution_id = struct.source_execution_id
|
55
60
|
input_values = parsed_json["input_values"].map do |v|
|
56
61
|
v = v.to_json
|
57
62
|
NodeInputVariableCompiledValue.from_json(json_object: v)
|
58
63
|
end
|
59
|
-
new(id: id, node_id: node_id, node_result_id: node_result_id, ts: ts, data: data,
|
60
|
-
additional_properties: struct)
|
64
|
+
new(id: id, node_id: node_id, node_result_id: node_result_id, ts: ts, data: data,
|
65
|
+
source_execution_id: source_execution_id, input_values: input_values, additional_properties: struct)
|
61
66
|
end
|
62
67
|
|
63
68
|
# Serialize an instance of InitiatedWorkflowNodeResultEvent to a JSON object
|
@@ -70,6 +75,7 @@ module Vellum
|
|
70
75
|
"node_result_id": @node_result_id,
|
71
76
|
"ts": @ts,
|
72
77
|
"data": @data,
|
78
|
+
"source_execution_id": @source_execution_id,
|
73
79
|
"input_values": @input_values
|
74
80
|
}.to_json
|
75
81
|
end
|
@@ -84,6 +90,7 @@ module Vellum
|
|
84
90
|
obj.node_result_id.is_a?(String) != false || raise("Passed value for field obj.node_result_id is not the expected type, validation failed.")
|
85
91
|
obj.ts&.is_a?(DateTime) != false || raise("Passed value for field obj.ts is not the expected type, validation failed.")
|
86
92
|
obj.data.nil? || WorkflowNodeResultData.validate_raw(obj: obj.data)
|
93
|
+
obj.source_execution_id&.is_a?(String) != false || raise("Passed value for field obj.source_execution_id is not the expected type, validation failed.")
|
87
94
|
obj.input_values&.is_a?(Array) != false || raise("Passed value for field obj.input_values is not the expected type, validation failed.")
|
88
95
|
end
|
89
96
|
end
|
@@ -7,11 +7,12 @@ require "json"
|
|
7
7
|
|
8
8
|
module Vellum
|
9
9
|
class PromptTemplateBlockProperties
|
10
|
-
attr_reader :chat_role, :chat_message_unterminated, :template, :template_type, :function_name,
|
10
|
+
attr_reader :chat_role, :chat_message_unterminated, :chat_source, :template, :template_type, :function_name,
|
11
11
|
:function_description, :function_parameters, :function_forced, :blocks, :additional_properties
|
12
12
|
|
13
13
|
# @param chat_role [CHAT_MESSAGE_ROLE]
|
14
14
|
# @param chat_message_unterminated [Boolean]
|
15
|
+
# @param chat_source [String]
|
15
16
|
# @param template [String]
|
16
17
|
# @param template_type [VELLUM_VARIABLE_TYPE]
|
17
18
|
# @param function_name [String]
|
@@ -21,13 +22,15 @@ module Vellum
|
|
21
22
|
# @param blocks [Array<PromptTemplateBlock>]
|
22
23
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
23
24
|
# @return [PromptTemplateBlockProperties]
|
24
|
-
def initialize(chat_role: nil, chat_message_unterminated: nil, template: nil, template_type: nil,
|
25
|
+
def initialize(chat_role: nil, chat_message_unterminated: nil, chat_source: nil, template: nil, template_type: nil,
|
25
26
|
function_name: nil, function_description: nil, function_parameters: nil, function_forced: nil, blocks: nil, additional_properties: nil)
|
26
27
|
# @type [CHAT_MESSAGE_ROLE]
|
27
28
|
@chat_role = chat_role
|
28
29
|
# @type [Boolean]
|
29
30
|
@chat_message_unterminated = chat_message_unterminated
|
30
31
|
# @type [String]
|
32
|
+
@chat_source = chat_source
|
33
|
+
# @type [String]
|
31
34
|
@template = template
|
32
35
|
# @type [VELLUM_VARIABLE_TYPE]
|
33
36
|
@template_type = template_type
|
@@ -54,6 +57,7 @@ module Vellum
|
|
54
57
|
parsed_json = JSON.parse(json_object)
|
55
58
|
chat_role = CHAT_MESSAGE_ROLE.key(parsed_json["chat_role"]) || parsed_json["chat_role"]
|
56
59
|
chat_message_unterminated = struct.chat_message_unterminated
|
60
|
+
chat_source = struct.chat_source
|
57
61
|
template = struct.template
|
58
62
|
template_type = VELLUM_VARIABLE_TYPE.key(parsed_json["template_type"]) || parsed_json["template_type"]
|
59
63
|
function_name = struct.function_name
|
@@ -64,8 +68,8 @@ module Vellum
|
|
64
68
|
v = v.to_json
|
65
69
|
PromptTemplateBlock.from_json(json_object: v)
|
66
70
|
end
|
67
|
-
new(chat_role: chat_role, chat_message_unterminated: chat_message_unterminated,
|
68
|
-
template_type: template_type, function_name: function_name, function_description: function_description, function_parameters: function_parameters, function_forced: function_forced, blocks: blocks, additional_properties: struct)
|
71
|
+
new(chat_role: chat_role, chat_message_unterminated: chat_message_unterminated, chat_source: chat_source,
|
72
|
+
template: template, template_type: template_type, function_name: function_name, function_description: function_description, function_parameters: function_parameters, function_forced: function_forced, blocks: blocks, additional_properties: struct)
|
69
73
|
end
|
70
74
|
|
71
75
|
# Serialize an instance of PromptTemplateBlockProperties to a JSON object
|
@@ -75,6 +79,7 @@ module Vellum
|
|
75
79
|
{
|
76
80
|
"chat_role": CHAT_MESSAGE_ROLE[@chat_role] || @chat_role,
|
77
81
|
"chat_message_unterminated": @chat_message_unterminated,
|
82
|
+
"chat_source": @chat_source,
|
78
83
|
"template": @template,
|
79
84
|
"template_type": VELLUM_VARIABLE_TYPE[@template_type] || @template_type,
|
80
85
|
"function_name": @function_name,
|
@@ -92,6 +97,7 @@ module Vellum
|
|
92
97
|
def self.validate_raw(obj:)
|
93
98
|
obj.chat_role&.is_a?(CHAT_MESSAGE_ROLE) != false || raise("Passed value for field obj.chat_role is not the expected type, validation failed.")
|
94
99
|
obj.chat_message_unterminated&.is_a?(Boolean) != false || raise("Passed value for field obj.chat_message_unterminated is not the expected type, validation failed.")
|
100
|
+
obj.chat_source&.is_a?(String) != false || raise("Passed value for field obj.chat_source is not the expected type, validation failed.")
|
95
101
|
obj.template&.is_a?(String) != false || raise("Passed value for field obj.template is not the expected type, validation failed.")
|
96
102
|
obj.template_type&.is_a?(VELLUM_VARIABLE_TYPE) != false || raise("Passed value for field obj.template_type is not the expected type, validation failed.")
|
97
103
|
obj.function_name&.is_a?(String) != false || raise("Passed value for field obj.function_name is not the expected type, validation failed.")
|