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:, top_k: OMIT, remove_stop_words: OMIT, score_threshold: OMIT, additional_properties: nil) ⇒ Vapi::TrieveKnowledgeBaseSearchPlan

Parameters:

  • top_k (Float) (defaults to: OMIT)

    Specifies the number of top chunks to return. This corresponds to the ‘page_size` parameter in Trieve.

  • 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



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_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    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_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.



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_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.



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

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:



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

def search_type
  @search_type
end

#top_kFloat (readonly)

Returns Specifies the number of top chunks to return. This corresponds to the ‘page_size` parameter in Trieve.

Returns:

  • (Float)

    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

Parameters:

  • json_object (String)

Returns:



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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


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

Returns:

  • (String)


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