Package com.google.genai.types
Class SlidingWindow
-
- All Implemented Interfaces:
public abstract class SlidingWindow extends JsonSerializable
Context window will be truncated by keeping only suffix of it.
Context window will always be cut at start of USER role turn. System instructions and `BidiGenerateContentSetup.prefix_turns` will not be subject to the sliding window mechanism, they will always stay at the beginning of context window.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public abstract classSlidingWindow.BuilderBuilder for SlidingWindow.
-
Field Summary
Fields Modifier and Type Field Description public final static StringMAX_READ_LENGTH_PROPERTY
-
Constructor Summary
Constructors Constructor Description SlidingWindow()
-
Method Summary
Modifier and Type Method Description abstract Optional<Long>targetTokens()Session reduction target -- how many tokens we should keep. static SlidingWindow.Builderbuilder()Instantiates a builder for SlidingWindow. abstract SlidingWindow.BuildertoBuilder()Creates a builder with the same values as this instance. static SlidingWindowfromJson(String jsonString)Deserializes a JSON string to a SlidingWindow object. -
Methods inherited from class com.google.genai.JsonSerializable
fromJsonNode, fromJsonString, objectMapper, setMaxReadLength, stringToJsonNode, toJson, toJsonNode, toJsonString -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
targetTokens
abstract Optional<Long> targetTokens()
Session reduction target -- how many tokens we should keep. Window shortening operation has some latency costs, so we should avoid running it on every turn. Should be <trigger_tokens. If not set, trigger_tokens/2 is assumed.
-
builder
static SlidingWindow.Builder builder()
Instantiates a builder for SlidingWindow.
-
toBuilder
abstract SlidingWindow.Builder toBuilder()
Creates a builder with the same values as this instance.
-
fromJson
static SlidingWindow fromJson(String jsonString)
Deserializes a JSON string to a SlidingWindow object.
-
-
-
-