diff --git a/sdk/openai/Azure.AI.OpenAI/api/Azure.AI.OpenAI.netstandard2.0.cs b/sdk/openai/Azure.AI.OpenAI/api/Azure.AI.OpenAI.netstandard2.0.cs index 8a8ed03b3049..07334a5e8649 100644 --- a/sdk/openai/Azure.AI.OpenAI/api/Azure.AI.OpenAI.netstandard2.0.cs +++ b/sdk/openai/Azure.AI.OpenAI/api/Azure.AI.OpenAI.netstandard2.0.cs @@ -205,8 +205,6 @@ public static partial class AzureOpenAIModelFactory public static Azure.AI.OpenAI.EmbeddingItem EmbeddingItem(System.ReadOnlyMemory embedding = default(System.ReadOnlyMemory), int index = 0) { throw null; } public static Azure.AI.OpenAI.Embeddings Embeddings(System.Collections.Generic.IEnumerable data = null, Azure.AI.OpenAI.EmbeddingsUsage usage = null) { throw null; } public static Azure.AI.OpenAI.EmbeddingsUsage EmbeddingsUsage(int promptTokens = 0, int totalTokens = 0) { throw null; } - public static Azure.AI.OpenAI.ImageGenerations ImageGenerations(System.DateTimeOffset created = default(System.DateTimeOffset), System.Collections.Generic.IEnumerable data = null) { throw null; } - public static Azure.AI.OpenAI.ImageLocation ImageLocation(System.Uri url = null) { throw null; } public static Azure.AI.OpenAI.PromptFilterResult PromptFilterResult(int promptIndex = 0, Azure.AI.OpenAI.ContentFilterResults contentFilterResults = null) { throw null; } public static Azure.AI.OpenAI.StreamingChatCompletionsUpdate StreamingChatCompletionsUpdate(string id, System.DateTimeOffset created, int? choiceIndex = default(int?), Azure.AI.OpenAI.ChatRole? role = default(Azure.AI.OpenAI.ChatRole?), string authorName = null, string contentUpdate = null, Azure.AI.OpenAI.CompletionsFinishReason? finishReason = default(Azure.AI.OpenAI.CompletionsFinishReason?), string functionName = null, string functionArgumentsUpdate = null, Azure.AI.OpenAI.AzureChatExtensionsMessageContext azureExtensionsContext = null) { throw null; } } @@ -437,14 +435,14 @@ public ImageGenerationOptions(string prompt) { } } public partial class ImageGenerations { - internal ImageGenerations() { } - public System.DateTimeOffset Created { get { throw null; } } + public ImageGenerations(System.DateTimeOffset created, System.Collections.Generic.IEnumerable data) { } + public System.DateTimeOffset Created { get { throw null; } set { } } public System.Collections.Generic.IReadOnlyList Data { get { throw null; } } } public partial class ImageLocation { - internal ImageLocation() { } - public System.Uri Url { get { throw null; } } + public ImageLocation(System.Uri url) { } + public System.Uri Url { get { throw null; } set { } } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct ImageSize : System.IEquatable diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIModelFactory.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIModelFactory.cs index 8f3cbe8191c9..e1186f2a58fd 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIModelFactory.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIModelFactory.cs @@ -207,31 +207,6 @@ public static ChatCompletions ChatCompletions(string id = null, DateTimeOffset c return new ChatCompletions(id, created, choices?.ToList(), promptFilterResults?.ToList(), usage); } - /// Initializes a new instance of ImageGenerations. - /// A timestamp when this job or item was created (in unix epochs). - /// The images generated by the operator. - /// A new instance for mocking. - public static ImageGenerations ImageGenerations(DateTimeOffset created = default, IEnumerable data = null) - { - data ??= new List(); - - return new ImageGenerations(created, data?.ToList()); - } - - /// Initializes a new instance of ImageLocation. - /// The URL that provides temporary access to download the generated image. - /// is null. - /// A new instance for mocking. - public static ImageLocation ImageLocation(Uri url = null) - { - if (url == null) - { - throw new ArgumentNullException(nameof(url)); - } - - return new ImageLocation(url); - } - /// Initializes a new instance of Embeddings. /// Embedding values for the prompts submitted in the request. /// Usage counts for tokens input using the embeddings API. diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageGenerationOptions.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageGenerationOptions.Serialization.cs index c5f2cc65360d..d5f5122bf9d0 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageGenerationOptions.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageGenerationOptions.Serialization.cs @@ -6,6 +6,7 @@ #nullable disable using System.Text.Json; +using Azure; using Azure.Core; namespace Azure.AI.OpenAI @@ -40,6 +41,68 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteEndObject(); } + internal static ImageGenerationOptions DeserializeImageGenerationOptions(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string prompt = default; + Optional n = default; + Optional size = default; + Optional responseFormat = default; + Optional user = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("prompt"u8)) + { + prompt = property.Value.GetString(); + continue; + } + if (property.NameEquals("n"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + n = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("size"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + size = new ImageSize(property.Value.GetString()); + continue; + } + if (property.NameEquals("response_format"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + responseFormat = new ImageGenerationResponseFormat(property.Value.GetString()); + continue; + } + if (property.NameEquals("user"u8)) + { + user = property.Value.GetString(); + continue; + } + } + return new ImageGenerationOptions(prompt, Optional.ToNullable(n), Optional.ToNullable(size), Optional.ToNullable(responseFormat), user.Value); + } + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static ImageGenerationOptions FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeImageGenerationOptions(document.RootElement); + } + /// Convert into a Utf8JsonRequestContent. internal virtual RequestContent ToRequestContent() { diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageGenerations.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageGenerations.Serialization.cs index 551e28de47f3..4cbdfec6ec1d 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageGenerations.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageGenerations.Serialization.cs @@ -9,11 +9,22 @@ using System.Collections.Generic; using System.Text.Json; using Azure; +using Azure.Core; namespace Azure.AI.OpenAI { - public partial class ImageGenerations + public partial class ImageGenerations : IUtf8JsonSerializable { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("created"u8); + writer.WriteNumberValue(Created, "U"); + writer.WritePropertyName("data"u8); + SerializeDataProperty(writer); + writer.WriteEndObject(); + } + internal static ImageGenerations DeserializeImageGenerations(JsonElement element) { if (element.ValueKind == JsonValueKind.Null) @@ -45,5 +56,13 @@ internal static ImageGenerations FromResponse(Response response) using var document = JsonDocument.Parse(response.Content); return DeserializeImageGenerations(document.RootElement); } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } } } diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageGenerations.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageGenerations.cs index a54bb97dc258..5cbc0864c4cc 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageGenerations.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageGenerations.cs @@ -19,7 +19,7 @@ public partial class ImageGenerations /// A timestamp when this job or item was created (in unix epochs). /// The images generated by the operator. /// is null. - internal ImageGenerations(DateTimeOffset created, IEnumerable data) + public ImageGenerations(DateTimeOffset created, IEnumerable data) { Argument.AssertNotNull(data, nameof(data)); @@ -37,6 +37,6 @@ internal ImageGenerations(DateTimeOffset created, IReadOnlyList d } /// A timestamp when this job or item was created (in unix epochs). - public DateTimeOffset Created { get; } + public DateTimeOffset Created { get; set; } } } diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageLocation.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageLocation.Serialization.cs index f4fc3c356a17..f230873afa2b 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageLocation.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageLocation.Serialization.cs @@ -8,11 +8,20 @@ using System; using System.Text.Json; using Azure; +using Azure.Core; namespace Azure.AI.OpenAI { - public partial class ImageLocation + public partial class ImageLocation : IUtf8JsonSerializable { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("url"u8); + writer.WriteStringValue(Url.AbsoluteUri); + writer.WriteEndObject(); + } + internal static ImageLocation DeserializeImageLocation(JsonElement element) { if (element.ValueKind == JsonValueKind.Null) @@ -38,5 +47,13 @@ internal static ImageLocation FromResponse(Response response) using var document = JsonDocument.Parse(response.Content); return DeserializeImageLocation(document.RootElement); } + + /// Convert into a Utf8JsonRequestContent. + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this); + return content; + } } } diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageLocation.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageLocation.cs index 8783a2d3c5ef..e79c0f81569f 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageLocation.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageLocation.cs @@ -16,7 +16,7 @@ public partial class ImageLocation /// Initializes a new instance of ImageLocation. /// The URL that provides temporary access to download the generated image. /// is null. - internal ImageLocation(Uri url) + public ImageLocation(Uri url) { Argument.AssertNotNull(url, nameof(url)); @@ -24,6 +24,6 @@ internal ImageLocation(Uri url) } /// The URL that provides temporary access to download the generated image. - public Uri Url { get; } + public Uri Url { get; set; } } } diff --git a/sdk/openai/Azure.AI.OpenAI/tsp-location.yaml b/sdk/openai/Azure.AI.OpenAI/tsp-location.yaml index 4a55b57e2add..058d08ad3b78 100644 --- a/sdk/openai/Azure.AI.OpenAI/tsp-location.yaml +++ b/sdk/openai/Azure.AI.OpenAI/tsp-location.yaml @@ -1,3 +1,5 @@ -directory: specification/cognitiveservices/OpenAI.Inference -commit: 42e2c0bcd77b0de6c523404668fa63511484d485 repo: Azure/azure-rest-api-specs +commit: 11c355acb30df44e292c51b1e1fbb22965760858 +directory: specification/cognitiveservices/OpenAI.Inference +additionalDirectories: [] +