Skip to content

Commit 432e848

Browse files
MarkDaoustcopybara-github
authored andcommitted
feat: Add part.media_resolution
feat: Add generate_content_config.thinking_level PiperOrigin-RevId: 831897369
1 parent 5ad6397 commit 432e848

File tree

7 files changed

+185
-0
lines changed

7 files changed

+185
-0
lines changed

Google.GenAI/LiveConverters.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,12 @@ internal JsonNode PartToMldev(JsonNode fromObject, JsonObject parentObject) {
11121112
Common.GetValueByPath(fromObject, new string[] { "functionCall" }));
11131113
}
11141114

1115+
if (Common.GetValueByPath(fromObject, new string[] { "mediaResolution" }) != null) {
1116+
Common.SetValueByPath(
1117+
toObject, new string[] { "mediaResolution" },
1118+
Common.GetValueByPath(fromObject, new string[] { "mediaResolution" }));
1119+
}
1120+
11151121
if (Common.GetValueByPath(fromObject, new string[] { "codeExecutionResult" }) != null) {
11161122
Common.SetValueByPath(
11171123
toObject, new string[] { "codeExecutionResult" },

Google.GenAI/Models.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,6 +1444,12 @@ internal JsonNode PartToMldev(JsonNode fromObject, JsonObject parentObject) {
14441444
Common.GetValueByPath(fromObject, new string[] { "functionCall" }));
14451445
}
14461446

1447+
if (Common.GetValueByPath(fromObject, new string[] { "mediaResolution" }) != null) {
1448+
Common.SetValueByPath(
1449+
toObject, new string[] { "mediaResolution" },
1450+
Common.GetValueByPath(fromObject, new string[] { "mediaResolution" }));
1451+
}
1452+
14471453
if (Common.GetValueByPath(fromObject, new string[] { "codeExecutionResult" }) != null) {
14481454
Common.SetValueByPath(
14491455
toObject, new string[] { "codeExecutionResult" },

Google.GenAI/types/Part.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ public record Part {
3838
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
3939
public FunctionCall ? FunctionCall { get; set; }
4040

41+
/// <summary>
42+
/// Media resolution for the input media.
43+
/// </summary>
44+
[JsonPropertyName("mediaResolution")]
45+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
46+
public PartMediaResolution
47+
? MediaResolution {
48+
get; set;
49+
}
50+
4151
/// <summary>
4252
/// Optional. Result of executing the [ExecutableCode].
4353
/// </summary>
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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;
20+
using System.Text.Json;
21+
using System.Text.Json.Serialization;
22+
using Google.GenAI.Serialization;
23+
24+
namespace Google.GenAI.Types {
25+
/// <summary>
26+
/// Media resolution for the input media.
27+
/// </summary>
28+
29+
public record PartMediaResolution {
30+
/// <summary>
31+
/// The tokenization quality used for given media.
32+
/// </summary>
33+
[JsonPropertyName("level")]
34+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
35+
public PartMediaResolutionLevel ? Level { get; set; }
36+
37+
/// <summary>
38+
/// Specifies the required sequence length for media tokenization.
39+
/// </summary>
40+
[JsonPropertyName("numTokens")]
41+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
42+
public int
43+
? NumTokens {
44+
get; set;
45+
}
46+
47+
/// <summary>
48+
/// Deserializes a JSON string to a PartMediaResolution object.
49+
/// </summary>
50+
/// <param name="jsonString">The JSON string to deserialize.</param>
51+
/// <param name="options">Optional JsonSerializerOptions.</param>
52+
/// <returns>The deserialized PartMediaResolution object, or null if deserialization
53+
/// fails.</returns>
54+
public static PartMediaResolution
55+
? FromJson(string jsonString, JsonSerializerOptions? options = null) {
56+
try {
57+
return JsonSerializer.Deserialize<PartMediaResolution>(jsonString, options);
58+
} catch (JsonException e) {
59+
Console.Error.WriteLine($"Error deserializing JSON: {e.ToString()}");
60+
return null;
61+
}
62+
}
63+
}
64+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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+
21+
namespace Google.GenAI.Types {
22+
/// <summary>
23+
/// The tokenization quality used for given media.
24+
/// </summary>
25+
[JsonConverter(typeof(JsonStringEnumConverter))]
26+
public enum PartMediaResolutionLevel {
27+
/// <summary>
28+
/// Media resolution has not been set.
29+
/// </summary>
30+
[JsonPropertyName("MEDIA_RESOLUTION_UNSPECIFIED")] MEDIA_RESOLUTION_UNSPECIFIED,
31+
32+
/// <summary>
33+
/// Media resolution set to low.
34+
/// </summary>
35+
[JsonPropertyName("MEDIA_RESOLUTION_LOW")] MEDIA_RESOLUTION_LOW,
36+
37+
/// <summary>
38+
/// Media resolution set to medium.
39+
/// </summary>
40+
[JsonPropertyName("MEDIA_RESOLUTION_MEDIUM")] MEDIA_RESOLUTION_MEDIUM,
41+
42+
/// <summary>
43+
/// Media resolution set to high.
44+
/// </summary>
45+
[JsonPropertyName("MEDIA_RESOLUTION_HIGH")] MEDIA_RESOLUTION_HIGH
46+
}
47+
}

Google.GenAI/types/ThinkingConfig.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ public int
4646
get; set;
4747
}
4848

49+
/// <summary>
50+
/// Optional. The level of thoughts tokens that the model should generate.
51+
/// </summary>
52+
[JsonPropertyName("thinkingLevel")]
53+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
54+
public ThinkingLevel
55+
? ThinkingLevel {
56+
get; set;
57+
}
58+
4959
/// <summary>
5060
/// Deserializes a JSON string to a ThinkingConfig object.
5161
/// </summary>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
21+
namespace Google.GenAI.Types {
22+
/// <summary>
23+
/// The level of thoughts tokens that the model should generate.
24+
/// </summary>
25+
[JsonConverter(typeof(JsonStringEnumConverter))]
26+
public enum ThinkingLevel {
27+
/// <summary>
28+
/// Default value.
29+
/// </summary>
30+
[JsonPropertyName("THINKING_LEVEL_UNSPECIFIED")] THINKING_LEVEL_UNSPECIFIED,
31+
32+
/// <summary>
33+
/// Low thinking level.
34+
/// </summary>
35+
[JsonPropertyName("LOW")] LOW,
36+
37+
/// <summary>
38+
/// High thinking level.
39+
/// </summary>
40+
[JsonPropertyName("HIGH")] HIGH
41+
}
42+
}

0 commit comments

Comments
 (0)