Class: Vellum::AdHocFulfilledPromptExecutionMeta
- Inherits:
-
Object
- Object
- Vellum::AdHocFulfilledPromptExecutionMeta
- Defined in:
- lib/vellum_ai/types/ad_hoc_fulfilled_prompt_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
- #finish_reason ⇒ Vellum::FinishReasonEnum readonly
- #latency ⇒ Integer readonly
- #usage ⇒ Vellum::MlModelUsage readonly
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(latency: OMIT, finish_reason: OMIT, usage: OMIT, cost: OMIT, additional_properties: nil) ⇒ Vellum::AdHocFulfilledPromptExecutionMeta constructor
- #to_json ⇒ String
Constructor Details
#initialize(latency: OMIT, finish_reason: OMIT, usage: OMIT, cost: OMIT, additional_properties: nil) ⇒ Vellum::AdHocFulfilledPromptExecutionMeta
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/vellum_ai/types/ad_hoc_fulfilled_prompt_execution_meta.rb', line 34 def initialize(latency: OMIT, finish_reason: OMIT, usage: OMIT, cost: OMIT, additional_properties: nil) @latency = latency if latency != OMIT @finish_reason = finish_reason if finish_reason != OMIT @usage = usage if usage != OMIT @cost = cost if cost != OMIT @additional_properties = additional_properties @_field_set = { "latency": latency, "finish_reason": finish_reason, "usage": usage, "cost": cost }.reject do | _k, v | v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
21 22 23 |
# File 'lib/vellum_ai/types/ad_hoc_fulfilled_prompt_execution_meta.rb', line 21 def additional_properties @additional_properties end |
#cost ⇒ Vellum::Price (readonly)
19 20 21 |
# File 'lib/vellum_ai/types/ad_hoc_fulfilled_prompt_execution_meta.rb', line 19 def cost @cost end |
#finish_reason ⇒ Vellum::FinishReasonEnum (readonly)
15 16 17 |
# File 'lib/vellum_ai/types/ad_hoc_fulfilled_prompt_execution_meta.rb', line 15 def finish_reason @finish_reason end |
#latency ⇒ Integer (readonly)
13 14 15 |
# File 'lib/vellum_ai/types/ad_hoc_fulfilled_prompt_execution_meta.rb', line 13 def latency @latency end |
#usage ⇒ Vellum::MlModelUsage (readonly)
17 18 19 |
# File 'lib/vellum_ai/types/ad_hoc_fulfilled_prompt_execution_meta.rb', line 17 def usage @usage end |
Class Method Details
.from_json(json_object:) ⇒ Vellum::AdHocFulfilledPromptExecutionMeta
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/vellum_ai/types/ad_hoc_fulfilled_prompt_execution_meta.rb', line 48 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) latency = parsed_json["latency"] finish_reason = parsed_json["finish_reason"] 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 new( latency: latency, finish_reason: finish_reason, usage: usage, cost: cost, additional_properties: struct ) end |
.validate_raw(obj:) ⇒ Void
85 86 87 88 89 90 |
# File 'lib/vellum_ai/types/ad_hoc_fulfilled_prompt_execution_meta.rb', line 85 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.") obj.finish_reason&.is_a?(Vellum::FinishReasonEnum) != false || raise("Passed value for field obj.finish_reason is not the expected type, validation failed.") obj.usage.nil? || Vellum::MlModelUsage.validate_raw(obj: obj.usage) obj.cost.nil? || Vellum::Price.validate_raw(obj: obj.cost) end |
Instance Method Details
#to_json ⇒ String
76 77 78 |
# File 'lib/vellum_ai/types/ad_hoc_fulfilled_prompt_execution_meta.rb', line 76 def to_json @_field_set&.to_json end |