Class: Vapi::TrieveKnowledgeBase

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, org_id:, name: OMIT, search_plan: OMIT, create_plan: OMIT, additional_properties: nil) ⇒ Vapi::TrieveKnowledgeBase

Parameters:

  • name (String) (defaults to: OMIT)

    This is the name of the knowledge base.

  • search_plan (Vapi::TrieveKnowledgeBaseSearchPlan) (defaults to: OMIT)

    This is the searching plan used when searching for relevant chunks from the vector store. You should configure this if you’re running into these issues:

    • Too much unnecessary context is being fed as knowledge base context.

    • Not enough relevant context is being fed as knowledge base context.

  • create_plan (Vapi::TrieveKnowledgeBaseImport) (defaults to: OMIT)

    This is the plan if you want us to create/import a new vector store using Trieve.

  • id (String)

    This is the id of the knowledge base.

  • org_id (String)

    This is the org id of the knowledge base.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/vapi_server_sdk/types/trieve_knowledge_base.rb', line 45

def initialize(id:, org_id:, name: OMIT, search_plan: OMIT, create_plan: OMIT, additional_properties: nil)
  @name = name if name != OMIT
  @search_plan = search_plan if search_plan != OMIT
  @create_plan = create_plan if create_plan != OMIT
  @id = id
  @org_id = org_id
  @additional_properties = additional_properties
  @_field_set = {
    "name": name,
    "searchPlan": search_plan,
    "createPlan": create_plan,
    "id": id,
    "orgId": org_id
  }.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.rb', line 26

def additional_properties
  @additional_properties
end

#create_planVapi::TrieveKnowledgeBaseImport (readonly)

Returns This is the plan if you want us to create/import a new vector store using Trieve.

Returns:



20
21
22
# File 'lib/vapi_server_sdk/types/trieve_knowledge_base.rb', line 20

def create_plan
  @create_plan
end

#idString (readonly)

Returns This is the id of the knowledge base.

Returns:

  • (String)

    This is the id of the knowledge base.



22
23
24
# File 'lib/vapi_server_sdk/types/trieve_knowledge_base.rb', line 22

def id
  @id
end

#nameString (readonly)

Returns This is the name of the knowledge base.

Returns:

  • (String)

    This is the name of the knowledge base.



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

def name
  @name
end

#org_idString (readonly)

Returns This is the org id of the knowledge base.

Returns:

  • (String)

    This is the org id of the knowledge base.



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

def org_id
  @org_id
end

#search_planVapi::TrieveKnowledgeBaseSearchPlan (readonly)

Returns This is the searching plan used when searching for relevant chunks from the vector store. You should configure this if you’re running into these issues:

  • Too much unnecessary context is being fed as knowledge base context.

  • Not enough relevant context is being fed as knowledge base context.

Returns:

  • (Vapi::TrieveKnowledgeBaseSearchPlan)

    This is the searching plan used when searching for relevant chunks from the vector store. You should configure this if you’re running into these issues:

    • Too much unnecessary context is being fed as knowledge base context.

    • Not enough relevant context is being fed as knowledge base context.



17
18
19
# File 'lib/vapi_server_sdk/types/trieve_knowledge_base.rb', line 17

def search_plan
  @search_plan
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::TrieveKnowledgeBase

Deserialize a JSON object to an instance of TrieveKnowledgeBase

Parameters:

  • json_object (String)

Returns:



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/vapi_server_sdk/types/trieve_knowledge_base.rb', line 67

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  name = parsed_json["name"]
  if parsed_json["searchPlan"].nil?
    search_plan = nil
  else
    search_plan = parsed_json["searchPlan"].to_json
    search_plan = Vapi::TrieveKnowledgeBaseSearchPlan.from_json(json_object: search_plan)
  end
  if parsed_json["createPlan"].nil?
    create_plan = nil
  else
    create_plan = parsed_json["createPlan"].to_json
    create_plan = Vapi::TrieveKnowledgeBaseImport.from_json(json_object: create_plan)
  end
  id = parsed_json["id"]
  org_id = parsed_json["orgId"]
  new(
    name: name,
    search_plan: search_plan,
    create_plan: create_plan,
    id: id,
    org_id: org_id,
    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)


108
109
110
111
112
113
114
# File 'lib/vapi_server_sdk/types/trieve_knowledge_base.rb', line 108

def self.validate_raw(obj:)
  obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
  obj.search_plan.nil? || Vapi::TrieveKnowledgeBaseSearchPlan.validate_raw(obj: obj.search_plan)
  obj.create_plan.nil? || Vapi::TrieveKnowledgeBaseImport.validate_raw(obj: obj.create_plan)
  obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
  obj.org_id.is_a?(String) != false || raise("Passed value for field obj.org_id is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of TrieveKnowledgeBase to a JSON object

Returns:

  • (String)


98
99
100
# File 'lib/vapi_server_sdk/types/trieve_knowledge_base.rb', line 98

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