Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
310 changes: 222 additions & 88 deletions Google.GenAI/LiveConverters.cs

Large diffs are not rendered by default.

396 changes: 249 additions & 147 deletions Google.GenAI/Models.cs

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions Google.GenAI/types/Blob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,23 @@

namespace Google.GenAI.Types {
/// <summary>
/// Content blob.
/// A content blob. A Blob contains data of a specific media type. It is used to represent images,
/// audio, and video.
/// </summary>

public record Blob {
/// <summary>
/// Raw bytes.
/// The raw bytes of the data.
/// </summary>
[JsonPropertyName("data")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public byte[] ? Data { get; set; }

/// <summary>
/// Optional. Display name of the blob. Used to provide a label or filename to distinguish
/// blobs. This field is only returned in PromptMessage for prompt management. It is currently
/// used in the Gemini GenerateContent calls only when server side tools (code_execution,
/// google_search, and url_context) are enabled. This field is not supported in Gemini API.
/// Optional. The display name of the blob. Used to provide a label or filename to distinguish
/// blobs. This field is only returned in `PromptMessage` for prompt management. It is used in
/// the Gemini calls only when server-side tools (`code_execution`, `google_search`, and
/// `url_context`) are enabled. This field is not supported in Gemini API.
/// </summary>
[JsonPropertyName("displayName")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
Expand Down
31 changes: 19 additions & 12 deletions Google.GenAI/types/Candidate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,27 +76,31 @@ public FinishReason
}

/// <summary>
/// Output only. Average log probability score of the candidate.
/// Output only. Grounding metadata for the candidate. This field is populated for
/// `GenerateContent` calls.
/// </summary>
[JsonPropertyName("avgLogprobs")]
[JsonPropertyName("groundingMetadata")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public double
? AvgLogprobs {
public GroundingMetadata
? GroundingMetadata {
get; set;
}

/// <summary>
/// Output only. Metadata specifies sources used to ground generated content.
/// Output only. The average log probability of the tokens in this candidate. This is a
/// length-normalized score that can be used to compare the quality of candidates of different
/// lengths. A higher average log probability suggests a more confident and coherent response.
/// </summary>
[JsonPropertyName("groundingMetadata")]
[JsonPropertyName("avgLogprobs")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public GroundingMetadata
? GroundingMetadata {
public double
? AvgLogprobs {
get; set;
}

/// <summary>
/// Output only. Index of the candidate.
/// Output only. The 0-based index of this candidate in the list of generated responses. This is
/// useful for distinguishing between multiple candidates when `candidate_count` > 1.
/// </summary>
[JsonPropertyName("index")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
Expand All @@ -106,7 +110,9 @@ public int
}

/// <summary>
/// Output only. Log-likelihood scores for the response tokens and top tokens
/// Output only. The detailed log probability information for the tokens in this candidate. This
/// is useful for debugging, understanding model uncertainty, and identifying potential
/// "hallucinations".
/// </summary>
[JsonPropertyName("logprobsResult")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
Expand All @@ -116,7 +122,7 @@ public LogprobsResult
}

/// <summary>
/// Output only. List of ratings for the safety of a response candidate. There is at most one
/// Output only. A list of ratings for the safety of a response candidate. There is at most one
/// rating per category.
/// </summary>
[JsonPropertyName("safetyRatings")]
Expand All @@ -127,7 +133,8 @@ public List<SafetyRating>
}

/// <summary>
/// Output only. Metadata related to url context retrieval tool.
/// Output only. Metadata returned when the model uses the `url_context` tool to get information
/// from a user-provided URL.
/// </summary>
[JsonPropertyName("urlContextMetadata")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
Expand Down
14 changes: 7 additions & 7 deletions Google.GenAI/types/Citation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@

namespace Google.GenAI.Types {
/// <summary>
/// Source attributions for content. This data type is not supported in Gemini API.
/// A citation for a piece of generatedcontent. This data type is not supported in Gemini API.
/// </summary>

public record Citation {
/// <summary>
/// Output only. End index into the content.
/// Output only. The end index of the citation in the content.
/// </summary>
[JsonPropertyName("endIndex")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int ? EndIndex { get; set; }

/// <summary>
/// Output only. License of the attribution.
/// Output only. The license of the source of the citation.
/// </summary>
[JsonPropertyName("license")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
Expand All @@ -45,7 +45,7 @@ public string
}

/// <summary>
/// Output only. Publication date of the attribution.
/// Output only. The publication date of the source of the citation.
/// </summary>
[JsonPropertyName("publicationDate")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
Expand All @@ -55,7 +55,7 @@ public GoogleTypeDate
}

/// <summary>
/// Output only. Start index into the content.
/// Output only. The start index of the citation in the content.
/// </summary>
[JsonPropertyName("startIndex")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
Expand All @@ -65,7 +65,7 @@ public int
}

/// <summary>
/// Output only. Title of the attribution.
/// Output only. The title of the source of the citation.
/// </summary>
[JsonPropertyName("title")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
Expand All @@ -75,7 +75,7 @@ public string
}

/// <summary>
/// Output only. Url reference of the attribution.
/// Output only. The URI of the source of the citation.
/// </summary>
[JsonPropertyName("uri")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
Expand Down
4 changes: 2 additions & 2 deletions Google.GenAI/types/Content.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public record Content {
public List<Part> ? Parts { get; set; }

/// <summary>
/// Optional. The producer of the content. Must be either 'user' or 'model'. Useful to set for
/// multi-turn conversations, otherwise can be left blank or unset.
/// Optional. The producer of the content. Must be either 'user' or 'model'. If not set, the
/// service will default to 'user'.
/// </summary>
[JsonPropertyName("role")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
Expand Down
18 changes: 9 additions & 9 deletions Google.GenAI/types/EnterpriseWebSearch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,21 @@ namespace Google.GenAI.Types {

public record EnterpriseWebSearch {
/// <summary>
/// Optional. List of domains to be excluded from the search results. The default limit is 2000
/// domains.
/// Optional. Sites with confidence level chosen &amp; above this value will be blocked from the
/// search results.
/// </summary>
[JsonPropertyName("excludeDomains")]
[JsonPropertyName("blockingConfidence")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<string> ? ExcludeDomains { get; set; }
public PhishBlockThreshold ? BlockingConfidence { get; set; }

/// <summary>
/// Optional. Sites with confidence level chosen &amp; above this value will be blocked from the
/// search results.
/// Optional. List of domains to be excluded from the search results. The default limit is 2000
/// domains.
/// </summary>
[JsonPropertyName("blockingConfidence")]
[JsonPropertyName("excludeDomains")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public PhishBlockThreshold
? BlockingConfidence {
public List<string>
? ExcludeDomains {
get; set;
}

Expand Down
14 changes: 7 additions & 7 deletions Google.GenAI/types/FileData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,23 @@

namespace Google.GenAI.Types {
/// <summary>
/// URI based data.
/// URI-based data. A FileData message contains a URI pointing to data of a specific media type.
/// It is used to represent images, audio, and video stored in Google Cloud Storage.
/// </summary>

public record FileData {
/// <summary>
/// Optional. Display name of the file data. Used to provide a label or filename to distinguish
/// file datas. This field is only returned in PromptMessage for prompt management. It is
/// currently used in the Gemini GenerateContent calls only when server side tools
/// (code_execution, google_search, and url_context) are enabled. This field is not supported in
/// Gemini API.
/// Optional. The display name of the file. Used to provide a label or filename to distinguish
/// files. This field is only returned in `PromptMessage` for prompt management. It is used in
/// the Gemini calls only when server side tools (`code_execution`, `google_search`, and
/// `url_context`) are enabled. This field is not supported in Gemini API.
/// </summary>
[JsonPropertyName("displayName")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string ? DisplayName { get; set; }

/// <summary>
/// URI.
/// The URI of the file in Google Cloud Storage.
/// </summary>
[JsonPropertyName("fileUri")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
Expand Down
75 changes: 75 additions & 0 deletions Google.GenAI/types/FileSearch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// Auto-generated code. Do not edit.

using System;
using System.Text.Json;
using System.Text.Json.Serialization;
using Google.GenAI.Serialization;

namespace Google.GenAI.Types {
/// <summary>
/// The FileSearch tool that retrieves knowledge from Semantic Retrieval corpora. Files are
/// imported to Semantic Retrieval corpora using the ImportFile API. This data type is not
/// supported in Vertex AI.
/// </summary>

public record FileSearch {
/// <summary>
/// The names of the file_search_stores to retrieve from. Example:
/// `fileSearchStores/my-file-search-store-123`
/// </summary>
[JsonPropertyName("fileSearchStoreNames")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<string> ? FileSearchStoreNames { get; set; }

/// <summary>
/// Optional. Metadata filter to apply to the semantic retrieval documents and chunks.
/// </summary>
[JsonPropertyName("metadataFilter")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string
? MetadataFilter {
get; set;
}

/// <summary>
/// Optional. The number of semantic retrieval chunks to retrieve.
/// </summary>
[JsonPropertyName("topK")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int
? TopK {
get; set;
}

/// <summary>
/// Deserializes a JSON string to a FileSearch object.
/// </summary>
/// <param name="jsonString">The JSON string to deserialize.</param>
/// <param name="options">Optional JsonSerializerOptions.</param>
/// <returns>The deserialized FileSearch object, or null if deserialization fails.</returns>
public static FileSearch ? FromJson(string jsonString, JsonSerializerOptions? options = null) {
try {
return JsonSerializer.Deserialize<FileSearch>(jsonString, options);
} catch (JsonException e) {
Console.Error.WriteLine($"Error deserializing JSON: {e.ToString()}");
return null;
}
}
}
}
Loading
Loading