Class: Vellum::TokenOverlappingWindowChunkerConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/vellum_ai/types/token_overlapping_window_chunker_config.rb

Overview

Configuration for token overlapping window chunking

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token_limit: OMIT, overlap_ratio: OMIT, additional_properties: nil) ⇒ Vellum::TokenOverlappingWindowChunkerConfig



24
25
26
27
28
29
30
31
# File 'lib/vellum_ai/types/token_overlapping_window_chunker_config.rb', line 24

def initialize(token_limit: OMIT, overlap_ratio: OMIT, additional_properties: nil)
  @token_limit = token_limit if token_limit != OMIT
  @overlap_ratio = overlap_ratio if overlap_ratio != OMIT
  @additional_properties = additional_properties
  @_field_set = { "token_limit": token_limit, "overlap_ratio": overlap_ratio }.reject do | _k, v |
  v == OMIT
end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)



13
14
15
# File 'lib/vellum_ai/types/token_overlapping_window_chunker_config.rb', line 13

def additional_properties
  @additional_properties
end

#overlap_ratioFloat (readonly)



11
12
13
# File 'lib/vellum_ai/types/token_overlapping_window_chunker_config.rb', line 11

def overlap_ratio
  @overlap_ratio
end

#token_limitInteger (readonly)



9
10
11
# File 'lib/vellum_ai/types/token_overlapping_window_chunker_config.rb', line 9

def token_limit
  @token_limit
end

Class Method Details

.from_json(json_object:) ⇒ Vellum::TokenOverlappingWindowChunkerConfig



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/vellum_ai/types/token_overlapping_window_chunker_config.rb', line 36

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  token_limit = parsed_json["token_limit"]
  overlap_ratio = parsed_json["overlap_ratio"]
  new(
    token_limit: token_limit,
    overlap_ratio: overlap_ratio,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void



59
60
61
62
# File 'lib/vellum_ai/types/token_overlapping_window_chunker_config.rb', line 59

def self.validate_raw(obj:)
  obj.token_limit&.is_a?(Integer) != false || raise("Passed value for field obj.token_limit is not the expected type, validation failed.")
  obj.overlap_ratio&.is_a?(Float) != false || raise("Passed value for field obj.overlap_ratio is not the expected type, validation failed.")
end

Instance Method Details

#to_jsonString



50
51
52
# File 'lib/vellum_ai/types/token_overlapping_window_chunker_config.rb', line 50

def to_json
  @_field_set&.to_json
end