vellum_ai 0.3.12 → 0.3.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/lib/requests.rb +2 -2
  3. data/lib/types_export.rb +30 -0
  4. data/lib/vellum_ai/test_suite_runs/client.rb +149 -0
  5. data/lib/vellum_ai/types/paginated_test_suite_run_execution_list.rb +64 -0
  6. data/lib/vellum_ai/types/test_suite_run_deployment_release_tag_exec_config.rb +57 -0
  7. data/lib/vellum_ai/types/test_suite_run_deployment_release_tag_exec_config_data.rb +50 -0
  8. data/lib/vellum_ai/types/test_suite_run_deployment_release_tag_exec_config_data_request.rb +50 -0
  9. data/lib/vellum_ai/types/test_suite_run_deployment_release_tag_exec_config_request.rb +57 -0
  10. data/lib/vellum_ai/types/test_suite_run_deployment_release_tag_exec_config_type_enum.rb +5 -0
  11. data/lib/vellum_ai/types/test_suite_run_exec_config.rb +90 -0
  12. data/lib/vellum_ai/types/test_suite_run_exec_config_request.rb +90 -0
  13. data/lib/vellum_ai/types/test_suite_run_execution.rb +69 -0
  14. data/lib/vellum_ai/types/test_suite_run_execution_chat_history_output.rb +54 -0
  15. data/lib/vellum_ai/types/test_suite_run_execution_error_output.rb +56 -0
  16. data/lib/vellum_ai/types/test_suite_run_execution_json_output.rb +50 -0
  17. data/lib/vellum_ai/types/test_suite_run_execution_metric_result.rb +54 -0
  18. data/lib/vellum_ai/types/test_suite_run_execution_number_output.rb +50 -0
  19. data/lib/vellum_ai/types/test_suite_run_execution_output.rb +142 -0
  20. data/lib/vellum_ai/types/test_suite_run_execution_search_results_output.rb +54 -0
  21. data/lib/vellum_ai/types/test_suite_run_execution_string_output.rb +50 -0
  22. data/lib/vellum_ai/types/test_suite_run_metric_error_output.rb +57 -0
  23. data/lib/vellum_ai/types/test_suite_run_metric_error_output_type_enum.rb +5 -0
  24. data/lib/vellum_ai/types/test_suite_run_metric_number_output.rb +51 -0
  25. data/lib/vellum_ai/types/test_suite_run_metric_number_output_type_enum.rb +5 -0
  26. data/lib/vellum_ai/types/test_suite_run_metric_output.rb +90 -0
  27. data/lib/vellum_ai/types/test_suite_run_read.rb +96 -0
  28. data/lib/vellum_ai/types/test_suite_run_state.rb +12 -0
  29. data/lib/vellum_ai/types/test_suite_run_test_suite.rb +55 -0
  30. data/lib/vellum_ai/types/test_suite_run_workflow_release_tag_exec_config.rb +57 -0
  31. data/lib/vellum_ai/types/test_suite_run_workflow_release_tag_exec_config_data.rb +50 -0
  32. data/lib/vellum_ai/types/test_suite_run_workflow_release_tag_exec_config_data_request.rb +50 -0
  33. data/lib/vellum_ai/types/test_suite_run_workflow_release_tag_exec_config_request.rb +57 -0
  34. data/lib/vellum_ai/types/test_suite_run_workflow_release_tag_exec_config_type_enum.rb +5 -0
  35. data/lib/vellum_ai/types/workflow_output_array.rb +2 -2
  36. data/lib/vellum_ai/types/workflow_output_chat_history.rb +2 -2
  37. data/lib/vellum_ai/types/workflow_output_error.rb +2 -2
  38. data/lib/vellum_ai/types/workflow_output_function_call.rb +2 -2
  39. data/lib/vellum_ai/types/workflow_output_image.rb +2 -2
  40. data/lib/vellum_ai/types/workflow_output_json.rb +2 -2
  41. data/lib/vellum_ai/types/workflow_output_number.rb +2 -2
  42. data/lib/vellum_ai/types/workflow_output_search_results.rb +2 -2
  43. data/lib/vellum_ai/types/workflow_output_string.rb +2 -2
  44. data/lib/vellum_ai.rb +5 -2
  45. metadata +33 -2
@@ -0,0 +1,90 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require_relative "test_suite_run_deployment_release_tag_exec_config_request"
5
+ require_relative "test_suite_run_workflow_release_tag_exec_config_request"
6
+
7
+ module Vellum
8
+ class TestSuiteRunExecConfigRequest
9
+ attr_reader :member, :discriminant
10
+
11
+ private_class_method :new
12
+ alias kind_of? is_a?
13
+ # @param member [Object]
14
+ # @param discriminant [String]
15
+ # @return [TestSuiteRunExecConfigRequest]
16
+ def initialize(member:, discriminant:)
17
+ # @type [Object]
18
+ @member = member
19
+ # @type [String]
20
+ @discriminant = discriminant
21
+ end
22
+
23
+ # Deserialize a JSON object to an instance of TestSuiteRunExecConfigRequest
24
+ #
25
+ # @param json_object [JSON]
26
+ # @return [TestSuiteRunExecConfigRequest]
27
+ def self.from_json(json_object:)
28
+ struct = JSON.parse(json_object, object_class: OpenStruct)
29
+ member = case struct.type
30
+ when "DEPLOYMENT_RELEASE_TAG"
31
+ TestSuiteRunDeploymentReleaseTagExecConfigRequest.from_json(json_object: json_object)
32
+ when "WORKFLOW_RELEASE_TAG"
33
+ TestSuiteRunWorkflowReleaseTagExecConfigRequest.from_json(json_object: json_object)
34
+ else
35
+ TestSuiteRunDeploymentReleaseTagExecConfigRequest.from_json(json_object: json_object)
36
+ end
37
+ new(member: member, discriminant: struct.type)
38
+ end
39
+
40
+ # For Union Types, to_json functionality is delegated to the wrapped member.
41
+ #
42
+ # @return [JSON]
43
+ def to_json(*_args)
44
+ case @discriminant
45
+ when "DEPLOYMENT_RELEASE_TAG"
46
+ { **@member.to_json, type: @discriminant }.to_json
47
+ when "WORKFLOW_RELEASE_TAG"
48
+ { **@member.to_json, type: @discriminant }.to_json
49
+ else
50
+ { "type": @discriminant, value: @member }.to_json
51
+ end
52
+ @member.to_json
53
+ end
54
+
55
+ # 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.
56
+ #
57
+ # @param obj [Object]
58
+ # @return [Void]
59
+ def self.validate_raw(obj:)
60
+ case obj.type
61
+ when "DEPLOYMENT_RELEASE_TAG"
62
+ TestSuiteRunDeploymentReleaseTagExecConfigRequest.validate_raw(obj: obj)
63
+ when "WORKFLOW_RELEASE_TAG"
64
+ TestSuiteRunWorkflowReleaseTagExecConfigRequest.validate_raw(obj: obj)
65
+ else
66
+ raise("Passed value matched no type within the union, validation failed.")
67
+ end
68
+ end
69
+
70
+ # For Union Types, is_a? functionality is delegated to the wrapped member.
71
+ #
72
+ # @param obj [Object]
73
+ # @return [Boolean]
74
+ def is_a?(obj)
75
+ @member.is_a?(obj)
76
+ end
77
+
78
+ # @param member [TestSuiteRunDeploymentReleaseTagExecConfigRequest]
79
+ # @return [TestSuiteRunExecConfigRequest]
80
+ def self.deployment_release_tag(member:)
81
+ new(member: member, discriminant: "DEPLOYMENT_RELEASE_TAG")
82
+ end
83
+
84
+ # @param member [TestSuiteRunWorkflowReleaseTagExecConfigRequest]
85
+ # @return [TestSuiteRunExecConfigRequest]
86
+ def self.workflow_release_tag(member:)
87
+ new(member: member, discriminant: "WORKFLOW_RELEASE_TAG")
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "test_suite_run_execution_output"
4
+ require_relative "test_suite_run_execution_metric_result"
5
+ require "json"
6
+
7
+ module Vellum
8
+ class TestSuiteRunExecution
9
+ attr_reader :id, :test_case_id, :outputs, :metric_results, :additional_properties
10
+
11
+ # @param id [String]
12
+ # @param test_case_id [String]
13
+ # @param outputs [Array<TestSuiteRunExecutionOutput>]
14
+ # @param metric_results [Array<TestSuiteRunExecutionMetricResult>]
15
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
16
+ # @return [TestSuiteRunExecution]
17
+ def initialize(id:, test_case_id:, outputs:, metric_results:, additional_properties: nil)
18
+ # @type [String]
19
+ @id = id
20
+ # @type [String]
21
+ @test_case_id = test_case_id
22
+ # @type [Array<TestSuiteRunExecutionOutput>]
23
+ @outputs = outputs
24
+ # @type [Array<TestSuiteRunExecutionMetricResult>]
25
+ @metric_results = metric_results
26
+ # @type [OpenStruct] Additional properties unmapped to the current class definition
27
+ @additional_properties = additional_properties
28
+ end
29
+
30
+ # Deserialize a JSON object to an instance of TestSuiteRunExecution
31
+ #
32
+ # @param json_object [JSON]
33
+ # @return [TestSuiteRunExecution]
34
+ def self.from_json(json_object:)
35
+ struct = JSON.parse(json_object, object_class: OpenStruct)
36
+ parsed_json = JSON.parse(json_object)
37
+ id = struct.id
38
+ test_case_id = struct.test_case_id
39
+ outputs = parsed_json["outputs"].map do |v|
40
+ v = v.to_json
41
+ TestSuiteRunExecutionOutput.from_json(json_object: v)
42
+ end
43
+ metric_results = parsed_json["metric_results"].map do |v|
44
+ v = v.to_json
45
+ TestSuiteRunExecutionMetricResult.from_json(json_object: v)
46
+ end
47
+ new(id: id, test_case_id: test_case_id, outputs: outputs, metric_results: metric_results,
48
+ additional_properties: struct)
49
+ end
50
+
51
+ # Serialize an instance of TestSuiteRunExecution to a JSON object
52
+ #
53
+ # @return [JSON]
54
+ def to_json(*_args)
55
+ { "id": @id, "test_case_id": @test_case_id, "outputs": @outputs, "metric_results": @metric_results }.to_json
56
+ end
57
+
58
+ # 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.
59
+ #
60
+ # @param obj [Object]
61
+ # @return [Void]
62
+ def self.validate_raw(obj:)
63
+ obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
64
+ obj.test_case_id.is_a?(String) != false || raise("Passed value for field obj.test_case_id is not the expected type, validation failed.")
65
+ obj.outputs.is_a?(Array) != false || raise("Passed value for field obj.outputs is not the expected type, validation failed.")
66
+ obj.metric_results.is_a?(Array) != false || raise("Passed value for field obj.metric_results is not the expected type, validation failed.")
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "chat_message"
4
+ require "json"
5
+
6
+ module Vellum
7
+ class TestSuiteRunExecutionChatHistoryOutput
8
+ attr_reader :output_variable_id, :value, :additional_properties
9
+
10
+ # @param output_variable_id [String]
11
+ # @param value [Array<ChatMessage>]
12
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
13
+ # @return [TestSuiteRunExecutionChatHistoryOutput]
14
+ def initialize(output_variable_id:, value: nil, additional_properties: nil)
15
+ # @type [String]
16
+ @output_variable_id = output_variable_id
17
+ # @type [Array<ChatMessage>]
18
+ @value = value
19
+ # @type [OpenStruct] Additional properties unmapped to the current class definition
20
+ @additional_properties = additional_properties
21
+ end
22
+
23
+ # Deserialize a JSON object to an instance of TestSuiteRunExecutionChatHistoryOutput
24
+ #
25
+ # @param json_object [JSON]
26
+ # @return [TestSuiteRunExecutionChatHistoryOutput]
27
+ def self.from_json(json_object:)
28
+ struct = JSON.parse(json_object, object_class: OpenStruct)
29
+ parsed_json = JSON.parse(json_object)
30
+ output_variable_id = struct.output_variable_id
31
+ value = parsed_json["value"].map do |v|
32
+ v = v.to_json
33
+ ChatMessage.from_json(json_object: v)
34
+ end
35
+ new(output_variable_id: output_variable_id, value: value, additional_properties: struct)
36
+ end
37
+
38
+ # Serialize an instance of TestSuiteRunExecutionChatHistoryOutput to a JSON object
39
+ #
40
+ # @return [JSON]
41
+ def to_json(*_args)
42
+ { "output_variable_id": @output_variable_id, "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.output_variable_id.is_a?(String) != false || raise("Passed value for field obj.output_variable_id is not the expected type, validation failed.")
51
+ obj.value&.is_a?(Array) != false || raise("Passed value for field obj.value is not the expected type, validation failed.")
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "vellum_error"
4
+ require "json"
5
+
6
+ module Vellum
7
+ class TestSuiteRunExecutionErrorOutput
8
+ attr_reader :output_variable_id, :value, :additional_properties
9
+
10
+ # @param output_variable_id [String]
11
+ # @param value [VellumError]
12
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
13
+ # @return [TestSuiteRunExecutionErrorOutput]
14
+ def initialize(output_variable_id:, value: nil, additional_properties: nil)
15
+ # @type [String]
16
+ @output_variable_id = output_variable_id
17
+ # @type [VellumError]
18
+ @value = value
19
+ # @type [OpenStruct] Additional properties unmapped to the current class definition
20
+ @additional_properties = additional_properties
21
+ end
22
+
23
+ # Deserialize a JSON object to an instance of TestSuiteRunExecutionErrorOutput
24
+ #
25
+ # @param json_object [JSON]
26
+ # @return [TestSuiteRunExecutionErrorOutput]
27
+ def self.from_json(json_object:)
28
+ struct = JSON.parse(json_object, object_class: OpenStruct)
29
+ parsed_json = JSON.parse(json_object)
30
+ output_variable_id = struct.output_variable_id
31
+ if parsed_json["value"].nil?
32
+ value = nil
33
+ else
34
+ value = parsed_json["value"].to_json
35
+ value = VellumError.from_json(json_object: value)
36
+ end
37
+ new(output_variable_id: output_variable_id, value: value, additional_properties: struct)
38
+ end
39
+
40
+ # Serialize an instance of TestSuiteRunExecutionErrorOutput to a JSON object
41
+ #
42
+ # @return [JSON]
43
+ def to_json(*_args)
44
+ { "output_variable_id": @output_variable_id, "value": @value }.to_json
45
+ end
46
+
47
+ # 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.
48
+ #
49
+ # @param obj [Object]
50
+ # @return [Void]
51
+ def self.validate_raw(obj:)
52
+ obj.output_variable_id.is_a?(String) != false || raise("Passed value for field obj.output_variable_id is not the expected type, validation failed.")
53
+ obj.value.nil? || VellumError.validate_raw(obj: obj.value)
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+
5
+ module Vellum
6
+ class TestSuiteRunExecutionJsonOutput
7
+ attr_reader :output_variable_id, :value, :additional_properties
8
+
9
+ # @param output_variable_id [String]
10
+ # @param value [Hash{String => String}]
11
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
12
+ # @return [TestSuiteRunExecutionJsonOutput]
13
+ def initialize(output_variable_id:, value: nil, additional_properties: nil)
14
+ # @type [String]
15
+ @output_variable_id = output_variable_id
16
+ # @type [Hash{String => String}]
17
+ @value = value
18
+ # @type [OpenStruct] Additional properties unmapped to the current class definition
19
+ @additional_properties = additional_properties
20
+ end
21
+
22
+ # Deserialize a JSON object to an instance of TestSuiteRunExecutionJsonOutput
23
+ #
24
+ # @param json_object [JSON]
25
+ # @return [TestSuiteRunExecutionJsonOutput]
26
+ def self.from_json(json_object:)
27
+ struct = JSON.parse(json_object, object_class: OpenStruct)
28
+ JSON.parse(json_object)
29
+ output_variable_id = struct.output_variable_id
30
+ value = struct.value
31
+ new(output_variable_id: output_variable_id, value: value, additional_properties: struct)
32
+ end
33
+
34
+ # Serialize an instance of TestSuiteRunExecutionJsonOutput to a JSON object
35
+ #
36
+ # @return [JSON]
37
+ def to_json(*_args)
38
+ { "output_variable_id": @output_variable_id, "value": @value }.to_json
39
+ end
40
+
41
+ # 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.
42
+ #
43
+ # @param obj [Object]
44
+ # @return [Void]
45
+ def self.validate_raw(obj:)
46
+ obj.output_variable_id.is_a?(String) != false || raise("Passed value for field obj.output_variable_id is not the expected type, validation failed.")
47
+ obj.value&.is_a?(Hash) != false || raise("Passed value for field obj.value is not the expected type, validation failed.")
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "test_suite_run_metric_output"
4
+ require "json"
5
+
6
+ module Vellum
7
+ class TestSuiteRunExecutionMetricResult
8
+ attr_reader :metric_id, :outputs, :additional_properties
9
+
10
+ # @param metric_id [String]
11
+ # @param outputs [Array<TestSuiteRunMetricOutput>]
12
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
13
+ # @return [TestSuiteRunExecutionMetricResult]
14
+ def initialize(metric_id:, outputs:, additional_properties: nil)
15
+ # @type [String]
16
+ @metric_id = metric_id
17
+ # @type [Array<TestSuiteRunMetricOutput>]
18
+ @outputs = outputs
19
+ # @type [OpenStruct] Additional properties unmapped to the current class definition
20
+ @additional_properties = additional_properties
21
+ end
22
+
23
+ # Deserialize a JSON object to an instance of TestSuiteRunExecutionMetricResult
24
+ #
25
+ # @param json_object [JSON]
26
+ # @return [TestSuiteRunExecutionMetricResult]
27
+ def self.from_json(json_object:)
28
+ struct = JSON.parse(json_object, object_class: OpenStruct)
29
+ parsed_json = JSON.parse(json_object)
30
+ metric_id = struct.metric_id
31
+ outputs = parsed_json["outputs"].map do |v|
32
+ v = v.to_json
33
+ TestSuiteRunMetricOutput.from_json(json_object: v)
34
+ end
35
+ new(metric_id: metric_id, outputs: outputs, additional_properties: struct)
36
+ end
37
+
38
+ # Serialize an instance of TestSuiteRunExecutionMetricResult to a JSON object
39
+ #
40
+ # @return [JSON]
41
+ def to_json(*_args)
42
+ { "metric_id": @metric_id, "outputs": @outputs }.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.metric_id.is_a?(String) != false || raise("Passed value for field obj.metric_id is not the expected type, validation failed.")
51
+ obj.outputs.is_a?(Array) != false || raise("Passed value for field obj.outputs is not the expected type, validation failed.")
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+
5
+ module Vellum
6
+ class TestSuiteRunExecutionNumberOutput
7
+ attr_reader :output_variable_id, :value, :additional_properties
8
+
9
+ # @param output_variable_id [String]
10
+ # @param value [Float]
11
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
12
+ # @return [TestSuiteRunExecutionNumberOutput]
13
+ def initialize(output_variable_id:, value: nil, additional_properties: nil)
14
+ # @type [String]
15
+ @output_variable_id = output_variable_id
16
+ # @type [Float]
17
+ @value = value
18
+ # @type [OpenStruct] Additional properties unmapped to the current class definition
19
+ @additional_properties = additional_properties
20
+ end
21
+
22
+ # Deserialize a JSON object to an instance of TestSuiteRunExecutionNumberOutput
23
+ #
24
+ # @param json_object [JSON]
25
+ # @return [TestSuiteRunExecutionNumberOutput]
26
+ def self.from_json(json_object:)
27
+ struct = JSON.parse(json_object, object_class: OpenStruct)
28
+ JSON.parse(json_object)
29
+ output_variable_id = struct.output_variable_id
30
+ value = struct.value
31
+ new(output_variable_id: output_variable_id, value: value, additional_properties: struct)
32
+ end
33
+
34
+ # Serialize an instance of TestSuiteRunExecutionNumberOutput to a JSON object
35
+ #
36
+ # @return [JSON]
37
+ def to_json(*_args)
38
+ { "output_variable_id": @output_variable_id, "value": @value }.to_json
39
+ end
40
+
41
+ # 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.
42
+ #
43
+ # @param obj [Object]
44
+ # @return [Void]
45
+ def self.validate_raw(obj:)
46
+ obj.output_variable_id.is_a?(String) != false || raise("Passed value for field obj.output_variable_id is not the expected type, validation failed.")
47
+ obj.value&.is_a?(Float) != false || raise("Passed value for field obj.value is not the expected type, validation failed.")
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,142 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require_relative "test_suite_run_execution_string_output"
5
+ require_relative "test_suite_run_execution_number_output"
6
+ require_relative "test_suite_run_execution_json_output"
7
+ require_relative "test_suite_run_execution_chat_history_output"
8
+ require_relative "test_suite_run_execution_search_results_output"
9
+ require_relative "test_suite_run_execution_error_output"
10
+
11
+ module Vellum
12
+ class TestSuiteRunExecutionOutput
13
+ attr_reader :member, :discriminant
14
+
15
+ private_class_method :new
16
+ alias kind_of? is_a?
17
+ # @param member [Object]
18
+ # @param discriminant [String]
19
+ # @return [TestSuiteRunExecutionOutput]
20
+ def initialize(member:, discriminant:)
21
+ # @type [Object]
22
+ @member = member
23
+ # @type [String]
24
+ @discriminant = discriminant
25
+ end
26
+
27
+ # Deserialize a JSON object to an instance of TestSuiteRunExecutionOutput
28
+ #
29
+ # @param json_object [JSON]
30
+ # @return [TestSuiteRunExecutionOutput]
31
+ def self.from_json(json_object:)
32
+ struct = JSON.parse(json_object, object_class: OpenStruct)
33
+ member = case struct.type
34
+ when "STRING"
35
+ TestSuiteRunExecutionStringOutput.from_json(json_object: json_object)
36
+ when "NUMBER"
37
+ TestSuiteRunExecutionNumberOutput.from_json(json_object: json_object)
38
+ when "JSON"
39
+ TestSuiteRunExecutionJsonOutput.from_json(json_object: json_object)
40
+ when "CHAT_HISTORY"
41
+ TestSuiteRunExecutionChatHistoryOutput.from_json(json_object: json_object)
42
+ when "SEARCH_RESULTS"
43
+ TestSuiteRunExecutionSearchResultsOutput.from_json(json_object: json_object)
44
+ when "ERROR"
45
+ TestSuiteRunExecutionErrorOutput.from_json(json_object: json_object)
46
+ else
47
+ TestSuiteRunExecutionStringOutput.from_json(json_object: json_object)
48
+ end
49
+ new(member: member, discriminant: struct.type)
50
+ end
51
+
52
+ # For Union Types, to_json functionality is delegated to the wrapped member.
53
+ #
54
+ # @return [JSON]
55
+ def to_json(*_args)
56
+ case @discriminant
57
+ when "STRING"
58
+ { **@member.to_json, type: @discriminant }.to_json
59
+ when "NUMBER"
60
+ { **@member.to_json, type: @discriminant }.to_json
61
+ when "JSON"
62
+ { **@member.to_json, type: @discriminant }.to_json
63
+ when "CHAT_HISTORY"
64
+ { **@member.to_json, type: @discriminant }.to_json
65
+ when "SEARCH_RESULTS"
66
+ { **@member.to_json, type: @discriminant }.to_json
67
+ when "ERROR"
68
+ { **@member.to_json, type: @discriminant }.to_json
69
+ else
70
+ { "type": @discriminant, value: @member }.to_json
71
+ end
72
+ @member.to_json
73
+ end
74
+
75
+ # 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.
76
+ #
77
+ # @param obj [Object]
78
+ # @return [Void]
79
+ def self.validate_raw(obj:)
80
+ case obj.type
81
+ when "STRING"
82
+ TestSuiteRunExecutionStringOutput.validate_raw(obj: obj)
83
+ when "NUMBER"
84
+ TestSuiteRunExecutionNumberOutput.validate_raw(obj: obj)
85
+ when "JSON"
86
+ TestSuiteRunExecutionJsonOutput.validate_raw(obj: obj)
87
+ when "CHAT_HISTORY"
88
+ TestSuiteRunExecutionChatHistoryOutput.validate_raw(obj: obj)
89
+ when "SEARCH_RESULTS"
90
+ TestSuiteRunExecutionSearchResultsOutput.validate_raw(obj: obj)
91
+ when "ERROR"
92
+ TestSuiteRunExecutionErrorOutput.validate_raw(obj: obj)
93
+ else
94
+ raise("Passed value matched no type within the union, validation failed.")
95
+ end
96
+ end
97
+
98
+ # For Union Types, is_a? functionality is delegated to the wrapped member.
99
+ #
100
+ # @param obj [Object]
101
+ # @return [Boolean]
102
+ def is_a?(obj)
103
+ @member.is_a?(obj)
104
+ end
105
+
106
+ # @param member [TestSuiteRunExecutionStringOutput]
107
+ # @return [TestSuiteRunExecutionOutput]
108
+ def self.string(member:)
109
+ new(member: member, discriminant: "STRING")
110
+ end
111
+
112
+ # @param member [TestSuiteRunExecutionNumberOutput]
113
+ # @return [TestSuiteRunExecutionOutput]
114
+ def self.number(member:)
115
+ new(member: member, discriminant: "NUMBER")
116
+ end
117
+
118
+ # @param member [TestSuiteRunExecutionJsonOutput]
119
+ # @return [TestSuiteRunExecutionOutput]
120
+ def self.json(member:)
121
+ new(member: member, discriminant: "JSON")
122
+ end
123
+
124
+ # @param member [TestSuiteRunExecutionChatHistoryOutput]
125
+ # @return [TestSuiteRunExecutionOutput]
126
+ def self.chat_history(member:)
127
+ new(member: member, discriminant: "CHAT_HISTORY")
128
+ end
129
+
130
+ # @param member [TestSuiteRunExecutionSearchResultsOutput]
131
+ # @return [TestSuiteRunExecutionOutput]
132
+ def self.search_results(member:)
133
+ new(member: member, discriminant: "SEARCH_RESULTS")
134
+ end
135
+
136
+ # @param member [TestSuiteRunExecutionErrorOutput]
137
+ # @return [TestSuiteRunExecutionOutput]
138
+ def self.error(member:)
139
+ new(member: member, discriminant: "ERROR")
140
+ end
141
+ end
142
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "search_result"
4
+ require "json"
5
+
6
+ module Vellum
7
+ class TestSuiteRunExecutionSearchResultsOutput
8
+ attr_reader :output_variable_id, :value, :additional_properties
9
+
10
+ # @param output_variable_id [String]
11
+ # @param value [Array<SearchResult>]
12
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
13
+ # @return [TestSuiteRunExecutionSearchResultsOutput]
14
+ def initialize(output_variable_id:, value: nil, additional_properties: nil)
15
+ # @type [String]
16
+ @output_variable_id = output_variable_id
17
+ # @type [Array<SearchResult>]
18
+ @value = value
19
+ # @type [OpenStruct] Additional properties unmapped to the current class definition
20
+ @additional_properties = additional_properties
21
+ end
22
+
23
+ # Deserialize a JSON object to an instance of TestSuiteRunExecutionSearchResultsOutput
24
+ #
25
+ # @param json_object [JSON]
26
+ # @return [TestSuiteRunExecutionSearchResultsOutput]
27
+ def self.from_json(json_object:)
28
+ struct = JSON.parse(json_object, object_class: OpenStruct)
29
+ parsed_json = JSON.parse(json_object)
30
+ output_variable_id = struct.output_variable_id
31
+ value = parsed_json["value"].map do |v|
32
+ v = v.to_json
33
+ SearchResult.from_json(json_object: v)
34
+ end
35
+ new(output_variable_id: output_variable_id, value: value, additional_properties: struct)
36
+ end
37
+
38
+ # Serialize an instance of TestSuiteRunExecutionSearchResultsOutput to a JSON object
39
+ #
40
+ # @return [JSON]
41
+ def to_json(*_args)
42
+ { "output_variable_id": @output_variable_id, "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.output_variable_id.is_a?(String) != false || raise("Passed value for field obj.output_variable_id is not the expected type, validation failed.")
51
+ obj.value&.is_a?(Array) != false || raise("Passed value for field obj.value is not the expected type, validation failed.")
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+
5
+ module Vellum
6
+ class TestSuiteRunExecutionStringOutput
7
+ attr_reader :output_variable_id, :value, :additional_properties
8
+
9
+ # @param output_variable_id [String]
10
+ # @param value [String]
11
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
12
+ # @return [TestSuiteRunExecutionStringOutput]
13
+ def initialize(output_variable_id:, value: nil, additional_properties: nil)
14
+ # @type [String]
15
+ @output_variable_id = output_variable_id
16
+ # @type [String]
17
+ @value = value
18
+ # @type [OpenStruct] Additional properties unmapped to the current class definition
19
+ @additional_properties = additional_properties
20
+ end
21
+
22
+ # Deserialize a JSON object to an instance of TestSuiteRunExecutionStringOutput
23
+ #
24
+ # @param json_object [JSON]
25
+ # @return [TestSuiteRunExecutionStringOutput]
26
+ def self.from_json(json_object:)
27
+ struct = JSON.parse(json_object, object_class: OpenStruct)
28
+ JSON.parse(json_object)
29
+ output_variable_id = struct.output_variable_id
30
+ value = struct.value
31
+ new(output_variable_id: output_variable_id, value: value, additional_properties: struct)
32
+ end
33
+
34
+ # Serialize an instance of TestSuiteRunExecutionStringOutput to a JSON object
35
+ #
36
+ # @return [JSON]
37
+ def to_json(*_args)
38
+ { "output_variable_id": @output_variable_id, "value": @value }.to_json
39
+ end
40
+
41
+ # 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.
42
+ #
43
+ # @param obj [Object]
44
+ # @return [Void]
45
+ def self.validate_raw(obj:)
46
+ obj.output_variable_id.is_a?(String) != false || raise("Passed value for field obj.output_variable_id is not the expected type, validation failed.")
47
+ obj.value&.is_a?(String) != false || raise("Passed value for field obj.value is not the expected type, validation failed.")
48
+ end
49
+ end
50
+ end