Class: Vellum::TestSuiteTestCase

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input_values:, evaluation_values:, id: nil, label: nil, additional_properties: nil) ⇒ TestSuiteTestCase

Parameters:

  • id (String) (defaults to: nil)
  • label (String) (defaults to: nil)
  • input_values (Array<TestCaseVariableValue>)
  • evaluation_values (Array<TestCaseVariableValue>)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/vellum_ai/types/test_suite_test_case.rb', line 16

def initialize(input_values:, evaluation_values:, id: nil, label: nil, additional_properties: nil)
  # @type [String]
  @id = id
  # @type [String]
  @label = label
  # @type [Array<TestCaseVariableValue>]
  @input_values = input_values
  # @type [Array<TestCaseVariableValue>]
  @evaluation_values = evaluation_values
  # @type [OpenStruct] Additional properties unmapped to the current class definition
  @additional_properties = additional_properties
end

Instance Attribute Details

#additional_propertiesObject (readonly)

Returns the value of attribute additional_properties.



8
9
10
# File 'lib/vellum_ai/types/test_suite_test_case.rb', line 8

def additional_properties
  @additional_properties
end

#evaluation_valuesObject (readonly)

Returns the value of attribute evaluation_values.



8
9
10
# File 'lib/vellum_ai/types/test_suite_test_case.rb', line 8

def evaluation_values
  @evaluation_values
end

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'lib/vellum_ai/types/test_suite_test_case.rb', line 8

def id
  @id
end

#input_valuesObject (readonly)

Returns the value of attribute input_values.



8
9
10
# File 'lib/vellum_ai/types/test_suite_test_case.rb', line 8

def input_values
  @input_values
end

#labelObject (readonly)

Returns the value of attribute label.



8
9
10
# File 'lib/vellum_ai/types/test_suite_test_case.rb', line 8

def label
  @label
end

Class Method Details

.from_json(json_object:) ⇒ TestSuiteTestCase

Deserialize a JSON object to an instance of TestSuiteTestCase

Parameters:

  • json_object (JSON)

Returns:



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/vellum_ai/types/test_suite_test_case.rb', line 33

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  id = struct.id
  label = struct.label
  input_values = parsed_json["input_values"].map do |v|
    v = v.to_json
    TestCaseVariableValue.from_json(json_object: v)
  end
  evaluation_values = parsed_json["evaluation_values"].map do |v|
    v = v.to_json
    TestCaseVariableValue.from_json(json_object: v)
  end
  new(id: id, label: label, input_values: input_values, evaluation_values: evaluation_values,
      additional_properties: struct)
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)


61
62
63
64
65
66
# File 'lib/vellum_ai/types/test_suite_test_case.rb', line 61

def self.validate_raw(obj:)
  obj.id&.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
  obj.label&.is_a?(String) != false || raise("Passed value for field obj.label is not the expected type, validation failed.")
  obj.input_values.is_a?(Array) != false || raise("Passed value for field obj.input_values is not the expected type, validation failed.")
  obj.evaluation_values.is_a?(Array) != false || raise("Passed value for field obj.evaluation_values is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ JSON

Serialize an instance of TestSuiteTestCase to a JSON object

Returns:

  • (JSON)


53
54
55
# File 'lib/vellum_ai/types/test_suite_test_case.rb', line 53

def to_json(*_args)
  { "id": @id, "label": @label, "input_values": @input_values, "evaluation_values": @evaluation_values }.to_json
end