Class: Vapi::KnowledgeBaseCost
- Inherits:
-
Object
- Object
- Vapi::KnowledgeBaseCost
- Defined in:
- lib/vapi_server_sdk/types/knowledge_base_cost.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#completion_tokens ⇒ Float
readonly
This is the number of completion tokens generated in the knowledge base query.
-
#cost ⇒ Float
readonly
This is the cost of the component in USD.
-
#model ⇒ Hash{String => Object}
readonly
This is the model that was used for processing the knowledge base.
-
#prompt_tokens ⇒ Float
readonly
This is the number of prompt tokens used in the knowledge base query.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Vapi::KnowledgeBaseCost
Deserialize a JSON object to an instance of KnowledgeBaseCost.
-
.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(model:, prompt_tokens:, completion_tokens:, cost:, additional_properties: nil) ⇒ Vapi::KnowledgeBaseCost constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of KnowledgeBaseCost to a JSON object.
Constructor Details
#initialize(model:, prompt_tokens:, completion_tokens:, cost:, additional_properties: nil) ⇒ Vapi::KnowledgeBaseCost
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/vapi_server_sdk/types/knowledge_base_cost.rb', line 30 def initialize(model:, prompt_tokens:, completion_tokens:, cost:, additional_properties: nil) @model = model @prompt_tokens = prompt_tokens @completion_tokens = completion_tokens @cost = cost @additional_properties = additional_properties @_field_set = { "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.
17 18 19 |
# File 'lib/vapi_server_sdk/types/knowledge_base_cost.rb', line 17 def additional_properties @additional_properties end |
#completion_tokens ⇒ Float (readonly)
Returns This is the number of completion tokens generated in the knowledge base query.
13 14 15 |
# File 'lib/vapi_server_sdk/types/knowledge_base_cost.rb', line 13 def completion_tokens @completion_tokens end |
#cost ⇒ Float (readonly)
Returns This is the cost of the component in USD.
15 16 17 |
# File 'lib/vapi_server_sdk/types/knowledge_base_cost.rb', line 15 def cost @cost end |
#model ⇒ Hash{String => Object} (readonly)
Returns This is the model that was used for processing the knowledge base.
9 10 11 |
# File 'lib/vapi_server_sdk/types/knowledge_base_cost.rb', line 9 def model @model end |
#prompt_tokens ⇒ Float (readonly)
Returns This is the number of prompt tokens used in the knowledge base query.
11 12 13 |
# File 'lib/vapi_server_sdk/types/knowledge_base_cost.rb', line 11 def prompt_tokens @prompt_tokens end |
Class Method Details
.from_json(json_object:) ⇒ Vapi::KnowledgeBaseCost
Deserialize a JSON object to an instance of KnowledgeBaseCost
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/vapi_server_sdk/types/knowledge_base_cost.rb', line 48 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) model = parsed_json["model"] prompt_tokens = parsed_json["promptTokens"] completion_tokens = parsed_json["completionTokens"] cost = parsed_json["cost"] new( 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.
77 78 79 80 81 82 |
# File 'lib/vapi_server_sdk/types/knowledge_base_cost.rb', line 77 def self.validate_raw(obj:) 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 KnowledgeBaseCost to a JSON object
67 68 69 |
# File 'lib/vapi_server_sdk/types/knowledge_base_cost.rb', line 67 def to_json(*_args) @_field_set&.to_json end |