Class: Vellum::AdHocExpandMeta

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cost: OMIT, model_name: OMIT, usage: OMIT, finish_reason: OMIT, additional_properties: nil) ⇒ Vellum::AdHocExpandMeta

Parameters:

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



37
38
39
40
41
42
43
44
45
46
# File 'lib/vellum_ai/types/ad_hoc_expand_meta.rb', line 37

def initialize(cost: OMIT, model_name: OMIT, usage: OMIT, finish_reason: OMIT, additional_properties: nil)
  @cost = cost if cost != OMIT
  @model_name = model_name if model_name != OMIT
  @usage = usage if usage != OMIT
  @finish_reason = finish_reason if finish_reason != OMIT
  @additional_properties = additional_properties
  @_field_set = { "cost": cost, "model_name": model_name, "usage": usage, "finish_reason": finish_reason }.reject do | _k, v |
  v == OMIT
end
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



20
21
22
# File 'lib/vellum_ai/types/ad_hoc_expand_meta.rb', line 20

def additional_properties
  @additional_properties
end

#costObject (readonly)

increase latency for some model hosts.



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

def cost
  @cost
end

#finish_reasonObject (readonly)

the execution finished.



18
19
20
# File 'lib/vellum_ai/types/ad_hoc_expand_meta.rb', line 18

def finish_reason
  @finish_reason
end

#model_nameObject (readonly)

Model invoked by the Prompt.



12
13
14
# File 'lib/vellum_ai/types/ad_hoc_expand_meta.rb', line 12

def model_name
  @model_name
end

#usageObject (readonly)

increase latency for some model hosts.



15
16
17
# File 'lib/vellum_ai/types/ad_hoc_expand_meta.rb', line 15

def usage
  @usage
end

Class Method Details

.from_json(json_object:) ⇒ Vellum::AdHocExpandMeta

Parameters:

  • json_object (String)

Returns:



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/vellum_ai/types/ad_hoc_expand_meta.rb', line 51

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  cost = parsed_json["cost"]
  model_name = parsed_json["model_name"]
  usage = parsed_json["usage"]
  finish_reason = parsed_json["finish_reason"]
  new(
    cost: cost,
    model_name: model_name,
    usage: usage,
    finish_reason: finish_reason,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


78
79
80
81
82
83
# File 'lib/vellum_ai/types/ad_hoc_expand_meta.rb', line 78

def self.validate_raw(obj:)
  obj.cost&.is_a?(Boolean) != false || raise("Passed value for field obj.cost is not the expected type, validation failed.")
  obj.model_name&.is_a?(Boolean) != false || raise("Passed value for field obj.model_name is not the expected type, validation failed.")
  obj.usage&.is_a?(Boolean) != false || raise("Passed value for field obj.usage is not the expected type, validation failed.")
  obj.finish_reason&.is_a?(Boolean) != false || raise("Passed value for field obj.finish_reason is not the expected type, validation failed.")
end

Instance Method Details

#to_jsonString

Returns:

  • (String)


69
70
71
# File 'lib/vellum_ai/types/ad_hoc_expand_meta.rb', line 69

def to_json
  @_field_set&.to_json
end