All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.aws.sdk.kotlin.services.bedrockagent.model.HierarchicalChunkingConfiguration.kt Maven / Gradle / Ivy

There is a newer version: 1.3.77
Show newest version
// Code generated by smithy-kotlin-codegen. DO NOT EDIT!

package aws.sdk.kotlin.services.bedrockagent.model

import aws.smithy.kotlin.runtime.SdkDsl

/**
 * 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.
 *
 * You configure the number of tokens to overlap, or repeat across adjacent chunks. For example, if you set overlap tokens to 60, the last 60 tokens in the first chunk are also included at the beginning of the second chunk. For each layer, you must also configure the maximum number of tokens in a chunk.
 */
public class HierarchicalChunkingConfiguration private constructor(builder: Builder) {
    /**
     * Token settings for each layer.
     */
    public val levelConfigurations: List = requireNotNull(builder.levelConfigurations) { "A non-null value must be provided for levelConfigurations" }
    /**
     * The number of tokens to repeat across chunks in the same layer.
     */
    public val overlapTokens: kotlin.Int = requireNotNull(builder.overlapTokens) { "A non-null value must be provided for overlapTokens" }

    public companion object {
        public operator fun invoke(block: Builder.() -> kotlin.Unit): aws.sdk.kotlin.services.bedrockagent.model.HierarchicalChunkingConfiguration = Builder().apply(block).build()
    }

    override fun toString(): kotlin.String = buildString {
        append("HierarchicalChunkingConfiguration(")
        append("levelConfigurations=$levelConfigurations,")
        append("overlapTokens=$overlapTokens")
        append(")")
    }

    override fun hashCode(): kotlin.Int {
        var result = levelConfigurations.hashCode()
        result = 31 * result + (overlapTokens)
        return result
    }

    override fun equals(other: kotlin.Any?): kotlin.Boolean {
        if (this === other) return true
        if (other == null || this::class != other::class) return false

        other as HierarchicalChunkingConfiguration

        if (levelConfigurations != other.levelConfigurations) return false
        if (overlapTokens != other.overlapTokens) return false

        return true
    }

    public inline fun copy(block: Builder.() -> kotlin.Unit = {}): aws.sdk.kotlin.services.bedrockagent.model.HierarchicalChunkingConfiguration = Builder(this).apply(block).build()

    @SdkDsl
    public class Builder {
        /**
         * Token settings for each layer.
         */
        public var levelConfigurations: List? = null
        /**
         * The number of tokens to repeat across chunks in the same layer.
         */
        public var overlapTokens: kotlin.Int? = null

        @PublishedApi
        internal constructor()
        @PublishedApi
        internal constructor(x: aws.sdk.kotlin.services.bedrockagent.model.HierarchicalChunkingConfiguration) : this() {
            this.levelConfigurations = x.levelConfigurations
            this.overlapTokens = x.overlapTokens
        }

        @PublishedApi
        internal fun build(): aws.sdk.kotlin.services.bedrockagent.model.HierarchicalChunkingConfiguration = HierarchicalChunkingConfiguration(this)

        internal fun correctErrors(): Builder {
            if (levelConfigurations == null) levelConfigurations = emptyList()
            if (overlapTokens == null) overlapTokens = 0
            return this
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy