Class: Vapi::KnowledgeBase
- Inherits:
-
Object
- Object
- Vapi::KnowledgeBase
- Defined in:
- lib/vapi_server_sdk/types/knowledge_base.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
- #file_ids ⇒ Array<String> readonly
- #provider ⇒ String readonly
- #top_k ⇒ Float readonly
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Vapi::KnowledgeBase
Deserialize a JSON object to an instance of KnowledgeBase.
-
.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(provider:, file_ids:, top_k: OMIT, additional_properties: nil) ⇒ Vapi::KnowledgeBase constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of KnowledgeBase to a JSON object.
Constructor Details
#initialize(provider:, file_ids:, top_k: OMIT, additional_properties: nil) ⇒ Vapi::KnowledgeBase
27 28 29 30 31 32 33 34 35 |
# File 'lib/vapi_server_sdk/types/knowledge_base.rb', line 27 def initialize(provider:, file_ids:, top_k: OMIT, additional_properties: nil) @provider = provider @top_k = top_k if top_k != OMIT @file_ids = file_ids @additional_properties = additional_properties @_field_set = { "provider": provider, "topK": top_k, "fileIds": file_ids }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
15 16 17 |
# File 'lib/vapi_server_sdk/types/knowledge_base.rb', line 15 def additional_properties @additional_properties end |
#file_ids ⇒ Array<String> (readonly)
13 14 15 |
# File 'lib/vapi_server_sdk/types/knowledge_base.rb', line 13 def file_ids @file_ids end |
#provider ⇒ String (readonly)
9 10 11 |
# File 'lib/vapi_server_sdk/types/knowledge_base.rb', line 9 def provider @provider end |
#top_k ⇒ Float (readonly)
11 12 13 |
# File 'lib/vapi_server_sdk/types/knowledge_base.rb', line 11 def top_k @top_k end |
Class Method Details
.from_json(json_object:) ⇒ Vapi::KnowledgeBase
Deserialize a JSON object to an instance of KnowledgeBase
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/vapi_server_sdk/types/knowledge_base.rb', line 41 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) provider = parsed_json["provider"] top_k = parsed_json["topK"] file_ids = parsed_json["fileIds"] new( provider: provider, top_k: top_k, file_ids: file_ids, 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.
68 69 70 71 72 |
# File 'lib/vapi_server_sdk/types/knowledge_base.rb', line 68 def self.validate_raw(obj:) obj.provider.is_a?(String) != false || raise("Passed value for field obj.provider is not the expected type, validation failed.") obj.top_k&.is_a?(Float) != false || raise("Passed value for field obj.top_k is not the expected type, validation failed.") obj.file_ids.is_a?(Array) != false || raise("Passed value for field obj.file_ids is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of KnowledgeBase to a JSON object
58 59 60 |
# File 'lib/vapi_server_sdk/types/knowledge_base.rb', line 58 def to_json(*_args) @_field_set&.to_json end |