Class: Vellum::SandboxScenario

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

Overview

Sandbox Scenario

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(label: OMIT, inputs:, id:, additional_properties: nil) ⇒ Vellum::SandboxScenario

Parameters:

  • label (String) (defaults to: OMIT)
  • inputs (Array<Vellum::ScenarioInput>)

    The inputs for the scenario

  • id (String)

    The id of the scenario

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



28
29
30
31
32
33
34
35
36
# File 'lib/vellum_ai/types/sandbox_scenario.rb', line 28

def initialize(label: OMIT, inputs:, id:, additional_properties: nil)
  @label = label if label != OMIT
  @inputs = inputs
  @id = id
  @additional_properties = additional_properties
  @_field_set = { "label": label, "inputs": inputs, "id": id }.reject do | _k, v |
  v == OMIT
end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



16
17
18
# File 'lib/vellum_ai/types/sandbox_scenario.rb', line 16

def additional_properties
  @additional_properties
end

#idString (readonly)

Returns The id of the scenario.

Returns:

  • (String)

    The id of the scenario



14
15
16
# File 'lib/vellum_ai/types/sandbox_scenario.rb', line 14

def id
  @id
end

#inputsArray<Vellum::ScenarioInput> (readonly)

Returns The inputs for the scenario.

Returns:



12
13
14
# File 'lib/vellum_ai/types/sandbox_scenario.rb', line 12

def inputs
  @inputs
end

#labelString (readonly)

Returns:

  • (String)


10
11
12
# File 'lib/vellum_ai/types/sandbox_scenario.rb', line 10

def label
  @label
end

Class Method Details

.from_json(json_object:) ⇒ Vellum::SandboxScenario

Parameters:

  • json_object (String)

Returns:



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/vellum_ai/types/sandbox_scenario.rb', line 41

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  label = parsed_json["label"]
  inputs = parsed_json["inputs"]&.map do | item |
  item = item.to_json
  Vellum::ScenarioInput.from_json(json_object: item)
end
  id = parsed_json["id"]
  new(
    label: label,
    inputs: inputs,
    id: id,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


69
70
71
72
73
# File 'lib/vellum_ai/types/sandbox_scenario.rb', line 69

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

Instance Method Details

#to_jsonString

Returns:

  • (String)


60
61
62
# File 'lib/vellum_ai/types/sandbox_scenario.rb', line 60

def to_json
  @_field_set&.to_json
end