Class: Vellum::TokenOverlappingWindowChunking

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

Overview

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(chunker_name:, chunker_config: OMIT, additional_properties: nil) ⇒ Vellum::TokenOverlappingWindowChunking

Parameters:

  • chunker_name (String)
  • chunker_config (Vellum::TokenOverlappingWindowChunkerConfig) (defaults to: OMIT)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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

def initialize(chunker_name:, chunker_config: OMIT, additional_properties: nil)
  @chunker_name = chunker_name
  @chunker_config = chunker_config if chunker_config != OMIT
  @additional_properties = additional_properties
  @_field_set = { "chunker_name": chunker_name, "chunker_config": chunker_config }.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



14
15
16
# File 'lib/vellum_ai/types/token_overlapping_window_chunking.rb', line 14

def additional_properties
  @additional_properties
end

#chunker_configVellum::TokenOverlappingWindowChunkerConfig (readonly)



12
13
14
# File 'lib/vellum_ai/types/token_overlapping_window_chunking.rb', line 12

def chunker_config
  @chunker_config
end

#chunker_nameString (readonly)

Returns:

  • (String)


10
11
12
# File 'lib/vellum_ai/types/token_overlapping_window_chunking.rb', line 10

def chunker_name
  @chunker_name
end

Class Method Details

.from_json(json_object:) ⇒ Vellum::TokenOverlappingWindowChunking

Parameters:

  • json_object (String)

Returns:



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/vellum_ai/types/token_overlapping_window_chunking.rb', line 37

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  chunker_name = parsed_json["chunker_name"]
  unless parsed_json["chunker_config"].nil?
    chunker_config = parsed_json["chunker_config"].to_json
    chunker_config = Vellum::TokenOverlappingWindowChunkerConfig.from_json(json_object: chunker_config)
  else
    chunker_config = nil
  end
  new(
    chunker_name: chunker_name,
    chunker_config: chunker_config,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


65
66
67
68
# File 'lib/vellum_ai/types/token_overlapping_window_chunking.rb', line 65

def self.validate_raw(obj:)
  obj.chunker_name.is_a?(String) != false || raise("Passed value for field obj.chunker_name is not the expected type, validation failed.")
  obj.chunker_config.nil? || Vellum::TokenOverlappingWindowChunkerConfig.validate_raw(obj: obj.chunker_config)
end

Instance Method Details

#to_jsonString

Returns:

  • (String)


56
57
58
# File 'lib/vellum_ai/types/token_overlapping_window_chunking.rb', line 56

def to_json
  @_field_set&.to_json
end