Class: Vellum::PromptNodeExecutionMeta
- Inherits:
-
Object
- Object
- Vellum::PromptNodeExecutionMeta
- 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
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
- #cost ⇒ Vellum::Price readonly
- #model_name ⇒ String readonly
- #usage ⇒ Vellum::MlModelUsage readonly
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(usage: OMIT, cost: OMIT, model_name: OMIT, additional_properties: nil) ⇒ Vellum::PromptNodeExecutionMeta constructor
- #to_json ⇒ String
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_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
18 19 20 |
# File 'lib/vellum_ai/types/prompt_node_execution_meta.rb', line 18 def additional_properties @additional_properties end |
#cost ⇒ Vellum::Price (readonly)
14 15 16 |
# File 'lib/vellum_ai/types/prompt_node_execution_meta.rb', line 14 def cost @cost end |
#model_name ⇒ String (readonly)
16 17 18 |
# File 'lib/vellum_ai/types/prompt_node_execution_meta.rb', line 16 def model_name @model_name end |
#usage ⇒ Vellum::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_json ⇒ String
69 70 71 |
# File 'lib/vellum_ai/types/prompt_node_execution_meta.rb', line 69 def to_json @_field_set&.to_json end |