Skip to content

Commit 3aa6dc3

Browse files
MarkDaoustcopybara-github
authored andcommitted
chore:test
FUTURE_COPYBARA_INTEGRATE_REVIEW=https://github.com/google-gemini/private-dotnet-genai/pull/56 from google-gemini:integration 95fde92a3f597a59389fc8259d69398a685b7b91 PiperOrigin-RevId: 888287753
1 parent 8e5dc09 commit 3aa6dc3

File tree

4 files changed

+119
-0
lines changed

4 files changed

+119
-0
lines changed

Google.GenAI/Batches.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,6 +1076,11 @@ internal JsonNode GenerateContentConfigToMldev(ApiClient apiClient, JsonNode fro
10761076
"modelArmorConfig parameter is not supported in Gemini API.");
10771077
}
10781078

1079+
if (Common.GetValueByPath(fromObject, new string[] { "serviceTier" }) != null) {
1080+
Common.SetValueByPath(parentObject, new string[] { "serviceTier" },
1081+
Common.GetValueByPath(fromObject, new string[] { "serviceTier" }));
1082+
}
1083+
10791084
return toObject;
10801085
}
10811086

Google.GenAI/Models.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,6 +1296,11 @@ internal JsonNode GenerateContentConfigToMldev(ApiClient apiClient, JsonNode fro
12961296
"modelArmorConfig parameter is not supported in Gemini API.");
12971297
}
12981298

1299+
if (Common.GetValueByPath(fromObject, new string[] { "serviceTier" }) != null) {
1300+
Common.SetValueByPath(parentObject, new string[] { "serviceTier" },
1301+
Common.GetValueByPath(fromObject, new string[] { "serviceTier" }));
1302+
}
1303+
12991304
return toObject;
13001305
}
13011306

@@ -1486,6 +1491,10 @@ internal JsonNode GenerateContentConfigToVertex(ApiClient apiClient, JsonNode fr
14861491
Common.GetValueByPath(fromObject, new string[] { "modelArmorConfig" }));
14871492
}
14881493

1494+
if (!Common.IsZero(Common.GetValueByPath(fromObject, new string[] { "serviceTier" }))) {
1495+
throw new NotSupportedException("serviceTier parameter is not supported in Vertex AI.");
1496+
}
1497+
14891498
return toObject;
14901499
}
14911500

Google.GenAI/types/GenerateContentConfig.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,16 @@ public ModelArmorConfig
372372
get; set;
373373
}
374374

375+
/// <summary>
376+
/// The service tier to use for the request. For example, FLEX.
377+
/// </summary>
378+
[JsonPropertyName("serviceTier")]
379+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
380+
public ServiceTier
381+
? ServiceTier {
382+
get; set;
383+
}
384+
375385
/// <summary>
376386
/// Deserializes a JSON string to a GenerateContentConfig object.
377387
/// </summary>

Google.GenAI/types/ServiceTier.cs

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
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+
using System.Text.Json.Serialization;
20+
using System.Collections.Generic;
21+
using System.Text.Json;
22+
23+
namespace Google.GenAI.Types {
24+
/// <summary>
25+
/// Pricing and performance service tier.
26+
/// </summary>
27+
28+
[JsonConverter(typeof(ServiceTierConverter))]
29+
public readonly record struct ServiceTier : IEquatable<ServiceTier> {
30+
public string Value { get; }
31+
32+
private ServiceTier(string value) {
33+
Value = value;
34+
}
35+
36+
/// <summary>
37+
/// Default service tier, which is standard.
38+
/// </summary>
39+
public static ServiceTier Unspecified { get; } = new("unspecified");
40+
41+
/// <summary>
42+
/// Standard service tier.
43+
/// </summary>
44+
public static ServiceTier Standard { get; } = new("standard");
45+
46+
/// <summary>
47+
/// Flex service tier.
48+
/// </summary>
49+
public static ServiceTier Flex { get; } = new("flex");
50+
51+
/// <summary>
52+
/// Priority service tier.
53+
/// </summary>
54+
public static ServiceTier Priority { get; } = new("priority");
55+
56+
public static IReadOnlyList<ServiceTier> AllValues {
57+
get;
58+
} = new[] { Unspecified, Standard, Flex, Priority };
59+
60+
public static ServiceTier FromString(string value) {
61+
if (string.IsNullOrEmpty(value)) {
62+
return new ServiceTier("unspecified");
63+
}
64+
65+
foreach (var known in AllValues) {
66+
if (known.Value == value) {
67+
return known;
68+
}
69+
}
70+
71+
return new ServiceTier(value);
72+
}
73+
74+
public override string ToString() => Value ?? string.Empty;
75+
76+
public static implicit operator ServiceTier(string value) => FromString(value);
77+
78+
public bool Equals(ServiceTier other) => Value == other.Value;
79+
80+
public override int GetHashCode() => Value?.GetHashCode() ?? 0;
81+
}
82+
83+
public class ServiceTierConverter : JsonConverter<ServiceTier> {
84+
public override ServiceTier Read(ref Utf8JsonReader reader, System.Type typeToConvert,
85+
JsonSerializerOptions options) {
86+
var value = reader.GetString();
87+
return ServiceTier.FromString(value);
88+
}
89+
90+
public override void Write(Utf8JsonWriter writer, ServiceTier value,
91+
JsonSerializerOptions options) {
92+
writer.WriteStringValue(value.Value);
93+
}
94+
}
95+
}

0 commit comments

Comments
 (0)