Class: Vapi::TrieveKnowledgeBaseSearchPlan
- Inherits:
-
Object
- Object
- Vapi::TrieveKnowledgeBaseSearchPlan
- Defined in:
- lib/vapi_server_sdk/types/trieve_knowledge_base_search_plan.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#remove_stop_words ⇒ Boolean
readonly
If true, stop words (specified in server/src/stop-words.txt in the git repo) will be removed.
-
#score_threshold ⇒ Float
readonly
This is the score threshold to filter out chunks with a score below the threshold for cosine distance metric.
-
#search_type ⇒ Vapi::TrieveKnowledgeBaseSearchPlanSearchType
readonly
This is the search method used when searching for relevant chunks from the vector store.
-
#top_k ⇒ Float
readonly
Specifies the number of top chunks to return.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Vapi::TrieveKnowledgeBaseSearchPlan
Deserialize a JSON object to an instance of TrieveKnowledgeBaseSearchPlan.
-
.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(search_type:, top_k: OMIT, remove_stop_words: OMIT, score_threshold: OMIT, additional_properties: nil) ⇒ Vapi::TrieveKnowledgeBaseSearchPlan constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of TrieveKnowledgeBaseSearchPlan to a JSON object.
Constructor Details
#initialize(search_type:, top_k: OMIT, remove_stop_words: OMIT, score_threshold: OMIT, additional_properties: nil) ⇒ Vapi::TrieveKnowledgeBaseSearchPlan
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/vapi_server_sdk/types/trieve_knowledge_base_search_plan.rb', line 47 def initialize(search_type:, top_k: OMIT, remove_stop_words: OMIT, score_threshold: OMIT, additional_properties: nil) @top_k = top_k if top_k != OMIT @remove_stop_words = remove_stop_words if remove_stop_words != OMIT @score_threshold = score_threshold if score_threshold != OMIT @search_type = search_type @additional_properties = additional_properties @_field_set = { "topK": top_k, "removeStopWords": remove_stop_words, "scoreThreshold": score_threshold, "searchType": search_type }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
26 27 28 |
# File 'lib/vapi_server_sdk/types/trieve_knowledge_base_search_plan.rb', line 26 def additional_properties @additional_properties end |
#remove_stop_words ⇒ Boolean (readonly)
Returns If true, stop words (specified in server/src/stop-words.txt in the git repo) will be removed. This will preserve queries that are entirely stop words.
14 15 16 |
# File 'lib/vapi_server_sdk/types/trieve_knowledge_base_search_plan.rb', line 14 def remove_stop_words @remove_stop_words end |
#score_threshold ⇒ Float (readonly)
Returns This is the score threshold to filter out chunks with a score below the threshold for cosine distance metric. For Manhattan Distance, Euclidean Distance, and Dot Product, it will filter out scores above the threshold distance. This threshold applies before weight and bias modifications. If not specified, this defaults to no threshold. A threshold of 0 will default to no threshold.
21 22 23 |
# File 'lib/vapi_server_sdk/types/trieve_knowledge_base_search_plan.rb', line 21 def score_threshold @score_threshold end |
#search_type ⇒ Vapi::TrieveKnowledgeBaseSearchPlanSearchType (readonly)
Returns This is the search method used when searching for relevant chunks from the vector store.
24 25 26 |
# File 'lib/vapi_server_sdk/types/trieve_knowledge_base_search_plan.rb', line 24 def search_type @search_type end |
#top_k ⇒ Float (readonly)
Returns Specifies the number of top chunks to return. This corresponds to the ‘page_size` parameter in Trieve.
11 12 13 |
# File 'lib/vapi_server_sdk/types/trieve_knowledge_base_search_plan.rb', line 11 def top_k @top_k end |
Class Method Details
.from_json(json_object:) ⇒ Vapi::TrieveKnowledgeBaseSearchPlan
Deserialize a JSON object to an instance of TrieveKnowledgeBaseSearchPlan
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/vapi_server_sdk/types/trieve_knowledge_base_search_plan.rb', line 68 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) top_k = parsed_json["topK"] remove_stop_words = parsed_json["removeStopWords"] score_threshold = parsed_json["scoreThreshold"] search_type = parsed_json["searchType"] new( top_k: top_k, remove_stop_words: remove_stop_words, score_threshold: score_threshold, search_type: search_type, 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.
97 98 99 100 101 102 |
# File 'lib/vapi_server_sdk/types/trieve_knowledge_base_search_plan.rb', line 97 def self.validate_raw(obj:) obj.top_k&.is_a?(Float) != false || raise("Passed value for field obj.top_k is not the expected type, validation failed.") obj.remove_stop_words&.is_a?(Boolean) != false || raise("Passed value for field obj.remove_stop_words is not the expected type, validation failed.") obj.score_threshold&.is_a?(Float) != false || raise("Passed value for field obj.score_threshold is not the expected type, validation failed.") obj.search_type.is_a?(Vapi::TrieveKnowledgeBaseSearchPlanSearchType) != false || raise("Passed value for field obj.search_type is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of TrieveKnowledgeBaseSearchPlan to a JSON object
87 88 89 |
# File 'lib/vapi_server_sdk/types/trieve_knowledge_base_search_plan.rb', line 87 def to_json(*_args) @_field_set&.to_json end |