Class: Vellum::SubmitCompletionActualRequest

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id: nil, external_id: nil, text: nil, quality: nil, timestamp: nil, additional_properties: nil) ⇒ SubmitCompletionActualRequest

Parameters:

  • id (String) (defaults to: nil)

    The Vellum-generated ID of a previously generated completion. Must provide either this or external_id.

  • external_id (String) (defaults to: nil)

    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.

  • text (String) (defaults to: nil)

    Text representing what the completion should have been.

  • quality (Float) (defaults to: nil)

    A number between 0 and 1 representing the quality of the completion. 0 is the worst, 1 is the best.

  • timestamp (DateTime) (defaults to: nil)

    Optionally provide the timestamp representing when this feedback was collected. Used for reporting purposes.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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 = timestamp
  # @type [OpenStruct] Additional properties unmapped to the current class definition
  @additional_properties = additional_properties
end

Instance Attribute Details

#additional_propertiesObject (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_idObject (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

#idObject (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

#qualityObject (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

#textObject (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

#timestampObject (readonly)

Returns the value of attribute timestamp.



8
9
10
# File 'lib/vellum_ai/types/submit_completion_actual_request.rb', line 8

def timestamp
  @timestamp
end

Class Method Details

.from_json(json_object:) ⇒ SubmitCompletionActualRequest

Deserialize a JSON object to an instance of SubmitCompletionActualRequest

Parameters:

  • json_object (JSON)

Returns:



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
  timestamp = DateTime.parse(parsed_json["timestamp"])
  new(id: id, external_id: external_id, text: text, quality: quality, timestamp: 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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


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.timestamp&.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

Returns:

  • (JSON)


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