Class: Vapi::TrieveKnowledgeBaseChunkPlan

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_ids: OMIT, websites: OMIT, target_splits_per_chunk: OMIT, split_delimiters: OMIT, rebalance_chunks: OMIT, additional_properties: nil) ⇒ Vapi::TrieveKnowledgeBaseChunkPlan

Parameters:

  • file_ids (Array<String>) (defaults to: OMIT)

    These are the file ids that will be used to create the vector store. To upload files, use the ‘POST /files` endpoint.

  • websites (Array<String>) (defaults to: OMIT)

    These are the websites that will be used to create the vector store.

  • target_splits_per_chunk (Float) (defaults to: OMIT)

    This is an optional field which allows you to specify the number of splits you want per chunk. If not specified, the default 20 is used. However, you may want to use a different number.

  • split_delimiters (Array<String>) (defaults to: OMIT)

    This is an optional field which allows you to specify the delimiters to use when splitting the file before chunking the text. If not specified, the default

    .!?n

    are used to split into sentences. However, you may want to use spaces or

    other delimiters.

  • rebalance_chunks (Boolean) (defaults to: OMIT)

    This is an optional field which allows you to specify whether or not to rebalance the chunks created from the file. If not specified, the default true is used. If true, Trieve will evenly distribute remainder splits across chunks such that 66 splits with a target_splits_per_chunk of 20 will result in 3 chunks with 22 splits each.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/vapi_server_sdk/types/trieve_knowledge_base_chunk_plan.rb', line 53

def initialize(file_ids: OMIT, websites: OMIT, target_splits_per_chunk: OMIT, split_delimiters: OMIT,
               rebalance_chunks: OMIT, additional_properties: nil)
  @file_ids = file_ids if file_ids != OMIT
  @websites = websites if websites != OMIT
  @target_splits_per_chunk = target_splits_per_chunk if target_splits_per_chunk != OMIT
  @split_delimiters = split_delimiters if split_delimiters != OMIT
  @rebalance_chunks = rebalance_chunks if rebalance_chunks != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "fileIds": file_ids,
    "websites": websites,
    "targetSplitsPerChunk": target_splits_per_chunk,
    "splitDelimiters": split_delimiters,
    "rebalanceChunks": rebalance_chunks
  }.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



29
30
31
# File 'lib/vapi_server_sdk/types/trieve_knowledge_base_chunk_plan.rb', line 29

def additional_properties
  @additional_properties
end

#file_idsArray<String> (readonly)

Returns These are the file ids that will be used to create the vector store. To upload files, use the ‘POST /files` endpoint.

Returns:

  • (Array<String>)

    These are the file ids that will be used to create the vector store. To upload files, use the ‘POST /files` endpoint.



10
11
12
# File 'lib/vapi_server_sdk/types/trieve_knowledge_base_chunk_plan.rb', line 10

def file_ids
  @file_ids
end

#rebalance_chunksBoolean (readonly)

Returns This is an optional field which allows you to specify whether or not to rebalance the chunks created from the file. If not specified, the default true is used. If true, Trieve will evenly distribute remainder splits across chunks such that 66 splits with a target_splits_per_chunk of 20 will result in 3 chunks with 22 splits each.

Returns:

  • (Boolean)

    This is an optional field which allows you to specify whether or not to rebalance the chunks created from the file. If not specified, the default true is used. If true, Trieve will evenly distribute remainder splits across chunks such that 66 splits with a target_splits_per_chunk of 20 will result in 3 chunks with 22 splits each.



27
28
29
# File 'lib/vapi_server_sdk/types/trieve_knowledge_base_chunk_plan.rb', line 27

def rebalance_chunks
  @rebalance_chunks
end

#split_delimitersArray<String> (readonly)

Returns This is an optional field which allows you to specify the delimiters to use when splitting the file before chunking the text. If not specified, the default

.!?n

are used to split into sentences. However, you may want to use spaces or

other delimiters.

Returns:

  • (Array<String>)

    This is an optional field which allows you to specify the delimiters to use when splitting the file before chunking the text. If not specified, the default

    .!?n

    are used to split into sentences. However, you may want to use spaces or

    other delimiters.



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

def split_delimiters
  @split_delimiters
end

#target_splits_per_chunkFloat (readonly)

Returns This is an optional field which allows you to specify the number of splits you want per chunk. If not specified, the default 20 is used. However, you may want to use a different number.

Returns:

  • (Float)

    This is an optional field which allows you to specify the number of splits you want per chunk. If not specified, the default 20 is used. However, you may want to use a different number.



16
17
18
# File 'lib/vapi_server_sdk/types/trieve_knowledge_base_chunk_plan.rb', line 16

def target_splits_per_chunk
  @target_splits_per_chunk
end

#websitesArray<String> (readonly)

Returns These are the websites that will be used to create the vector store.

Returns:

  • (Array<String>)

    These are the websites that will be used to create the vector store.



12
13
14
# File 'lib/vapi_server_sdk/types/trieve_knowledge_base_chunk_plan.rb', line 12

def websites
  @websites
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::TrieveKnowledgeBaseChunkPlan

Deserialize a JSON object to an instance of TrieveKnowledgeBaseChunkPlan

Parameters:

  • json_object (String)

Returns:



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/vapi_server_sdk/types/trieve_knowledge_base_chunk_plan.rb', line 76

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  file_ids = parsed_json["fileIds"]
  websites = parsed_json["websites"]
  target_splits_per_chunk = parsed_json["targetSplitsPerChunk"]
  split_delimiters = parsed_json["splitDelimiters"]
  rebalance_chunks = parsed_json["rebalanceChunks"]
  new(
    file_ids: file_ids,
    websites: websites,
    target_splits_per_chunk: target_splits_per_chunk,
    split_delimiters: split_delimiters,
    rebalance_chunks: rebalance_chunks,
    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)


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

def self.validate_raw(obj:)
  obj.file_ids&.is_a?(Array) != false || raise("Passed value for field obj.file_ids is not the expected type, validation failed.")
  obj.websites&.is_a?(Array) != false || raise("Passed value for field obj.websites is not the expected type, validation failed.")
  obj.target_splits_per_chunk&.is_a?(Float) != false || raise("Passed value for field obj.target_splits_per_chunk is not the expected type, validation failed.")
  obj.split_delimiters&.is_a?(Array) != false || raise("Passed value for field obj.split_delimiters is not the expected type, validation failed.")
  obj.rebalance_chunks&.is_a?(Boolean) != false || raise("Passed value for field obj.rebalance_chunks is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of TrieveKnowledgeBaseChunkPlan to a JSON object

Returns:

  • (String)


97
98
99
# File 'lib/vapi_server_sdk/types/trieve_knowledge_base_chunk_plan.rb', line 97

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