Class: Vellum::GenerateStreamResultData

Inherits:
Object
  • Object
show all
Defined in:
lib/vellum_ai/types/generate_stream_result_data.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(completion_index:, completion:, additional_properties: nil) ⇒ Vellum::GenerateStreamResultData

Parameters:

  • completion_index (Integer)
  • completion (Vellum::EnrichedNormalizedCompletion)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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

def initialize(completion_index:, completion:, additional_properties: nil)
  @completion_index = completion_index
  @completion = completion
  @additional_properties = additional_properties
  @_field_set = { "completion_index": completion_index, "completion": completion }
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



13
14
15
# File 'lib/vellum_ai/types/generate_stream_result_data.rb', line 13

def additional_properties
  @additional_properties
end

#completionVellum::EnrichedNormalizedCompletion (readonly)



11
12
13
# File 'lib/vellum_ai/types/generate_stream_result_data.rb', line 11

def completion
  @completion
end

#completion_indexInteger (readonly)

Returns:

  • (Integer)


9
10
11
# File 'lib/vellum_ai/types/generate_stream_result_data.rb', line 9

def completion_index
  @completion_index
end

Class Method Details

.from_json(json_object:) ⇒ Vellum::GenerateStreamResultData

Parameters:

  • json_object (String)

Returns:



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/vellum_ai/types/generate_stream_result_data.rb', line 34

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  completion_index = parsed_json["completion_index"]
  unless parsed_json["completion"].nil?
    completion = parsed_json["completion"].to_json
    completion = Vellum::EnrichedNormalizedCompletion.from_json(json_object: completion)
  else
    completion = nil
  end
  new(
    completion_index: completion_index,
    completion: completion,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


62
63
64
65
# File 'lib/vellum_ai/types/generate_stream_result_data.rb', line 62

def self.validate_raw(obj:)
  obj.completion_index.is_a?(Integer) != false || raise("Passed value for field obj.completion_index is not the expected type, validation failed.")
  Vellum::EnrichedNormalizedCompletion.validate_raw(obj: obj.completion)
end

Instance Method Details

#to_jsonString

Returns:

  • (String)


53
54
55
# File 'lib/vellum_ai/types/generate_stream_result_data.rb', line 53

def to_json
  @_field_set&.to_json
end