Class: Vellum::StreamingPromptExecutionMeta

Inherits:
Object
  • Object
show all
Defined in:
lib/vellum_ai/types/streaming_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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(latency: nil, additional_properties: nil) ⇒ StreamingPromptExecutionMeta

Parameters:

  • latency (Integer) (defaults to: nil)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



13
14
15
16
17
18
# File 'lib/vellum_ai/types/streaming_prompt_execution_meta.rb', line 13

def initialize(latency: nil, additional_properties: nil)
  # @type [Integer]
  @latency = latency
  # @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/streaming_prompt_execution_meta.rb', line 8

def additional_properties
  @additional_properties
end

#latencyObject (readonly)

Returns the value of attribute latency.



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

def latency
  @latency
end

Class Method Details

.from_json(json_object:) ⇒ StreamingPromptExecutionMeta

Deserialize a JSON object to an instance of StreamingPromptExecutionMeta

Parameters:

  • json_object (JSON)

Returns:



24
25
26
27
28
29
# File 'lib/vellum_ai/types/streaming_prompt_execution_meta.rb', line 24

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  JSON.parse(json_object)
  latency = struct.latency
  new(latency: latency, 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)


42
43
44
# File 'lib/vellum_ai/types/streaming_prompt_execution_meta.rb', line 42

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.")
end

Instance Method Details

#to_json(*_args) ⇒ JSON

Serialize an instance of StreamingPromptExecutionMeta to a JSON object

Returns:

  • (JSON)


34
35
36
# File 'lib/vellum_ai/types/streaming_prompt_execution_meta.rb', line 34

def to_json(*_args)
  { "latency": @latency }.to_json
end