Class: Vapi::AnalysisCost
- Inherits:
-
Object
- Object
- Vapi::AnalysisCost
- Defined in:
- lib/vapi_server_sdk/types/analysis_cost.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#analysis_type ⇒ Vapi::AnalysisCostAnalysisType
readonly
This is the type of analysis performed.
-
#completion_tokens ⇒ Float
readonly
This is the number of completion tokens generated in the analysis.
-
#cost ⇒ Float
readonly
This is the cost of the component in USD.
-
#model ⇒ Hash{String => Object}
readonly
This is the model that was used to perform the analysis.
-
#prompt_tokens ⇒ Float
readonly
This is the number of prompt tokens used in the analysis.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Vapi::AnalysisCost
Deserialize a JSON object to an instance of AnalysisCost.
-
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.
Instance Method Summary collapse
- #initialize(analysis_type:, model:, prompt_tokens:, completion_tokens:, cost:, additional_properties: nil) ⇒ Vapi::AnalysisCost constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of AnalysisCost to a JSON object.
Constructor Details
#initialize(analysis_type:, model:, prompt_tokens:, completion_tokens:, cost:, additional_properties: nil) ⇒ Vapi::AnalysisCost
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/vapi_server_sdk/types/analysis_cost.rb', line 34 def initialize(analysis_type:, model:, prompt_tokens:, completion_tokens:, cost:, additional_properties: nil) @analysis_type = analysis_type @model = model @prompt_tokens = prompt_tokens @completion_tokens = completion_tokens @cost = cost @additional_properties = additional_properties @_field_set = { "analysisType": analysis_type, "model": model, "promptTokens": prompt_tokens, "completionTokens": completion_tokens, "cost": cost } end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
20 21 22 |
# File 'lib/vapi_server_sdk/types/analysis_cost.rb', line 20 def additional_properties @additional_properties end |
#analysis_type ⇒ Vapi::AnalysisCostAnalysisType (readonly)
Returns This is the type of analysis performed.
10 11 12 |
# File 'lib/vapi_server_sdk/types/analysis_cost.rb', line 10 def analysis_type @analysis_type end |
#completion_tokens ⇒ Float (readonly)
Returns This is the number of completion tokens generated in the analysis.
16 17 18 |
# File 'lib/vapi_server_sdk/types/analysis_cost.rb', line 16 def completion_tokens @completion_tokens end |
#cost ⇒ Float (readonly)
Returns This is the cost of the component in USD.
18 19 20 |
# File 'lib/vapi_server_sdk/types/analysis_cost.rb', line 18 def cost @cost end |
#model ⇒ Hash{String => Object} (readonly)
Returns This is the model that was used to perform the analysis.
12 13 14 |
# File 'lib/vapi_server_sdk/types/analysis_cost.rb', line 12 def model @model end |
#prompt_tokens ⇒ Float (readonly)
Returns This is the number of prompt tokens used in the analysis.
14 15 16 |
# File 'lib/vapi_server_sdk/types/analysis_cost.rb', line 14 def prompt_tokens @prompt_tokens end |
Class Method Details
.from_json(json_object:) ⇒ Vapi::AnalysisCost
Deserialize a JSON object to an instance of AnalysisCost
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/vapi_server_sdk/types/analysis_cost.rb', line 54 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) analysis_type = parsed_json["analysisType"] model = parsed_json["model"] prompt_tokens = parsed_json["promptTokens"] completion_tokens = parsed_json["completionTokens"] cost = parsed_json["cost"] new( analysis_type: analysis_type, model: model, prompt_tokens: prompt_tokens, completion_tokens: completion_tokens, cost: cost, additional_properties: struct ) end |
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given
hash and check each fields type against the current object's property
definitions.
85 86 87 88 89 90 91 |
# File 'lib/vapi_server_sdk/types/analysis_cost.rb', line 85 def self.validate_raw(obj:) obj.analysis_type.is_a?(Vapi::AnalysisCostAnalysisType) != false || raise("Passed value for field obj.analysis_type is not the expected type, validation failed.") obj.model.is_a?(Hash) != false || raise("Passed value for field obj.model is not the expected type, validation failed.") obj.prompt_tokens.is_a?(Float) != false || raise("Passed value for field obj.prompt_tokens is not the expected type, validation failed.") obj.completion_tokens.is_a?(Float) != false || raise("Passed value for field obj.completion_tokens is not the expected type, validation failed.") obj.cost.is_a?(Float) != false || raise("Passed value for field obj.cost is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of AnalysisCost to a JSON object
75 76 77 |
# File 'lib/vapi_server_sdk/types/analysis_cost.rb', line 75 def to_json(*_args) @_field_set&.to_json end |