Class: AWSCDK::Bedrock::CfnDataSource::ChunkingConfigurationProperty

Inherits:
Jsii::Struct
  • Object
show all
Defined in:
bedrock/cfn_data_source.rb

Overview

Details about how to chunk the documents in the data source.

A chunk refers to an excerpt from a data source that is returned when the knowledge base that it belongs to is queried.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(chunking_strategy:, fixed_size_chunking_configuration: nil, hierarchical_chunking_configuration: nil, semantic_chunking_configuration: nil) ⇒ ChunkingConfigurationProperty

Returns a new instance of ChunkingConfigurationProperty.

Parameters:



808
809
810
811
812
813
814
815
816
817
# File 'bedrock/cfn_data_source.rb', line 808

def initialize(chunking_strategy:, fixed_size_chunking_configuration: nil, hierarchical_chunking_configuration: nil, semantic_chunking_configuration: nil)
  @chunking_strategy = chunking_strategy
  Jsii::Type.check_type(@chunking_strategy, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "chunkingStrategy")
  @fixed_size_chunking_configuration = fixed_size_chunking_configuration.is_a?(Hash) ? ::AWSCDK::Bedrock::CfnDataSource::FixedSizeChunkingConfigurationProperty.new(**fixed_size_chunking_configuration.transform_keys(&:to_sym)) : fixed_size_chunking_configuration
  Jsii::Type.check_type(@fixed_size_chunking_configuration, JSON.parse(Base64.strict_decode64("eyJ1bmlvbiI6eyJ0eXBlcyI6W3siZnFuIjoiYXdzLWNkay1saWIuSVJlc29sdmFibGUifSx7ImZxbiI6ImF3cy1jZGstbGliLmF3c19iZWRyb2NrLkNmbkRhdGFTb3VyY2UuRml4ZWRTaXplQ2h1bmtpbmdDb25maWd1cmF0aW9uUHJvcGVydHkifV19fQ==")), "fixedSizeChunkingConfiguration") unless @fixed_size_chunking_configuration.nil?
  @hierarchical_chunking_configuration = hierarchical_chunking_configuration.is_a?(Hash) ? ::AWSCDK::Bedrock::CfnDataSource::HierarchicalChunkingConfigurationProperty.new(**hierarchical_chunking_configuration.transform_keys(&:to_sym)) : hierarchical_chunking_configuration
  Jsii::Type.check_type(@hierarchical_chunking_configuration, JSON.parse(Base64.strict_decode64("eyJ1bmlvbiI6eyJ0eXBlcyI6W3siZnFuIjoiYXdzLWNkay1saWIuSVJlc29sdmFibGUifSx7ImZxbiI6ImF3cy1jZGstbGliLmF3c19iZWRyb2NrLkNmbkRhdGFTb3VyY2UuSGllcmFyY2hpY2FsQ2h1bmtpbmdDb25maWd1cmF0aW9uUHJvcGVydHkifV19fQ==")), "hierarchicalChunkingConfiguration") unless @hierarchical_chunking_configuration.nil?
  @semantic_chunking_configuration = semantic_chunking_configuration.is_a?(Hash) ? ::AWSCDK::Bedrock::CfnDataSource::SemanticChunkingConfigurationProperty.new(**semantic_chunking_configuration.transform_keys(&:to_sym)) : semantic_chunking_configuration
  Jsii::Type.check_type(@semantic_chunking_configuration, JSON.parse(Base64.strict_decode64("eyJ1bmlvbiI6eyJ0eXBlcyI6W3siZnFuIjoiYXdzLWNkay1saWIuSVJlc29sdmFibGUifSx7ImZxbiI6ImF3cy1jZGstbGliLmF3c19iZWRyb2NrLkNmbkRhdGFTb3VyY2UuU2VtYW50aWNDaHVua2luZ0NvbmZpZ3VyYXRpb25Qcm9wZXJ0eSJ9XX19")), "semanticChunkingConfiguration") unless @semantic_chunking_configuration.nil?
end

Instance Attribute Details

#chunking_strategyString (readonly)

Knowledge base can split your source data into chunks.

A chunk refers to an excerpt from a data source that is returned when the knowledge base that it belongs to is queried. You have the following options for chunking your data. If you opt for NONE , then you may want to pre-process your files by splitting them up such that each file corresponds to a chunk.

  • FIXED_SIZE – Amazon Bedrock splits your source data into chunks of the approximate size that you set in the fixed_size_chunking_configuration .
  • HIERARCHICAL – Split documents into layers of chunks where the first layer contains large chunks, and the second layer contains smaller chunks derived from the first layer.
  • SEMANTIC – Split documents into chunks based on groups of similar content derived with natural language processing.
  • NONE – Amazon Bedrock treats each file as one chunk. If you choose this option, you may want to pre-process your documents by splitting them into separate files.


830
831
832
# File 'bedrock/cfn_data_source.rb', line 830

def chunking_strategy
  @chunking_strategy
end

#fixed_size_chunking_configurationAWSCDK::IResolvable, ... (readonly)

Configurations for when you choose fixed-size chunking.

If you set the chunking_strategy as NONE , exclude this field.



837
838
839
# File 'bedrock/cfn_data_source.rb', line 837

def fixed_size_chunking_configuration
  @fixed_size_chunking_configuration
end

#hierarchical_chunking_configurationAWSCDK::IResolvable, ... (readonly)

Settings for hierarchical document chunking for a data source.

Hierarchical chunking splits documents into layers of chunks where the first layer contains large chunks, and the second layer contains smaller chunks derived from the first layer.



844
845
846
# File 'bedrock/cfn_data_source.rb', line 844

def hierarchical_chunking_configuration
  @hierarchical_chunking_configuration
end

#semantic_chunking_configurationAWSCDK::IResolvable, ... (readonly)

Settings for semantic document chunking for a data source.

Semantic chunking splits a document into into smaller documents based on groups of similar content derived from the text with natural language processing.



851
852
853
# File 'bedrock/cfn_data_source.rb', line 851

def semantic_chunking_configuration
  @semantic_chunking_configuration
end

Class Method Details

.jsii_propertiesObject



853
854
855
856
857
858
859
860
# File 'bedrock/cfn_data_source.rb', line 853

def self.jsii_properties
  {
    :chunking_strategy => "chunkingStrategy",
    :fixed_size_chunking_configuration => "fixedSizeChunkingConfiguration",
    :hierarchical_chunking_configuration => "hierarchicalChunkingConfiguration",
    :semantic_chunking_configuration => "semanticChunkingConfiguration",
  }
end

Instance Method Details

#to_jsiiObject



862
863
864
865
866
867
868
869
870
871
# File 'bedrock/cfn_data_source.rb', line 862

def to_jsii
  result = {}
  result.merge!({
    "chunkingStrategy" => @chunking_strategy,
    "fixedSizeChunkingConfiguration" => @fixed_size_chunking_configuration,
    "hierarchicalChunkingConfiguration" => @hierarchical_chunking_configuration,
    "semanticChunkingConfiguration" => @semantic_chunking_configuration,
  })
  result.compact
end