|
| 1 | +/* |
| 2 | + * Copyright 2025 Google LLC |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +// Auto-generated code. Do not edit. |
| 18 | + |
| 19 | +package com.google.genai.types; |
| 20 | + |
| 21 | +import com.fasterxml.jackson.annotation.JsonCreator; |
| 22 | +import com.fasterxml.jackson.annotation.JsonProperty; |
| 23 | +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; |
| 24 | +import com.google.auto.value.AutoValue; |
| 25 | +import com.google.genai.JsonSerializable; |
| 26 | +import java.util.Optional; |
| 27 | + |
| 28 | +/** |
| 29 | + * Context window will be truncated by keeping only suffix of it. |
| 30 | + * |
| 31 | + * <p>Context window will always be cut at start of USER role turn. System instructions and |
| 32 | + * `BidiGenerateContentSetup.prefix_turns` will not be subject to the sliding window mechanism, they |
| 33 | + * will always stay at the beginning of context window. |
| 34 | + */ |
| 35 | +@AutoValue |
| 36 | +@JsonDeserialize(builder = SlidingWindow.Builder.class) |
| 37 | +public abstract class SlidingWindow extends JsonSerializable { |
| 38 | + /** |
| 39 | + * Session reduction target -- how many tokens we should keep. Window shortening operation has |
| 40 | + * some latency costs, so we should avoid running it on every turn. Should be < trigger_tokens. If |
| 41 | + * not set, trigger_tokens/2 is assumed. |
| 42 | + */ |
| 43 | + @JsonProperty("targetTokens") |
| 44 | + public abstract Optional<Long> targetTokens(); |
| 45 | + |
| 46 | + /** Instantiates a builder for SlidingWindow. */ |
| 47 | + public static Builder builder() { |
| 48 | + return new AutoValue_SlidingWindow.Builder(); |
| 49 | + } |
| 50 | + |
| 51 | + /** Creates a builder with the same values as this instance. */ |
| 52 | + public abstract Builder toBuilder(); |
| 53 | + |
| 54 | + /** Builder for SlidingWindow. */ |
| 55 | + @AutoValue.Builder |
| 56 | + public abstract static class Builder { |
| 57 | + /** For internal usage. Please use `SlidingWindow.builder()` for instantiation. */ |
| 58 | + @JsonCreator |
| 59 | + private static Builder create() { |
| 60 | + return new AutoValue_SlidingWindow.Builder(); |
| 61 | + } |
| 62 | + |
| 63 | + @JsonProperty("targetTokens") |
| 64 | + public abstract Builder targetTokens(Long targetTokens); |
| 65 | + |
| 66 | + public abstract SlidingWindow build(); |
| 67 | + } |
| 68 | + |
| 69 | + /** Deserializes a JSON string to a SlidingWindow object. */ |
| 70 | + public static SlidingWindow fromJson(String jsonString) { |
| 71 | + return JsonSerializable.fromJsonString(jsonString, SlidingWindow.class); |
| 72 | + } |
| 73 | +} |
0 commit comments