|
| 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.List; |
| 27 | +import java.util.Optional; |
| 28 | + |
| 29 | +/** Usage metadata about response(s). */ |
| 30 | +@AutoValue |
| 31 | +@JsonDeserialize(builder = UsageMetadata.Builder.class) |
| 32 | +public abstract class UsageMetadata extends JsonSerializable { |
| 33 | + /** |
| 34 | + * Number of tokens in the prompt. When `cached_content` is set, this is still the total effective |
| 35 | + * prompt size meaning this includes the number of tokens in the cached content. |
| 36 | + */ |
| 37 | + @JsonProperty("promptTokenCount") |
| 38 | + public abstract Optional<Integer> promptTokenCount(); |
| 39 | + |
| 40 | + /** Number of tokens in the cached part of the prompt (the cached content). */ |
| 41 | + @JsonProperty("cachedContentTokenCount") |
| 42 | + public abstract Optional<Integer> cachedContentTokenCount(); |
| 43 | + |
| 44 | + /** Total number of tokens across all the generated response candidates. */ |
| 45 | + @JsonProperty("responseTokenCount") |
| 46 | + public abstract Optional<Integer> responseTokenCount(); |
| 47 | + |
| 48 | + /** Number of tokens present in tool-use prompt(s). */ |
| 49 | + @JsonProperty("toolUsePromptTokenCount") |
| 50 | + public abstract Optional<Integer> toolUsePromptTokenCount(); |
| 51 | + |
| 52 | + /** Number of tokens of thoughts for thinking models. */ |
| 53 | + @JsonProperty("thoughtsTokenCount") |
| 54 | + public abstract Optional<Integer> thoughtsTokenCount(); |
| 55 | + |
| 56 | + /** Total token count for prompt, response candidates, and tool-use prompts(if present). */ |
| 57 | + @JsonProperty("totalTokenCount") |
| 58 | + public abstract Optional<Integer> totalTokenCount(); |
| 59 | + |
| 60 | + /** List of modalities that were processed in the request input. */ |
| 61 | + @JsonProperty("promptTokensDetails") |
| 62 | + public abstract Optional<List<ModalityTokenCount>> promptTokensDetails(); |
| 63 | + |
| 64 | + /** List of modalities that were processed in the cache input. */ |
| 65 | + @JsonProperty("cacheTokensDetails") |
| 66 | + public abstract Optional<List<ModalityTokenCount>> cacheTokensDetails(); |
| 67 | + |
| 68 | + /** List of modalities that were returned in the response. */ |
| 69 | + @JsonProperty("responseTokensDetails") |
| 70 | + public abstract Optional<List<ModalityTokenCount>> responseTokensDetails(); |
| 71 | + |
| 72 | + /** List of modalities that were processed in the tool-use prompt. */ |
| 73 | + @JsonProperty("toolUsePromptTokensDetails") |
| 74 | + public abstract Optional<List<ModalityTokenCount>> toolUsePromptTokensDetails(); |
| 75 | + |
| 76 | + /** |
| 77 | + * Traffic type. This shows whether a request consumes Pay-As-You-Go or Provisioned Throughput |
| 78 | + * quota. |
| 79 | + */ |
| 80 | + @JsonProperty("trafficType") |
| 81 | + public abstract Optional<String> trafficType(); |
| 82 | + |
| 83 | + /** Instantiates a builder for UsageMetadata. */ |
| 84 | + public static Builder builder() { |
| 85 | + return new AutoValue_UsageMetadata.Builder(); |
| 86 | + } |
| 87 | + |
| 88 | + /** Creates a builder with the same values as this instance. */ |
| 89 | + public abstract Builder toBuilder(); |
| 90 | + |
| 91 | + /** Builder for UsageMetadata. */ |
| 92 | + @AutoValue.Builder |
| 93 | + public abstract static class Builder { |
| 94 | + /** For internal usage. Please use `UsageMetadata.builder()` for instantiation. */ |
| 95 | + @JsonCreator |
| 96 | + private static Builder create() { |
| 97 | + return new AutoValue_UsageMetadata.Builder(); |
| 98 | + } |
| 99 | + |
| 100 | + @JsonProperty("promptTokenCount") |
| 101 | + public abstract Builder promptTokenCount(Integer promptTokenCount); |
| 102 | + |
| 103 | + @JsonProperty("cachedContentTokenCount") |
| 104 | + public abstract Builder cachedContentTokenCount(Integer cachedContentTokenCount); |
| 105 | + |
| 106 | + @JsonProperty("responseTokenCount") |
| 107 | + public abstract Builder responseTokenCount(Integer responseTokenCount); |
| 108 | + |
| 109 | + @JsonProperty("toolUsePromptTokenCount") |
| 110 | + public abstract Builder toolUsePromptTokenCount(Integer toolUsePromptTokenCount); |
| 111 | + |
| 112 | + @JsonProperty("thoughtsTokenCount") |
| 113 | + public abstract Builder thoughtsTokenCount(Integer thoughtsTokenCount); |
| 114 | + |
| 115 | + @JsonProperty("totalTokenCount") |
| 116 | + public abstract Builder totalTokenCount(Integer totalTokenCount); |
| 117 | + |
| 118 | + @JsonProperty("promptTokensDetails") |
| 119 | + public abstract Builder promptTokensDetails(List<ModalityTokenCount> promptTokensDetails); |
| 120 | + |
| 121 | + @JsonProperty("cacheTokensDetails") |
| 122 | + public abstract Builder cacheTokensDetails(List<ModalityTokenCount> cacheTokensDetails); |
| 123 | + |
| 124 | + @JsonProperty("responseTokensDetails") |
| 125 | + public abstract Builder responseTokensDetails(List<ModalityTokenCount> responseTokensDetails); |
| 126 | + |
| 127 | + @JsonProperty("toolUsePromptTokensDetails") |
| 128 | + public abstract Builder toolUsePromptTokensDetails( |
| 129 | + List<ModalityTokenCount> toolUsePromptTokensDetails); |
| 130 | + |
| 131 | + @JsonProperty("trafficType") |
| 132 | + public abstract Builder trafficType(String trafficType); |
| 133 | + |
| 134 | + public abstract UsageMetadata build(); |
| 135 | + } |
| 136 | + |
| 137 | + /** Deserializes a JSON string to a UsageMetadata object. */ |
| 138 | + public static UsageMetadata fromJson(String jsonString) { |
| 139 | + return JsonSerializable.fromJsonString(jsonString, UsageMetadata.class); |
| 140 | + } |
| 141 | +} |
0 commit comments