Class: Vellum::FulfilledExecutePromptResponse
- Inherits:
-
Object
- Object
- Vellum::FulfilledExecutePromptResponse
- Defined in:
- lib/vellum_ai/types/fulfilled_execute_prompt_response.rb
Overview
The successful response from the model containing all of the resolved values generated by the prompt.
Instance Attribute Summary collapse
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#execution_id ⇒ Object
readonly
Returns the value of attribute execution_id.
-
#meta ⇒ Object
readonly
Returns the value of attribute meta.
-
#outputs ⇒ Object
readonly
Returns the value of attribute outputs.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ FulfilledExecutePromptResponse
Deserialize a JSON object to an instance of FulfilledExecutePromptResponse.
-
.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(execution_id:, outputs:, meta: nil, raw: nil, additional_properties: nil) ⇒ FulfilledExecutePromptResponse constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of FulfilledExecutePromptResponse to a JSON object.
Constructor Details
#initialize(execution_id:, outputs:, meta: nil, raw: nil, additional_properties: nil) ⇒ FulfilledExecutePromptResponse
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/vellum_ai/types/fulfilled_execute_prompt_response.rb', line 18 def initialize(execution_id:, outputs:, meta: nil, raw: nil, additional_properties: nil) # @type [PromptExecutionMeta] @meta = # @type [Hash{String => String}] The subset of the raw response from the model that the request opted into with `expand_raw`. @raw = raw # @type [String] The ID of the execution. @execution_id = execution_id # @type [Array<PromptOutput>] @outputs = outputs # @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.
10 11 12 |
# File 'lib/vellum_ai/types/fulfilled_execute_prompt_response.rb', line 10 def additional_properties @additional_properties end |
#execution_id ⇒ Object (readonly)
Returns the value of attribute execution_id.
10 11 12 |
# File 'lib/vellum_ai/types/fulfilled_execute_prompt_response.rb', line 10 def execution_id @execution_id end |
#meta ⇒ Object (readonly)
Returns the value of attribute meta.
10 11 12 |
# File 'lib/vellum_ai/types/fulfilled_execute_prompt_response.rb', line 10 def @meta end |
#outputs ⇒ Object (readonly)
Returns the value of attribute outputs.
10 11 12 |
# File 'lib/vellum_ai/types/fulfilled_execute_prompt_response.rb', line 10 def outputs @outputs end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
10 11 12 |
# File 'lib/vellum_ai/types/fulfilled_execute_prompt_response.rb', line 10 def raw @raw end |
Class Method Details
.from_json(json_object:) ⇒ FulfilledExecutePromptResponse
Deserialize a JSON object to an instance of FulfilledExecutePromptResponse
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/vellum_ai/types/fulfilled_execute_prompt_response.rb', line 35 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) if parsed_json["meta"].nil? = nil else = parsed_json["meta"].to_json = PromptExecutionMeta.from_json(json_object: ) end raw = struct.raw execution_id = struct.execution_id outputs = parsed_json["outputs"].map do |v| v = v.to_json PromptOutput.from_json(json_object: v) end new(meta: , raw: raw, execution_id: execution_id, outputs: outputs, 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.
64 65 66 67 68 69 |
# File 'lib/vellum_ai/types/fulfilled_execute_prompt_response.rb', line 64 def self.validate_raw(obj:) obj..nil? || PromptExecutionMeta.validate_raw(obj: obj.) obj.raw&.is_a?(Hash) != false || raise("Passed value for field obj.raw is not the expected type, validation failed.") obj.execution_id.is_a?(String) != false || raise("Passed value for field obj.execution_id is not the expected type, validation failed.") obj.outputs.is_a?(Array) != false || raise("Passed value for field obj.outputs is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ JSON
Serialize an instance of FulfilledExecutePromptResponse to a JSON object
56 57 58 |
# File 'lib/vellum_ai/types/fulfilled_execute_prompt_response.rb', line 56 def to_json(*_args) { "meta": @meta, "raw": @raw, "execution_id": @execution_id, "outputs": @outputs }.to_json end |