Class: Vapi::TrieveKnowledgeBaseSearchPlan

Inherits:
Object
  • Object
show all
Defined in:
lib/vapi_server_sdk/types/trieve_knowledge_base_search_plan.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(search_type:, remove_stop_words: OMIT, score_threshold: OMIT, additional_properties: nil) ⇒ Vapi::TrieveKnowledgeBaseSearchPlan

Parameters:

  • remove_stop_words (Boolean) (defaults to: OMIT)

    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.

  • score_threshold (Float) (defaults to: OMIT)

    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.

  • search_type (Vapi::TrieveKnowledgeBaseSearchPlanSearchType)

    This is the search method used when searching for relevant chunks from the vector store.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/vapi_server_sdk/types/trieve_knowledge_base_search_plan.rb', line 42

def initialize(search_type:, remove_stop_words: OMIT, score_threshold: OMIT, additional_properties: nil)
  @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 = {
    "removeStopWords": remove_stop_words,
    "scoreThreshold": score_threshold,
    "searchType": search_type
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



23
24
25
# File 'lib/vapi_server_sdk/types/trieve_knowledge_base_search_plan.rb', line 23

def additional_properties
  @additional_properties
end

#remove_stop_wordsBoolean (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.

Returns:

  • (Boolean)

    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.



11
12
13
# File 'lib/vapi_server_sdk/types/trieve_knowledge_base_search_plan.rb', line 11

def remove_stop_words
  @remove_stop_words
end

#score_thresholdFloat (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.

Returns:

  • (Float)

    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.



18
19
20
# File 'lib/vapi_server_sdk/types/trieve_knowledge_base_search_plan.rb', line 18

def score_threshold
  @score_threshold
end

#search_typeVapi::TrieveKnowledgeBaseSearchPlanSearchType (readonly)

Returns This is the search method used when searching for relevant chunks from the vector store.

Returns:



21
22
23
# File 'lib/vapi_server_sdk/types/trieve_knowledge_base_search_plan.rb', line 21

def search_type
  @search_type
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::TrieveKnowledgeBaseSearchPlan

Deserialize a JSON object to an instance of TrieveKnowledgeBaseSearchPlan

Parameters:

  • json_object (String)

Returns:



60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/vapi_server_sdk/types/trieve_knowledge_base_search_plan.rb', line 60

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  remove_stop_words = parsed_json["removeStopWords"]
  score_threshold = parsed_json["scoreThreshold"]
  search_type = parsed_json["searchType"]
  new(
    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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


87
88
89
90
91
# File 'lib/vapi_server_sdk/types/trieve_knowledge_base_search_plan.rb', line 87

def self.validate_raw(obj:)
  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

Returns:

  • (String)


77
78
79
# File 'lib/vapi_server_sdk/types/trieve_knowledge_base_search_plan.rb', line 77

def to_json(*_args)
  @_field_set&.to_json
end