Class: Vellum::PromptNodeExecutionMeta

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

Overview

request opted into with ‘expand_meta`.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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



30
31
32
33
34
35
36
37
38
# File 'lib/vellum_ai/types/prompt_node_execution_meta.rb', line 30

def initialize(usage: OMIT, cost: OMIT, model_name: OMIT, additional_properties: nil)
  @usage = usage if usage != OMIT
  @cost = cost if cost != OMIT
  @model_name = model_name if model_name != OMIT
  @additional_properties = additional_properties
  @_field_set = { "usage": usage, "cost": cost, "model_name": model_name }.reject do | _k, v |
  v == OMIT
end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)



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

def additional_properties
  @additional_properties
end

#costVellum::Price (readonly)



14
15
16
# File 'lib/vellum_ai/types/prompt_node_execution_meta.rb', line 14

def cost
  @cost
end

#model_nameString (readonly)



16
17
18
# File 'lib/vellum_ai/types/prompt_node_execution_meta.rb', line 16

def model_name
  @model_name
end

#usageVellum::MlModelUsage (readonly)



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

def usage
  @usage
end

Class Method Details

.from_json(json_object:) ⇒ Vellum::PromptNodeExecutionMeta



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/vellum_ai/types/prompt_node_execution_meta.rb', line 43

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  unless parsed_json["usage"].nil?
    usage = parsed_json["usage"].to_json
    usage = Vellum::MlModelUsage.from_json(json_object: usage)
  else
    usage = nil
  end
  unless parsed_json["cost"].nil?
    cost = parsed_json["cost"].to_json
    cost = Vellum::Price.from_json(json_object: cost)
  else
    cost = nil
  end
  model_name = parsed_json["model_name"]
  new(
    usage: usage,
    cost: cost,
    model_name: model_name,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void



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

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

Instance Method Details

#to_jsonString



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

def to_json
  @_field_set&.to_json
end