Class: Vellum::ScenarioInputRequest
- Inherits:
-
Object
- Object
- Vellum::ScenarioInputRequest
- Defined in:
- lib/vellum_ai/types/scenario_input_request.rb
Instance Attribute Summary collapse
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#chat_history ⇒ Object
readonly
Returns the value of attribute chat_history.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ ScenarioInputRequest
Deserialize a JSON object to an instance of ScenarioInputRequest.
-
.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.
Instance Method Summary collapse
- #initialize(key:, type: nil, value: nil, chat_history: nil, additional_properties: nil) ⇒ ScenarioInputRequest constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of ScenarioInputRequest to a JSON object.
Constructor Details
#initialize(key:, type: nil, value: nil, chat_history: nil, additional_properties: nil) ⇒ ScenarioInputRequest
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/vellum_ai/types/scenario_input_request.rb', line 17 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<ChatMessageRequest>] @chat_history = chat_history # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties end |
Instance Attribute Details
#additional_properties ⇒ Object (readonly)
Returns the value of attribute additional_properties.
9 10 11 |
# File 'lib/vellum_ai/types/scenario_input_request.rb', line 9 def additional_properties @additional_properties end |
#chat_history ⇒ Object (readonly)
Returns the value of attribute chat_history.
9 10 11 |
# File 'lib/vellum_ai/types/scenario_input_request.rb', line 9 def chat_history @chat_history end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
9 10 11 |
# File 'lib/vellum_ai/types/scenario_input_request.rb', line 9 def key @key end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
9 10 11 |
# File 'lib/vellum_ai/types/scenario_input_request.rb', line 9 def type @type end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
9 10 11 |
# File 'lib/vellum_ai/types/scenario_input_request.rb', line 9 def value @value end |
Class Method Details
.from_json(json_object:) ⇒ ScenarioInputRequest
Deserialize a JSON object to an instance of ScenarioInputRequest
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/vellum_ai/types/scenario_input_request.rb', line 34 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 ChatMessageRequest.from_json(json_object: v) end new(key: key, type: type, value: value, chat_history: chat_history, 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.
63 64 65 66 67 68 |
# File 'lib/vellum_ai/types/scenario_input_request.rb', line 63 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 |
Instance Method Details
#to_json(*_args) ⇒ JSON
Serialize an instance of ScenarioInputRequest to a JSON object
50 51 52 53 54 55 56 57 |
# File 'lib/vellum_ai/types/scenario_input_request.rb', line 50 def to_json(*_args) { "key": @key, "type": SCENARIO_INPUT_TYPE_ENUM[@type] || @type, "value": @value, "chat_history": @chat_history }.to_json end |