class Vellum::ScenarioInput

def self.from_json(json_object:)

Returns:
  • (ScenarioInput) -

Parameters:
  • json_object (JSON) --
def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  key = struct.key
  type = SCENARIO_INPUT_TYPE_ENUM.key(parsed_json["type"]) || parsed_json["type"]
  value = struct.value
  chat_history = parsed_json["chat_history"].map do |v|
    v = v.to_json
    ChatMessage.from_json(json_object: v)
  end
  new(key: key, type: type, value: value, chat_history: chat_history, additional_properties: struct)
end

def self.validate_raw(obj:)

Returns:
  • (Void) -

Parameters:
  • obj (Object) --
def self.validate_raw(obj:)
  obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
  obj.type&.is_a?(SCENARIO_INPUT_TYPE_ENUM) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
  obj.value&.is_a?(String) != false || raise("Passed value for field obj.value is not the expected type, validation failed.")
  obj.chat_history&.is_a?(Array) != false || raise("Passed value for field obj.chat_history is not the expected type, validation failed.")
end

def initialize(key:, type: nil, value: nil, chat_history: nil, additional_properties: nil)

Returns:
  • (ScenarioInput) -

Parameters:
  • additional_properties (OpenStruct) -- Additional properties unmapped to the current class definition
  • chat_history (Array) --
  • value (String) --
  • type (SCENARIO_INPUT_TYPE_ENUM) --
  • key (String) --
def initialize(key:, type: nil, value: nil, chat_history: nil, additional_properties: nil)
  # @type [String]
  @key = key
  # @type [SCENARIO_INPUT_TYPE_ENUM]
  @type = type
  # @type [String]
  @value = value
  # @type [Array<ChatMessage>]
  @chat_history = chat_history
  # @type [OpenStruct] Additional properties unmapped to the current class definition
  @additional_properties = additional_properties
end

def to_json(*_args)

Returns:
  • (JSON) -
def to_json(*_args)
  {
    "key": @key,
    "type": SCENARIO_INPUT_TYPE_ENUM[@type] || @type,
    "value": @value,
    "chat_history": @chat_history
  }.to_json
end