Class: Vellum::SubmitCompletionActualRequest
- Inherits:
-
Object
- Object
- Vellum::SubmitCompletionActualRequest
- Defined in:
- lib/vellum_ai/types/submit_completion_actual_request.rb
Instance Attribute Summary collapse
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#external_id ⇒ Object
readonly
Returns the value of attribute external_id.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#quality ⇒ Object
readonly
Returns the value of attribute quality.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ SubmitCompletionActualRequest
Deserialize a JSON object to an instance of SubmitCompletionActualRequest.
-
.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(id: nil, external_id: nil, text: nil, quality: nil, timestamp: nil, additional_properties: nil) ⇒ SubmitCompletionActualRequest constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of SubmitCompletionActualRequest to a JSON object.
Constructor Details
#initialize(id: nil, external_id: nil, text: nil, quality: nil, timestamp: nil, additional_properties: nil) ⇒ SubmitCompletionActualRequest
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/vellum_ai/types/submit_completion_actual_request.rb', line 17 def initialize(id: nil, external_id: nil, text: nil, quality: nil, timestamp: nil, additional_properties: nil) # @type [String] The Vellum-generated ID of a previously generated completion. Must provide either this or external_id. @id = id # @type [String] The external ID that was originally provided when generating the completion that you'd now like to submit actuals for. Must provide either this or id. @external_id = external_id # @type [String] Text representing what the completion _should_ have been. @text = text # @type [Float] A number between 0 and 1 representing the quality of the completion. 0 is the worst, 1 is the best. @quality = quality # @type [DateTime] Optionally provide the timestamp representing when this feedback was collected. Used for reporting purposes. @timestamp = # @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.
8 9 10 |
# File 'lib/vellum_ai/types/submit_completion_actual_request.rb', line 8 def additional_properties @additional_properties end |
#external_id ⇒ Object (readonly)
Returns the value of attribute external_id.
8 9 10 |
# File 'lib/vellum_ai/types/submit_completion_actual_request.rb', line 8 def external_id @external_id end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
8 9 10 |
# File 'lib/vellum_ai/types/submit_completion_actual_request.rb', line 8 def id @id end |
#quality ⇒ Object (readonly)
Returns the value of attribute quality.
8 9 10 |
# File 'lib/vellum_ai/types/submit_completion_actual_request.rb', line 8 def quality @quality end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
8 9 10 |
# File 'lib/vellum_ai/types/submit_completion_actual_request.rb', line 8 def text @text end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
8 9 10 |
# File 'lib/vellum_ai/types/submit_completion_actual_request.rb', line 8 def @timestamp end |
Class Method Details
.from_json(json_object:) ⇒ SubmitCompletionActualRequest
Deserialize a JSON object to an instance of SubmitCompletionActualRequest
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/vellum_ai/types/submit_completion_actual_request.rb', line 36 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) id = struct.id external_id = struct.external_id text = struct.text quality = struct.quality = DateTime.parse(parsed_json["timestamp"]) new(id: id, external_id: external_id, text: text, quality: quality, timestamp: , 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.
59 60 61 62 63 64 65 |
# File 'lib/vellum_ai/types/submit_completion_actual_request.rb', line 59 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.external_id&.is_a?(String) != false || raise("Passed value for field obj.external_id is not the expected type, validation failed.") obj.text&.is_a?(String) != false || raise("Passed value for field obj.text is not the expected type, validation failed.") obj.quality&.is_a?(Float) != false || raise("Passed value for field obj.quality is not the expected type, validation failed.") obj.&.is_a?(DateTime) != false || raise("Passed value for field obj.timestamp is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ JSON
Serialize an instance of SubmitCompletionActualRequest to a JSON object
51 52 53 |
# File 'lib/vellum_ai/types/submit_completion_actual_request.rb', line 51 def to_json(*_args) { "id": @id, "external_id": @external_id, "text": @text, "quality": @quality, "timestamp": @timestamp }.to_json end |