From 5d1a36dfa234347dd1e5716999564ec0608ee554 Mon Sep 17 00:00:00 2001 From: Jaycee Li Date: Wed, 26 Nov 2025 11:57:20 -0800 Subject: [PATCH] chore: Refactor GenerateContentConfig to inherit from GenerationConfig feat: Add enableAffectiveDialog field in the GenerateContentConfig PiperOrigin-RevId: 837208137 --- Google.GenAI/Batches.cs | 170 +++++----- Google.GenAI/LiveConverters.cs | 12 +- Google.GenAI/Models.cs | 344 ++++++++++---------- Google.GenAI/types/GenerateContentConfig.cs | 295 +++++++++-------- Google.GenAI/types/GenerationConfig.cs | 32 +- Google.GenAI/types/MediaResolution.cs | 4 +- 6 files changed, 442 insertions(+), 415 deletions(-) diff --git a/Google.GenAI/Batches.cs b/Google.GenAI/Batches.cs index 24da94cb..9af64f4b 100644 --- a/Google.GenAI/Batches.cs +++ b/Google.GenAI/Batches.cs @@ -878,28 +878,14 @@ internal JsonNode GenerateContentConfigToMldev(ApiClient apiClient, JsonNode fro JsonObject parentObject) { JsonObject toObject = new JsonObject(); - if (Common.GetValueByPath(fromObject, new string[] { "systemInstruction" }) != null) { - Common.SetValueByPath( - parentObject, new string[] { "systemInstruction" }, - ContentToMldev( - JsonNode.Parse(JsonSerializer.Serialize(Transformers.TContent( - Common.GetValueByPath(fromObject, new string[] { "systemInstruction" })))), - toObject)); - } - - if (Common.GetValueByPath(fromObject, new string[] { "temperature" }) != null) { - Common.SetValueByPath(toObject, new string[] { "temperature" }, - Common.GetValueByPath(fromObject, new string[] { "temperature" })); - } - - if (Common.GetValueByPath(fromObject, new string[] { "topP" }) != null) { - Common.SetValueByPath(toObject, new string[] { "topP" }, - Common.GetValueByPath(fromObject, new string[] { "topP" })); + if (!Common.IsZero( + Common.GetValueByPath(fromObject, new string[] { "modelSelectionConfig" }))) { + throw new NotSupportedException( + "modelSelectionConfig parameter is not supported in Gemini API."); } - if (Common.GetValueByPath(fromObject, new string[] { "topK" }) != null) { - Common.SetValueByPath(toObject, new string[] { "topK" }, - Common.GetValueByPath(fromObject, new string[] { "topK" })); + if (!Common.IsZero(Common.GetValueByPath(fromObject, new string[] { "audioTimestamp" }))) { + throw new NotSupportedException("audioTimestamp parameter is not supported in Gemini API."); } if (Common.GetValueByPath(fromObject, new string[] { "candidateCount" }) != null) { @@ -907,21 +893,16 @@ internal JsonNode GenerateContentConfigToMldev(ApiClient apiClient, JsonNode fro Common.GetValueByPath(fromObject, new string[] { "candidateCount" })); } - if (Common.GetValueByPath(fromObject, new string[] { "maxOutputTokens" }) != null) { - Common.SetValueByPath( - toObject, new string[] { "maxOutputTokens" }, - Common.GetValueByPath(fromObject, new string[] { "maxOutputTokens" })); - } - - if (Common.GetValueByPath(fromObject, new string[] { "stopSequences" }) != null) { - Common.SetValueByPath(toObject, new string[] { "stopSequences" }, - Common.GetValueByPath(fromObject, new string[] { "stopSequences" })); + if (!Common.IsZero( + Common.GetValueByPath(fromObject, new string[] { "enableAffectiveDialog" }))) { + throw new NotSupportedException( + "enableAffectiveDialog parameter is not supported in Gemini API."); } - if (Common.GetValueByPath(fromObject, new string[] { "responseLogprobs" }) != null) { + if (Common.GetValueByPath(fromObject, new string[] { "frequencyPenalty" }) != null) { Common.SetValueByPath( - toObject, new string[] { "responseLogprobs" }, - Common.GetValueByPath(fromObject, new string[] { "responseLogprobs" })); + toObject, new string[] { "frequencyPenalty" }, + Common.GetValueByPath(fromObject, new string[] { "frequencyPenalty" })); } if (Common.GetValueByPath(fromObject, new string[] { "logprobs" }) != null) { @@ -929,21 +910,34 @@ internal JsonNode GenerateContentConfigToMldev(ApiClient apiClient, JsonNode fro Common.GetValueByPath(fromObject, new string[] { "logprobs" })); } + if (Common.GetValueByPath(fromObject, new string[] { "maxOutputTokens" }) != null) { + Common.SetValueByPath( + toObject, new string[] { "maxOutputTokens" }, + Common.GetValueByPath(fromObject, new string[] { "maxOutputTokens" })); + } + + if (Common.GetValueByPath(fromObject, new string[] { "mediaResolution" }) != null) { + Common.SetValueByPath( + toObject, new string[] { "mediaResolution" }, + Common.GetValueByPath(fromObject, new string[] { "mediaResolution" })); + } + if (Common.GetValueByPath(fromObject, new string[] { "presencePenalty" }) != null) { Common.SetValueByPath( toObject, new string[] { "presencePenalty" }, Common.GetValueByPath(fromObject, new string[] { "presencePenalty" })); } - if (Common.GetValueByPath(fromObject, new string[] { "frequencyPenalty" }) != null) { + if (Common.GetValueByPath(fromObject, new string[] { "responseJsonSchema" }) != null) { Common.SetValueByPath( - toObject, new string[] { "frequencyPenalty" }, - Common.GetValueByPath(fromObject, new string[] { "frequencyPenalty" })); + toObject, new string[] { "responseJsonSchema" }, + Common.GetValueByPath(fromObject, new string[] { "responseJsonSchema" })); } - if (Common.GetValueByPath(fromObject, new string[] { "seed" }) != null) { - Common.SetValueByPath(toObject, new string[] { "seed" }, - Common.GetValueByPath(fromObject, new string[] { "seed" })); + if (Common.GetValueByPath(fromObject, new string[] { "responseLogprobs" }) != null) { + Common.SetValueByPath( + toObject, new string[] { "responseLogprobs" }, + Common.GetValueByPath(fromObject, new string[] { "responseLogprobs" })); } if (Common.GetValueByPath(fromObject, new string[] { "responseMimeType" }) != null) { @@ -952,26 +946,72 @@ internal JsonNode GenerateContentConfigToMldev(ApiClient apiClient, JsonNode fro Common.GetValueByPath(fromObject, new string[] { "responseMimeType" })); } + if (Common.GetValueByPath(fromObject, new string[] { "responseModalities" }) != null) { + Common.SetValueByPath( + toObject, new string[] { "responseModalities" }, + Common.GetValueByPath(fromObject, new string[] { "responseModalities" })); + } + if (Common.GetValueByPath(fromObject, new string[] { "responseSchema" }) != null) { Common.SetValueByPath(toObject, new string[] { "responseSchema" }, Transformers.TSchema(Common.GetValueByPath( fromObject, new string[] { "responseSchema" }))); } - if (Common.GetValueByPath(fromObject, new string[] { "responseJsonSchema" }) != null) { - Common.SetValueByPath( - toObject, new string[] { "responseJsonSchema" }, - Common.GetValueByPath(fromObject, new string[] { "responseJsonSchema" })); - } - if (!Common.IsZero(Common.GetValueByPath(fromObject, new string[] { "routingConfig" }))) { throw new NotSupportedException("routingConfig parameter is not supported in Gemini API."); } - if (!Common.IsZero( - Common.GetValueByPath(fromObject, new string[] { "modelSelectionConfig" }))) { - throw new NotSupportedException( - "modelSelectionConfig parameter is not supported in Gemini API."); + if (Common.GetValueByPath(fromObject, new string[] { "seed" }) != null) { + Common.SetValueByPath(toObject, new string[] { "seed" }, + Common.GetValueByPath(fromObject, new string[] { "seed" })); + } + + if (Common.GetValueByPath(fromObject, new string[] { "speechConfig" }) != null) { + Common.SetValueByPath(toObject, new string[] { "speechConfig" }, + Transformers.TSpeechConfig(Common.GetValueByPath( + fromObject, new string[] { "speechConfig" }))); + } + + if (Common.GetValueByPath(fromObject, new string[] { "stopSequences" }) != null) { + Common.SetValueByPath(toObject, new string[] { "stopSequences" }, + Common.GetValueByPath(fromObject, new string[] { "stopSequences" })); + } + + if (Common.GetValueByPath(fromObject, new string[] { "temperature" }) != null) { + Common.SetValueByPath(toObject, new string[] { "temperature" }, + Common.GetValueByPath(fromObject, new string[] { "temperature" })); + } + + if (Common.GetValueByPath(fromObject, new string[] { "thinkingConfig" }) != null) { + Common.SetValueByPath(toObject, new string[] { "thinkingConfig" }, + Common.GetValueByPath(fromObject, new string[] { "thinkingConfig" })); + } + + if (Common.GetValueByPath(fromObject, new string[] { "topK" }) != null) { + Common.SetValueByPath(toObject, new string[] { "topK" }, + Common.GetValueByPath(fromObject, new string[] { "topK" })); + } + + if (Common.GetValueByPath(fromObject, new string[] { "topP" }) != null) { + Common.SetValueByPath(toObject, new string[] { "topP" }, + Common.GetValueByPath(fromObject, new string[] { "topP" })); + } + + if (Common.GetValueByPath(fromObject, new string[] { "enableEnhancedCivicAnswers" }) != + null) { + Common.SetValueByPath( + toObject, new string[] { "enableEnhancedCivicAnswers" }, + Common.GetValueByPath(fromObject, new string[] { "enableEnhancedCivicAnswers" })); + } + + if (Common.GetValueByPath(fromObject, new string[] { "systemInstruction" }) != null) { + Common.SetValueByPath( + parentObject, new string[] { "systemInstruction" }, + ContentToMldev( + JsonNode.Parse(JsonSerializer.Serialize(Transformers.TContent( + Common.GetValueByPath(fromObject, new string[] { "systemInstruction" })))), + toObject)); } if (Common.GetValueByPath(fromObject, new string[] { "safetySettings" }) != null) { @@ -1018,33 +1058,6 @@ internal JsonNode GenerateContentConfigToMldev(ApiClient apiClient, JsonNode fro Common.GetValueByPath(fromObject, new string[] { "cachedContent" }))); } - if (Common.GetValueByPath(fromObject, new string[] { "responseModalities" }) != null) { - Common.SetValueByPath( - toObject, new string[] { "responseModalities" }, - Common.GetValueByPath(fromObject, new string[] { "responseModalities" })); - } - - if (Common.GetValueByPath(fromObject, new string[] { "mediaResolution" }) != null) { - Common.SetValueByPath( - toObject, new string[] { "mediaResolution" }, - Common.GetValueByPath(fromObject, new string[] { "mediaResolution" })); - } - - if (Common.GetValueByPath(fromObject, new string[] { "speechConfig" }) != null) { - Common.SetValueByPath(toObject, new string[] { "speechConfig" }, - Transformers.TSpeechConfig(Common.GetValueByPath( - fromObject, new string[] { "speechConfig" }))); - } - - if (!Common.IsZero(Common.GetValueByPath(fromObject, new string[] { "audioTimestamp" }))) { - throw new NotSupportedException("audioTimestamp parameter is not supported in Gemini API."); - } - - if (Common.GetValueByPath(fromObject, new string[] { "thinkingConfig" }) != null) { - Common.SetValueByPath(toObject, new string[] { "thinkingConfig" }, - Common.GetValueByPath(fromObject, new string[] { "thinkingConfig" })); - } - if (Common.GetValueByPath(fromObject, new string[] { "imageConfig" }) != null) { Common.SetValueByPath( toObject, new string[] { "imageConfig" }, @@ -1053,13 +1066,6 @@ internal JsonNode GenerateContentConfigToMldev(ApiClient apiClient, JsonNode fro toObject)); } - if (Common.GetValueByPath(fromObject, new string[] { "enableEnhancedCivicAnswers" }) != - null) { - Common.SetValueByPath( - toObject, new string[] { "enableEnhancedCivicAnswers" }, - Common.GetValueByPath(fromObject, new string[] { "enableEnhancedCivicAnswers" })); - } - return toObject; } diff --git a/Google.GenAI/LiveConverters.cs b/Google.GenAI/LiveConverters.cs index a332bd2a..cde06a87 100644 --- a/Google.GenAI/LiveConverters.cs +++ b/Google.GenAI/LiveConverters.cs @@ -186,12 +186,6 @@ internal JsonNode GenerationConfigToVertex(JsonNode fromObject, JsonObject paren Common.GetValueByPath(fromObject, new string[] { "modelSelectionConfig" })); } - if (Common.GetValueByPath(fromObject, new string[] { "responseJsonSchema" }) != null) { - Common.SetValueByPath( - toObject, new string[] { "responseJsonSchema" }, - Common.GetValueByPath(fromObject, new string[] { "responseJsonSchema" })); - } - if (Common.GetValueByPath(fromObject, new string[] { "audioTimestamp" }) != null) { Common.SetValueByPath(toObject, new string[] { "audioTimestamp" }, Common.GetValueByPath(fromObject, new string[] { "audioTimestamp" })); @@ -237,6 +231,12 @@ internal JsonNode GenerationConfigToVertex(JsonNode fromObject, JsonObject paren Common.GetValueByPath(fromObject, new string[] { "presencePenalty" })); } + if (Common.GetValueByPath(fromObject, new string[] { "responseJsonSchema" }) != null) { + Common.SetValueByPath( + toObject, new string[] { "responseJsonSchema" }, + Common.GetValueByPath(fromObject, new string[] { "responseJsonSchema" })); + } + if (Common.GetValueByPath(fromObject, new string[] { "responseLogprobs" }) != null) { Common.SetValueByPath( toObject, new string[] { "responseLogprobs" }, diff --git a/Google.GenAI/Models.cs b/Google.GenAI/Models.cs index aa09f897..c450005d 100644 --- a/Google.GenAI/Models.cs +++ b/Google.GenAI/Models.cs @@ -920,28 +920,14 @@ internal JsonNode GenerateContentConfigToMldev(ApiClient apiClient, JsonNode fro JsonObject parentObject) { JsonObject toObject = new JsonObject(); - if (Common.GetValueByPath(fromObject, new string[] { "systemInstruction" }) != null) { - Common.SetValueByPath( - parentObject, new string[] { "systemInstruction" }, - ContentToMldev( - JsonNode.Parse(JsonSerializer.Serialize(Transformers.TContent( - Common.GetValueByPath(fromObject, new string[] { "systemInstruction" })))), - toObject)); - } - - if (Common.GetValueByPath(fromObject, new string[] { "temperature" }) != null) { - Common.SetValueByPath(toObject, new string[] { "temperature" }, - Common.GetValueByPath(fromObject, new string[] { "temperature" })); - } - - if (Common.GetValueByPath(fromObject, new string[] { "topP" }) != null) { - Common.SetValueByPath(toObject, new string[] { "topP" }, - Common.GetValueByPath(fromObject, new string[] { "topP" })); + if (!Common.IsZero( + Common.GetValueByPath(fromObject, new string[] { "modelSelectionConfig" }))) { + throw new NotSupportedException( + "modelSelectionConfig parameter is not supported in Gemini API."); } - if (Common.GetValueByPath(fromObject, new string[] { "topK" }) != null) { - Common.SetValueByPath(toObject, new string[] { "topK" }, - Common.GetValueByPath(fromObject, new string[] { "topK" })); + if (!Common.IsZero(Common.GetValueByPath(fromObject, new string[] { "audioTimestamp" }))) { + throw new NotSupportedException("audioTimestamp parameter is not supported in Gemini API."); } if (Common.GetValueByPath(fromObject, new string[] { "candidateCount" }) != null) { @@ -949,21 +935,16 @@ internal JsonNode GenerateContentConfigToMldev(ApiClient apiClient, JsonNode fro Common.GetValueByPath(fromObject, new string[] { "candidateCount" })); } - if (Common.GetValueByPath(fromObject, new string[] { "maxOutputTokens" }) != null) { - Common.SetValueByPath( - toObject, new string[] { "maxOutputTokens" }, - Common.GetValueByPath(fromObject, new string[] { "maxOutputTokens" })); - } - - if (Common.GetValueByPath(fromObject, new string[] { "stopSequences" }) != null) { - Common.SetValueByPath(toObject, new string[] { "stopSequences" }, - Common.GetValueByPath(fromObject, new string[] { "stopSequences" })); + if (!Common.IsZero( + Common.GetValueByPath(fromObject, new string[] { "enableAffectiveDialog" }))) { + throw new NotSupportedException( + "enableAffectiveDialog parameter is not supported in Gemini API."); } - if (Common.GetValueByPath(fromObject, new string[] { "responseLogprobs" }) != null) { + if (Common.GetValueByPath(fromObject, new string[] { "frequencyPenalty" }) != null) { Common.SetValueByPath( - toObject, new string[] { "responseLogprobs" }, - Common.GetValueByPath(fromObject, new string[] { "responseLogprobs" })); + toObject, new string[] { "frequencyPenalty" }, + Common.GetValueByPath(fromObject, new string[] { "frequencyPenalty" })); } if (Common.GetValueByPath(fromObject, new string[] { "logprobs" }) != null) { @@ -971,21 +952,34 @@ internal JsonNode GenerateContentConfigToMldev(ApiClient apiClient, JsonNode fro Common.GetValueByPath(fromObject, new string[] { "logprobs" })); } + if (Common.GetValueByPath(fromObject, new string[] { "maxOutputTokens" }) != null) { + Common.SetValueByPath( + toObject, new string[] { "maxOutputTokens" }, + Common.GetValueByPath(fromObject, new string[] { "maxOutputTokens" })); + } + + if (Common.GetValueByPath(fromObject, new string[] { "mediaResolution" }) != null) { + Common.SetValueByPath( + toObject, new string[] { "mediaResolution" }, + Common.GetValueByPath(fromObject, new string[] { "mediaResolution" })); + } + if (Common.GetValueByPath(fromObject, new string[] { "presencePenalty" }) != null) { Common.SetValueByPath( toObject, new string[] { "presencePenalty" }, Common.GetValueByPath(fromObject, new string[] { "presencePenalty" })); } - if (Common.GetValueByPath(fromObject, new string[] { "frequencyPenalty" }) != null) { + if (Common.GetValueByPath(fromObject, new string[] { "responseJsonSchema" }) != null) { Common.SetValueByPath( - toObject, new string[] { "frequencyPenalty" }, - Common.GetValueByPath(fromObject, new string[] { "frequencyPenalty" })); + toObject, new string[] { "responseJsonSchema" }, + Common.GetValueByPath(fromObject, new string[] { "responseJsonSchema" })); } - if (Common.GetValueByPath(fromObject, new string[] { "seed" }) != null) { - Common.SetValueByPath(toObject, new string[] { "seed" }, - Common.GetValueByPath(fromObject, new string[] { "seed" })); + if (Common.GetValueByPath(fromObject, new string[] { "responseLogprobs" }) != null) { + Common.SetValueByPath( + toObject, new string[] { "responseLogprobs" }, + Common.GetValueByPath(fromObject, new string[] { "responseLogprobs" })); } if (Common.GetValueByPath(fromObject, new string[] { "responseMimeType" }) != null) { @@ -994,26 +988,72 @@ internal JsonNode GenerateContentConfigToMldev(ApiClient apiClient, JsonNode fro Common.GetValueByPath(fromObject, new string[] { "responseMimeType" })); } + if (Common.GetValueByPath(fromObject, new string[] { "responseModalities" }) != null) { + Common.SetValueByPath( + toObject, new string[] { "responseModalities" }, + Common.GetValueByPath(fromObject, new string[] { "responseModalities" })); + } + if (Common.GetValueByPath(fromObject, new string[] { "responseSchema" }) != null) { Common.SetValueByPath(toObject, new string[] { "responseSchema" }, Transformers.TSchema(Common.GetValueByPath( fromObject, new string[] { "responseSchema" }))); } - if (Common.GetValueByPath(fromObject, new string[] { "responseJsonSchema" }) != null) { - Common.SetValueByPath( - toObject, new string[] { "responseJsonSchema" }, - Common.GetValueByPath(fromObject, new string[] { "responseJsonSchema" })); - } - if (!Common.IsZero(Common.GetValueByPath(fromObject, new string[] { "routingConfig" }))) { throw new NotSupportedException("routingConfig parameter is not supported in Gemini API."); } - if (!Common.IsZero( - Common.GetValueByPath(fromObject, new string[] { "modelSelectionConfig" }))) { - throw new NotSupportedException( - "modelSelectionConfig parameter is not supported in Gemini API."); + if (Common.GetValueByPath(fromObject, new string[] { "seed" }) != null) { + Common.SetValueByPath(toObject, new string[] { "seed" }, + Common.GetValueByPath(fromObject, new string[] { "seed" })); + } + + if (Common.GetValueByPath(fromObject, new string[] { "speechConfig" }) != null) { + Common.SetValueByPath(toObject, new string[] { "speechConfig" }, + Transformers.TSpeechConfig(Common.GetValueByPath( + fromObject, new string[] { "speechConfig" }))); + } + + if (Common.GetValueByPath(fromObject, new string[] { "stopSequences" }) != null) { + Common.SetValueByPath(toObject, new string[] { "stopSequences" }, + Common.GetValueByPath(fromObject, new string[] { "stopSequences" })); + } + + if (Common.GetValueByPath(fromObject, new string[] { "temperature" }) != null) { + Common.SetValueByPath(toObject, new string[] { "temperature" }, + Common.GetValueByPath(fromObject, new string[] { "temperature" })); + } + + if (Common.GetValueByPath(fromObject, new string[] { "thinkingConfig" }) != null) { + Common.SetValueByPath(toObject, new string[] { "thinkingConfig" }, + Common.GetValueByPath(fromObject, new string[] { "thinkingConfig" })); + } + + if (Common.GetValueByPath(fromObject, new string[] { "topK" }) != null) { + Common.SetValueByPath(toObject, new string[] { "topK" }, + Common.GetValueByPath(fromObject, new string[] { "topK" })); + } + + if (Common.GetValueByPath(fromObject, new string[] { "topP" }) != null) { + Common.SetValueByPath(toObject, new string[] { "topP" }, + Common.GetValueByPath(fromObject, new string[] { "topP" })); + } + + if (Common.GetValueByPath(fromObject, new string[] { "enableEnhancedCivicAnswers" }) != + null) { + Common.SetValueByPath( + toObject, new string[] { "enableEnhancedCivicAnswers" }, + Common.GetValueByPath(fromObject, new string[] { "enableEnhancedCivicAnswers" })); + } + + if (Common.GetValueByPath(fromObject, new string[] { "systemInstruction" }) != null) { + Common.SetValueByPath( + parentObject, new string[] { "systemInstruction" }, + ContentToMldev( + JsonNode.Parse(JsonSerializer.Serialize(Transformers.TContent( + Common.GetValueByPath(fromObject, new string[] { "systemInstruction" })))), + toObject)); } if (Common.GetValueByPath(fromObject, new string[] { "safetySettings" }) != null) { @@ -1060,33 +1100,6 @@ internal JsonNode GenerateContentConfigToMldev(ApiClient apiClient, JsonNode fro Common.GetValueByPath(fromObject, new string[] { "cachedContent" }))); } - if (Common.GetValueByPath(fromObject, new string[] { "responseModalities" }) != null) { - Common.SetValueByPath( - toObject, new string[] { "responseModalities" }, - Common.GetValueByPath(fromObject, new string[] { "responseModalities" })); - } - - if (Common.GetValueByPath(fromObject, new string[] { "mediaResolution" }) != null) { - Common.SetValueByPath( - toObject, new string[] { "mediaResolution" }, - Common.GetValueByPath(fromObject, new string[] { "mediaResolution" })); - } - - if (Common.GetValueByPath(fromObject, new string[] { "speechConfig" }) != null) { - Common.SetValueByPath(toObject, new string[] { "speechConfig" }, - Transformers.TSpeechConfig(Common.GetValueByPath( - fromObject, new string[] { "speechConfig" }))); - } - - if (!Common.IsZero(Common.GetValueByPath(fromObject, new string[] { "audioTimestamp" }))) { - throw new NotSupportedException("audioTimestamp parameter is not supported in Gemini API."); - } - - if (Common.GetValueByPath(fromObject, new string[] { "thinkingConfig" }) != null) { - Common.SetValueByPath(toObject, new string[] { "thinkingConfig" }, - Common.GetValueByPath(fromObject, new string[] { "thinkingConfig" })); - } - if (Common.GetValueByPath(fromObject, new string[] { "imageConfig" }) != null) { Common.SetValueByPath( toObject, new string[] { "imageConfig" }, @@ -1095,13 +1108,6 @@ internal JsonNode GenerateContentConfigToMldev(ApiClient apiClient, JsonNode fro toObject)); } - if (Common.GetValueByPath(fromObject, new string[] { "enableEnhancedCivicAnswers" }) != - null) { - Common.SetValueByPath( - toObject, new string[] { "enableEnhancedCivicAnswers" }, - Common.GetValueByPath(fromObject, new string[] { "enableEnhancedCivicAnswers" })); - } - return toObject; } @@ -1109,25 +1115,15 @@ internal JsonNode GenerateContentConfigToVertex(ApiClient apiClient, JsonNode fr JsonObject parentObject) { JsonObject toObject = new JsonObject(); - if (Common.GetValueByPath(fromObject, new string[] { "systemInstruction" }) != null) { - Common.SetValueByPath(parentObject, new string[] { "systemInstruction" }, - Transformers.TContent(Common.GetValueByPath( - fromObject, new string[] { "systemInstruction" }))); - } - - if (Common.GetValueByPath(fromObject, new string[] { "temperature" }) != null) { - Common.SetValueByPath(toObject, new string[] { "temperature" }, - Common.GetValueByPath(fromObject, new string[] { "temperature" })); - } - - if (Common.GetValueByPath(fromObject, new string[] { "topP" }) != null) { - Common.SetValueByPath(toObject, new string[] { "topP" }, - Common.GetValueByPath(fromObject, new string[] { "topP" })); + if (Common.GetValueByPath(fromObject, new string[] { "modelSelectionConfig" }) != null) { + Common.SetValueByPath( + toObject, new string[] { "modelConfig" }, + Common.GetValueByPath(fromObject, new string[] { "modelSelectionConfig" })); } - if (Common.GetValueByPath(fromObject, new string[] { "topK" }) != null) { - Common.SetValueByPath(toObject, new string[] { "topK" }, - Common.GetValueByPath(fromObject, new string[] { "topK" })); + if (Common.GetValueByPath(fromObject, new string[] { "audioTimestamp" }) != null) { + Common.SetValueByPath(toObject, new string[] { "audioTimestamp" }, + Common.GetValueByPath(fromObject, new string[] { "audioTimestamp" })); } if (Common.GetValueByPath(fromObject, new string[] { "candidateCount" }) != null) { @@ -1135,21 +1131,16 @@ internal JsonNode GenerateContentConfigToVertex(ApiClient apiClient, JsonNode fr Common.GetValueByPath(fromObject, new string[] { "candidateCount" })); } - if (Common.GetValueByPath(fromObject, new string[] { "maxOutputTokens" }) != null) { + if (Common.GetValueByPath(fromObject, new string[] { "enableAffectiveDialog" }) != null) { Common.SetValueByPath( - toObject, new string[] { "maxOutputTokens" }, - Common.GetValueByPath(fromObject, new string[] { "maxOutputTokens" })); - } - - if (Common.GetValueByPath(fromObject, new string[] { "stopSequences" }) != null) { - Common.SetValueByPath(toObject, new string[] { "stopSequences" }, - Common.GetValueByPath(fromObject, new string[] { "stopSequences" })); + toObject, new string[] { "enableAffectiveDialog" }, + Common.GetValueByPath(fromObject, new string[] { "enableAffectiveDialog" })); } - if (Common.GetValueByPath(fromObject, new string[] { "responseLogprobs" }) != null) { + if (Common.GetValueByPath(fromObject, new string[] { "frequencyPenalty" }) != null) { Common.SetValueByPath( - toObject, new string[] { "responseLogprobs" }, - Common.GetValueByPath(fromObject, new string[] { "responseLogprobs" })); + toObject, new string[] { "frequencyPenalty" }, + Common.GetValueByPath(fromObject, new string[] { "frequencyPenalty" })); } if (Common.GetValueByPath(fromObject, new string[] { "logprobs" }) != null) { @@ -1157,21 +1148,34 @@ internal JsonNode GenerateContentConfigToVertex(ApiClient apiClient, JsonNode fr Common.GetValueByPath(fromObject, new string[] { "logprobs" })); } + if (Common.GetValueByPath(fromObject, new string[] { "maxOutputTokens" }) != null) { + Common.SetValueByPath( + toObject, new string[] { "maxOutputTokens" }, + Common.GetValueByPath(fromObject, new string[] { "maxOutputTokens" })); + } + + if (Common.GetValueByPath(fromObject, new string[] { "mediaResolution" }) != null) { + Common.SetValueByPath( + toObject, new string[] { "mediaResolution" }, + Common.GetValueByPath(fromObject, new string[] { "mediaResolution" })); + } + if (Common.GetValueByPath(fromObject, new string[] { "presencePenalty" }) != null) { Common.SetValueByPath( toObject, new string[] { "presencePenalty" }, Common.GetValueByPath(fromObject, new string[] { "presencePenalty" })); } - if (Common.GetValueByPath(fromObject, new string[] { "frequencyPenalty" }) != null) { + if (Common.GetValueByPath(fromObject, new string[] { "responseJsonSchema" }) != null) { Common.SetValueByPath( - toObject, new string[] { "frequencyPenalty" }, - Common.GetValueByPath(fromObject, new string[] { "frequencyPenalty" })); + toObject, new string[] { "responseJsonSchema" }, + Common.GetValueByPath(fromObject, new string[] { "responseJsonSchema" })); } - if (Common.GetValueByPath(fromObject, new string[] { "seed" }) != null) { - Common.SetValueByPath(toObject, new string[] { "seed" }, - Common.GetValueByPath(fromObject, new string[] { "seed" })); + if (Common.GetValueByPath(fromObject, new string[] { "responseLogprobs" }) != null) { + Common.SetValueByPath( + toObject, new string[] { "responseLogprobs" }, + Common.GetValueByPath(fromObject, new string[] { "responseLogprobs" })); } if (Common.GetValueByPath(fromObject, new string[] { "responseMimeType" }) != null) { @@ -1180,27 +1184,69 @@ internal JsonNode GenerateContentConfigToVertex(ApiClient apiClient, JsonNode fr Common.GetValueByPath(fromObject, new string[] { "responseMimeType" })); } + if (Common.GetValueByPath(fromObject, new string[] { "responseModalities" }) != null) { + Common.SetValueByPath( + toObject, new string[] { "responseModalities" }, + Common.GetValueByPath(fromObject, new string[] { "responseModalities" })); + } + if (Common.GetValueByPath(fromObject, new string[] { "responseSchema" }) != null) { Common.SetValueByPath(toObject, new string[] { "responseSchema" }, Transformers.TSchema(Common.GetValueByPath( fromObject, new string[] { "responseSchema" }))); } - if (Common.GetValueByPath(fromObject, new string[] { "responseJsonSchema" }) != null) { - Common.SetValueByPath( - toObject, new string[] { "responseJsonSchema" }, - Common.GetValueByPath(fromObject, new string[] { "responseJsonSchema" })); - } - if (Common.GetValueByPath(fromObject, new string[] { "routingConfig" }) != null) { Common.SetValueByPath(toObject, new string[] { "routingConfig" }, Common.GetValueByPath(fromObject, new string[] { "routingConfig" })); } - if (Common.GetValueByPath(fromObject, new string[] { "modelSelectionConfig" }) != null) { - Common.SetValueByPath( - toObject, new string[] { "modelConfig" }, - Common.GetValueByPath(fromObject, new string[] { "modelSelectionConfig" })); + if (Common.GetValueByPath(fromObject, new string[] { "seed" }) != null) { + Common.SetValueByPath(toObject, new string[] { "seed" }, + Common.GetValueByPath(fromObject, new string[] { "seed" })); + } + + if (Common.GetValueByPath(fromObject, new string[] { "speechConfig" }) != null) { + Common.SetValueByPath(toObject, new string[] { "speechConfig" }, + Transformers.TSpeechConfig(Common.GetValueByPath( + fromObject, new string[] { "speechConfig" }))); + } + + if (Common.GetValueByPath(fromObject, new string[] { "stopSequences" }) != null) { + Common.SetValueByPath(toObject, new string[] { "stopSequences" }, + Common.GetValueByPath(fromObject, new string[] { "stopSequences" })); + } + + if (Common.GetValueByPath(fromObject, new string[] { "temperature" }) != null) { + Common.SetValueByPath(toObject, new string[] { "temperature" }, + Common.GetValueByPath(fromObject, new string[] { "temperature" })); + } + + if (Common.GetValueByPath(fromObject, new string[] { "thinkingConfig" }) != null) { + Common.SetValueByPath(toObject, new string[] { "thinkingConfig" }, + Common.GetValueByPath(fromObject, new string[] { "thinkingConfig" })); + } + + if (Common.GetValueByPath(fromObject, new string[] { "topK" }) != null) { + Common.SetValueByPath(toObject, new string[] { "topK" }, + Common.GetValueByPath(fromObject, new string[] { "topK" })); + } + + if (Common.GetValueByPath(fromObject, new string[] { "topP" }) != null) { + Common.SetValueByPath(toObject, new string[] { "topP" }, + Common.GetValueByPath(fromObject, new string[] { "topP" })); + } + + if (!Common.IsZero( + Common.GetValueByPath(fromObject, new string[] { "enableEnhancedCivicAnswers" }))) { + throw new NotSupportedException( + "enableEnhancedCivicAnswers parameter is not supported in Vertex AI."); + } + + if (Common.GetValueByPath(fromObject, new string[] { "systemInstruction" }) != null) { + Common.SetValueByPath(parentObject, new string[] { "systemInstruction" }, + Transformers.TContent(Common.GetValueByPath( + fromObject, new string[] { "systemInstruction" }))); } if (Common.GetValueByPath(fromObject, new string[] { "safetySettings" }) != null) { @@ -1238,34 +1284,6 @@ internal JsonNode GenerateContentConfigToVertex(ApiClient apiClient, JsonNode fr Common.GetValueByPath(fromObject, new string[] { "cachedContent" }))); } - if (Common.GetValueByPath(fromObject, new string[] { "responseModalities" }) != null) { - Common.SetValueByPath( - toObject, new string[] { "responseModalities" }, - Common.GetValueByPath(fromObject, new string[] { "responseModalities" })); - } - - if (Common.GetValueByPath(fromObject, new string[] { "mediaResolution" }) != null) { - Common.SetValueByPath( - toObject, new string[] { "mediaResolution" }, - Common.GetValueByPath(fromObject, new string[] { "mediaResolution" })); - } - - if (Common.GetValueByPath(fromObject, new string[] { "speechConfig" }) != null) { - Common.SetValueByPath(toObject, new string[] { "speechConfig" }, - Transformers.TSpeechConfig(Common.GetValueByPath( - fromObject, new string[] { "speechConfig" }))); - } - - if (Common.GetValueByPath(fromObject, new string[] { "audioTimestamp" }) != null) { - Common.SetValueByPath(toObject, new string[] { "audioTimestamp" }, - Common.GetValueByPath(fromObject, new string[] { "audioTimestamp" })); - } - - if (Common.GetValueByPath(fromObject, new string[] { "thinkingConfig" }) != null) { - Common.SetValueByPath(toObject, new string[] { "thinkingConfig" }, - Common.GetValueByPath(fromObject, new string[] { "thinkingConfig" })); - } - if (Common.GetValueByPath(fromObject, new string[] { "imageConfig" }) != null) { Common.SetValueByPath( toObject, new string[] { "imageConfig" }, @@ -1274,12 +1292,6 @@ internal JsonNode GenerateContentConfigToVertex(ApiClient apiClient, JsonNode fr toObject)); } - if (!Common.IsZero( - Common.GetValueByPath(fromObject, new string[] { "enableEnhancedCivicAnswers" }))) { - throw new NotSupportedException( - "enableEnhancedCivicAnswers parameter is not supported in Vertex AI."); - } - return toObject; } @@ -2344,12 +2356,6 @@ internal JsonNode GenerationConfigToVertex(JsonNode fromObject, JsonObject paren Common.GetValueByPath(fromObject, new string[] { "modelSelectionConfig" })); } - if (Common.GetValueByPath(fromObject, new string[] { "responseJsonSchema" }) != null) { - Common.SetValueByPath( - toObject, new string[] { "responseJsonSchema" }, - Common.GetValueByPath(fromObject, new string[] { "responseJsonSchema" })); - } - if (Common.GetValueByPath(fromObject, new string[] { "audioTimestamp" }) != null) { Common.SetValueByPath(toObject, new string[] { "audioTimestamp" }, Common.GetValueByPath(fromObject, new string[] { "audioTimestamp" })); @@ -2395,6 +2401,12 @@ internal JsonNode GenerationConfigToVertex(JsonNode fromObject, JsonObject paren Common.GetValueByPath(fromObject, new string[] { "presencePenalty" })); } + if (Common.GetValueByPath(fromObject, new string[] { "responseJsonSchema" }) != null) { + Common.SetValueByPath( + toObject, new string[] { "responseJsonSchema" }, + Common.GetValueByPath(fromObject, new string[] { "responseJsonSchema" })); + } + if (Common.GetValueByPath(fromObject, new string[] { "responseLogprobs" }) != null) { Common.SetValueByPath( toObject, new string[] { "responseLogprobs" }, diff --git a/Google.GenAI/types/GenerateContentConfig.cs b/Google.GenAI/types/GenerateContentConfig.cs index ff3a0544..69e35663 100644 --- a/Google.GenAI/types/GenerateContentConfig.cs +++ b/Google.GenAI/types/GenerateContentConfig.cs @@ -30,72 +30,66 @@ namespace Google.GenAI.Types { public record GenerateContentConfig { /// - /// Used to override HTTP request options. + /// Optional. Config for model selection. /// - [JsonPropertyName("httpOptions")] + [JsonPropertyName("modelSelectionConfig")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public HttpOptions ? HttpOptions { get; set; } + public ModelSelectionConfig ? ModelSelectionConfig { get; set; } /// - /// Instructions for the model to steer it toward better performance. For example, "Answer as - /// concisely as possible" or "Don't use technical terms in your response". + /// Optional. If enabled, audio timestamp will be included in the request to the model. This + /// field is not supported in Gemini API. /// - [JsonPropertyName("systemInstruction")] + [JsonPropertyName("audioTimestamp")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public Content - ? SystemInstruction { + public bool + ? AudioTimestamp { get; set; } /// - /// Value that controls the degree of randomness in token selection. Lower temperatures are good - /// for prompts that require a less open-ended or creative response, while higher temperatures - /// can lead to more diverse or creative results. + /// Optional. Number of candidates to generate. /// - [JsonPropertyName("temperature")] + [JsonPropertyName("candidateCount")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public double - ? Temperature { + public int + ? CandidateCount { get; set; } /// - /// Tokens are selected from the most to least probable until the sum of their probabilities - /// equals this value. Use a lower value for less random responses and a higher value for more - /// random responses. + /// Optional. If enabled, the model will detect emotions and adapt its responses accordingly. + /// This field is not supported in Gemini API. /// - [JsonPropertyName("topP")] + [JsonPropertyName("enableAffectiveDialog")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public double - ? TopP { + public bool + ? EnableAffectiveDialog { get; set; } /// - /// For each token selection step, the ``top_k`` tokens with the highest probabilities are - /// sampled. Then tokens are further filtered based on ``top_p`` with the final token selected - /// using temperature sampling. Use a lower number for less random responses and a higher number - /// for more random responses. + /// Optional. Frequency penalties. /// - [JsonPropertyName("topK")] + [JsonPropertyName("frequencyPenalty")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public double - ? TopK { + ? FrequencyPenalty { get; set; } /// - /// Number of response variations to return. + /// Optional. Logit probabilities. /// - [JsonPropertyName("candidateCount")] + [JsonPropertyName("logprobs")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public int - ? CandidateCount { + ? Logprobs { get; set; } /// - /// Maximum number of tokens that can be generated in the response. + /// Optional. The maximum number of output tokens to generate per message. /// [JsonPropertyName("maxOutputTokens")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] @@ -105,19 +99,48 @@ public int } /// - /// List of strings that tells the model to stop generating text if one of the strings is - /// encountered in the response. + /// Optional. If specified, the media resolution specified will be used. /// - [JsonPropertyName("stopSequences")] + [JsonPropertyName("mediaResolution")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public List - ? StopSequences { + public MediaResolution + ? MediaResolution { + get; set; + } + + /// + /// Optional. Positive penalties. + /// + [JsonPropertyName("presencePenalty")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public double + ? PresencePenalty { + get; set; + } + + /// + /// Optional. Output schema of the generated response. This is an alternative to + /// `response_schema` that accepts JSON Schema (https://json-schema.org/). If set, + /// `response_schema` must be omitted, but `response_mime_type` is required. While the full JSON + /// Schema may be sent, not all features are supported. Specifically, only the following + /// properties are supported: - `$id` - `$defs` - `$ref` - `$anchor` - `type` - `format` - + /// `title` - `description` - `enum` (for strings and numbers) - `items` - `prefixItems` - + /// `minItems` - `maxItems` - `minimum` - `maximum` - `anyOf` - `oneOf` (interpreted the same as + /// `anyOf`) - `properties` - `additionalProperties` - `required` The non-standard + /// `propertyOrdering` property may also be set. Cyclic references are unrolled to a limited + /// degree and, as such, may only be used within non-required properties. (Nullable properties + /// are not sufficient.) If `$ref` is set on a sub-schema, no other properties, except for than + /// those starting as a `$`, may be set. + /// + [JsonPropertyName("responseJsonSchema")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public object + ? ResponseJsonSchema { get; set; } /// - /// Whether to return the log probabilities of the tokens that were chosen by the model at each - /// step. + /// Optional. If true, export the logprobs results in response. /// [JsonPropertyName("responseLogprobs")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] @@ -127,216 +150,203 @@ public bool } /// - /// Number of top candidate tokens to return the log probabilities for at each generation step. + /// Optional. Output response mimetype of the generated candidate text. Supported mimetype: - + /// `text/plain`: (default) Text output. - `application/json`: JSON response in the candidates. + /// The model needs to be prompted to output the appropriate response type, otherwise the + /// behavior is undefined. This is a preview feature. /// - [JsonPropertyName("logprobs")] + [JsonPropertyName("responseMimeType")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public int - ? Logprobs { + public string + ? ResponseMimeType { get; set; } /// - /// Positive values penalize tokens that already appear in the generated text, increasing the - /// probability of generating more diverse content. + /// Optional. The modalities of the response. /// - [JsonPropertyName("presencePenalty")] + [JsonPropertyName("responseModalities")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public double - ? PresencePenalty { + public List + ? ResponseModalities { get; set; } /// - /// Positive values penalize tokens that repeatedly appear in the generated text, increasing the - /// probability of generating more diverse content. + /// Optional. The `Schema` object allows the definition of input and output data types. These + /// types can be objects, but also primitives and arrays. Represents a select subset of an + /// OpenAPI 3.0 schema object (https://spec.openapis.org/oas/v3.0.3#schema). If set, a + /// compatible response_mime_type must also be set. Compatible mimetypes: `application/json`: + /// Schema for JSON response. /// - [JsonPropertyName("frequencyPenalty")] + [JsonPropertyName("responseSchema")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public double - ? FrequencyPenalty { + public Schema + ? ResponseSchema { get; set; } /// - /// When ``seed`` is fixed to a specific number, the model makes a best effort to provide the - /// same response for repeated requests. By default, a random number is used. + /// Optional. Routing configuration. This field is not supported in Gemini API. /// - [JsonPropertyName("seed")] + [JsonPropertyName("routingConfig")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public int - ? Seed { + public GenerationConfigRoutingConfig + ? RoutingConfig { get; set; } /// - /// Output response mimetype of the generated candidate text. Supported mimetype: - - /// `text/plain`: (default) Text output. - `application/json`: JSON response in the candidates. - /// The model needs to be prompted to output the appropriate response type, otherwise the - /// behavior is undefined. This is a preview feature. + /// Optional. Seed. /// - [JsonPropertyName("responseMimeType")] + [JsonPropertyName("seed")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public string - ? ResponseMimeType { + public int + ? Seed { get; set; } /// - /// The `Schema` object allows the definition of input and output data types. These types can be - /// objects, but also primitives and arrays. Represents a select subset of an OpenAPI 3.0 schema - /// object (https://spec.openapis.org/oas/v3.0.3#schema). If set, a compatible - /// response_mime_type must also be set. Compatible mimetypes: `application/json`: Schema for - /// JSON response. If `response_schema` doesn't process your schema correctly, try using - /// `response_json_schema` instead. + /// Optional. The speech generation config. /// - [JsonPropertyName("responseSchema")] + [JsonPropertyName("speechConfig")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public Schema - ? ResponseSchema { + public SpeechConfig + ? SpeechConfig { get; set; } /// - /// Optional. Output schema of the generated response. This is an alternative to - /// `response_schema` that accepts JSON Schema (https://json-schema.org/). If set, - /// `response_schema` must be omitted, but `response_mime_type` is required. While the full JSON - /// Schema may be sent, not all features are supported. Specifically, only the following - /// properties are supported: - `$id` - `$defs` - `$ref` - `$anchor` - `type` - `format` - - /// `title` - `description` - `enum` (for strings and numbers) - `items` - `prefixItems` - - /// `minItems` - `maxItems` - `minimum` - `maximum` - `anyOf` - `oneOf` (interpreted the same as - /// `anyOf`) - `properties` - `additionalProperties` - `required` The non-standard - /// `propertyOrdering` property may also be set. Cyclic references are unrolled to a limited - /// degree and, as such, may only be used within non-required properties. (Nullable properties - /// are not sufficient.) If `$ref` is set on a sub-schema, no other properties, except for than - /// those starting as a `$`, may be set. + /// Optional. Stop sequences. /// - [JsonPropertyName("responseJsonSchema")] + [JsonPropertyName("stopSequences")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public object - ? ResponseJsonSchema { + public List + ? StopSequences { get; set; } /// - /// Configuration for model router requests. + /// Optional. Controls the randomness of predictions. /// - [JsonPropertyName("routingConfig")] + [JsonPropertyName("temperature")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public GenerationConfigRoutingConfig - ? RoutingConfig { + public double + ? Temperature { get; set; } /// - /// Configuration for model selection. + /// Optional. Config for thinking features. An error will be returned if this field is set for + /// models that don't support thinking. /// - [JsonPropertyName("modelSelectionConfig")] + [JsonPropertyName("thinkingConfig")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public ModelSelectionConfig - ? ModelSelectionConfig { + public ThinkingConfig + ? ThinkingConfig { get; set; } /// - /// Safety settings in the request to block unsafe content in the response. + /// Optional. If specified, top-k sampling will be used. /// - [JsonPropertyName("safetySettings")] + [JsonPropertyName("topK")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public List - ? SafetySettings { + public double + ? TopK { get; set; } /// - /// Code that enables the system to interact with external systems to perform an action outside - /// of the knowledge and scope of the model. + /// Optional. If specified, nucleus sampling will be used. /// - [JsonPropertyName("tools")] + [JsonPropertyName("topP")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public List - ? Tools { + public double + ? TopP { get; set; } /// - /// Associates model output to a specific function call. + /// Optional. Enables enhanced civic answers. It may not be available for all models. This field + /// is not supported in Vertex AI. /// - [JsonPropertyName("toolConfig")] + [JsonPropertyName("enableEnhancedCivicAnswers")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public ToolConfig - ? ToolConfig { + public bool + ? EnableEnhancedCivicAnswers { get; set; } /// - /// Labels with user-defined metadata to break down billed charges. + /// Used to override HTTP request options. /// - [JsonPropertyName("labels")] + [JsonPropertyName("httpOptions")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public Dictionary - ? Labels { + public HttpOptions + ? HttpOptions { get; set; } /// - /// Resource name of a context cache that can be used in subsequent requests. + /// Instructions for the model to steer it toward better performance. For example, "Answer as + /// concisely as possible" or "Don't use technical terms in your response". /// - [JsonPropertyName("cachedContent")] + [JsonPropertyName("systemInstruction")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public string - ? CachedContent { + public Content + ? SystemInstruction { get; set; } /// - /// The requested modalities of the response. Represents the set of modalities that the model - /// can return. + /// Safety settings in the request to block unsafe content in the response. /// - [JsonPropertyName("responseModalities")] + [JsonPropertyName("safetySettings")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public List - ? ResponseModalities { + public List + ? SafetySettings { get; set; } /// - /// If specified, the media resolution specified will be used. + /// Code that enables the system to interact with external systems to perform an action outside + /// of the knowledge and scope of the model. /// - [JsonPropertyName("mediaResolution")] + [JsonPropertyName("tools")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public MediaResolution - ? MediaResolution { + public List + ? Tools { get; set; } /// - /// The speech generation configuration. + /// Associates model output to a specific function call. /// - [JsonPropertyName("speechConfig")] + [JsonPropertyName("toolConfig")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public SpeechConfig - ? SpeechConfig { + public ToolConfig + ? ToolConfig { get; set; } /// - /// If enabled, audio timestamp will be included in the request to the model. + /// Labels with user-defined metadata to break down billed charges. /// - [JsonPropertyName("audioTimestamp")] + [JsonPropertyName("labels")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public bool - ? AudioTimestamp { + public Dictionary + ? Labels { get; set; } /// - /// The thinking features configuration. + /// Resource name of a context cache that can be used in subsequent requests. /// - [JsonPropertyName("thinkingConfig")] + [JsonPropertyName("cachedContent")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public ThinkingConfig - ? ThinkingConfig { + public string + ? CachedContent { get; set; } @@ -350,17 +360,6 @@ public ImageConfig get; set; } - /// - /// Enables enhanced civic answers. It may not be available for all models. This field is not - /// supported in Vertex AI. - /// - [JsonPropertyName("enableEnhancedCivicAnswers")] - [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public bool - ? EnableEnhancedCivicAnswers { - get; set; - } - /// /// Deserializes a JSON string to a GenerateContentConfig object. /// diff --git a/Google.GenAI/types/GenerationConfig.cs b/Google.GenAI/types/GenerationConfig.cs index d5544804..1bdf08aa 100644 --- a/Google.GenAI/types/GenerationConfig.cs +++ b/Google.GenAI/types/GenerationConfig.cs @@ -34,17 +34,6 @@ public record GenerationConfig { [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public ModelSelectionConfig ? ModelSelectionConfig { get; set; } - /// - /// Output schema of the generated response. This is an alternative to `response_schema` that - /// accepts JSON Schema (https://json-schema.org/). - /// - [JsonPropertyName("responseJsonSchema")] - [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] - public object - ? ResponseJsonSchema { - get; set; - } - /// /// Optional. If enabled, audio timestamp will be included in the request to the model. This /// field is not supported in Gemini API. @@ -127,6 +116,27 @@ public double get; set; } + /// + /// Optional. Output schema of the generated response. This is an alternative to + /// `response_schema` that accepts JSON Schema (https://json-schema.org/). If set, + /// `response_schema` must be omitted, but `response_mime_type` is required. While the full JSON + /// Schema may be sent, not all features are supported. Specifically, only the following + /// properties are supported: - `$id` - `$defs` - `$ref` - `$anchor` - `type` - `format` - + /// `title` - `description` - `enum` (for strings and numbers) - `items` - `prefixItems` - + /// `minItems` - `maxItems` - `minimum` - `maximum` - `anyOf` - `oneOf` (interpreted the same as + /// `anyOf`) - `properties` - `additionalProperties` - `required` The non-standard + /// `propertyOrdering` property may also be set. Cyclic references are unrolled to a limited + /// degree and, as such, may only be used within non-required properties. (Nullable properties + /// are not sufficient.) If `$ref` is set on a sub-schema, no other properties, except for than + /// those starting as a `$`, may be set. + /// + [JsonPropertyName("responseJsonSchema")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] + public object + ? ResponseJsonSchema { + get; set; + } + /// /// Optional. If true, export the logprobs results in response. /// diff --git a/Google.GenAI/types/MediaResolution.cs b/Google.GenAI/types/MediaResolution.cs index 95cbfb6c..591102ff 100644 --- a/Google.GenAI/types/MediaResolution.cs +++ b/Google.GenAI/types/MediaResolution.cs @@ -20,12 +20,12 @@ namespace Google.GenAI.Types { /// - /// The media resolution to use. + /// If specified, the media resolution specified will be used. /// [JsonConverter(typeof(JsonStringEnumConverter))] public enum MediaResolution { /// - /// Media resolution has not been set + /// Media resolution has not been set. /// [JsonPropertyName("MEDIA_RESOLUTION_UNSPECIFIED")] MEDIA_RESOLUTION_UNSPECIFIED,