diff --git a/src/GeminiDotnet.Extensions.AI/GeminiToMEAIMapper.cs b/src/GeminiDotnet.Extensions.AI/GeminiToMEAIMapper.cs index 66ffec2..72ea2b4 100644 --- a/src/GeminiDotnet.Extensions.AI/GeminiToMEAIMapper.cs +++ b/src/GeminiDotnet.Extensions.AI/GeminiToMEAIMapper.cs @@ -2,7 +2,6 @@ using GeminiDotnet.V1Beta.Models; using Microsoft.Extensions.AI; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Text.Json; #pragma warning disable MEAI001 // Experimental API (CodeInterpreter*, WebSearchTool*Content) diff --git a/src/GeminiDotnet/V1/API_REVISION b/src/GeminiDotnet/V1/API_REVISION index a79e9de..d74753e 100644 --- a/src/GeminiDotnet/V1/API_REVISION +++ b/src/GeminiDotnet/V1/API_REVISION @@ -1 +1 @@ -20260310 \ No newline at end of file +20260426 \ No newline at end of file diff --git a/src/GeminiDotnet/V1/GenerateContentRequest.cs b/src/GeminiDotnet/V1/GenerateContentRequest.cs index c97255e..79614e7 100644 --- a/src/GeminiDotnet/V1/GenerateContentRequest.cs +++ b/src/GeminiDotnet/V1/GenerateContentRequest.cs @@ -53,6 +53,13 @@ public sealed record GenerateContentRequest [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] public IReadOnlyList? SafetySettings { get; init; } + /// + /// Optional. The service tier of the request. + /// + [JsonPropertyName("serviceTier")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public ServiceTier? ServiceTier { get; init; } + /// /// Optional. Configures the logging behavior for a given request. If set, it takes /// precedence over the project-level logging config. diff --git a/src/GeminiDotnet/V1/Models/BatchEmbedContentsResponse.cs b/src/GeminiDotnet/V1/Models/BatchEmbedContentsResponse.cs index 48bf840..2a412ce 100644 --- a/src/GeminiDotnet/V1/Models/BatchEmbedContentsResponse.cs +++ b/src/GeminiDotnet/V1/Models/BatchEmbedContentsResponse.cs @@ -14,5 +14,12 @@ public sealed record BatchEmbedContentsResponse [JsonPropertyName("embeddings")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] public IReadOnlyList? Embeddings { get; init; } + + /// + /// Output only. The usage metadata for the request. + /// + [JsonPropertyName("usageMetadata")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public EmbeddingUsageMetadata? UsageMetadata { get; init; } } diff --git a/src/GeminiDotnet/V1/Models/Blob.cs b/src/GeminiDotnet/V1/Models/Blob.cs index 9982bd1..92d5bd5 100644 --- a/src/GeminiDotnet/V1/Models/Blob.cs +++ b/src/GeminiDotnet/V1/Models/Blob.cs @@ -17,12 +17,20 @@ public sealed record Blob /// /// The IANA standard MIME type of the source data. - /// Examples: - /// - image/png - /// - image/jpeg - /// If an unsupported MIME type is provided, an error will be returned. For a - /// complete list of supported types, see [Supported file - /// formats](https://ai.google.dev/gemini-api/docs/prompting_with_media#supported_file_formats). + /// Examples of supported types: + /// - Images: image/png, image/jpeg, image/jpg, image/webp, image/heic, + /// image/heif, image/gif, image/avif + /// - Audio: audio/*, video/audio/s16le, video/audio/wav + /// - Video: video/* + /// - Text: text/plain, text/html, text/css, text/javascript, + /// text/x-typescript, text/csv, text/markdown, text/x-python, text/xml, + /// text/rtf, video/text/timestamp + /// - Applications: application/x-javascript, application/x-typescript, + /// application/x-python-code, application/json, application/x-ipynb+json, + /// application/rtf, application/pdf For additional context, + /// see [Supported file + /// formats](https://ai.google.dev/gemini-api/docs/file-input-methods#supported-content-types). + /// // /// [JsonPropertyName("mimeType")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] diff --git a/src/GeminiDotnet/V1/Models/EmbedContentConfiguration.cs b/src/GeminiDotnet/V1/Models/EmbedContentConfiguration.cs new file mode 100644 index 0000000..93cf968 --- /dev/null +++ b/src/GeminiDotnet/V1/Models/EmbedContentConfiguration.cs @@ -0,0 +1,54 @@ +using System.Text.Json.Serialization; + +namespace GeminiDotnet.V1.Models; + +/// +/// Configurations for the EmbedContent request. +/// +public sealed record EmbedContentConfiguration +{ + /// + /// Optional. Whether to extract audio from video content. + /// + [JsonPropertyName("audioTrackExtraction")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public bool? AudioTrackExtraction { get; init; } + + /// + /// Optional. Whether to silently truncate the input content if it's longer + /// than the maximum sequence length. + /// + [JsonPropertyName("autoTruncate")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public bool? AutoTruncate { get; init; } + + /// + /// Optional. Whether to enable OCR for document content. + /// + [JsonPropertyName("documentOcr")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public bool? DocumentOcr { get; init; } + + /// + /// Optional. Reduced dimension for the output embedding. If set, excessive + /// values in the output embedding are truncated from the end. + /// + [JsonPropertyName("outputDimensionality")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public int? OutputDimensionality { get; init; } + + /// + /// Optional. The task type of the embedding. + /// + [JsonPropertyName("taskType")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public TaskType? TaskType { get; init; } + + /// + /// Optional. The title for the text. + /// + [JsonPropertyName("title")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public string? Title { get; init; } +} + diff --git a/src/GeminiDotnet/V1/Models/EmbedContentRequest.cs b/src/GeminiDotnet/V1/Models/EmbedContentRequest.cs index ec10946..49c104d 100644 --- a/src/GeminiDotnet/V1/Models/EmbedContentRequest.cs +++ b/src/GeminiDotnet/V1/Models/EmbedContentRequest.cs @@ -13,6 +13,13 @@ public sealed record EmbedContentRequest [JsonPropertyName("content")] public required Content Content { get; init; } + /// + /// Optional. Configuration for the EmbedContent request. + /// + [JsonPropertyName("embedContentConfig")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public EmbedContentConfiguration? EmbedContentConfiguration { get; init; } + /// /// Required. The model's resource name. This serves as an ID for the Model to use. /// This name should match a model name returned by the ListModels method. @@ -22,7 +29,8 @@ public sealed record EmbedContentRequest public required string Model { get; init; } /// - /// Optional. Optional reduced dimension for the output embedding. If set, excessive + /// Optional. Deprecated: Please use EmbedContentConfig.output_dimensionality instead. + /// Optional reduced dimension for the output embedding. If set, excessive /// values in the output embedding are truncated from the end. Supported by /// newer models since 2024 only. You cannot set this value if using the /// earlier model (models/embedding-001). @@ -32,7 +40,8 @@ public sealed record EmbedContentRequest public int? OutputDimensionality { get; init; } /// - /// Optional. Optional task type for which the embeddings will be used. Not supported on + /// Optional. Deprecated: Please use EmbedContentConfig.task_type instead. + /// Optional task type for which the embeddings will be used. Not supported on /// earlier models (models/embedding-001). /// [JsonPropertyName("taskType")] @@ -40,7 +49,8 @@ public sealed record EmbedContentRequest public TaskType? TaskType { get; init; } /// - /// Optional. An optional title for the text. Only applicable when TaskType is + /// Optional. Deprecated: Please use EmbedContentConfig.title instead. + /// An optional title for the text. Only applicable when TaskType is /// RETRIEVAL_DOCUMENT. /// Note: Specifying a for RETRIEVAL_DOCUMENT provides better quality /// embeddings for retrieval. diff --git a/src/GeminiDotnet/V1/Models/EmbedContentResponse.cs b/src/GeminiDotnet/V1/Models/EmbedContentResponse.cs index 04e3a82..1e66947 100644 --- a/src/GeminiDotnet/V1/Models/EmbedContentResponse.cs +++ b/src/GeminiDotnet/V1/Models/EmbedContentResponse.cs @@ -13,5 +13,12 @@ public sealed record EmbedContentResponse [JsonPropertyName("embedding")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] public ContentEmbedding? Embedding { get; init; } + + /// + /// Output only. The usage metadata for the request. + /// + [JsonPropertyName("usageMetadata")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public EmbeddingUsageMetadata? UsageMetadata { get; init; } } diff --git a/src/GeminiDotnet/V1/Models/EmbeddingUsageMetadata.cs b/src/GeminiDotnet/V1/Models/EmbeddingUsageMetadata.cs new file mode 100644 index 0000000..35067fc --- /dev/null +++ b/src/GeminiDotnet/V1/Models/EmbeddingUsageMetadata.cs @@ -0,0 +1,24 @@ +using System.Text.Json.Serialization; + +namespace GeminiDotnet.V1.Models; + +/// +/// Metadata on the usage of the embedding request. +/// +public sealed record EmbeddingUsageMetadata +{ + /// + /// Output only. Number of tokens in the prompt. + /// + [JsonPropertyName("promptTokenCount")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public int? PromptTokenCount { get; init; } + + /// + /// Output only. List of modalities that were processed in the request input. + /// + [JsonPropertyName("promptTokenDetails")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public IReadOnlyList? PromptTokenDetails { get; init; } +} + diff --git a/src/GeminiDotnet/V1/ServiceTier.cs b/src/GeminiDotnet/V1/ServiceTier.cs new file mode 100644 index 0000000..2e8a350 --- /dev/null +++ b/src/GeminiDotnet/V1/ServiceTier.cs @@ -0,0 +1,32 @@ +using System.Text.Json.Serialization; + +namespace GeminiDotnet.V1; + +[JsonConverter(typeof(JsonStringEnumConverter))] +public enum ServiceTier +{ + /// + /// Default service tier, which is standard. + /// + [JsonStringEnumMemberName("unspecified")] + Unspecified, + + /// + /// Standard service tier. + /// + [JsonStringEnumMemberName("standard")] + Standard, + + /// + /// Flex service tier. + /// + [JsonStringEnumMemberName("flex")] + Flex, + + /// + /// Priority service tier. + /// + [JsonStringEnumMemberName("priority")] + Priority, +} + diff --git a/src/GeminiDotnet/V1Beta/API_REVISION b/src/GeminiDotnet/V1Beta/API_REVISION index a79e9de..d74753e 100644 --- a/src/GeminiDotnet/V1Beta/API_REVISION +++ b/src/GeminiDotnet/V1Beta/API_REVISION @@ -1 +1 @@ -20260310 \ No newline at end of file +20260426 \ No newline at end of file diff --git a/src/GeminiDotnet/V1Beta/Blob.cs b/src/GeminiDotnet/V1Beta/Blob.cs index 9587143..d39f136 100644 --- a/src/GeminiDotnet/V1Beta/Blob.cs +++ b/src/GeminiDotnet/V1Beta/Blob.cs @@ -17,12 +17,20 @@ public sealed record Blob /// /// The IANA standard MIME type of the source data. - /// Examples: - /// - image/png - /// - image/jpeg - /// If an unsupported MIME type is provided, an error will be returned. For a - /// complete list of supported types, see [Supported file - /// formats](https://ai.google.dev/gemini-api/docs/prompting_with_media#supported_file_formats). + /// Examples of supported types: + /// - Images: image/png, image/jpeg, image/jpg, image/webp, image/heic, + /// image/heif, image/gif, image/avif + /// - Audio: audio/*, video/audio/s16le, video/audio/wav + /// - Video: video/* + /// - Text: text/plain, text/html, text/css, text/javascript, + /// text/x-typescript, text/csv, text/markdown, text/x-python, text/xml, + /// text/rtf, video/text/timestamp + /// - Applications: application/x-javascript, application/x-typescript, + /// application/x-python-code, application/json, application/x-ipynb+json, + /// application/rtf, application/pdf For additional context, + /// see [Supported file + /// formats](https://ai.google.dev/gemini-api/docs/file-input-methods#supported-content-types). + /// // /// [JsonPropertyName("mimeType")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] diff --git a/src/GeminiDotnet/V1Beta/CachedContents/McpServer.cs b/src/GeminiDotnet/V1Beta/CachedContents/McpServer.cs index e087e45..5e38b5f 100644 --- a/src/GeminiDotnet/V1Beta/CachedContents/McpServer.cs +++ b/src/GeminiDotnet/V1Beta/CachedContents/McpServer.cs @@ -5,7 +5,7 @@ namespace GeminiDotnet.V1Beta.CachedContents; /// /// A MCPServer is a server that can be called by the model to perform actions. /// It is a server that implements the MCP protocol. -/// Next ID: 5 +/// Next ID: 6 /// public sealed record McpServer { diff --git a/src/GeminiDotnet/V1Beta/CachedContents/SearchTypes.cs b/src/GeminiDotnet/V1Beta/CachedContents/SearchTypes.cs index 1628029..225f604 100644 --- a/src/GeminiDotnet/V1Beta/CachedContents/SearchTypes.cs +++ b/src/GeminiDotnet/V1Beta/CachedContents/SearchTypes.cs @@ -8,14 +8,14 @@ namespace GeminiDotnet.V1Beta.CachedContents; public sealed record SearchTypes { /// - /// Optional. Setting this field enables image search. Image bytes are returned. + /// Optional. Enables image search. Image bytes are returned. /// [JsonPropertyName("imageSearch")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] public ImageSearch? ImageSearch { get; init; } /// - /// Optional. Setting this field enables web search. Only text results are returned. + /// Optional. Enables web search. Only text results are returned. /// [JsonPropertyName("webSearch")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] diff --git a/src/GeminiDotnet/V1Beta/CachedContents/Tool.cs b/src/GeminiDotnet/V1Beta/CachedContents/Tool.cs index 235aadb..37ac234 100644 --- a/src/GeminiDotnet/V1Beta/CachedContents/Tool.cs +++ b/src/GeminiDotnet/V1Beta/CachedContents/Tool.cs @@ -7,7 +7,7 @@ namespace GeminiDotnet.V1Beta.CachedContents; /// A is a piece of code that enables the system to interact with /// external systems to perform an action, or set of actions, outside of /// knowledge and scope of the model. -/// Next ID: 15 +/// Next ID: 16 /// public sealed record Tool { diff --git a/src/GeminiDotnet/V1Beta/CachedContents/ToolConfiguration.cs b/src/GeminiDotnet/V1Beta/CachedContents/ToolConfiguration.cs index 69b788b..b43e9d6 100644 --- a/src/GeminiDotnet/V1Beta/CachedContents/ToolConfiguration.cs +++ b/src/GeminiDotnet/V1Beta/CachedContents/ToolConfiguration.cs @@ -15,6 +15,15 @@ public sealed record ToolConfiguration [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] public FunctionCallingConfiguration? FunctionCallingConfiguration { get; init; } + /// + /// Optional. If true, the API response will include the server-side tool calls and + /// responses within the message. This allows clients to + /// observe the server's tool interactions. + /// + [JsonPropertyName("includeServerSideToolInvocations")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public bool? IncludeServerSideToolInvocations { get; init; } + /// /// Optional. Retrieval config. /// diff --git a/src/GeminiDotnet/V1Beta/CodeExecutionResult.cs b/src/GeminiDotnet/V1Beta/CodeExecutionResult.cs index 39f1849..274f9fa 100644 --- a/src/GeminiDotnet/V1Beta/CodeExecutionResult.cs +++ b/src/GeminiDotnet/V1Beta/CodeExecutionResult.cs @@ -8,6 +8,14 @@ namespace GeminiDotnet.V1Beta; /// public sealed record CodeExecutionResult { + /// + /// Optional. The identifier of the part this result is for. + /// Only populated if the corresponding has an id. + /// + [JsonPropertyName("id")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public string? Id { get; init; } + /// /// Required. Outcome of the code execution. /// diff --git a/src/GeminiDotnet/V1Beta/ExecutableCode.cs b/src/GeminiDotnet/V1Beta/ExecutableCode.cs index 9459e83..25008e8 100644 --- a/src/GeminiDotnet/V1Beta/ExecutableCode.cs +++ b/src/GeminiDotnet/V1Beta/ExecutableCode.cs @@ -17,6 +17,14 @@ public sealed record ExecutableCode [JsonPropertyName("code")] public required string Code { get; init; } + /// + /// Optional. Unique identifier of the part. + /// The server returns the with the matching . + /// + [JsonPropertyName("id")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public string? Id { get; init; } + /// /// Required. Programming language of the . /// diff --git a/src/GeminiDotnet/V1Beta/FileSearchStores/ImportFileRequest.cs b/src/GeminiDotnet/V1Beta/FileSearchStores/ImportFileRequest.cs index 2798f29..f35f4ee 100644 --- a/src/GeminiDotnet/V1Beta/FileSearchStores/ImportFileRequest.cs +++ b/src/GeminiDotnet/V1Beta/FileSearchStores/ImportFileRequest.cs @@ -4,7 +4,6 @@ namespace GeminiDotnet.V1Beta.FileSearchStores; /// /// Request for ImportFile to import a File API file with a . -/// LINT.IfChange(ImportFileRequest) /// public sealed record ImportFileRequest { diff --git a/src/GeminiDotnet/V1Beta/GenerateContentRequest.cs b/src/GeminiDotnet/V1Beta/GenerateContentRequest.cs index c1231a5..3d39c56 100644 --- a/src/GeminiDotnet/V1Beta/GenerateContentRequest.cs +++ b/src/GeminiDotnet/V1Beta/GenerateContentRequest.cs @@ -63,6 +63,13 @@ public sealed record GenerateContentRequest [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] public IReadOnlyList? SafetySettings { get; init; } + /// + /// Optional. The service tier of the request. + /// + [JsonPropertyName("serviceTier")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public ServiceTier? ServiceTier { get; init; } + /// /// Optional. Configures the logging behavior for a given request. If set, it takes /// precedence over the project-level logging config. diff --git a/src/GeminiDotnet/V1Beta/ImageConfiguration.cs b/src/GeminiDotnet/V1Beta/ImageConfiguration.cs index 14cfac6..bbfc58a 100644 --- a/src/GeminiDotnet/V1Beta/ImageConfiguration.cs +++ b/src/GeminiDotnet/V1Beta/ImageConfiguration.cs @@ -19,7 +19,7 @@ public sealed record ImageConfiguration public string? AspectRatio { get; init; } /// - /// Optional. Specifies the size of generated images. Supported values are 512PX, 1K, + /// Optional. Specifies the size of generated images. Supported values are 512, 1K, /// 2K, 4K. If not specified, the model will use default value 1K. /// [JsonPropertyName("imageSize")] diff --git a/src/GeminiDotnet/V1Beta/Models/BatchEmbedContentsResponse.cs b/src/GeminiDotnet/V1Beta/Models/BatchEmbedContentsResponse.cs index 829aa74..084e835 100644 --- a/src/GeminiDotnet/V1Beta/Models/BatchEmbedContentsResponse.cs +++ b/src/GeminiDotnet/V1Beta/Models/BatchEmbedContentsResponse.cs @@ -14,5 +14,12 @@ public sealed record BatchEmbedContentsResponse [JsonPropertyName("embeddings")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] public IReadOnlyList? Embeddings { get; init; } + + /// + /// Output only. The usage metadata for the request. + /// + [JsonPropertyName("usageMetadata")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public EmbeddingUsageMetadata? UsageMetadata { get; init; } } diff --git a/src/GeminiDotnet/V1Beta/Models/EmbedContentConfiguration.cs b/src/GeminiDotnet/V1Beta/Models/EmbedContentConfiguration.cs new file mode 100644 index 0000000..c48df6e --- /dev/null +++ b/src/GeminiDotnet/V1Beta/Models/EmbedContentConfiguration.cs @@ -0,0 +1,54 @@ +using System.Text.Json.Serialization; + +namespace GeminiDotnet.V1Beta.Models; + +/// +/// Configurations for the EmbedContent request. +/// +public sealed record EmbedContentConfiguration +{ + /// + /// Optional. Whether to extract audio from video content. + /// + [JsonPropertyName("audioTrackExtraction")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public bool? AudioTrackExtraction { get; init; } + + /// + /// Optional. Whether to silently truncate the input content if it's longer + /// than the maximum sequence length. + /// + [JsonPropertyName("autoTruncate")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public bool? AutoTruncate { get; init; } + + /// + /// Optional. Whether to enable OCR for document content. + /// + [JsonPropertyName("documentOcr")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public bool? DocumentOcr { get; init; } + + /// + /// Optional. Reduced dimension for the output embedding. If set, excessive + /// values in the output embedding are truncated from the end. + /// + [JsonPropertyName("outputDimensionality")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public int? OutputDimensionality { get; init; } + + /// + /// Optional. The task type of the embedding. + /// + [JsonPropertyName("taskType")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public TaskType? TaskType { get; init; } + + /// + /// Optional. The title for the text. + /// + [JsonPropertyName("title")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public string? Title { get; init; } +} + diff --git a/src/GeminiDotnet/V1Beta/Models/EmbedContentRequest.cs b/src/GeminiDotnet/V1Beta/Models/EmbedContentRequest.cs index 76c88ef..484f53c 100644 --- a/src/GeminiDotnet/V1Beta/Models/EmbedContentRequest.cs +++ b/src/GeminiDotnet/V1Beta/Models/EmbedContentRequest.cs @@ -13,6 +13,13 @@ public sealed record EmbedContentRequest [JsonPropertyName("content")] public required Content Content { get; init; } + /// + /// Optional. Configuration for the EmbedContent request. + /// + [JsonPropertyName("embedContentConfig")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public EmbedContentConfiguration? EmbedContentConfiguration { get; init; } + /// /// Required. The model's resource name. This serves as an ID for the Model to use. /// This name should match a model name returned by the ListModels method. @@ -22,7 +29,8 @@ public sealed record EmbedContentRequest public required string Model { get; init; } /// - /// Optional. Optional reduced dimension for the output embedding. If set, excessive + /// Optional. Deprecated: Please use EmbedContentConfig.output_dimensionality instead. + /// Optional reduced dimension for the output embedding. If set, excessive /// values in the output embedding are truncated from the end. Supported by /// newer models since 2024 only. You cannot set this value if using the /// earlier model (models/embedding-001). @@ -32,7 +40,8 @@ public sealed record EmbedContentRequest public int? OutputDimensionality { get; init; } /// - /// Optional. Optional task type for which the embeddings will be used. Not supported on + /// Optional. Deprecated: Please use EmbedContentConfig.task_type instead. + /// Optional task type for which the embeddings will be used. Not supported on /// earlier models (models/embedding-001). /// [JsonPropertyName("taskType")] @@ -40,7 +49,8 @@ public sealed record EmbedContentRequest public TaskType? TaskType { get; init; } /// - /// Optional. An optional title for the text. Only applicable when TaskType is + /// Optional. Deprecated: Please use EmbedContentConfig.title instead. + /// An optional title for the text. Only applicable when TaskType is /// RETRIEVAL_DOCUMENT. /// Note: Specifying a for RETRIEVAL_DOCUMENT provides better quality /// embeddings for retrieval. diff --git a/src/GeminiDotnet/V1Beta/Models/EmbedContentResponse.cs b/src/GeminiDotnet/V1Beta/Models/EmbedContentResponse.cs index 44ed157..803e095 100644 --- a/src/GeminiDotnet/V1Beta/Models/EmbedContentResponse.cs +++ b/src/GeminiDotnet/V1Beta/Models/EmbedContentResponse.cs @@ -13,5 +13,12 @@ public sealed record EmbedContentResponse [JsonPropertyName("embedding")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] public ContentEmbedding? Embedding { get; init; } + + /// + /// Output only. The usage metadata for the request. + /// + [JsonPropertyName("usageMetadata")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public EmbeddingUsageMetadata? UsageMetadata { get; init; } } diff --git a/src/GeminiDotnet/V1Beta/Models/EmbeddingUsageMetadata.cs b/src/GeminiDotnet/V1Beta/Models/EmbeddingUsageMetadata.cs new file mode 100644 index 0000000..bc8630c --- /dev/null +++ b/src/GeminiDotnet/V1Beta/Models/EmbeddingUsageMetadata.cs @@ -0,0 +1,24 @@ +using System.Text.Json.Serialization; + +namespace GeminiDotnet.V1Beta.Models; + +/// +/// Metadata on the usage of the embedding request. +/// +public sealed record EmbeddingUsageMetadata +{ + /// + /// Output only. Number of tokens in the prompt. + /// + [JsonPropertyName("promptTokenCount")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public int? PromptTokenCount { get; init; } + + /// + /// Output only. List of modalities that were processed in the request input. + /// + [JsonPropertyName("promptTokenDetails")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public IReadOnlyList? PromptTokenDetails { get; init; } +} + diff --git a/src/GeminiDotnet/V1Beta/Models/RetrievedContext.cs b/src/GeminiDotnet/V1Beta/Models/RetrievedContext.cs index b5a31ed..1fca646 100644 --- a/src/GeminiDotnet/V1Beta/Models/RetrievedContext.cs +++ b/src/GeminiDotnet/V1Beta/Models/RetrievedContext.cs @@ -22,6 +22,21 @@ public sealed record RetrievedContext [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] public string? FileSearchStore { get; init; } + /// + /// Optional. The media blob resource name for multimodal file search results. + /// Format: fileSearchStores/{file_search_store_id}/media/{blob_id} + /// + [JsonPropertyName("mediaId")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public string? MediaId { get; init; } + + /// + /// Optional. Page number of the retrieved context, if applicable. + /// + [JsonPropertyName("pageNumber")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public int? PageNumber { get; init; } + /// /// Optional. Text of the chunk. /// diff --git a/src/GeminiDotnet/V1Beta/Part.cs b/src/GeminiDotnet/V1Beta/Part.cs index 42d6c76..3a5fefb 100644 --- a/src/GeminiDotnet/V1Beta/Part.cs +++ b/src/GeminiDotnet/V1Beta/Part.cs @@ -98,6 +98,24 @@ public sealed record Part [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] public string? ThoughtSignature { get; init; } + /// + /// Server-side tool call. This field is populated when the model + /// predicts a tool invocation that should be executed on the server. + /// The client is expected to echo this message back to the API. + /// + [JsonPropertyName("toolCall")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public ToolCall? ToolCall { get; init; } + + /// + /// The output from a server-side execution. This field is + /// populated by the client with the results of executing the + /// corresponding . + /// + [JsonPropertyName("toolResponse")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public ToolResponse? ToolResponse { get; init; } + /// /// Optional. Video metadata. The metadata should only be specified while the video /// data is presented in inline_data or file_data. diff --git a/src/GeminiDotnet/V1Beta/ServiceTier.cs b/src/GeminiDotnet/V1Beta/ServiceTier.cs new file mode 100644 index 0000000..fecdb5d --- /dev/null +++ b/src/GeminiDotnet/V1Beta/ServiceTier.cs @@ -0,0 +1,32 @@ +using System.Text.Json.Serialization; + +namespace GeminiDotnet.V1Beta; + +[JsonConverter(typeof(JsonStringEnumConverter))] +public enum ServiceTier +{ + /// + /// Default service tier, which is standard. + /// + [JsonStringEnumMemberName("unspecified")] + Unspecified, + + /// + /// Standard service tier. + /// + [JsonStringEnumMemberName("standard")] + Standard, + + /// + /// Flex service tier. + /// + [JsonStringEnumMemberName("flex")] + Flex, + + /// + /// Priority service tier. + /// + [JsonStringEnumMemberName("priority")] + Priority, +} + diff --git a/src/GeminiDotnet/V1Beta/ToolCall.cs b/src/GeminiDotnet/V1Beta/ToolCall.cs new file mode 100644 index 0000000..9798262 --- /dev/null +++ b/src/GeminiDotnet/V1Beta/ToolCall.cs @@ -0,0 +1,37 @@ +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace GeminiDotnet.V1Beta; + +/// +/// A predicted server-side returned from the model. This message +/// contains information about a tool that the model wants to invoke. +/// The client is NOT expected to execute this . Instead, the +/// client should pass this back to the API in a subsequent turn +/// within a message, along with the corresponding . +/// +public sealed record ToolCall +{ + /// + /// Optional. The tool call arguments. + /// Example: {"arg1" : "value1", "arg2" : "value2" , ...} + /// + [JsonPropertyName("args")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public JsonElement Arguments { get; init; } + + /// + /// Optional. Unique identifier of the tool call. + /// The server returns the tool response with the matching . + /// + [JsonPropertyName("id")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public string? Id { get; init; } + + /// + /// Required. The type of tool that was called. + /// + [JsonPropertyName("toolType")] + public required ToolType ToolType { get; init; } +} + diff --git a/src/GeminiDotnet/V1Beta/ToolResponse.cs b/src/GeminiDotnet/V1Beta/ToolResponse.cs new file mode 100644 index 0000000..1ae96e9 --- /dev/null +++ b/src/GeminiDotnet/V1Beta/ToolResponse.cs @@ -0,0 +1,35 @@ +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace GeminiDotnet.V1Beta; + +/// +/// The output from a server-side execution. This message contains +/// the results of a tool invocation that was initiated by a +/// from the model. The client should pass this back to the API +/// in a subsequent turn within a message, along with the corresponding +/// . +/// +public sealed record ToolResponse +{ + /// + /// Optional. The identifier of the tool call this response is for. + /// + [JsonPropertyName("id")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public string? Id { get; init; } + + /// + /// Optional. The tool response. + /// + [JsonPropertyName("response")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public JsonElement Response { get; init; } + + /// + /// Required. The type of tool that was called, matching the tool_type in the + /// corresponding . + /// + [JsonPropertyName("toolType")] + public required ToolType ToolType { get; init; } +} diff --git a/src/GeminiDotnet/V1Beta/ToolType.cs b/src/GeminiDotnet/V1Beta/ToolType.cs new file mode 100644 index 0000000..4f04185 --- /dev/null +++ b/src/GeminiDotnet/V1Beta/ToolType.cs @@ -0,0 +1,45 @@ +using System.Text.Json.Serialization; + +namespace GeminiDotnet.V1Beta; + +/// +/// The type of tool in the function call. +/// +public enum ToolType +{ + /// + /// Unspecified tool type. + /// + [JsonPropertyName("TOOL_TYPE_UNSPECIFIED")] + Unspecified = 0, + + /// + /// Google search tool, maps to Tool.google_search.search_types.web_search. + /// + [JsonPropertyName("GOOGLE_SEARCH_WEB")] + GoogleSearchWeb = 1, + + /// + /// Image search tool, maps to Tool.google_search.search_types.image_search. + /// + [JsonPropertyName("GOOGLE_SEARCH_IMAGE")] + GoogleSearchImage = 2, + + /// + /// URL context tool, maps to Tool.url_context. + /// + [JsonPropertyName("URL_CONTEXT")] + UrlContext = 3, + + /// + /// Google maps tool, maps to Tool.google_maps. + /// + [JsonStringEnumMemberName("GOOGLE_MAPS")] + GoogleMaps = 4, + + /// + /// File search tool, maps to Tool.file_search. + /// + [JsonStringEnumMemberName("FILE_SEARCH")] + FileSearch = 5, +} diff --git a/tests/GeminiDotnet.Extensions.AI.Examples/FileUploadExample.cs b/tests/GeminiDotnet.Extensions.AI.Examples/FileUploadExample.cs index c1be88f..5027367 100644 --- a/tests/GeminiDotnet.Extensions.AI.Examples/FileUploadExample.cs +++ b/tests/GeminiDotnet.Extensions.AI.Examples/FileUploadExample.cs @@ -1,5 +1,4 @@ using Microsoft.Extensions.AI; -using System.Diagnostics.CodeAnalysis; #pragma warning disable MEAI001 // Type is for evaluation purposes only diff --git a/tests/GeminiDotnet.Extensions.AI.Tests/GeminiHostedFileClientTests.cs b/tests/GeminiDotnet.Extensions.AI.Tests/GeminiHostedFileClientTests.cs index a5eb1d1..a88fe91 100644 --- a/tests/GeminiDotnet.Extensions.AI.Tests/GeminiHostedFileClientTests.cs +++ b/tests/GeminiDotnet.Extensions.AI.Tests/GeminiHostedFileClientTests.cs @@ -1,7 +1,6 @@ using GeminiDotnet.V1Beta; using GeminiDotnet.V1Beta.Files; using Microsoft.Extensions.AI; -using System.Diagnostics.CodeAnalysis; using System.Net; using File = GeminiDotnet.V1Beta.Files.File;