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

commonMain.aws.sdk.kotlin.services.bedrockruntime.model.TokenUsage.kt Maven / Gradle / Ivy

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

package aws.sdk.kotlin.services.bedrockruntime.model

import aws.smithy.kotlin.runtime.SdkDsl

/**
 * The tokens used in a message API inference call.
 */
public class TokenUsage private constructor(builder: Builder) {
    /**
     * The number of tokens sent in the request to the model.
     */
    public val inputTokens: kotlin.Int = requireNotNull(builder.inputTokens) { "A non-null value must be provided for inputTokens" }
    /**
     * The number of tokens that the model generated for the request.
     */
    public val outputTokens: kotlin.Int = requireNotNull(builder.outputTokens) { "A non-null value must be provided for outputTokens" }
    /**
     * The total of input tokens and tokens generated by the model.
     */
    public val totalTokens: kotlin.Int = requireNotNull(builder.totalTokens) { "A non-null value must be provided for totalTokens" }

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

    override fun toString(): kotlin.String = buildString {
        append("TokenUsage(")
        append("inputTokens=$inputTokens,")
        append("outputTokens=$outputTokens,")
        append("totalTokens=$totalTokens")
        append(")")
    }

    override fun hashCode(): kotlin.Int {
        var result = inputTokens
        result = 31 * result + (outputTokens)
        result = 31 * result + (totalTokens)
        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 TokenUsage

        if (inputTokens != other.inputTokens) return false
        if (outputTokens != other.outputTokens) return false
        if (totalTokens != other.totalTokens) return false

        return true
    }

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

    @SdkDsl
    public class Builder {
        /**
         * The number of tokens sent in the request to the model.
         */
        public var inputTokens: kotlin.Int? = null
        /**
         * The number of tokens that the model generated for the request.
         */
        public var outputTokens: kotlin.Int? = null
        /**
         * The total of input tokens and tokens generated by the model.
         */
        public var totalTokens: kotlin.Int? = null

        @PublishedApi
        internal constructor()
        @PublishedApi
        internal constructor(x: aws.sdk.kotlin.services.bedrockruntime.model.TokenUsage) : this() {
            this.inputTokens = x.inputTokens
            this.outputTokens = x.outputTokens
            this.totalTokens = x.totalTokens
        }

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

        internal fun correctErrors(): Builder {
            if (inputTokens == null) inputTokens = 0
            if (outputTokens == null) outputTokens = 0
            if (totalTokens == null) totalTokens = 0
            return this
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy