Class: Vellum::StreamingExecutePromptEvent
- Inherits:
-
Object
- Object
- Vellum::StreamingExecutePromptEvent
- Defined in:
- lib/vellum_ai/types/streaming_execute_prompt_event.rb
Overview
The data returned for each delta during the prompt execution stream.
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.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
-
#output_index ⇒ Object
readonly
Returns the value of attribute output_index.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ StreamingExecutePromptEvent
Deserialize a JSON object to an instance of StreamingExecutePromptEvent.
-
.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(output:, output_index:, execution_id:, meta: nil, raw: nil, additional_properties: nil) ⇒ StreamingExecutePromptEvent constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of StreamingExecutePromptEvent to a JSON object.
Constructor Details
#initialize(output:, output_index:, execution_id:, meta: nil, raw: nil, additional_properties: nil) ⇒ StreamingExecutePromptEvent
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/vellum_ai/types/streaming_execute_prompt_event.rb', line 19 def initialize(output:, output_index:, execution_id:, meta: nil, raw: nil, additional_properties: nil) # @type [PromptOutput] @output = output # @type [Integer] @output_index = output_index # @type [String] @execution_id = execution_id # @type [StreamingPromptExecutionMeta] @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 [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/streaming_execute_prompt_event.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/streaming_execute_prompt_event.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/streaming_execute_prompt_event.rb', line 10 def @meta end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
10 11 12 |
# File 'lib/vellum_ai/types/streaming_execute_prompt_event.rb', line 10 def output @output end |
#output_index ⇒ Object (readonly)
Returns the value of attribute output_index.
10 11 12 |
# File 'lib/vellum_ai/types/streaming_execute_prompt_event.rb', line 10 def output_index @output_index end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
10 11 12 |
# File 'lib/vellum_ai/types/streaming_execute_prompt_event.rb', line 10 def raw @raw end |
Class Method Details
.from_json(json_object:) ⇒ StreamingExecutePromptEvent
Deserialize a JSON object to an instance of StreamingExecutePromptEvent
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/vellum_ai/types/streaming_execute_prompt_event.rb', line 38 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) if parsed_json["output"].nil? output = nil else output = parsed_json["output"].to_json output = PromptOutput.from_json(json_object: output) end output_index = struct.output_index execution_id = struct.execution_id if parsed_json["meta"].nil? = nil else = parsed_json["meta"].to_json = StreamingPromptExecutionMeta.from_json(json_object: ) end raw = struct.raw new(output: output, output_index: output_index, execution_id: execution_id, meta: , raw: raw, 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.
77 78 79 80 81 82 83 |
# File 'lib/vellum_ai/types/streaming_execute_prompt_event.rb', line 77 def self.validate_raw(obj:) PromptOutput.validate_raw(obj: obj.output) obj.output_index.is_a?(Integer) != false || raise("Passed value for field obj.output_index 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..nil? || StreamingPromptExecutionMeta.validate_raw(obj: obj.) obj.raw&.is_a?(Hash) != false || raise("Passed value for field obj.raw is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ JSON
Serialize an instance of StreamingExecutePromptEvent to a JSON object
63 64 65 66 67 68 69 70 71 |
# File 'lib/vellum_ai/types/streaming_execute_prompt_event.rb', line 63 def to_json(*_args) { "output": @output, "output_index": @output_index, "execution_id": @execution_id, "meta": @meta, "raw": @raw }.to_json end |