PromptPrefix

class PromptPrefix


Represents a prompt prefix for on-device prompt caching.

By providing the shared prefix, the system can cache the processing of this prefix on supported devices, potentially reducing inference time. To enable prefix caching, use PromptPrefix for the static part of your prompt and TextPart for the dynamic part.

Note: Pre-processing the prefix may introduce a small amount of one-time latency. It's recommended to only use this for prefixes that are expected to be used multiple times.

Summary

Public constructors

PromptPrefix(textString: String)

Public functions

operator String

Kotlin destructuring operator returning textString.

PromptPrefix
copy(textString: String)

Creates a copy of this PromptPrefix with an updated textString, preserving internal prefix caching configuration.

open operator Boolean
equals(other: Any?)
open Int
open String

Public properties

String

The static text prefix to cache.

Public constructors

PromptPrefix

PromptPrefix(textString: String)
Parameters
textString: String

The static text prefix to cache.

Public functions

component1

operator fun component1(): String

Kotlin destructuring operator returning textString.

Retained for binary backwards compatibility with the previous data class definition of PromptPrefix.

copy

fun copy(textString: String = this.textString): PromptPrefix

Creates a copy of this PromptPrefix with an updated textString, preserving internal prefix caching configuration.

equals

open operator fun equals(other: Any?): Boolean

hashCode

open fun hashCode(): Int

toString

open fun toString(): String

Public properties

textString

val textString: String

The static text prefix to cache.