Class: Vellum::GenerateRequest
- Inherits:
-
Object
- Object
- Vellum::GenerateRequest
- Defined in:
- lib/vellum_ai/types/generate_request.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#chat_history ⇒ Object
readonly
special chat_history variable, if included in the prompt.
-
#external_ids ⇒ Object
readonly
outside of Vellum.
-
#input_values ⇒ Hash{String => Object}
readonly
Key/value pairs for each template variable defined in the deployment’s prompt.
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(input_values:, chat_history: OMIT, external_ids: OMIT, additional_properties: nil) ⇒ Vellum::GenerateRequest constructor
- #to_json ⇒ String
Constructor Details
#initialize(input_values:, chat_history: OMIT, external_ids: OMIT, additional_properties: nil) ⇒ Vellum::GenerateRequest
31 32 33 34 35 36 37 38 39 |
# File 'lib/vellum_ai/types/generate_request.rb', line 31 def initialize(input_values:, chat_history: OMIT, external_ids: OMIT, additional_properties: nil) @input_values = input_values @chat_history = chat_history if chat_history != OMIT @external_ids = external_ids if external_ids != OMIT @additional_properties = additional_properties @_field_set = { "input_values": input_values, "chat_history": chat_history, "external_ids": external_ids }.reject do | _k, v | v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
17 18 19 |
# File 'lib/vellum_ai/types/generate_request.rb', line 17 def additional_properties @additional_properties end |
#chat_history ⇒ Object (readonly)
special chat_history variable, if included in the prompt.
12 13 14 |
# File 'lib/vellum_ai/types/generate_request.rb', line 12 def chat_history @chat_history end |
#external_ids ⇒ Object (readonly)
outside of Vellum. Note that this should generally be a list of length one.
15 16 17 |
# File 'lib/vellum_ai/types/generate_request.rb', line 15 def external_ids @external_ids end |
#input_values ⇒ Hash{String => Object} (readonly)
Returns Key/value pairs for each template variable defined in the deployment’s prompt.
9 10 11 |
# File 'lib/vellum_ai/types/generate_request.rb', line 9 def input_values @input_values end |
Class Method Details
.from_json(json_object:) ⇒ Vellum::GenerateRequest
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/vellum_ai/types/generate_request.rb', line 44 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) input_values = parsed_json["input_values"] chat_history = parsed_json["chat_history"]&.map do | item | item = item.to_json Vellum::ChatMessageRequest.from_json(json_object: item) end external_ids = parsed_json["external_ids"] new( input_values: input_values, chat_history: chat_history, external_ids: external_ids, additional_properties: struct ) end |
.validate_raw(obj:) ⇒ Void
72 73 74 75 76 |
# File 'lib/vellum_ai/types/generate_request.rb', line 72 def self.validate_raw(obj:) obj.input_values.is_a?(Hash) != false || raise("Passed value for field obj.input_values 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.") obj.external_ids&.is_a?(Array) != false || raise("Passed value for field obj.external_ids is not the expected type, validation failed.") end |
Instance Method Details
#to_json ⇒ String
63 64 65 |
# File 'lib/vellum_ai/types/generate_request.rb', line 63 def to_json @_field_set&.to_json end |