Class: Vellum::PromptExecutionMeta
- Inherits:
-
Object
- Object
- Vellum::PromptExecutionMeta
- Defined in:
- lib/vellum_ai/types/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.
-
#deployment_release_tag ⇒ Object
readonly
Returns the value of attribute deployment_release_tag.
-
#finish_reason ⇒ Object
readonly
Returns the value of attribute finish_reason.
-
#latency ⇒ Object
readonly
Returns the value of attribute latency.
-
#model_name ⇒ Object
readonly
Returns the value of attribute model_name.
-
#prompt_version_id ⇒ Object
readonly
Returns the value of attribute prompt_version_id.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ PromptExecutionMeta
Deserialize a JSON object to an instance of PromptExecutionMeta.
-
.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(model_name: nil, latency: nil, deployment_release_tag: nil, prompt_version_id: nil, finish_reason: nil, additional_properties: nil) ⇒ PromptExecutionMeta constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of PromptExecutionMeta to a JSON object.
Constructor Details
#initialize(model_name: nil, latency: nil, deployment_release_tag: nil, prompt_version_id: nil, finish_reason: nil, additional_properties: nil) ⇒ PromptExecutionMeta
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/vellum_ai/types/prompt_execution_meta.rb', line 19 def initialize(model_name: nil, latency: nil, deployment_release_tag: nil, prompt_version_id: nil, finish_reason: nil, additional_properties: nil) # @type [String] @model_name = model_name # @type [Integer] @latency = latency # @type [String] @deployment_release_tag = deployment_release_tag # @type [String] @prompt_version_id = prompt_version_id # @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/prompt_execution_meta.rb', line 9 def additional_properties @additional_properties end |
#deployment_release_tag ⇒ Object (readonly)
Returns the value of attribute deployment_release_tag.
9 10 11 |
# File 'lib/vellum_ai/types/prompt_execution_meta.rb', line 9 def deployment_release_tag @deployment_release_tag end |
#finish_reason ⇒ Object (readonly)
Returns the value of attribute finish_reason.
9 10 11 |
# File 'lib/vellum_ai/types/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/prompt_execution_meta.rb', line 9 def latency @latency end |
#model_name ⇒ Object (readonly)
Returns the value of attribute model_name.
9 10 11 |
# File 'lib/vellum_ai/types/prompt_execution_meta.rb', line 9 def model_name @model_name end |
#prompt_version_id ⇒ Object (readonly)
Returns the value of attribute prompt_version_id.
9 10 11 |
# File 'lib/vellum_ai/types/prompt_execution_meta.rb', line 9 def prompt_version_id @prompt_version_id end |
Class Method Details
.from_json(json_object:) ⇒ PromptExecutionMeta
Deserialize a JSON object to an instance of PromptExecutionMeta
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/vellum_ai/types/prompt_execution_meta.rb', line 39 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) model_name = struct.model_name latency = struct.latency deployment_release_tag = struct.deployment_release_tag prompt_version_id = struct.prompt_version_id finish_reason = FINISH_REASON_ENUM.key(parsed_json["finish_reason"]) || parsed_json["finish_reason"] new(model_name: model_name, latency: latency, deployment_release_tag: deployment_release_tag, prompt_version_id: prompt_version_id, 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.
68 69 70 71 72 73 74 |
# File 'lib/vellum_ai/types/prompt_execution_meta.rb', line 68 def self.validate_raw(obj:) obj.model_name&.is_a?(String) != false || raise("Passed value for field obj.model_name is not the expected type, validation failed.") obj.latency&.is_a?(Integer) != false || raise("Passed value for field obj.latency is not the expected type, validation failed.") obj.deployment_release_tag&.is_a?(String) != false || raise("Passed value for field obj.deployment_release_tag is not the expected type, validation failed.") obj.prompt_version_id&.is_a?(String) != false || raise("Passed value for field obj.prompt_version_id 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 PromptExecutionMeta to a JSON object
54 55 56 57 58 59 60 61 62 |
# File 'lib/vellum_ai/types/prompt_execution_meta.rb', line 54 def to_json(*_args) { "model_name": @model_name, "latency": @latency, "deployment_release_tag": @deployment_release_tag, "prompt_version_id": @prompt_version_id, "finish_reason": FINISH_REASON_ENUM[@finish_reason] || @finish_reason }.to_json end |