Class: Vellum::RejectedPromptExecutionMeta
- Inherits:
-
Object
- Object
- Vellum::RejectedPromptExecutionMeta
- Defined in:
- lib/vellum_ai/types/rejected_prompt_execution_meta.rb
Overview
The subset of the metadata tracked by Vellum during prompt execution that the request opted into with ‘expand_meta`.
Instance Attribute Summary collapse
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#finish_reason ⇒ Object
readonly
Returns the value of attribute finish_reason.
-
#latency ⇒ Object
readonly
Returns the value of attribute latency.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ RejectedPromptExecutionMeta
Deserialize a JSON object to an instance of RejectedPromptExecutionMeta.
-
.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(latency: nil, finish_reason: nil, additional_properties: nil) ⇒ RejectedPromptExecutionMeta constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of RejectedPromptExecutionMeta to a JSON object.
Constructor Details
#initialize(latency: nil, finish_reason: nil, additional_properties: nil) ⇒ RejectedPromptExecutionMeta
15 16 17 18 19 20 21 22 |
# File 'lib/vellum_ai/types/rejected_prompt_execution_meta.rb', line 15 def initialize(latency: nil, finish_reason: nil, additional_properties: nil) # @type [Integer] @latency = latency # @type [FINISH_REASON_ENUM] @finish_reason = finish_reason # @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/rejected_prompt_execution_meta.rb', line 9 def additional_properties @additional_properties end |
#finish_reason ⇒ Object (readonly)
Returns the value of attribute finish_reason.
9 10 11 |
# File 'lib/vellum_ai/types/rejected_prompt_execution_meta.rb', line 9 def finish_reason @finish_reason end |
#latency ⇒ Object (readonly)
Returns the value of attribute latency.
9 10 11 |
# File 'lib/vellum_ai/types/rejected_prompt_execution_meta.rb', line 9 def latency @latency end |
Class Method Details
.from_json(json_object:) ⇒ RejectedPromptExecutionMeta
Deserialize a JSON object to an instance of RejectedPromptExecutionMeta
28 29 30 31 32 33 34 |
# File 'lib/vellum_ai/types/rejected_prompt_execution_meta.rb', line 28 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) latency = struct.latency finish_reason = FINISH_REASON_ENUM.key(parsed_json["finish_reason"]) || parsed_json["finish_reason"] new(latency: latency, finish_reason: finish_reason, 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.
47 48 49 50 |
# File 'lib/vellum_ai/types/rejected_prompt_execution_meta.rb', line 47 def self.validate_raw(obj:) obj.latency&.is_a?(Integer) != false || raise("Passed value for field obj.latency is not the expected type, validation failed.") obj.finish_reason&.is_a?(FINISH_REASON_ENUM) != false || raise("Passed value for field obj.finish_reason is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ JSON
Serialize an instance of RejectedPromptExecutionMeta to a JSON object
39 40 41 |
# File 'lib/vellum_ai/types/rejected_prompt_execution_meta.rb', line 39 def to_json(*_args) { "latency": @latency, "finish_reason": FINISH_REASON_ENUM[@finish_reason] || @finish_reason }.to_json end |