diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/AIOpenAIModelFactory.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AIOpenAIModelFactory.cs
index a423a6d69aee3..ccb567f9a271b 100644
--- a/sdk/openai/Azure.AI.OpenAI/src/Generated/AIOpenAIModelFactory.cs
+++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AIOpenAIModelFactory.cs
@@ -8,6 +8,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using Azure;
namespace Azure.AI.OpenAI
{
@@ -48,25 +49,66 @@ public static EmbeddingsUsage EmbeddingsUsage(int promptTokens = default, int to
return new EmbeddingsUsage(promptTokens, totalTokens);
}
+ /// Initializes a new instance of PromptFilterResult.
+ /// The index of this prompt in the set of prompt results.
+ /// Content filtering results for this prompt.
+ /// A new instance for mocking.
+ public static PromptFilterResult PromptFilterResult(int promptIndex = default, ContentFilterResults contentFilterResults = null)
+ {
+ return new PromptFilterResult(promptIndex, contentFilterResults);
+ }
+
+ /// Initializes a new instance of ContentFilterResults.
+ ///
+ /// Describes language related to anatomical organs and genitals, romantic relationships,
+ /// acts portrayed in erotic or affectionate terms, physical sexual acts, including
+ /// those portrayed as an assault or a forced sexual violent act against one’s will,
+ /// prostitution, pornography, and abuse.
+ ///
+ ///
+ /// Describes language related to physical actions intended to hurt, injure, damage, or
+ /// kill someone or something; describes weapons, etc.
+ ///
+ ///
+ /// Describes language attacks or uses that include pejorative or discriminatory language
+ /// with reference to a person or identity group on the basis of certain differentiating
+ /// attributes of these groups including but not limited to race, ethnicity, nationality,
+ /// gender identity and expression, sexual orientation, religion, immigration status, ability
+ /// status, personal appearance, and body size.
+ ///
+ ///
+ /// Describes language related to physical actions intended to purposely hurt, injure,
+ /// or damage one’s body, or kill oneself.
+ ///
+ /// A new instance for mocking.
+ public static ContentFilterResults ContentFilterResults(ContentFilterResult sexual = null, ContentFilterResult violence = null, ContentFilterResult hate = null, ContentFilterResult selfHarm = null)
+ {
+ return new ContentFilterResults(sexual, violence, hate, selfHarm);
+ }
+
+ /// Initializes a new instance of ContentFilterResult.
+ /// Ratings for the intensity and risk level of filtered content.
+ /// A value indicating whether or not the content has been filtered.
+ /// A new instance for mocking.
+ public static ContentFilterResult ContentFilterResult(ContentFilterSeverity severity = default, bool filtered = default)
+ {
+ return new ContentFilterResult(severity, filtered);
+ }
+
/// Initializes a new instance of Choice.
/// The generated text for a given completions prompt.
/// The ordered index associated with this completions choice.
+ ///
+ /// Information about the content filtering category (hate, sexual, violence, self_harm), if it
+ /// has been detected, as well as the severity level (very_low, low, medium, high-scale that
+ /// determines the intensity and risk level of harmful content) and if it has been filtered or not.
+ ///
/// The log probabilities model for tokens associated with this completions choice.
/// Reason for finishing.
- /// or is null.
/// A new instance for mocking.
- public static Choice Choice(string text = null, int index = default, CompletionsLogProbabilityModel logProbabilityModel = null, CompletionsFinishReason finishReason = default)
+ public static Choice Choice(string text = null, int index = default, ContentFilterResults contentFilterResults = null, CompletionsLogProbabilityModel logProbabilityModel = null, CompletionsFinishReason finishReason = default)
{
- if (text == null)
- {
- throw new ArgumentNullException(nameof(text));
- }
- if (logProbabilityModel == null)
- {
- throw new ArgumentNullException(nameof(logProbabilityModel));
- }
-
- return new Choice(text, index, logProbabilityModel, finishReason);
+ return new Choice(text, index, contentFilterResults, logProbabilityModel, finishReason);
}
/// Initializes a new instance of CompletionsLogProbabilityModel.
diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIOperationState.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIOperationState.cs
new file mode 100644
index 0000000000000..69d6772dfc5da
--- /dev/null
+++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIOperationState.cs
@@ -0,0 +1,60 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.ComponentModel;
+
+namespace Azure.AI.OpenAI
+{
+ /// The state of a job or item.
+ internal readonly partial struct AzureOpenAIOperationState : IEquatable
+ {
+ private readonly string _value;
+
+ /// Initializes a new instance of .
+ /// is null.
+ public AzureOpenAIOperationState(string value)
+ {
+ _value = value ?? throw new ArgumentNullException(nameof(value));
+ }
+
+ private const string NotRunningValue = "notRunning";
+ private const string RunningValue = "running";
+ private const string SucceededValue = "succeeded";
+ private const string CanceledValue = "canceled";
+ private const string FailedValue = "failed";
+
+ /// The operation was created and is queued to be processed in the future.
+ public static AzureOpenAIOperationState NotRunning { get; } = new AzureOpenAIOperationState(NotRunningValue);
+ /// The operation has started to be processed.
+ public static AzureOpenAIOperationState Running { get; } = new AzureOpenAIOperationState(RunningValue);
+ /// The operation has successfully be processed and is ready for consumption.
+ public static AzureOpenAIOperationState Succeeded { get; } = new AzureOpenAIOperationState(SucceededValue);
+ /// The operation has been canceled and is incomplete.
+ public static AzureOpenAIOperationState Canceled { get; } = new AzureOpenAIOperationState(CanceledValue);
+ /// The operation has completed processing with a failure and cannot be further consumed.
+ public static AzureOpenAIOperationState Failed { get; } = new AzureOpenAIOperationState(FailedValue);
+ /// Determines if two values are the same.
+ public static bool operator ==(AzureOpenAIOperationState left, AzureOpenAIOperationState right) => left.Equals(right);
+ /// Determines if two values are not the same.
+ public static bool operator !=(AzureOpenAIOperationState left, AzureOpenAIOperationState right) => !left.Equals(right);
+ /// Converts a string to a .
+ public static implicit operator AzureOpenAIOperationState(string value) => new AzureOpenAIOperationState(value);
+
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override bool Equals(object obj) => obj is AzureOpenAIOperationState other && Equals(other);
+ ///
+ public bool Equals(AzureOpenAIOperationState other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase);
+
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override int GetHashCode() => _value?.GetHashCode() ?? 0;
+ ///
+ public override string ToString() => _value;
+ }
+}
diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/BatchImageGenerationOperationResponse.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/BatchImageGenerationOperationResponse.Serialization.cs
new file mode 100644
index 0000000000000..b00357bf1902a
--- /dev/null
+++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/BatchImageGenerationOperationResponse.Serialization.cs
@@ -0,0 +1,84 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System.Text.Json;
+using Azure;
+using Azure.Core;
+
+namespace Azure.AI.OpenAI
+{
+ internal partial class BatchImageGenerationOperationResponse
+ {
+ internal static BatchImageGenerationOperationResponse DeserializeBatchImageGenerationOperationResponse(JsonElement element)
+ {
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ string id = default;
+ long created = default;
+ Optional expires = default;
+ Optional result = default;
+ AzureOpenAIOperationState status = default;
+ Optional error = default;
+ foreach (var property in element.EnumerateObject())
+ {
+ if (property.NameEquals("id"u8))
+ {
+ id = property.Value.GetString();
+ continue;
+ }
+ if (property.NameEquals("created"u8))
+ {
+ created = property.Value.GetInt64();
+ continue;
+ }
+ if (property.NameEquals("expires"u8))
+ {
+ if (property.Value.ValueKind == JsonValueKind.Null)
+ {
+ continue;
+ }
+ expires = property.Value.GetInt64();
+ continue;
+ }
+ if (property.NameEquals("result"u8))
+ {
+ if (property.Value.ValueKind == JsonValueKind.Null)
+ {
+ continue;
+ }
+ result = ImageGenerations.DeserializeImageGenerations(property.Value);
+ continue;
+ }
+ if (property.NameEquals("status"u8))
+ {
+ status = new AzureOpenAIOperationState(property.Value.GetString());
+ continue;
+ }
+ if (property.NameEquals("error"u8))
+ {
+ if (property.Value.ValueKind == JsonValueKind.Null)
+ {
+ continue;
+ }
+ error = JsonSerializer.Deserialize(property.Value.GetRawText());
+ continue;
+ }
+ }
+ return new BatchImageGenerationOperationResponse(id, created, Optional.ToNullable(expires), result.Value, status, error.Value);
+ }
+
+ /// Deserializes the model from a raw response.
+ /// The response to deserialize the model from.
+ internal static BatchImageGenerationOperationResponse FromResponse(Response response)
+ {
+ using var document = JsonDocument.Parse(response.Content);
+ return DeserializeBatchImageGenerationOperationResponse(document.RootElement);
+ }
+ }
+}
diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/BatchImageGenerationOperationResponse.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/BatchImageGenerationOperationResponse.cs
new file mode 100644
index 0000000000000..03ab2390ca12a
--- /dev/null
+++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/BatchImageGenerationOperationResponse.cs
@@ -0,0 +1,61 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using Azure;
+using Azure.Core;
+
+namespace Azure.AI.OpenAI
+{
+ /// A polling status update or final response payload for an image operation.
+ internal partial class BatchImageGenerationOperationResponse
+ {
+ /// Initializes a new instance of BatchImageGenerationOperationResponse.
+ /// The ID of the operation.
+ /// A timestamp when this job or item was created (in unix epochs).
+ /// The status of the operation.
+ /// is null.
+ internal BatchImageGenerationOperationResponse(string id, long created, AzureOpenAIOperationState status)
+ {
+ Argument.AssertNotNull(id, nameof(id));
+
+ Id = id;
+ Created = created;
+ Status = status;
+ }
+
+ /// Initializes a new instance of BatchImageGenerationOperationResponse.
+ /// The ID of the operation.
+ /// A timestamp when this job or item was created (in unix epochs).
+ /// A timestamp when this operation and its associated images expire and will be deleted (in unix epochs).
+ /// The result of the operation if the operation succeeded.
+ /// The status of the operation.
+ /// The error if the operation failed.
+ internal BatchImageGenerationOperationResponse(string id, long created, long? expires, ImageGenerations result, AzureOpenAIOperationState status, ResponseError error)
+ {
+ Id = id;
+ Created = created;
+ Expires = expires;
+ Result = result;
+ Status = status;
+ Error = error;
+ }
+
+ /// The ID of the operation.
+ public string Id { get; }
+ /// A timestamp when this job or item was created (in unix epochs).
+ public long Created { get; }
+ /// A timestamp when this operation and its associated images expire and will be deleted (in unix epochs).
+ public long? Expires { get; }
+ /// The result of the operation if the operation succeeded.
+ public ImageGenerations Result { get; }
+ /// The status of the operation.
+ public AzureOpenAIOperationState Status { get; }
+ /// The error if the operation failed.
+ public ResponseError Error { get; }
+ }
+}
diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatChoice.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatChoice.Serialization.cs
index 5c54cde879cb9..3bff6ea2e0a41 100644
--- a/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatChoice.Serialization.cs
+++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatChoice.Serialization.cs
@@ -23,6 +23,7 @@ internal static ChatChoice DeserializeChatChoice(JsonElement element)
int index = default;
CompletionsFinishReason finishReason = default;
Optional delta = default;
+ Optional contentFilterResults = default;
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("message"u8))
@@ -53,8 +54,17 @@ internal static ChatChoice DeserializeChatChoice(JsonElement element)
delta = ChatMessage.DeserializeChatMessage(property.Value);
continue;
}
+ if (property.NameEquals("content_filter_results"u8))
+ {
+ if (property.Value.ValueKind == JsonValueKind.Null)
+ {
+ continue;
+ }
+ contentFilterResults = ContentFilterResults.DeserializeContentFilterResults(property.Value);
+ continue;
+ }
}
- return new ChatChoice(message.Value, index, finishReason, delta.Value);
+ return new ChatChoice(message.Value, index, finishReason, delta.Value, contentFilterResults.Value);
}
/// Deserializes the model from a raw response.
diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatChoice.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatChoice.cs
index 70728769f6b53..ea0c7072f3499 100644
--- a/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatChoice.cs
+++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatChoice.cs
@@ -28,12 +28,18 @@ internal ChatChoice(int index, CompletionsFinishReason finishReason)
/// The ordered index associated with this chat completions choice.
/// The reason that this chat completions choice completed its generated.
/// The delta message content for a streaming response.
- internal ChatChoice(ChatMessage message, int index, CompletionsFinishReason finishReason, ChatMessage internalStreamingDeltaMessage)
+ ///
+ /// Information about the content filtering category (hate, sexual, violence, self_harm), if it
+ /// has been detected, as well as the severity level (very_low, low, medium, high-scale that
+ /// determines the intensity and risk level of harmful content) and if it has been filtered or not.
+ ///
+ internal ChatChoice(ChatMessage message, int index, CompletionsFinishReason finishReason, ChatMessage internalStreamingDeltaMessage, ContentFilterResults contentFilterResults)
{
Message = message;
Index = index;
FinishReason = finishReason;
InternalStreamingDeltaMessage = internalStreamingDeltaMessage;
+ ContentFilterResults = contentFilterResults;
}
/// The chat message for a given chat completions prompt.
@@ -42,5 +48,11 @@ internal ChatChoice(ChatMessage message, int index, CompletionsFinishReason fini
public int Index { get; }
/// The reason that this chat completions choice completed its generated.
public CompletionsFinishReason FinishReason { get; }
+ ///
+ /// Information about the content filtering category (hate, sexual, violence, self_harm), if it
+ /// has been detected, as well as the severity level (very_low, low, medium, high-scale that
+ /// determines the intensity and risk level of harmful content) and if it has been filtered or not.
+ ///
+ public ContentFilterResults ContentFilterResults { get; }
}
}
diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatCompletions.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatCompletions.Serialization.cs
index fa993a0a5a273..0cb4477618827 100644
--- a/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatCompletions.Serialization.cs
+++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatCompletions.Serialization.cs
@@ -23,6 +23,7 @@ internal static ChatCompletions DeserializeChatCompletions(JsonElement element)
string id = default;
int created = default;
IReadOnlyList choices = default;
+ Optional> promptAnnotations = default;
CompletionsUsage usage = default;
foreach (var property in element.EnumerateObject())
{
@@ -46,13 +47,27 @@ internal static ChatCompletions DeserializeChatCompletions(JsonElement element)
choices = array;
continue;
}
+ if (property.NameEquals("prompt_annotations"u8))
+ {
+ if (property.Value.ValueKind == JsonValueKind.Null)
+ {
+ continue;
+ }
+ List array = new List();
+ foreach (var item in property.Value.EnumerateArray())
+ {
+ array.Add(PromptFilterResult.DeserializePromptFilterResult(item));
+ }
+ promptAnnotations = array;
+ continue;
+ }
if (property.NameEquals("usage"u8))
{
usage = CompletionsUsage.DeserializeCompletionsUsage(property.Value);
continue;
}
}
- return new ChatCompletions(id, created, choices, usage);
+ return new ChatCompletions(id, created, choices, Optional.ToList(promptAnnotations), usage);
}
/// Deserializes the model from a raw response.
diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatCompletions.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatCompletions.cs
index 48ab1397bf7be..71e958d5032f9 100644
--- a/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatCompletions.cs
+++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatCompletions.cs
@@ -41,6 +41,7 @@ internal ChatCompletions(string id, int internalCreatedSecondsAfterUnixEpoch, IE
Id = id;
InternalCreatedSecondsAfterUnixEpoch = internalCreatedSecondsAfterUnixEpoch;
Choices = choices.ToList();
+ PromptFilterResults = new ChangeTrackingList();
Usage = usage;
}
@@ -55,12 +56,17 @@ internal ChatCompletions(string id, int internalCreatedSecondsAfterUnixEpoch, IE
/// Generally, `n` choices are generated per provided prompt with a default value of 1.
/// Token limits and other settings may limit the number of choices generated.
///
+ ///
+ /// Content filtering results for zero or more prompts in the request. In a streaming request,
+ /// results for different prompts may arrive at different times or in different orders.
+ ///
/// Usage information for tokens processed and generated as part of this completions operation.
- internal ChatCompletions(string id, int internalCreatedSecondsAfterUnixEpoch, IReadOnlyList choices, CompletionsUsage usage)
+ internal ChatCompletions(string id, int internalCreatedSecondsAfterUnixEpoch, IReadOnlyList choices, IReadOnlyList promptFilterResults, CompletionsUsage usage)
{
Id = id;
InternalCreatedSecondsAfterUnixEpoch = internalCreatedSecondsAfterUnixEpoch;
Choices = choices;
+ PromptFilterResults = promptFilterResults;
Usage = usage;
}
@@ -72,6 +78,11 @@ internal ChatCompletions(string id, int internalCreatedSecondsAfterUnixEpoch, IR
/// Token limits and other settings may limit the number of choices generated.
///
public IReadOnlyList Choices { get; }
+ ///
+ /// Content filtering results for zero or more prompts in the request. In a streaming request,
+ /// results for different prompts may arrive at different times or in different orders.
+ ///
+ public IReadOnlyList PromptFilterResults { get; }
/// Usage information for tokens processed and generated as part of this completions operation.
public CompletionsUsage Usage { get; }
}
diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatCompletionsOptions.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatCompletionsOptions.cs
index 5fe242ebebc96..91cfda8bd12f2 100644
--- a/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatCompletionsOptions.cs
+++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatCompletionsOptions.cs
@@ -26,6 +26,13 @@ public partial class ChatCompletionsOptions
/// the behavior of the assistant, followed by alternating messages between the User and
/// Assistant roles.
///
+ /// A list of functions the model may generate JSON inputs for.
+ ///
+ /// Controls how the model responds to function calls. "none" means the model does not call a function,
+ /// and responds to the end-user. "auto" means the model can pick between an end-user or calling a function.
+ /// Specifying a particular function via `{"name": "my_function"}` forces the model to call that function.
+ /// "none" is the default when no functions are present. "auto" is the default if functions are present.
+ ///
/// The maximum number of tokens to generate.
///
/// The sampling temperature to use that controls the apparent creativity of generated completions.
@@ -78,9 +85,11 @@ public partial class ChatCompletionsOptions
/// Not applicable to Azure OpenAI, where deployment information should be included in the Azure
/// resource URI that's connected to.
///
- internal ChatCompletionsOptions(IList messages, int? maxTokens, float? temperature, float? nucleusSamplingFactor, IDictionary internalStringKeyedTokenSelectionBiases, string user, int? choiceCount, IList stopSequences, float? presencePenalty, float? frequencyPenalty, bool? internalShouldStreamResponse, string internalNonAzureModelName)
+ internal ChatCompletionsOptions(IList messages, IList functions, FunctionCallPreset? functionCall, int? maxTokens, float? temperature, float? nucleusSamplingFactor, IDictionary internalStringKeyedTokenSelectionBiases, string user, int? choiceCount, IList stopSequences, float? presencePenalty, float? frequencyPenalty, bool? internalShouldStreamResponse, string internalNonAzureModelName)
{
Messages = messages;
+ Functions = functions;
+ FunctionCall = functionCall;
MaxTokens = maxTokens;
Temperature = temperature;
NucleusSamplingFactor = nucleusSamplingFactor;
@@ -101,5 +110,14 @@ internal ChatCompletionsOptions(IList messages, int? maxTokens, flo
/// Assistant roles.
///
public IList Messages { get; }
+ /// A list of functions the model may generate JSON inputs for.
+ public IList Functions { get; }
+ ///
+ /// Controls how the model responds to function calls. "none" means the model does not call a function,
+ /// and responds to the end-user. "auto" means the model can pick between an end-user or calling a function.
+ /// Specifying a particular function via `{"name": "my_function"}` forces the model to call that function.
+ /// "none" is the default when no functions are present. "auto" is the default if functions are present.
+ ///
+ public FunctionCallPreset? FunctionCall { get; set; }
}
}
diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatMessage.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatMessage.Serialization.cs
index 5d5a5b2aa3592..6248864eacbc6 100644
--- a/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatMessage.Serialization.cs
+++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatMessage.Serialization.cs
@@ -23,6 +23,16 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
writer.WritePropertyName("content"u8);
writer.WriteStringValue(Content);
}
+ if (Optional.IsDefined(Name))
+ {
+ writer.WritePropertyName("name"u8);
+ writer.WriteStringValue(Name);
+ }
+ if (Optional.IsDefined(FunctionCall))
+ {
+ writer.WritePropertyName("function_call"u8);
+ writer.WriteObjectValue(FunctionCall);
+ }
writer.WriteEndObject();
}
@@ -34,6 +44,8 @@ internal static ChatMessage DeserializeChatMessage(JsonElement element)
}
ChatRole role = default;
Optional content = default;
+ Optional name = default;
+ Optional functionCall = default;
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("role"u8))
@@ -46,8 +58,22 @@ internal static ChatMessage DeserializeChatMessage(JsonElement element)
content = property.Value.GetString();
continue;
}
+ if (property.NameEquals("name"u8))
+ {
+ name = property.Value.GetString();
+ continue;
+ }
+ if (property.NameEquals("function_call"u8))
+ {
+ if (property.Value.ValueKind == JsonValueKind.Null)
+ {
+ continue;
+ }
+ functionCall = FunctionCall.DeserializeFunctionCall(property.Value);
+ continue;
+ }
}
- return new ChatMessage(role, content.Value);
+ return new ChatMessage(role, content.Value, name.Value, functionCall.Value);
}
/// Deserializes the model from a raw response.
diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatMessage.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatMessage.cs
index e15a2eb083614..858e117931524 100644
--- a/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatMessage.cs
+++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatMessage.cs
@@ -17,9 +17,34 @@ public ChatMessage(ChatRole role)
Role = role;
}
+ /// Initializes a new instance of ChatMessage.
+ /// The role associated with this message payload.
+ /// The text associated with this message payload.
+ ///
+ /// The name of the author of this message. `name` is required if role is `function`, and it should be the name of the
+ /// function whose response is in the `content`. May contain a-z, A-Z, 0-9, and underscores, with a maximum length of
+ /// 64 characters.
+ ///
+ /// The name and arguments of a function that should be called, as generated by the model.
+ internal ChatMessage(ChatRole role, string content, string name, FunctionCall functionCall)
+ {
+ Role = role;
+ Content = content;
+ Name = name;
+ FunctionCall = functionCall;
+ }
+
/// The role associated with this message payload.
public ChatRole Role { get; set; }
/// The text associated with this message payload.
public string Content { get; set; }
+ ///
+ /// The name of the author of this message. `name` is required if role is `function`, and it should be the name of the
+ /// function whose response is in the `content`. May contain a-z, A-Z, 0-9, and underscores, with a maximum length of
+ /// 64 characters.
+ ///
+ public string Name { get; set; }
+ /// The name and arguments of a function that should be called, as generated by the model.
+ public FunctionCall FunctionCall { get; set; }
}
}
diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatRole.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatRole.cs
index 9c4c08bfe6d5a..479889b3f4ed1 100644
--- a/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatRole.cs
+++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatRole.cs
@@ -25,6 +25,7 @@ public ChatRole(string value)
private const string SystemValue = "system";
private const string AssistantValue = "assistant";
private const string UserValue = "user";
+ private const string FunctionValue = "function";
/// The role that instructs or sets the behavior of the assistant.
public static ChatRole System { get; } = new ChatRole(SystemValue);
@@ -32,6 +33,8 @@ public ChatRole(string value)
public static ChatRole Assistant { get; } = new ChatRole(AssistantValue);
/// The role that provides input for chat completions.
public static ChatRole User { get; } = new ChatRole(UserValue);
+ /// The role that provides function results for char completions.
+ public static ChatRole Function { get; } = new ChatRole(FunctionValue);
/// Determines if two values are the same.
public static bool operator ==(ChatRole left, ChatRole right) => left.Equals(right);
/// Determines if two values are not the same.
diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/Choice.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/Choice.Serialization.cs
index a87598d550006..bc6a804356e6e 100644
--- a/sdk/openai/Azure.AI.OpenAI/src/Generated/Choice.Serialization.cs
+++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/Choice.Serialization.cs
@@ -21,6 +21,7 @@ internal static Choice DeserializeChoice(JsonElement element)
}
string text = default;
int index = default;
+ Optional contentFilterResults = default;
CompletionsLogProbabilityModel logprobs = default;
CompletionsFinishReason finishReason = default;
foreach (var property in element.EnumerateObject())
@@ -35,6 +36,15 @@ internal static Choice DeserializeChoice(JsonElement element)
index = property.Value.GetInt32();
continue;
}
+ if (property.NameEquals("content_filter_results"u8))
+ {
+ if (property.Value.ValueKind == JsonValueKind.Null)
+ {
+ continue;
+ }
+ contentFilterResults = ContentFilterResults.DeserializeContentFilterResults(property.Value);
+ continue;
+ }
if (property.NameEquals("logprobs"u8))
{
logprobs = CompletionsLogProbabilityModel.DeserializeCompletionsLogProbabilityModel(property.Value);
@@ -46,7 +56,7 @@ internal static Choice DeserializeChoice(JsonElement element)
continue;
}
}
- return new Choice(text, index, logprobs, finishReason);
+ return new Choice(text, index, contentFilterResults.Value, logprobs, finishReason);
}
/// Deserializes the model from a raw response.
diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/Choice.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/Choice.cs
index f072a81241759..24423df14b84d 100644
--- a/sdk/openai/Azure.AI.OpenAI/src/Generated/Choice.cs
+++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/Choice.cs
@@ -17,10 +17,35 @@ namespace Azure.AI.OpenAI
///
public partial class Choice
{
+ /// Initializes a new instance of Choice.
+ /// The generated text for a given completions prompt.
+ /// The ordered index associated with this completions choice.
+ ///
+ /// Information about the content filtering category (hate, sexual, violence, self_harm), if it
+ /// has been detected, as well as the severity level (very_low, low, medium, high-scale that
+ /// determines the intensity and risk level of harmful content) and if it has been filtered or not.
+ ///
+ /// The log probabilities model for tokens associated with this completions choice.
+ /// Reason for finishing.
+ internal Choice(string text, int index, ContentFilterResults contentFilterResults, CompletionsLogProbabilityModel logProbabilityModel, CompletionsFinishReason finishReason)
+ {
+ Text = text;
+ Index = index;
+ ContentFilterResults = contentFilterResults;
+ LogProbabilityModel = logProbabilityModel;
+ FinishReason = finishReason;
+ }
+
/// The generated text for a given completions prompt.
public string Text { get; }
/// The ordered index associated with this completions choice.
public int Index { get; }
+ ///
+ /// Information about the content filtering category (hate, sexual, violence, self_harm), if it
+ /// has been detected, as well as the severity level (very_low, low, medium, high-scale that
+ /// determines the intensity and risk level of harmful content) and if it has been filtered or not.
+ ///
+ public ContentFilterResults ContentFilterResults { get; }
/// The log probabilities model for tokens associated with this completions choice.
public CompletionsLogProbabilityModel LogProbabilityModel { get; }
/// Reason for finishing.
diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/Completions.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/Completions.Serialization.cs
index c6f3ba4095d30..84dda6a515c1a 100644
--- a/sdk/openai/Azure.AI.OpenAI/src/Generated/Completions.Serialization.cs
+++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/Completions.Serialization.cs
@@ -22,6 +22,7 @@ internal static Completions DeserializeCompletions(JsonElement element)
}
string id = default;
int created = default;
+ Optional> promptAnnotations = default;
IReadOnlyList choices = default;
CompletionsUsage usage = default;
foreach (var property in element.EnumerateObject())
@@ -36,6 +37,20 @@ internal static Completions DeserializeCompletions(JsonElement element)
created = property.Value.GetInt32();
continue;
}
+ if (property.NameEquals("prompt_annotations"u8))
+ {
+ if (property.Value.ValueKind == JsonValueKind.Null)
+ {
+ continue;
+ }
+ List array = new List();
+ foreach (var item in property.Value.EnumerateArray())
+ {
+ array.Add(PromptFilterResult.DeserializePromptFilterResult(item));
+ }
+ promptAnnotations = array;
+ continue;
+ }
if (property.NameEquals("choices"u8))
{
List array = new List();
@@ -52,7 +67,7 @@ internal static Completions DeserializeCompletions(JsonElement element)
continue;
}
}
- return new Completions(id, created, choices, usage);
+ return new Completions(id, created, Optional.ToList(promptAnnotations), choices, usage);
}
/// Deserializes the model from a raw response.
diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/Completions.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/Completions.cs
index 648d446086d8c..e94661888cf0d 100644
--- a/sdk/openai/Azure.AI.OpenAI/src/Generated/Completions.cs
+++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/Completions.cs
@@ -40,6 +40,7 @@ internal Completions(string id, int internalCreatedSecondsAfterUnixEpoch, IEnume
Id = id;
InternalCreatedSecondsAfterUnixEpoch = internalCreatedSecondsAfterUnixEpoch;
+ PromptFilterResults = new ChangeTrackingList();
Choices = choices.ToList();
Usage = usage;
}
@@ -50,16 +51,21 @@ internal Completions(string id, int internalCreatedSecondsAfterUnixEpoch, IEnume
/// The first timestamp associated with generation activity for this completions response,
/// represented as seconds since the beginning of the Unix epoch of 00:00 on 1 Jan 1970.
///
+ ///
+ /// Content filtering results for zero or more prompts in the request. In a streaming request,
+ /// results for different prompts may arrive at different times or in different orders.
+ ///
///
/// The collection of completions choices associated with this completions response.
/// Generally, `n` choices are generated per provided prompt with a default value of 1.
/// Token limits and other settings may limit the number of choices generated.
///
/// Usage information for tokens processed and generated as part of this completions operation.
- internal Completions(string id, int internalCreatedSecondsAfterUnixEpoch, IReadOnlyList choices, CompletionsUsage usage)
+ internal Completions(string id, int internalCreatedSecondsAfterUnixEpoch, IReadOnlyList promptFilterResults, IReadOnlyList choices, CompletionsUsage usage)
{
Id = id;
InternalCreatedSecondsAfterUnixEpoch = internalCreatedSecondsAfterUnixEpoch;
+ PromptFilterResults = promptFilterResults;
Choices = choices;
Usage = usage;
}
@@ -67,6 +73,11 @@ internal Completions(string id, int internalCreatedSecondsAfterUnixEpoch, IReadO
/// A unique identifier associated with this completions response.
public string Id { get; }
///
+ /// Content filtering results for zero or more prompts in the request. In a streaming request,
+ /// results for different prompts may arrive at different times or in different orders.
+ ///
+ public IReadOnlyList PromptFilterResults { get; }
+ ///
/// The collection of completions choices associated with this completions response.
/// Generally, `n` choices are generated per provided prompt with a default value of 1.
/// Token limits and other settings may limit the number of choices generated.
diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/CompletionsFinishReason.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/CompletionsFinishReason.cs
index 1bd3d0f5f847c..dc427b9585277 100644
--- a/sdk/openai/Azure.AI.OpenAI/src/Generated/CompletionsFinishReason.cs
+++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/CompletionsFinishReason.cs
@@ -14,6 +14,7 @@ namespace Azure.AI.OpenAI
public readonly partial struct CompletionsFinishReason : IEquatable
{
private readonly string _value;
+ private const string FunctionCallValue = "function_call";
/// Completions ended normally and reached its end of token generation.
public static CompletionsFinishReason Stopped { get; } = new CompletionsFinishReason(StoppedValue);
@@ -24,6 +25,8 @@ namespace Azure.AI.OpenAI
/// moderation policies.
///
public static CompletionsFinishReason ContentFiltered { get; } = new CompletionsFinishReason(ContentFilteredValue);
+ /// Completion ended normally, with the model requesting a function to be called.
+ public static CompletionsFinishReason FunctionCall { get; } = new CompletionsFinishReason(FunctionCallValue);
/// Determines if two values are the same.
public static bool operator ==(CompletionsFinishReason left, CompletionsFinishReason right) => left.Equals(right);
/// Determines if two values are not the same.
diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterResult.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterResult.Serialization.cs
new file mode 100644
index 0000000000000..b01b7f952d7df
--- /dev/null
+++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterResult.Serialization.cs
@@ -0,0 +1,48 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System.Text.Json;
+using Azure;
+using Azure.Core;
+
+namespace Azure.AI.OpenAI
+{
+ public partial class ContentFilterResult
+ {
+ internal static ContentFilterResult DeserializeContentFilterResult(JsonElement element)
+ {
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ ContentFilterSeverity severity = default;
+ bool filtered = default;
+ foreach (var property in element.EnumerateObject())
+ {
+ if (property.NameEquals("severity"u8))
+ {
+ severity = new ContentFilterSeverity(property.Value.GetString());
+ continue;
+ }
+ if (property.NameEquals("filtered"u8))
+ {
+ filtered = property.Value.GetBoolean();
+ continue;
+ }
+ }
+ return new ContentFilterResult(severity, filtered);
+ }
+
+ /// Deserializes the model from a raw response.
+ /// The response to deserialize the model from.
+ internal static ContentFilterResult FromResponse(Response response)
+ {
+ using var document = JsonDocument.Parse(response.Content);
+ return DeserializeContentFilterResult(document.RootElement);
+ }
+ }
+}
diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterResult.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterResult.cs
new file mode 100644
index 0000000000000..6309cf40d23e4
--- /dev/null
+++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterResult.cs
@@ -0,0 +1,27 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+namespace Azure.AI.OpenAI
+{
+ /// Information about filtered content severity level and if it has been filtered or not.
+ public partial class ContentFilterResult
+ {
+ /// Initializes a new instance of ContentFilterResult.
+ /// Ratings for the intensity and risk level of filtered content.
+ /// A value indicating whether or not the content has been filtered.
+ internal ContentFilterResult(ContentFilterSeverity severity, bool filtered)
+ {
+ Severity = severity;
+ Filtered = filtered;
+ }
+
+ /// Ratings for the intensity and risk level of filtered content.
+ public ContentFilterSeverity Severity { get; }
+ /// A value indicating whether or not the content has been filtered.
+ public bool Filtered { get; }
+ }
+}
diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterResults.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterResults.Serialization.cs
new file mode 100644
index 0000000000000..4e5b1cc62ad85
--- /dev/null
+++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterResults.Serialization.cs
@@ -0,0 +1,76 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System.Text.Json;
+using Azure;
+using Azure.Core;
+
+namespace Azure.AI.OpenAI
+{
+ public partial class ContentFilterResults
+ {
+ internal static ContentFilterResults DeserializeContentFilterResults(JsonElement element)
+ {
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ Optional sexual = default;
+ Optional violence = default;
+ Optional hate = default;
+ Optional selfHarm = default;
+ foreach (var property in element.EnumerateObject())
+ {
+ if (property.NameEquals("sexual"u8))
+ {
+ if (property.Value.ValueKind == JsonValueKind.Null)
+ {
+ continue;
+ }
+ sexual = ContentFilterResult.DeserializeContentFilterResult(property.Value);
+ continue;
+ }
+ if (property.NameEquals("violence"u8))
+ {
+ if (property.Value.ValueKind == JsonValueKind.Null)
+ {
+ continue;
+ }
+ violence = ContentFilterResult.DeserializeContentFilterResult(property.Value);
+ continue;
+ }
+ if (property.NameEquals("hate"u8))
+ {
+ if (property.Value.ValueKind == JsonValueKind.Null)
+ {
+ continue;
+ }
+ hate = ContentFilterResult.DeserializeContentFilterResult(property.Value);
+ continue;
+ }
+ if (property.NameEquals("self_harm"u8))
+ {
+ if (property.Value.ValueKind == JsonValueKind.Null)
+ {
+ continue;
+ }
+ selfHarm = ContentFilterResult.DeserializeContentFilterResult(property.Value);
+ continue;
+ }
+ }
+ return new ContentFilterResults(sexual.Value, violence.Value, hate.Value, selfHarm.Value);
+ }
+
+ /// Deserializes the model from a raw response.
+ /// The response to deserialize the model from.
+ internal static ContentFilterResults FromResponse(Response response)
+ {
+ using var document = JsonDocument.Parse(response.Content);
+ return DeserializeContentFilterResults(document.RootElement);
+ }
+ }
+}
diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterResults.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterResults.cs
new file mode 100644
index 0000000000000..1132a5df81dff
--- /dev/null
+++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterResults.cs
@@ -0,0 +1,74 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+namespace Azure.AI.OpenAI
+{
+ /// Information about the content filtering category, if it has been detected.
+ public partial class ContentFilterResults
+ {
+ /// Initializes a new instance of ContentFilterResults.
+ internal ContentFilterResults()
+ {
+ }
+
+ /// Initializes a new instance of ContentFilterResults.
+ ///
+ /// Describes language related to anatomical organs and genitals, romantic relationships,
+ /// acts portrayed in erotic or affectionate terms, physical sexual acts, including
+ /// those portrayed as an assault or a forced sexual violent act against one’s will,
+ /// prostitution, pornography, and abuse.
+ ///
+ ///
+ /// Describes language related to physical actions intended to hurt, injure, damage, or
+ /// kill someone or something; describes weapons, etc.
+ ///
+ ///
+ /// Describes language attacks or uses that include pejorative or discriminatory language
+ /// with reference to a person or identity group on the basis of certain differentiating
+ /// attributes of these groups including but not limited to race, ethnicity, nationality,
+ /// gender identity and expression, sexual orientation, religion, immigration status, ability
+ /// status, personal appearance, and body size.
+ ///
+ ///
+ /// Describes language related to physical actions intended to purposely hurt, injure,
+ /// or damage one’s body, or kill oneself.
+ ///
+ internal ContentFilterResults(ContentFilterResult sexual, ContentFilterResult violence, ContentFilterResult hate, ContentFilterResult selfHarm)
+ {
+ Sexual = sexual;
+ Violence = violence;
+ Hate = hate;
+ SelfHarm = selfHarm;
+ }
+
+ ///
+ /// Describes language related to anatomical organs and genitals, romantic relationships,
+ /// acts portrayed in erotic or affectionate terms, physical sexual acts, including
+ /// those portrayed as an assault or a forced sexual violent act against one’s will,
+ /// prostitution, pornography, and abuse.
+ ///
+ public ContentFilterResult Sexual { get; }
+ ///
+ /// Describes language related to physical actions intended to hurt, injure, damage, or
+ /// kill someone or something; describes weapons, etc.
+ ///
+ public ContentFilterResult Violence { get; }
+ ///
+ /// Describes language attacks or uses that include pejorative or discriminatory language
+ /// with reference to a person or identity group on the basis of certain differentiating
+ /// attributes of these groups including but not limited to race, ethnicity, nationality,
+ /// gender identity and expression, sexual orientation, religion, immigration status, ability
+ /// status, personal appearance, and body size.
+ ///
+ public ContentFilterResult Hate { get; }
+ ///
+ /// Describes language related to physical actions intended to purposely hurt, injure,
+ /// or damage one’s body, or kill oneself.
+ ///
+ public ContentFilterResult SelfHarm { get; }
+ }
+}
diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterSeverity.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterSeverity.cs
new file mode 100644
index 0000000000000..50af18b35fc4c
--- /dev/null
+++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterSeverity.cs
@@ -0,0 +1,74 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.ComponentModel;
+
+namespace Azure.AI.OpenAI
+{
+ /// Ratings for the intensity and risk level of harmful content.
+ public readonly partial struct ContentFilterSeverity : IEquatable
+ {
+ private readonly string _value;
+
+ /// Initializes a new instance of .
+ /// is null.
+ public ContentFilterSeverity(string value)
+ {
+ _value = value ?? throw new ArgumentNullException(nameof(value));
+ }
+
+ private const string SafeValue = "safe";
+ private const string LowValue = "low";
+ private const string MediumValue = "medium";
+ private const string HighValue = "high";
+
+ ///
+ /// Content may be related to violence, self-harm, sexual, or hate categories but the terms
+ /// are used in general, journalistic, scientific, medical, and similar professional contexts,
+ /// which are appropriate for most audiences.
+ ///
+ public static ContentFilterSeverity Safe { get; } = new ContentFilterSeverity(SafeValue);
+ ///
+ /// Content that expresses prejudiced, judgmental, or opinionated views, includes offensive
+ /// use of language, stereotyping, use cases exploring a fictional world (for example, gaming,
+ /// literature) and depictions at low intensity.
+ ///
+ public static ContentFilterSeverity Low { get; } = new ContentFilterSeverity(LowValue);
+ ///
+ /// Content that uses offensive, insulting, mocking, intimidating, or demeaning language
+ /// towards specific identity groups, includes depictions of seeking and executing harmful
+ /// instructions, fantasies, glorification, promotion of harm at medium intensity.
+ ///
+ public static ContentFilterSeverity Medium { get; } = new ContentFilterSeverity(MediumValue);
+ ///
+ /// Content that displays explicit and severe harmful instructions, actions,
+ /// damage, or abuse; includes endorsement, glorification, or promotion of severe
+ /// harmful acts, extreme or illegal forms of harm, radicalization, or non-consensual
+ /// power exchange or abuse.
+ ///
+ public static ContentFilterSeverity High { get; } = new ContentFilterSeverity(HighValue);
+ /// Determines if two values are the same.
+ public static bool operator ==(ContentFilterSeverity left, ContentFilterSeverity right) => left.Equals(right);
+ /// Determines if two values are not the same.
+ public static bool operator !=(ContentFilterSeverity left, ContentFilterSeverity right) => !left.Equals(right);
+ /// Converts a string to a .
+ public static implicit operator ContentFilterSeverity(string value) => new ContentFilterSeverity(value);
+
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override bool Equals(object obj) => obj is ContentFilterSeverity other && Equals(other);
+ ///
+ public bool Equals(ContentFilterSeverity other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase);
+
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override int GetHashCode() => _value?.GetHashCode() ?? 0;
+ ///
+ public override string ToString() => _value;
+ }
+}
diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/Docs/OpenAIClient.xml b/sdk/openai/Azure.AI.OpenAI/src/Generated/Docs/OpenAIClient.xml
index a98717f007b73..4754f86cd2e68 100644
--- a/sdk/openai/Azure.AI.OpenAI/src/Generated/Docs/OpenAIClient.xml
+++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/Docs/OpenAIClient.xml
@@ -114,9 +114,20 @@ var chatCompletionsOptions = new ChatCompletionsOptions(new ChatMessage[]
new ChatMessage(ChatRole.System)
{
Content = "",
+ Name = "",
+ FunctionCall = new FunctionCall("", ""),
}
})
{
+ Functions =
+{
+ new FunctionDefinition("")
+{
+ Description = "",
+ Parameters = BinaryData.FromString(""),
+ }
+ },
+ FunctionCall = FunctionCallPreset.Auto,
MaxTokens = 1234,
Temperature = 3.14f,
NucleusSamplingFactor = 3.14f,
@@ -144,9 +155,20 @@ var chatCompletionsOptions = new ChatCompletionsOptions(new ChatMessage[]
new ChatMessage(ChatRole.System)
{
Content = "",
+ Name = "",
+ FunctionCall = new FunctionCall("", ""),
}
})
{
+ Functions =
+{
+ new FunctionDefinition("")
+{
+ Description = "",
+ Parameters = BinaryData.FromString(""),
+ }
+ },
+ FunctionCall = FunctionCallPreset.Auto,
MaxTokens = 1234,
Temperature = 3.14f,
NucleusSamplingFactor = 3.14f,
@@ -167,5 +189,13 @@ var result = client.GetChatCompletions("", chatCompletionsOptions)
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/FunctionCall.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/FunctionCall.Serialization.cs
new file mode 100644
index 0000000000000..66e19e41a66da
--- /dev/null
+++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/FunctionCall.Serialization.cs
@@ -0,0 +1,66 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System.Text.Json;
+using Azure;
+using Azure.Core;
+
+namespace Azure.AI.OpenAI
+{
+ public partial class FunctionCall : IUtf8JsonSerializable
+ {
+ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
+ {
+ writer.WriteStartObject();
+ writer.WritePropertyName("name"u8);
+ writer.WriteStringValue(Name);
+ writer.WritePropertyName("arguments"u8);
+ writer.WriteStringValue(Arguments);
+ writer.WriteEndObject();
+ }
+
+ internal static FunctionCall DeserializeFunctionCall(JsonElement element)
+ {
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ string name = default;
+ string arguments = default;
+ foreach (var property in element.EnumerateObject())
+ {
+ if (property.NameEquals("name"u8))
+ {
+ name = property.Value.GetString();
+ continue;
+ }
+ if (property.NameEquals("arguments"u8))
+ {
+ arguments = property.Value.GetString();
+ continue;
+ }
+ }
+ return new FunctionCall(name, arguments);
+ }
+
+ /// Deserializes the model from a raw response.
+ /// The response to deserialize the model from.
+ internal static FunctionCall FromResponse(Response response)
+ {
+ using var document = JsonDocument.Parse(response.Content);
+ return DeserializeFunctionCall(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/FunctionCall.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/FunctionCall.cs
new file mode 100644
index 0000000000000..1cdb28a6107cd
--- /dev/null
+++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/FunctionCall.cs
@@ -0,0 +1,44 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using Azure.Core;
+
+namespace Azure.AI.OpenAI
+{
+ /// The name and arguments of a function that should be called, as generated by the model.
+ public partial class FunctionCall
+ {
+ /// Initializes a new instance of FunctionCall.
+ /// The name of the function to call.
+ ///
+ /// The arguments to call the function with, as generated by the model in JSON format.
+ /// Note that the model does not always generate valid JSON, and may hallucinate parameters
+ /// not defined by your function schema. Validate the arguments in your code before calling
+ /// your function.
+ ///
+ /// or is null.
+ public FunctionCall(string name, string arguments)
+ {
+ Argument.AssertNotNull(name, nameof(name));
+ Argument.AssertNotNull(arguments, nameof(arguments));
+
+ Name = name;
+ Arguments = arguments;
+ }
+
+ /// The name of the function to call.
+ public string Name { get; set; }
+ ///
+ /// The arguments to call the function with, as generated by the model in JSON format.
+ /// Note that the model does not always generate valid JSON, and may hallucinate parameters
+ /// not defined by your function schema. Validate the arguments in your code before calling
+ /// your function.
+ ///
+ public string Arguments { get; set; }
+ }
+}
diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/FunctionCallPreset.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/FunctionCallPreset.cs
new file mode 100644
index 0000000000000..3391798a9e63e
--- /dev/null
+++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/FunctionCallPreset.cs
@@ -0,0 +1,60 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.ComponentModel;
+
+namespace Azure.AI.OpenAI
+{
+ ///
+ /// The collection of predefined behaviors for handling request-provided function information in a chat completions
+ /// operation.
+ ///
+ public readonly partial struct FunctionCallPreset : IEquatable
+ {
+ private readonly string _value;
+
+ /// Initializes a new instance of .
+ /// is null.
+ public FunctionCallPreset(string value)
+ {
+ _value = value ?? throw new ArgumentNullException(nameof(value));
+ }
+
+ private const string AutoValue = "auto";
+ private const string NoneValue = "none";
+
+ ///
+ /// Specifies that the model may either use any of the functions provided in this chat completions request or
+ /// instead return a standard chat completions response as if no functions were provided.
+ ///
+ public static FunctionCallPreset Auto { get; } = new FunctionCallPreset(AutoValue);
+ ///
+ /// Specifies that the model should not respond with a function call and should instead provide a standard chat
+ /// completions response. Response content may still be influenced by the provided function information.
+ ///
+ public static FunctionCallPreset None { get; } = new FunctionCallPreset(NoneValue);
+ /// Determines if two values are the same.
+ public static bool operator ==(FunctionCallPreset left, FunctionCallPreset right) => left.Equals(right);
+ /// Determines if two values are not the same.
+ public static bool operator !=(FunctionCallPreset left, FunctionCallPreset right) => !left.Equals(right);
+ /// Converts a string to a .
+ public static implicit operator FunctionCallPreset(string value) => new FunctionCallPreset(value);
+
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override bool Equals(object obj) => obj is FunctionCallPreset other && Equals(other);
+ ///
+ public bool Equals(FunctionCallPreset other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase);
+
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override int GetHashCode() => _value?.GetHashCode() ?? 0;
+ ///
+ public override string ToString() => _value;
+ }
+}
diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/FunctionDefinition.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/FunctionDefinition.Serialization.cs
new file mode 100644
index 0000000000000..aa5f68a4499a4
--- /dev/null
+++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/FunctionDefinition.Serialization.cs
@@ -0,0 +1,45 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System.Text.Json;
+using Azure.Core;
+
+namespace Azure.AI.OpenAI
+{
+ public partial class FunctionDefinition : IUtf8JsonSerializable
+ {
+ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
+ {
+ writer.WriteStartObject();
+ writer.WritePropertyName("name"u8);
+ writer.WriteStringValue(Name);
+ if (Optional.IsDefined(Description))
+ {
+ writer.WritePropertyName("description"u8);
+ writer.WriteStringValue(Description);
+ }
+ if (Optional.IsDefined(Parameters))
+ {
+ writer.WritePropertyName("parameters"u8);
+#if NET6_0_OR_GREATER
+ writer.WriteRawValue(Parameters);
+#else
+ JsonSerializer.Serialize(writer, JsonDocument.Parse(Parameters.ToString()).RootElement);
+#endif
+ }
+ writer.WriteEndObject();
+ }
+
+ /// 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/FunctionDefinition.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/FunctionDefinition.cs
new file mode 100644
index 0000000000000..b57e218cb01b2
--- /dev/null
+++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/FunctionDefinition.cs
@@ -0,0 +1,79 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using Azure.Core;
+
+namespace Azure.AI.OpenAI
+{
+ /// The definition of a caller-specified function that chat completions may invoke in response to matching user input.
+ public partial class FunctionDefinition
+ {
+ /// Initializes a new instance of FunctionDefinition.
+ /// The name of the function to be called.
+ /// is null.
+ public FunctionDefinition(string name)
+ {
+ Argument.AssertNotNull(name, nameof(name));
+
+ Name = name;
+ }
+
+ /// Initializes a new instance of FunctionDefinition.
+ /// The name of the function to be called.
+ ///
+ /// A description of what the function does. The model will use this description when selecting the function and
+ /// interpreting its parameters.
+ ///
+ /// The parameters the functions accepts, described as a JSON Schema object.
+ internal FunctionDefinition(string name, string description, BinaryData parameters)
+ {
+ Name = name;
+ Description = description;
+ Parameters = parameters;
+ }
+
+ /// The name of the function to be called.
+ public string Name { get; }
+ ///
+ /// A description of what the function does. The model will use this description when selecting the function and
+ /// interpreting its parameters.
+ ///
+ public string Description { get; set; }
+ ///
+ /// The parameters the functions accepts, described as a JSON Schema object.
+ ///
+ /// To assign an object to this property use .
+ ///
+ ///
+ /// To assign an already formated json string to this property use .
+ ///
+ ///
+ /// Examples:
+ ///
+ /// -
+ /// BinaryData.FromObjectAsJson("foo")
+ /// Creates a payload of "foo".
+ ///
+ /// -
+ /// BinaryData.FromString("\"foo\"")
+ /// Creates a payload of "foo".
+ ///
+ /// -
+ /// BinaryData.FromObjectAsJson(new { key = "value" })
+ /// Creates a payload of { "key": "value" }.
+ ///
+ /// -
+ /// BinaryData.FromString("{\"key\": \"value\"}")
+ /// Creates a payload of { "key": "value" }.
+ ///
+ ///
+ ///
+ ///
+ public BinaryData Parameters { get; set; }
+ }
+}
diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageGenerationOptions.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageGenerationOptions.Serialization.cs
new file mode 100644
index 0000000000000..2211d79917bf9
--- /dev/null
+++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageGenerationOptions.Serialization.cs
@@ -0,0 +1,51 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System.Text.Json;
+using Azure.Core;
+
+namespace Azure.AI.OpenAI
+{
+ internal partial class ImageGenerationOptions : IUtf8JsonSerializable
+ {
+ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
+ {
+ writer.WriteStartObject();
+ writer.WritePropertyName("prompt"u8);
+ writer.WriteStringValue(Prompt);
+ if (Optional.IsDefined(ImageCount))
+ {
+ writer.WritePropertyName("n"u8);
+ writer.WriteNumberValue(ImageCount.Value);
+ }
+ if (Optional.IsDefined(Size))
+ {
+ writer.WritePropertyName("size"u8);
+ writer.WriteStringValue(Size.Value.ToString());
+ }
+ if (Optional.IsDefined(ResponseFormat))
+ {
+ writer.WritePropertyName("response_format"u8);
+ writer.WriteStringValue(ResponseFormat.Value.ToString());
+ }
+ if (Optional.IsDefined(User))
+ {
+ writer.WritePropertyName("user"u8);
+ writer.WriteStringValue(User);
+ }
+ writer.WriteEndObject();
+ }
+
+ /// 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/ImageGenerationOptions.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageGenerationOptions.cs
new file mode 100644
index 0000000000000..61616d1e60fbc
--- /dev/null
+++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageGenerationOptions.cs
@@ -0,0 +1,58 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using Azure.Core;
+
+namespace Azure.AI.OpenAI
+{
+ /// Represents the request data used to generate images.
+ internal partial class ImageGenerationOptions
+ {
+ /// Initializes a new instance of ImageGenerationOptions.
+ /// A description of the desired images.
+ /// is null.
+ public ImageGenerationOptions(string prompt)
+ {
+ Argument.AssertNotNull(prompt, nameof(prompt));
+
+ Prompt = prompt;
+ }
+
+ /// Initializes a new instance of ImageGenerationOptions.
+ /// A description of the desired images.
+ /// The number of images to generate (defaults to 1).
+ /// The desired size of the generated images. Must be one of 256x256, 512x512, or 1024x1024 (defaults to 1024x1024).
+ ///
+ /// The format in which image generation response items should be presented.
+ /// Azure OpenAI only supports URL response items.
+ ///
+ /// A unique identifier representing your end-user, which can help to monitor and detect abuse.
+ internal ImageGenerationOptions(string prompt, int? imageCount, ImageSize? size, ImageGenerationResponseFormat? responseFormat, string user)
+ {
+ Prompt = prompt;
+ ImageCount = imageCount;
+ Size = size;
+ ResponseFormat = responseFormat;
+ User = user;
+ }
+
+ /// A description of the desired images.
+ public string Prompt { get; }
+ /// The number of images to generate (defaults to 1).
+ public int? ImageCount { get; set; }
+ /// The desired size of the generated images. Must be one of 256x256, 512x512, or 1024x1024 (defaults to 1024x1024).
+ public ImageSize? Size { get; set; }
+ ///
+ /// The format in which image generation response items should be presented.
+ /// Azure OpenAI only supports URL response items.
+ ///
+ public ImageGenerationResponseFormat? ResponseFormat { get; set; }
+ /// A unique identifier representing your end-user, which can help to monitor and detect abuse.
+ public string User { get; set; }
+ }
+}
diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageGenerationResponseFormat.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageGenerationResponseFormat.cs
new file mode 100644
index 0000000000000..ce53e220d177b
--- /dev/null
+++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageGenerationResponseFormat.cs
@@ -0,0 +1,51 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.ComponentModel;
+
+namespace Azure.AI.OpenAI
+{
+ /// The format in which the generated images are returned.
+ internal readonly partial struct ImageGenerationResponseFormat : IEquatable
+ {
+ private readonly string _value;
+
+ /// Initializes a new instance of .
+ /// is null.
+ public ImageGenerationResponseFormat(string value)
+ {
+ _value = value ?? throw new ArgumentNullException(nameof(value));
+ }
+
+ private const string UrlValue = "url";
+ private const string Base64Value = "b64_json";
+
+ /// Image generation response items should provide a URL from which the image may be retrieved.
+ public static ImageGenerationResponseFormat Url { get; } = new ImageGenerationResponseFormat(UrlValue);
+ /// Image generation response items should provide image data as a base64-encoded string.
+ public static ImageGenerationResponseFormat Base64 { get; } = new ImageGenerationResponseFormat(Base64Value);
+ /// Determines if two values are the same.
+ public static bool operator ==(ImageGenerationResponseFormat left, ImageGenerationResponseFormat right) => left.Equals(right);
+ /// Determines if two values are not the same.
+ public static bool operator !=(ImageGenerationResponseFormat left, ImageGenerationResponseFormat right) => !left.Equals(right);
+ /// Converts a string to a .
+ public static implicit operator ImageGenerationResponseFormat(string value) => new ImageGenerationResponseFormat(value);
+
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override bool Equals(object obj) => obj is ImageGenerationResponseFormat other && Equals(other);
+ ///
+ public bool Equals(ImageGenerationResponseFormat other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase);
+
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override int GetHashCode() => _value?.GetHashCode() ?? 0;
+ ///
+ public override string ToString() => _value;
+ }
+}
diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageGenerations.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageGenerations.Serialization.cs
new file mode 100644
index 0000000000000..f2656fbded4b3
--- /dev/null
+++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageGenerations.Serialization.cs
@@ -0,0 +1,49 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System.Collections.Generic;
+using System.Text.Json;
+using Azure;
+using Azure.Core;
+
+namespace Azure.AI.OpenAI
+{
+ internal partial class ImageGenerations
+ {
+ internal static ImageGenerations DeserializeImageGenerations(JsonElement element)
+ {
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ long created = default;
+ IReadOnlyList data = default;
+ foreach (var property in element.EnumerateObject())
+ {
+ if (property.NameEquals("created"u8))
+ {
+ created = property.Value.GetInt64();
+ continue;
+ }
+ if (property.NameEquals("data"u8))
+ {
+ data = property.Value.();
+ continue;
+ }
+ }
+ return new ImageGenerations(created, data);
+ }
+
+ /// Deserializes the model from a raw response.
+ /// The response to deserialize the model from.
+ internal static ImageGenerations FromResponse(Response response)
+ {
+ using var document = JsonDocument.Parse(response.Content);
+ return DeserializeImageGenerations(document.RootElement);
+ }
+ }
+}
diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageGenerations.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageGenerations.cs
new file mode 100644
index 0000000000000..6c9206b3df50f
--- /dev/null
+++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageGenerations.cs
@@ -0,0 +1,44 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Azure.Core;
+
+namespace Azure.AI.OpenAI
+{
+ /// The result of the operation if the operation succeeded.
+ internal partial class ImageGenerations
+ {
+ /// Initializes a new instance of ImageGenerations.
+ /// A timestamp when this job or item was created (in unix epochs).
+ /// The images generated by the operator.
+ /// is null.
+ internal ImageGenerations(long internalCreatedSecondsAfterUnixEpoch, IEnumerable internalEmittedImageResponseItems)
+ {
+ Argument.AssertNotNull(internalEmittedImageResponseItems, nameof(internalEmittedImageResponseItems));
+
+ InternalCreatedSecondsAfterUnixEpoch = internalCreatedSecondsAfterUnixEpoch;
+ InternalEmittedImageResponseItems = internalEmittedImageResponseItems.ToList();
+ }
+
+ /// Initializes a new instance of ImageGenerations.
+ /// A timestamp when this job or item was created (in unix epochs).
+ /// The images generated by the operator.
+ internal ImageGenerations(long internalCreatedSecondsAfterUnixEpoch, IReadOnlyList internalEmittedImageResponseItems)
+ {
+ InternalCreatedSecondsAfterUnixEpoch = internalCreatedSecondsAfterUnixEpoch;
+ InternalEmittedImageResponseItems = internalEmittedImageResponseItems;
+ }
+
+ /// A timestamp when this job or item was created (in unix epochs).
+ public long InternalCreatedSecondsAfterUnixEpoch { get; }
+ /// The images generated by the operator.
+ public IReadOnlyList InternalEmittedImageResponseItems { get; }
+ }
+}
diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageLocation.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageLocation.Serialization.cs
new file mode 100644
index 0000000000000..e53498326e0e2
--- /dev/null
+++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageLocation.Serialization.cs
@@ -0,0 +1,43 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.Text.Json;
+using Azure;
+using Azure.Core;
+
+namespace Azure.AI.OpenAI
+{
+ internal partial class ImageLocation
+ {
+ internal static ImageLocation DeserializeImageLocation(JsonElement element)
+ {
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ Uri url = default;
+ foreach (var property in element.EnumerateObject())
+ {
+ if (property.NameEquals("url"u8))
+ {
+ url = new Uri(property.Value.GetString());
+ continue;
+ }
+ }
+ return new ImageLocation(url);
+ }
+
+ /// Deserializes the model from a raw response.
+ /// The response to deserialize the model from.
+ internal static ImageLocation FromResponse(Response response)
+ {
+ using var document = JsonDocument.Parse(response.Content);
+ return DeserializeImageLocation(document.RootElement);
+ }
+ }
+}
diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageLocation.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageLocation.cs
new file mode 100644
index 0000000000000..37f4e9371827c
--- /dev/null
+++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageLocation.cs
@@ -0,0 +1,29 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using Azure.Core;
+
+namespace Azure.AI.OpenAI
+{
+ /// An image response item that provides a URL from which an image may be accessed.
+ internal 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)
+ {
+ Argument.AssertNotNull(url, nameof(url));
+
+ Url = url;
+ }
+
+ /// The URL that provides temporary access to download the generated image.
+ public Uri Url { get; }
+ }
+}
diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageSize.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageSize.cs
new file mode 100644
index 0000000000000..22bded6ea1ab1
--- /dev/null
+++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ImageSize.cs
@@ -0,0 +1,54 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System;
+using System.ComponentModel;
+
+namespace Azure.AI.OpenAI
+{
+ /// The desired size of the generated images. Must be one of 256x256, 512x512, or 1024x1024.
+ internal readonly partial struct ImageSize : IEquatable
+ {
+ private readonly string _value;
+
+ /// Initializes a new instance of .
+ /// is null.
+ public ImageSize(string value)
+ {
+ _value = value ?? throw new ArgumentNullException(nameof(value));
+ }
+
+ private const string Size256x256Value = "256x256";
+ private const string Size512x512Value = "512x512";
+ private const string Size1024x1024Value = "1024x1024";
+
+ /// Image size of 256x256.
+ public static ImageSize Size256x256 { get; } = new ImageSize(Size256x256Value);
+ /// Image size of 512x512.
+ public static ImageSize Size512x512 { get; } = new ImageSize(Size512x512Value);
+ /// Image size of 1024x1024.
+ public static ImageSize Size1024x1024 { get; } = new ImageSize(Size1024x1024Value);
+ /// Determines if two values are the same.
+ public static bool operator ==(ImageSize left, ImageSize right) => left.Equals(right);
+ /// Determines if two values are not the same.
+ public static bool operator !=(ImageSize left, ImageSize right) => !left.Equals(right);
+ /// Converts a string to a .
+ public static implicit operator ImageSize(string value) => new ImageSize(value);
+
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override bool Equals(object obj) => obj is ImageSize other && Equals(other);
+ ///
+ public bool Equals(ImageSize other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase);
+
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override int GetHashCode() => _value?.GetHashCode() ?? 0;
+ ///
+ public override string ToString() => _value;
+ }
+}
diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/OpenAIClient.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/OpenAIClient.cs
index 075a6ef2d8dae..ecc48833fdb0e 100644
--- a/sdk/openai/Azure.AI.OpenAI/src/Generated/OpenAIClient.cs
+++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/OpenAIClient.cs
@@ -37,6 +37,133 @@ protected OpenAIClient()
{
}
+ /// Starts the generation of a batch of images from a text caption.
+ /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples.
+ /// Represents the request data used to generate images.
+ /// The cancellation token to use.
+ /// is null.
+ ///
+ internal virtual async Task> BeginAzureBatchImageGenerationAsync(WaitUntil waitUntil, ImageGenerationOptions imageGenerationOptions, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNull(imageGenerationOptions, nameof(imageGenerationOptions));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Operation response = await BeginAzureBatchImageGenerationAsync(waitUntil, imageGenerationOptions.ToRequestContent(), context).ConfigureAwait(false);
+ return ProtocolOperationHelpers.Convert(response, BatchImageGenerationOperationResponse.FromResponse, ClientDiagnostics, "OpenAIClient.BeginAzureBatchImageGeneration");
+ }
+
+ /// Starts the generation of a batch of images from a text caption.
+ /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples.
+ /// Represents the request data used to generate images.
+ /// The cancellation token to use.
+ /// is null.
+ ///
+ internal virtual Operation BeginAzureBatchImageGeneration(WaitUntil waitUntil, ImageGenerationOptions imageGenerationOptions, CancellationToken cancellationToken = default)
+ {
+ Argument.AssertNotNull(imageGenerationOptions, nameof(imageGenerationOptions));
+
+ RequestContext context = FromCancellationToken(cancellationToken);
+ Operation response = BeginAzureBatchImageGeneration(waitUntil, imageGenerationOptions.ToRequestContent(), context);
+ return ProtocolOperationHelpers.Convert(response, BatchImageGenerationOperationResponse.FromResponse, ClientDiagnostics, "OpenAIClient.BeginAzureBatchImageGeneration");
+ }
+
+ ///
+ /// [Protocol Method] Starts the generation of a batch of images from a text caption
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples.
+ /// The content to send as the body of the request.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// Service returned a non-success status code.
+ /// The representing an asynchronous operation on the service.
+ ///
+ internal virtual async Task> BeginAzureBatchImageGenerationAsync(WaitUntil waitUntil, RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("OpenAIClient.BeginAzureBatchImageGeneration");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateBeginAzureBatchImageGenerationRequest(content, context);
+ return await ProtocolOperationHelpers.ProcessMessageAsync(_pipeline, message, ClientDiagnostics, "OpenAIClient.BeginAzureBatchImageGeneration", OperationFinalStateVia.Location, context, waitUntil).ConfigureAwait(false);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ ///
+ /// [Protocol Method] Starts the generation of a batch of images from a text caption
+ ///
+ /// -
+ ///
+ /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
+ ///
+ ///
+ /// -
+ ///
+ /// Please try the simpler convenience overload with strongly typed models first.
+ ///
+ ///
+ ///
+ ///
+ /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples.
+ /// The content to send as the body of the request.
+ /// The request context, which can override default behaviors of the client pipeline on a per-call basis.
+ /// is null.
+ /// Service returned a non-success status code.
+ /// The representing an asynchronous operation on the service.
+ ///
+ internal virtual Operation BeginAzureBatchImageGeneration(WaitUntil waitUntil, RequestContent content, RequestContext context = null)
+ {
+ Argument.AssertNotNull(content, nameof(content));
+
+ using var scope = ClientDiagnostics.CreateScope("OpenAIClient.BeginAzureBatchImageGeneration");
+ scope.Start();
+ try
+ {
+ using HttpMessage message = CreateBeginAzureBatchImageGenerationRequest(content, context);
+ return ProtocolOperationHelpers.ProcessMessage(_pipeline, message, ClientDiagnostics, "OpenAIClient.BeginAzureBatchImageGeneration", OperationFinalStateVia.Location, context, waitUntil);
+ }
+ catch (Exception e)
+ {
+ scope.Failed(e);
+ throw;
+ }
+ }
+
+ internal HttpMessage CreateBeginAzureBatchImageGenerationRequest(RequestContent content, RequestContext context)
+ {
+ var message = _pipeline.CreateMessage(context, ResponseClassifier202);
+ var request = message.Request;
+ request.Method = RequestMethod.Post;
+ var uri = new RawRequestUriBuilder();
+ uri.Reset(_endpoint);
+ uri.AppendRaw("/openai", false);
+ uri.AppendPath("/images/generations:submit", false);
+ uri.AppendQuery("api-version", _apiVersion, true);
+ request.Uri = uri;
+ request.Headers.Add("Accept", "application/json");
+ request.Headers.Add("Content-Type", "application/json");
+ request.Content = content;
+ return message;
+ }
+
private static RequestContext DefaultRequestContext = new RequestContext();
internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default)
{
@@ -50,5 +177,7 @@ internal static RequestContext FromCancellationToken(CancellationToken cancellat
private static ResponseClassifier _responseClassifier200;
private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 });
+ private static ResponseClassifier _responseClassifier202;
+ private static ResponseClassifier ResponseClassifier202 => _responseClassifier202 ??= new StatusCodeClassifier(stackalloc ushort[] { 202 });
}
}
diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/OpenAIClientOptions.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/OpenAIClientOptions.cs
index 738e64701d54e..95066fd3239c0 100644
--- a/sdk/openai/Azure.AI.OpenAI/src/Generated/OpenAIClientOptions.cs
+++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/OpenAIClientOptions.cs
@@ -13,15 +13,19 @@ namespace Azure.AI.OpenAI
/// Client options for OpenAIClient.
public partial class OpenAIClientOptions : ClientOptions
{
- private const ServiceVersion LatestVersion = ServiceVersion.V2023_03_15_Preview;
+ private const ServiceVersion LatestVersion = ServiceVersion.V2023_07_01_Preview;
/// The version of the service to use.
public enum ServiceVersion
{
/// Service version "2022-12-01".
V2022_12_01 = 1,
- /// Service version "2023-03-15-preview".
- V2023_03_15_Preview = 2,
+ /// Service version "2023-05-15".
+ V2023_05_15 = 2,
+ /// Service version "2023-06-01-preview".
+ V2023_06_01_Preview = 3,
+ /// Service version "2023-07-01-preview".
+ V2023_07_01_Preview = 4,
}
internal string Version { get; }
@@ -32,7 +36,9 @@ public OpenAIClientOptions(ServiceVersion version = LatestVersion)
Version = version switch
{
ServiceVersion.V2022_12_01 => "2022-12-01",
- ServiceVersion.V2023_03_15_Preview => "2023-03-15-preview",
+ ServiceVersion.V2023_05_15 => "2023-05-15",
+ ServiceVersion.V2023_06_01_Preview => "2023-06-01-preview",
+ ServiceVersion.V2023_07_01_Preview => "2023-07-01-preview",
_ => throw new NotSupportedException()
};
}
diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/PromptFilterResult.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/PromptFilterResult.Serialization.cs
new file mode 100644
index 0000000000000..d1a5970f07b91
--- /dev/null
+++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/PromptFilterResult.Serialization.cs
@@ -0,0 +1,52 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+using System.Text.Json;
+using Azure;
+using Azure.Core;
+
+namespace Azure.AI.OpenAI
+{
+ public partial class PromptFilterResult
+ {
+ internal static PromptFilterResult DeserializePromptFilterResult(JsonElement element)
+ {
+ if (element.ValueKind == JsonValueKind.Null)
+ {
+ return null;
+ }
+ int promptIndex = default;
+ Optional contentFilterResults = default;
+ foreach (var property in element.EnumerateObject())
+ {
+ if (property.NameEquals("prompt_index"u8))
+ {
+ promptIndex = property.Value.GetInt32();
+ continue;
+ }
+ if (property.NameEquals("content_filter_results"u8))
+ {
+ if (property.Value.ValueKind == JsonValueKind.Null)
+ {
+ continue;
+ }
+ contentFilterResults = ContentFilterResults.DeserializeContentFilterResults(property.Value);
+ continue;
+ }
+ }
+ return new PromptFilterResult(promptIndex, contentFilterResults.Value);
+ }
+
+ /// Deserializes the model from a raw response.
+ /// The response to deserialize the model from.
+ internal static PromptFilterResult FromResponse(Response response)
+ {
+ using var document = JsonDocument.Parse(response.Content);
+ return DeserializePromptFilterResult(document.RootElement);
+ }
+ }
+}
diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/PromptFilterResult.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/PromptFilterResult.cs
new file mode 100644
index 0000000000000..25a722ac88b65
--- /dev/null
+++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/PromptFilterResult.cs
@@ -0,0 +1,34 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+//
+
+#nullable disable
+
+namespace Azure.AI.OpenAI
+{
+ /// Content filtering results for a single prompt in the request.
+ public partial class PromptFilterResult
+ {
+ /// Initializes a new instance of PromptFilterResult.
+ /// The index of this prompt in the set of prompt results.
+ internal PromptFilterResult(int promptIndex)
+ {
+ PromptIndex = promptIndex;
+ }
+
+ /// Initializes a new instance of PromptFilterResult.
+ /// The index of this prompt in the set of prompt results.
+ /// Content filtering results for this prompt.
+ internal PromptFilterResult(int promptIndex, ContentFilterResults contentFilterResults)
+ {
+ PromptIndex = promptIndex;
+ ContentFilterResults = contentFilterResults;
+ }
+
+ /// The index of this prompt in the set of prompt results.
+ public int PromptIndex { get; }
+ /// Content filtering results for this prompt.
+ public ContentFilterResults ContentFilterResults { get; }
+ }
+}
diff --git a/sdk/openai/Azure.AI.OpenAI/tests/Generated/Samples/Samples_OpenAIClient.cs b/sdk/openai/Azure.AI.OpenAI/tests/Generated/Samples/Samples_OpenAIClient.cs
index 89bf7a0e369d5..ededd85b18574 100644
--- a/sdk/openai/Azure.AI.OpenAI/tests/Generated/Samples/Samples_OpenAIClient.cs
+++ b/sdk/openai/Azure.AI.OpenAI/tests/Generated/Samples/Samples_OpenAIClient.cs
@@ -75,9 +75,20 @@ public async Task Example_GetChatCompletions_Convenience_Async()
new ChatMessage(ChatRole.System)
{
Content = "",
+ Name = "",
+ FunctionCall = new FunctionCall("", ""),
}
})
{
+ Functions =
+{
+ new FunctionDefinition("")
+{
+ Description = "",
+ Parameters = BinaryData.FromString(""),
+ }
+ },
+ FunctionCall = FunctionCallPreset.Auto,
MaxTokens = 1234,
Temperature = 3.14f,
NucleusSamplingFactor = 3.14f,
diff --git a/sdk/openai/Azure.AI.OpenAI/tsp-location.yaml b/sdk/openai/Azure.AI.OpenAI/tsp-location.yaml
index 92ca017d7149f..cf79195f4005b 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: 6af0ff9b1a10e4d498699eab53cc1e6b797bda8c
repo: Azure/azure-rest-api-specs
+directory: specification/cognitiveservices/OpenAI.Inference
+additionalDirectories: []
+commit: d68166cff82b0e9ce3c4a7201e11dfeceab2e77b
+