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 3a5d6e5c456c..3e5b95502002 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 @@ -90,7 +90,7 @@ public static partial class AzureOpenAIModelFactory public static Azure.AI.OpenAI.CompletionsLogProbabilityModel CompletionsLogProbabilityModel(System.Collections.Generic.IEnumerable tokens = null, System.Collections.Generic.IEnumerable tokenLogProbabilities = null, System.Collections.Generic.IEnumerable> topLogProbabilities = null, System.Collections.Generic.IEnumerable textOffsets = null) { throw null; } public static Azure.AI.OpenAI.CompletionsUsage CompletionsUsage(int completionTokens = 0, int promptTokens = 0, int totalTokens = 0) { throw null; } public static Azure.AI.OpenAI.ContentFilterResult ContentFilterResult(Azure.AI.OpenAI.ContentFilterSeverity severity = default(Azure.AI.OpenAI.ContentFilterSeverity), bool filtered = false) { throw null; } - public static Azure.AI.OpenAI.ContentFilterResults ContentFilterResults(Azure.AI.OpenAI.ContentFilterResult sexual = null, Azure.AI.OpenAI.ContentFilterResult violence = null, Azure.AI.OpenAI.ContentFilterResult hate = null, Azure.AI.OpenAI.ContentFilterResult selfHarm = null) { throw null; } + public static Azure.AI.OpenAI.ContentFilterResults ContentFilterResults(Azure.AI.OpenAI.ContentFilterResult sexual = null, Azure.AI.OpenAI.ContentFilterResult violence = null, Azure.AI.OpenAI.ContentFilterResult hate = null, Azure.AI.OpenAI.ContentFilterResult selfHarm = null, Azure.ResponseError error = null) { throw null; } public static Azure.AI.OpenAI.EmbeddingItem EmbeddingItem(System.Collections.Generic.IEnumerable embedding = null, 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; } @@ -248,6 +248,7 @@ internal ContentFilterResult() { } public partial class ContentFilterResults { internal ContentFilterResults() { } + public Azure.ResponseError Error { get { throw null; } } public Azure.AI.OpenAI.ContentFilterResult Hate { get { throw null; } } public Azure.AI.OpenAI.ContentFilterResult SelfHarm { get { throw null; } } public Azure.AI.OpenAI.ContentFilterResult Sexual { get { throw null; } } @@ -381,7 +382,7 @@ public OpenAIClient(System.Uri endpoint, Azure.Core.TokenCredential tokenCredent } public partial class OpenAIClientOptions : Azure.Core.ClientOptions { - public OpenAIClientOptions(Azure.AI.OpenAI.OpenAIClientOptions.ServiceVersion version = Azure.AI.OpenAI.OpenAIClientOptions.ServiceVersion.V2023_08_01_Preview) { } + public OpenAIClientOptions(Azure.AI.OpenAI.OpenAIClientOptions.ServiceVersion version = Azure.AI.OpenAI.OpenAIClientOptions.ServiceVersion.V2023_09_01_Preview) { } public enum ServiceVersion { V2022_12_01 = 1, @@ -389,6 +390,7 @@ public enum ServiceVersion V2023_06_01_Preview = 3, V2023_07_01_Preview = 4, V2023_08_01_Preview = 5, + V2023_09_01_Preview = 6, } } public partial class PromptFilterResult diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionFormat.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionFormat.cs new file mode 100644 index 000000000000..7806fa3b1171 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionFormat.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 +{ + /// Defines the format of the output. + internal readonly partial struct AudioTranscriptionFormat : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AudioTranscriptionFormat(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string SimpleJsonValue = "json"; + private const string VerboseJsonValue = "verbose_json"; + private const string TextValue = "text"; + private const string SrtValue = "srt"; + private const string VttValue = "vtt"; + + /// This format will return an JSON structure containing a single "text" with the transcription. + public static AudioTranscriptionFormat SimpleJson { get; } = new AudioTranscriptionFormat(SimpleJsonValue); + /// This format will return an JSON structure containing an enriched structure with the transcription. + public static AudioTranscriptionFormat VerboseJson { get; } = new AudioTranscriptionFormat(VerboseJsonValue); + /// This will make the response return the transcription as plain/text. + public static AudioTranscriptionFormat Text { get; } = new AudioTranscriptionFormat(TextValue); + /// The transcription will be provided in SRT format (SubRip Text) in the form of plain/text. + public static AudioTranscriptionFormat Srt { get; } = new AudioTranscriptionFormat(SrtValue); + /// The transcription will be provided in VTT format (Web Video Text Tracks) in the form of plain/text. + public static AudioTranscriptionFormat Vtt { get; } = new AudioTranscriptionFormat(VttValue); + /// Determines if two values are the same. + public static bool operator ==(AudioTranscriptionFormat left, AudioTranscriptionFormat right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AudioTranscriptionFormat left, AudioTranscriptionFormat right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator AudioTranscriptionFormat(string value) => new AudioTranscriptionFormat(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AudioTranscriptionFormat other && Equals(other); + /// + public bool Equals(AudioTranscriptionFormat 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/AudioTranscriptionOptionsPlainText.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionOptionsPlainText.Serialization.cs new file mode 100644 index 000000000000..b47bf1fcce31 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionOptionsPlainText.Serialization.cs @@ -0,0 +1,56 @@ +// 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 AudioTranscriptionOptionsPlainText : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("file"u8); + writer.WriteBase64StringValue(File.ToArray(), "D"); + if (Optional.IsDefined(Prompt)) + { + writer.WritePropertyName("prompt"u8); + writer.WriteStringValue(Prompt); + } + if (Optional.IsDefined(Temperature)) + { + writer.WritePropertyName("temperature"u8); + writer.WriteNumberValue(Temperature.Value); + } + if (Optional.IsDefined(InternalNonAzureModelName)) + { + writer.WritePropertyName("model"u8); + writer.WriteStringValue(InternalNonAzureModelName); + } + if (Optional.IsDefined(Language)) + { + writer.WritePropertyName("language"u8); + writer.WriteStringValue(Language); + } + if (Optional.IsDefined(ResponseFormat)) + { + writer.WritePropertyName("response_format"u8); + writer.WriteStringValue(ResponseFormat.Value.ToString()); + } + 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/AudioTranscriptionOptionsPlainText.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionOptionsPlainText.cs new file mode 100644 index 000000000000..478e1e3f149c --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionOptionsPlainText.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; + +namespace Azure.AI.OpenAI +{ + /// This will make the response return the transcription as plain/text. + internal partial class AudioTranscriptionOptionsPlainText + { + /// Initializes a new instance of AudioTranscriptionOptionsPlainText. + /// The audio file object to transcribe. + /// is null. + public AudioTranscriptionOptionsPlainText(BinaryData file) + { + Argument.AssertNotNull(file, nameof(file)); + + File = file; + } + + /// Initializes a new instance of AudioTranscriptionOptionsPlainText. + /// The audio file object to transcribe. + /// An optional text to guide the model's style or continue a previous audio segment. The prompt should match the audio language. + /// + /// The sampling temperature, between 0 and 1. + /// Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + /// If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit. + /// + /// + /// The model name to provide as part of this transcription request. + /// Not applicable to Azure OpenAI, where deployment information should be included in the Azure + /// resource URI that's connected to. + /// + /// The language of the input audio. Supplying the input language in ISO-639-1 format will improve accuracy and latency. + /// The format of the transcription output, in one of these options: json, text, srt, verbose_json, or vtt. + internal AudioTranscriptionOptionsPlainText(BinaryData file, string prompt, float? temperature, string internalNonAzureModelName, string language, AudioTranscriptionFormat? responseFormat) + { + File = file; + Prompt = prompt; + Temperature = temperature; + InternalNonAzureModelName = internalNonAzureModelName; + Language = language; + ResponseFormat = responseFormat; + } + + /// + /// The audio file object to transcribe. + /// + /// To assign a byte[] to this property use . + /// The byte[] will be serialized to a Base64 encoded string. + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromBytes(new byte[] { 1, 2, 3 }) + /// Creates a payload of "AQID". + /// + /// + /// + /// + public BinaryData File { get; } + /// An optional text to guide the model's style or continue a previous audio segment. The prompt should match the audio language. + public string Prompt { get; set; } + /// + /// The sampling temperature, between 0 and 1. + /// Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + /// If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit. + /// + public float? Temperature { get; set; } + /// + /// The model name to provide as part of this transcription request. + /// Not applicable to Azure OpenAI, where deployment information should be included in the Azure + /// resource URI that's connected to. + /// + public string InternalNonAzureModelName { get; set; } + /// The language of the input audio. Supplying the input language in ISO-639-1 format will improve accuracy and latency. + public string Language { get; set; } + /// The format of the transcription output, in one of these options: json, text, srt, verbose_json, or vtt. + public AudioTranscriptionFormat? ResponseFormat { get; set; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionOptionsSimpleJson.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionOptionsSimpleJson.Serialization.cs new file mode 100644 index 000000000000..2dbc26698001 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionOptionsSimpleJson.Serialization.cs @@ -0,0 +1,56 @@ +// 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 AudioTranscriptionOptionsSimpleJson : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("file"u8); + writer.WriteBase64StringValue(File.ToArray(), "D"); + if (Optional.IsDefined(Prompt)) + { + writer.WritePropertyName("prompt"u8); + writer.WriteStringValue(Prompt); + } + if (Optional.IsDefined(Temperature)) + { + writer.WritePropertyName("temperature"u8); + writer.WriteNumberValue(Temperature.Value); + } + if (Optional.IsDefined(InternalNonAzureModelName)) + { + writer.WritePropertyName("model"u8); + writer.WriteStringValue(InternalNonAzureModelName); + } + if (Optional.IsDefined(Language)) + { + writer.WritePropertyName("language"u8); + writer.WriteStringValue(Language); + } + if (Optional.IsDefined(ResponseFormat)) + { + writer.WritePropertyName("response_format"u8); + writer.WriteStringValue(ResponseFormat.Value.ToString()); + } + 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/AudioTranscriptionOptionsSimpleJson.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionOptionsSimpleJson.cs new file mode 100644 index 000000000000..5a6c84d62bc3 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionOptionsSimpleJson.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; + +namespace Azure.AI.OpenAI +{ + /// This format will return an JSON structure containing a single "text" with the transcription. + internal partial class AudioTranscriptionOptionsSimpleJson + { + /// Initializes a new instance of AudioTranscriptionOptionsSimpleJson. + /// The audio file object to transcribe. + /// is null. + public AudioTranscriptionOptionsSimpleJson(BinaryData file) + { + Argument.AssertNotNull(file, nameof(file)); + + File = file; + } + + /// Initializes a new instance of AudioTranscriptionOptionsSimpleJson. + /// The audio file object to transcribe. + /// An optional text to guide the model's style or continue a previous audio segment. The prompt should match the audio language. + /// + /// The sampling temperature, between 0 and 1. + /// Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + /// If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit. + /// + /// + /// The model name to provide as part of this transcription request. + /// Not applicable to Azure OpenAI, where deployment information should be included in the Azure + /// resource URI that's connected to. + /// + /// The language of the input audio. Supplying the input language in ISO-639-1 format will improve accuracy and latency. + /// The format of the transcription output, in one of these options: json, text, srt, verbose_json, or vtt. + internal AudioTranscriptionOptionsSimpleJson(BinaryData file, string prompt, float? temperature, string internalNonAzureModelName, string language, AudioTranscriptionFormat? responseFormat) + { + File = file; + Prompt = prompt; + Temperature = temperature; + InternalNonAzureModelName = internalNonAzureModelName; + Language = language; + ResponseFormat = responseFormat; + } + + /// + /// The audio file object to transcribe. + /// + /// To assign a byte[] to this property use . + /// The byte[] will be serialized to a Base64 encoded string. + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromBytes(new byte[] { 1, 2, 3 }) + /// Creates a payload of "AQID". + /// + /// + /// + /// + public BinaryData File { get; } + /// An optional text to guide the model's style or continue a previous audio segment. The prompt should match the audio language. + public string Prompt { get; set; } + /// + /// The sampling temperature, between 0 and 1. + /// Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + /// If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit. + /// + public float? Temperature { get; set; } + /// + /// The model name to provide as part of this transcription request. + /// Not applicable to Azure OpenAI, where deployment information should be included in the Azure + /// resource URI that's connected to. + /// + public string InternalNonAzureModelName { get; set; } + /// The language of the input audio. Supplying the input language in ISO-639-1 format will improve accuracy and latency. + public string Language { get; set; } + /// The format of the transcription output, in one of these options: json, text, srt, verbose_json, or vtt. + public AudioTranscriptionFormat? ResponseFormat { get; set; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionOptionsSrt.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionOptionsSrt.Serialization.cs new file mode 100644 index 000000000000..8fa9a2d40c65 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionOptionsSrt.Serialization.cs @@ -0,0 +1,56 @@ +// 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 AudioTranscriptionOptionsSrt : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("file"u8); + writer.WriteBase64StringValue(File.ToArray(), "D"); + if (Optional.IsDefined(Prompt)) + { + writer.WritePropertyName("prompt"u8); + writer.WriteStringValue(Prompt); + } + if (Optional.IsDefined(Temperature)) + { + writer.WritePropertyName("temperature"u8); + writer.WriteNumberValue(Temperature.Value); + } + if (Optional.IsDefined(InternalNonAzureModelName)) + { + writer.WritePropertyName("model"u8); + writer.WriteStringValue(InternalNonAzureModelName); + } + if (Optional.IsDefined(Language)) + { + writer.WritePropertyName("language"u8); + writer.WriteStringValue(Language); + } + if (Optional.IsDefined(ResponseFormat)) + { + writer.WritePropertyName("response_format"u8); + writer.WriteStringValue(ResponseFormat.Value.ToString()); + } + 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/AudioTranscriptionOptionsSrt.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionOptionsSrt.cs new file mode 100644 index 000000000000..d2f4d06c1c98 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionOptionsSrt.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; + +namespace Azure.AI.OpenAI +{ + /// The transcription will be provided in SRT format (SubRip Text) in the form of plain/text. + internal partial class AudioTranscriptionOptionsSrt + { + /// Initializes a new instance of AudioTranscriptionOptionsSrt. + /// The audio file object to transcribe. + /// is null. + public AudioTranscriptionOptionsSrt(BinaryData file) + { + Argument.AssertNotNull(file, nameof(file)); + + File = file; + } + + /// Initializes a new instance of AudioTranscriptionOptionsSrt. + /// The audio file object to transcribe. + /// An optional text to guide the model's style or continue a previous audio segment. The prompt should match the audio language. + /// + /// The sampling temperature, between 0 and 1. + /// Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + /// If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit. + /// + /// + /// The model name to provide as part of this transcription request. + /// Not applicable to Azure OpenAI, where deployment information should be included in the Azure + /// resource URI that's connected to. + /// + /// The language of the input audio. Supplying the input language in ISO-639-1 format will improve accuracy and latency. + /// The format of the transcription output, in one of these options: json, text, srt, verbose_json, or vtt. + internal AudioTranscriptionOptionsSrt(BinaryData file, string prompt, float? temperature, string internalNonAzureModelName, string language, AudioTranscriptionFormat? responseFormat) + { + File = file; + Prompt = prompt; + Temperature = temperature; + InternalNonAzureModelName = internalNonAzureModelName; + Language = language; + ResponseFormat = responseFormat; + } + + /// + /// The audio file object to transcribe. + /// + /// To assign a byte[] to this property use . + /// The byte[] will be serialized to a Base64 encoded string. + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromBytes(new byte[] { 1, 2, 3 }) + /// Creates a payload of "AQID". + /// + /// + /// + /// + public BinaryData File { get; } + /// An optional text to guide the model's style or continue a previous audio segment. The prompt should match the audio language. + public string Prompt { get; set; } + /// + /// The sampling temperature, between 0 and 1. + /// Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + /// If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit. + /// + public float? Temperature { get; set; } + /// + /// The model name to provide as part of this transcription request. + /// Not applicable to Azure OpenAI, where deployment information should be included in the Azure + /// resource URI that's connected to. + /// + public string InternalNonAzureModelName { get; set; } + /// The language of the input audio. Supplying the input language in ISO-639-1 format will improve accuracy and latency. + public string Language { get; set; } + /// The format of the transcription output, in one of these options: json, text, srt, verbose_json, or vtt. + public AudioTranscriptionFormat? ResponseFormat { get; set; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionOptionsVerboseJson.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionOptionsVerboseJson.Serialization.cs new file mode 100644 index 000000000000..be090bbdf9af --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionOptionsVerboseJson.Serialization.cs @@ -0,0 +1,56 @@ +// 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 AudioTranscriptionOptionsVerboseJson : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("file"u8); + writer.WriteBase64StringValue(File.ToArray(), "D"); + if (Optional.IsDefined(Prompt)) + { + writer.WritePropertyName("prompt"u8); + writer.WriteStringValue(Prompt); + } + if (Optional.IsDefined(Temperature)) + { + writer.WritePropertyName("temperature"u8); + writer.WriteNumberValue(Temperature.Value); + } + if (Optional.IsDefined(InternalNonAzureModelName)) + { + writer.WritePropertyName("model"u8); + writer.WriteStringValue(InternalNonAzureModelName); + } + if (Optional.IsDefined(Language)) + { + writer.WritePropertyName("language"u8); + writer.WriteStringValue(Language); + } + if (Optional.IsDefined(ResponseFormat)) + { + writer.WritePropertyName("response_format"u8); + writer.WriteStringValue(ResponseFormat.Value.ToString()); + } + 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/AudioTranscriptionOptionsVerboseJson.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionOptionsVerboseJson.cs new file mode 100644 index 000000000000..cf79a853104d --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionOptionsVerboseJson.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; + +namespace Azure.AI.OpenAI +{ + /// This format will return an JSON structure containing an enriched structure with the transcription. + internal partial class AudioTranscriptionOptionsVerboseJson + { + /// Initializes a new instance of AudioTranscriptionOptionsVerboseJson. + /// The audio file object to transcribe. + /// is null. + public AudioTranscriptionOptionsVerboseJson(BinaryData file) + { + Argument.AssertNotNull(file, nameof(file)); + + File = file; + } + + /// Initializes a new instance of AudioTranscriptionOptionsVerboseJson. + /// The audio file object to transcribe. + /// An optional text to guide the model's style or continue a previous audio segment. The prompt should match the audio language. + /// + /// The sampling temperature, between 0 and 1. + /// Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + /// If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit. + /// + /// + /// The model name to provide as part of this transcription request. + /// Not applicable to Azure OpenAI, where deployment information should be included in the Azure + /// resource URI that's connected to. + /// + /// The language of the input audio. Supplying the input language in ISO-639-1 format will improve accuracy and latency. + /// The format of the transcription output, in one of these options: json, text, srt, verbose_json, or vtt. + internal AudioTranscriptionOptionsVerboseJson(BinaryData file, string prompt, float? temperature, string internalNonAzureModelName, string language, AudioTranscriptionFormat? responseFormat) + { + File = file; + Prompt = prompt; + Temperature = temperature; + InternalNonAzureModelName = internalNonAzureModelName; + Language = language; + ResponseFormat = responseFormat; + } + + /// + /// The audio file object to transcribe. + /// + /// To assign a byte[] to this property use . + /// The byte[] will be serialized to a Base64 encoded string. + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromBytes(new byte[] { 1, 2, 3 }) + /// Creates a payload of "AQID". + /// + /// + /// + /// + public BinaryData File { get; } + /// An optional text to guide the model's style or continue a previous audio segment. The prompt should match the audio language. + public string Prompt { get; set; } + /// + /// The sampling temperature, between 0 and 1. + /// Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + /// If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit. + /// + public float? Temperature { get; set; } + /// + /// The model name to provide as part of this transcription request. + /// Not applicable to Azure OpenAI, where deployment information should be included in the Azure + /// resource URI that's connected to. + /// + public string InternalNonAzureModelName { get; set; } + /// The language of the input audio. Supplying the input language in ISO-639-1 format will improve accuracy and latency. + public string Language { get; set; } + /// The format of the transcription output, in one of these options: json, text, srt, verbose_json, or vtt. + public AudioTranscriptionFormat? ResponseFormat { get; set; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionOptionsVtt.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionOptionsVtt.Serialization.cs new file mode 100644 index 000000000000..d2452af0dc34 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionOptionsVtt.Serialization.cs @@ -0,0 +1,56 @@ +// 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 AudioTranscriptionOptionsVtt : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("file"u8); + writer.WriteBase64StringValue(File.ToArray(), "D"); + if (Optional.IsDefined(Prompt)) + { + writer.WritePropertyName("prompt"u8); + writer.WriteStringValue(Prompt); + } + if (Optional.IsDefined(Temperature)) + { + writer.WritePropertyName("temperature"u8); + writer.WriteNumberValue(Temperature.Value); + } + if (Optional.IsDefined(InternalNonAzureModelName)) + { + writer.WritePropertyName("model"u8); + writer.WriteStringValue(InternalNonAzureModelName); + } + if (Optional.IsDefined(Language)) + { + writer.WritePropertyName("language"u8); + writer.WriteStringValue(Language); + } + if (Optional.IsDefined(ResponseFormat)) + { + writer.WritePropertyName("response_format"u8); + writer.WriteStringValue(ResponseFormat.Value.ToString()); + } + 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/AudioTranscriptionOptionsVtt.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionOptionsVtt.cs new file mode 100644 index 000000000000..1514c520da5a --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionOptionsVtt.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; + +namespace Azure.AI.OpenAI +{ + /// The transcription will be provided in VTT format (Web Video Text Tracks) in the form of plain/text. + internal partial class AudioTranscriptionOptionsVtt + { + /// Initializes a new instance of AudioTranscriptionOptionsVtt. + /// The audio file object to transcribe. + /// is null. + public AudioTranscriptionOptionsVtt(BinaryData file) + { + Argument.AssertNotNull(file, nameof(file)); + + File = file; + } + + /// Initializes a new instance of AudioTranscriptionOptionsVtt. + /// The audio file object to transcribe. + /// An optional text to guide the model's style or continue a previous audio segment. The prompt should match the audio language. + /// + /// The sampling temperature, between 0 and 1. + /// Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + /// If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit. + /// + /// + /// The model name to provide as part of this transcription request. + /// Not applicable to Azure OpenAI, where deployment information should be included in the Azure + /// resource URI that's connected to. + /// + /// The language of the input audio. Supplying the input language in ISO-639-1 format will improve accuracy and latency. + /// The format of the transcription output, in one of these options: json, text, srt, verbose_json, or vtt. + internal AudioTranscriptionOptionsVtt(BinaryData file, string prompt, float? temperature, string internalNonAzureModelName, string language, AudioTranscriptionFormat? responseFormat) + { + File = file; + Prompt = prompt; + Temperature = temperature; + InternalNonAzureModelName = internalNonAzureModelName; + Language = language; + ResponseFormat = responseFormat; + } + + /// + /// The audio file object to transcribe. + /// + /// To assign a byte[] to this property use . + /// The byte[] will be serialized to a Base64 encoded string. + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromBytes(new byte[] { 1, 2, 3 }) + /// Creates a payload of "AQID". + /// + /// + /// + /// + public BinaryData File { get; } + /// An optional text to guide the model's style or continue a previous audio segment. The prompt should match the audio language. + public string Prompt { get; set; } + /// + /// The sampling temperature, between 0 and 1. + /// Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + /// If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit. + /// + public float? Temperature { get; set; } + /// + /// The model name to provide as part of this transcription request. + /// Not applicable to Azure OpenAI, where deployment information should be included in the Azure + /// resource URI that's connected to. + /// + public string InternalNonAzureModelName { get; set; } + /// The language of the input audio. Supplying the input language in ISO-639-1 format will improve accuracy and latency. + public string Language { get; set; } + /// The format of the transcription output, in one of these options: json, text, srt, verbose_json, or vtt. + public AudioTranscriptionFormat? ResponseFormat { get; set; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionSegment.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionSegment.Serialization.cs new file mode 100644 index 000000000000..0b9917154d52 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionSegment.Serialization.cs @@ -0,0 +1,102 @@ +// 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 AudioTranscriptionSegment + { + internal static AudioTranscriptionSegment DeserializeAudioTranscriptionSegment(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int id = default; + float start = default; + float end = default; + string text = default; + float temperature = default; + float avgLogprob = default; + float compressionRatio = default; + float noSpeechProb = default; + IReadOnlyList tokens = default; + int seek = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("start"u8)) + { + start = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("end"u8)) + { + end = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("text"u8)) + { + text = property.Value.GetString(); + continue; + } + if (property.NameEquals("temperature"u8)) + { + temperature = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("avg_logprob"u8)) + { + avgLogprob = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("compression_ratio"u8)) + { + compressionRatio = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("no_speech_prob"u8)) + { + noSpeechProb = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("tokens"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetInt32()); + } + tokens = array; + continue; + } + if (property.NameEquals("seek"u8)) + { + seek = property.Value.GetInt32(); + continue; + } + } + return new AudioTranscriptionSegment(id, start, end, text, temperature, avgLogprob, compressionRatio, noSpeechProb, tokens, seek); + } + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static AudioTranscriptionSegment FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeAudioTranscriptionSegment(document.RootElement); + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionSegment.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionSegment.cs new file mode 100644 index 000000000000..ebbb239c3908 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionSegment.cs @@ -0,0 +1,93 @@ +// 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 +{ + /// Transcription segment. + internal partial class AudioTranscriptionSegment + { + /// Initializes a new instance of AudioTranscriptionSegment. + /// Segment identifier. + /// Segment start offset. + /// Segment end offset. + /// Segment text. + /// Temperature. + /// Average log probability. + /// Compression ratio. + /// Probability of 'no speech'. + /// Tokens in this segment. + /// TODO. + /// or is null. + internal AudioTranscriptionSegment(int id, float start, float end, string text, float temperature, float averageLogProb, float compressionRatio, float noSpeechProb, IEnumerable tokens, int seek) + { + Argument.AssertNotNull(text, nameof(text)); + Argument.AssertNotNull(tokens, nameof(tokens)); + + Id = id; + Start = start; + End = end; + Text = text; + Temperature = temperature; + AverageLogProb = averageLogProb; + CompressionRatio = compressionRatio; + NoSpeechProb = noSpeechProb; + Tokens = tokens.ToList(); + Seek = seek; + } + + /// Initializes a new instance of AudioTranscriptionSegment. + /// Segment identifier. + /// Segment start offset. + /// Segment end offset. + /// Segment text. + /// Temperature. + /// Average log probability. + /// Compression ratio. + /// Probability of 'no speech'. + /// Tokens in this segment. + /// TODO. + internal AudioTranscriptionSegment(int id, float start, float end, string text, float temperature, float averageLogProb, float compressionRatio, float noSpeechProb, IReadOnlyList tokens, int seek) + { + Id = id; + Start = start; + End = end; + Text = text; + Temperature = temperature; + AverageLogProb = averageLogProb; + CompressionRatio = compressionRatio; + NoSpeechProb = noSpeechProb; + Tokens = tokens; + Seek = seek; + } + + /// Segment identifier. + public int Id { get; } + /// Segment start offset. + public float Start { get; } + /// Segment end offset. + public float End { get; } + /// Segment text. + public string Text { get; } + /// Temperature. + public float Temperature { get; } + /// Average log probability. + public float AverageLogProb { get; } + /// Compression ratio. + public float CompressionRatio { get; } + /// Probability of 'no speech'. + public float NoSpeechProb { get; } + /// Tokens in this segment. + public IReadOnlyList Tokens { get; } + /// TODO. + public int Seek { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionSimpleJson.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionSimpleJson.Serialization.cs new file mode 100644 index 000000000000..999a349daa31 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionSimpleJson.Serialization.cs @@ -0,0 +1,42 @@ +// 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 AudioTranscriptionSimpleJson + { + internal static AudioTranscriptionSimpleJson DeserializeAudioTranscriptionSimpleJson(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string text = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("text"u8)) + { + text = property.Value.GetString(); + continue; + } + } + return new AudioTranscriptionSimpleJson(text); + } + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static AudioTranscriptionSimpleJson FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeAudioTranscriptionSimpleJson(document.RootElement); + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionSimpleJson.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionSimpleJson.cs new file mode 100644 index 000000000000..aa18aa50e5f6 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionSimpleJson.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 +{ + /// Transcription response containing only the transcribed text. + internal partial class AudioTranscriptionSimpleJson + { + /// Initializes a new instance of AudioTranscriptionSimpleJson. + /// Transcribed text. + /// is null. + internal AudioTranscriptionSimpleJson(string text) + { + Argument.AssertNotNull(text, nameof(text)); + + Text = text; + } + + /// Transcribed text. + public string Text { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionTask.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionTask.cs new file mode 100644 index 000000000000..f48e69026b6c --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionTask.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 +{ + /// Audio transcription task type. + internal readonly partial struct AudioTranscriptionTask : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AudioTranscriptionTask(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string TranscribeValue = "transcribe"; + private const string TranslateValue = "translate"; + + /// Value for a transcription task. + public static AudioTranscriptionTask Transcribe { get; } = new AudioTranscriptionTask(TranscribeValue); + /// Value for a translation task. + public static AudioTranscriptionTask Translate { get; } = new AudioTranscriptionTask(TranslateValue); + /// Determines if two values are the same. + public static bool operator ==(AudioTranscriptionTask left, AudioTranscriptionTask right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AudioTranscriptionTask left, AudioTranscriptionTask right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator AudioTranscriptionTask(string value) => new AudioTranscriptionTask(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AudioTranscriptionTask other && Equals(other); + /// + public bool Equals(AudioTranscriptionTask 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/AudioTranscriptionVerboseJson.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionVerboseJson.Serialization.cs new file mode 100644 index 000000000000..272de5302ba4 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionVerboseJson.Serialization.cs @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace Azure.AI.OpenAI +{ + internal partial class AudioTranscriptionVerboseJson + { + internal static AudioTranscriptionVerboseJson DeserializeAudioTranscriptionVerboseJson(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AudioTranscriptionTask task = default; + string language = default; + TimeSpan duration = default; + IReadOnlyList segments = default; + string text = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("task"u8)) + { + task = new AudioTranscriptionTask(property.Value.GetString()); + continue; + } + if (property.NameEquals("language"u8)) + { + language = property.Value.GetString(); + continue; + } + if (property.NameEquals("duration"u8)) + { + duration = TimeSpan.FromSeconds(property.Value.GetDouble()); + continue; + } + if (property.NameEquals("segments"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(AudioTranscriptionSegment.DeserializeAudioTranscriptionSegment(item)); + } + segments = array; + continue; + } + if (property.NameEquals("text"u8)) + { + text = property.Value.GetString(); + continue; + } + } + return new AudioTranscriptionVerboseJson(text, task, language, duration, segments); + } + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new AudioTranscriptionVerboseJson FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeAudioTranscriptionVerboseJson(document.RootElement); + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionVerboseJson.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionVerboseJson.cs new file mode 100644 index 000000000000..d14d61a0fc87 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranscriptionVerboseJson.cs @@ -0,0 +1,63 @@ +// 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 +{ + /// Transcription response. + internal partial class AudioTranscriptionVerboseJson : AudioTranscriptionSimpleJson + { + /// Initializes a new instance of AudioTranscriptionVerboseJson. + /// Transcribed text. + /// Audio transcription task. + /// Language detected in the source audio file. + /// Duration. + /// Segments. + /// , or is null. + internal AudioTranscriptionVerboseJson(string text, AudioTranscriptionTask task, string language, TimeSpan duration, IEnumerable segments) : base(text) + { + Argument.AssertNotNull(text, nameof(text)); + Argument.AssertNotNull(language, nameof(language)); + Argument.AssertNotNull(segments, nameof(segments)); + + Task = task; + Language = language; + Duration = duration; + Segments = segments.ToList(); + } + + /// Initializes a new instance of AudioTranscriptionVerboseJson. + /// Transcribed text. + /// Audio transcription task. + /// Language detected in the source audio file. + /// Duration. + /// Segments. + /// is null. + internal AudioTranscriptionVerboseJson(string text, AudioTranscriptionTask task, string language, TimeSpan duration, IReadOnlyList segments) : base(text) + { + Argument.AssertNotNull(text, nameof(text)); + + Task = task; + Language = language; + Duration = duration; + Segments = segments; + } + + /// Audio transcription task. + public AudioTranscriptionTask Task { get; } + /// Language detected in the source audio file. + public string Language { get; } + /// Duration. + public TimeSpan Duration { get; } + /// Segments. + public IReadOnlyList Segments { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranslationOptionsPlainText.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranslationOptionsPlainText.Serialization.cs new file mode 100644 index 000000000000..790b11d3bfe6 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranslationOptionsPlainText.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 AudioTranslationOptionsPlainText : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("file"u8); + writer.WriteBase64StringValue(File.ToArray(), "D"); + if (Optional.IsDefined(Prompt)) + { + writer.WritePropertyName("prompt"u8); + writer.WriteStringValue(Prompt); + } + if (Optional.IsDefined(Temperature)) + { + writer.WritePropertyName("temperature"u8); + writer.WriteNumberValue(Temperature.Value); + } + if (Optional.IsDefined(InternalNonAzureModelName)) + { + writer.WritePropertyName("model"u8); + writer.WriteStringValue(InternalNonAzureModelName); + } + if (Optional.IsDefined(ResponseFormat)) + { + writer.WritePropertyName("response_format"u8); + writer.WriteStringValue(ResponseFormat.Value.ToString()); + } + 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/AudioTranslationOptionsPlainText.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranslationOptionsPlainText.cs new file mode 100644 index 000000000000..dddc61ccdc90 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranslationOptionsPlainText.cs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; + +namespace Azure.AI.OpenAI +{ + /// This will make the response return the translation as plain/text. + internal partial class AudioTranslationOptionsPlainText + { + /// Initializes a new instance of AudioTranslationOptionsPlainText. + /// The audio file object to transcribe. + /// is null. + public AudioTranslationOptionsPlainText(BinaryData file) + { + Argument.AssertNotNull(file, nameof(file)); + + File = file; + } + + /// Initializes a new instance of AudioTranslationOptionsPlainText. + /// The audio file object to transcribe. + /// An optional text to guide the model's style or continue a previous audio segment. The prompt should match the audio language. + /// + /// The sampling temperature, between 0 and 1. + /// Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + /// If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit. + /// + /// + /// The model name to provide as part of this transcription request. + /// Not applicable to Azure OpenAI, where deployment information should be included in the Azure + /// resource URI that's connected to. + /// + /// The format of the transcription output, in one of these options: json, text, srt, verbose_json, or vtt. + internal AudioTranslationOptionsPlainText(BinaryData file, string prompt, float? temperature, string internalNonAzureModelName, AudioTranscriptionFormat? responseFormat) + { + File = file; + Prompt = prompt; + Temperature = temperature; + InternalNonAzureModelName = internalNonAzureModelName; + ResponseFormat = responseFormat; + } + + /// + /// The audio file object to transcribe. + /// + /// To assign a byte[] to this property use . + /// The byte[] will be serialized to a Base64 encoded string. + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromBytes(new byte[] { 1, 2, 3 }) + /// Creates a payload of "AQID". + /// + /// + /// + /// + public BinaryData File { get; } + /// An optional text to guide the model's style or continue a previous audio segment. The prompt should match the audio language. + public string Prompt { get; set; } + /// + /// The sampling temperature, between 0 and 1. + /// Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + /// If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit. + /// + public float? Temperature { get; set; } + /// + /// The model name to provide as part of this transcription request. + /// Not applicable to Azure OpenAI, where deployment information should be included in the Azure + /// resource URI that's connected to. + /// + public string InternalNonAzureModelName { get; set; } + /// The format of the transcription output, in one of these options: json, text, srt, verbose_json, or vtt. + public AudioTranscriptionFormat? ResponseFormat { get; set; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranslationOptionsSimpleJson.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranslationOptionsSimpleJson.Serialization.cs new file mode 100644 index 000000000000..794d5e477190 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranslationOptionsSimpleJson.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 AudioTranslationOptionsSimpleJson : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("file"u8); + writer.WriteBase64StringValue(File.ToArray(), "D"); + if (Optional.IsDefined(Prompt)) + { + writer.WritePropertyName("prompt"u8); + writer.WriteStringValue(Prompt); + } + if (Optional.IsDefined(Temperature)) + { + writer.WritePropertyName("temperature"u8); + writer.WriteNumberValue(Temperature.Value); + } + if (Optional.IsDefined(InternalNonAzureModelName)) + { + writer.WritePropertyName("model"u8); + writer.WriteStringValue(InternalNonAzureModelName); + } + if (Optional.IsDefined(ResponseFormat)) + { + writer.WritePropertyName("response_format"u8); + writer.WriteStringValue(ResponseFormat.Value.ToString()); + } + 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/AudioTranslationOptionsSimpleJson.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranslationOptionsSimpleJson.cs new file mode 100644 index 000000000000..ab1b69183c5b --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranslationOptionsSimpleJson.cs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; + +namespace Azure.AI.OpenAI +{ + /// This format will return an JSON structure containing a single "text" with the translation. + internal partial class AudioTranslationOptionsSimpleJson + { + /// Initializes a new instance of AudioTranslationOptionsSimpleJson. + /// The audio file object to transcribe. + /// is null. + public AudioTranslationOptionsSimpleJson(BinaryData file) + { + Argument.AssertNotNull(file, nameof(file)); + + File = file; + } + + /// Initializes a new instance of AudioTranslationOptionsSimpleJson. + /// The audio file object to transcribe. + /// An optional text to guide the model's style or continue a previous audio segment. The prompt should match the audio language. + /// + /// The sampling temperature, between 0 and 1. + /// Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + /// If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit. + /// + /// + /// The model name to provide as part of this transcription request. + /// Not applicable to Azure OpenAI, where deployment information should be included in the Azure + /// resource URI that's connected to. + /// + /// The format of the transcription output, in one of these options: json, text, srt, verbose_json, or vtt. + internal AudioTranslationOptionsSimpleJson(BinaryData file, string prompt, float? temperature, string internalNonAzureModelName, AudioTranscriptionFormat? responseFormat) + { + File = file; + Prompt = prompt; + Temperature = temperature; + InternalNonAzureModelName = internalNonAzureModelName; + ResponseFormat = responseFormat; + } + + /// + /// The audio file object to transcribe. + /// + /// To assign a byte[] to this property use . + /// The byte[] will be serialized to a Base64 encoded string. + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromBytes(new byte[] { 1, 2, 3 }) + /// Creates a payload of "AQID". + /// + /// + /// + /// + public BinaryData File { get; } + /// An optional text to guide the model's style or continue a previous audio segment. The prompt should match the audio language. + public string Prompt { get; set; } + /// + /// The sampling temperature, between 0 and 1. + /// Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + /// If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit. + /// + public float? Temperature { get; set; } + /// + /// The model name to provide as part of this transcription request. + /// Not applicable to Azure OpenAI, where deployment information should be included in the Azure + /// resource URI that's connected to. + /// + public string InternalNonAzureModelName { get; set; } + /// The format of the transcription output, in one of these options: json, text, srt, verbose_json, or vtt. + public AudioTranscriptionFormat? ResponseFormat { get; set; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranslationOptionsSrt.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranslationOptionsSrt.Serialization.cs new file mode 100644 index 000000000000..696ff0f5e174 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranslationOptionsSrt.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 AudioTranslationOptionsSrt : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("file"u8); + writer.WriteBase64StringValue(File.ToArray(), "D"); + if (Optional.IsDefined(Prompt)) + { + writer.WritePropertyName("prompt"u8); + writer.WriteStringValue(Prompt); + } + if (Optional.IsDefined(Temperature)) + { + writer.WritePropertyName("temperature"u8); + writer.WriteNumberValue(Temperature.Value); + } + if (Optional.IsDefined(InternalNonAzureModelName)) + { + writer.WritePropertyName("model"u8); + writer.WriteStringValue(InternalNonAzureModelName); + } + if (Optional.IsDefined(ResponseFormat)) + { + writer.WritePropertyName("response_format"u8); + writer.WriteStringValue(ResponseFormat.Value.ToString()); + } + 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/AudioTranslationOptionsSrt.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranslationOptionsSrt.cs new file mode 100644 index 000000000000..a7216ea91e1e --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranslationOptionsSrt.cs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; + +namespace Azure.AI.OpenAI +{ + /// The translation will be provided in SRT format (SubRip Text) in the form of plain/text. + internal partial class AudioTranslationOptionsSrt + { + /// Initializes a new instance of AudioTranslationOptionsSrt. + /// The audio file object to transcribe. + /// is null. + public AudioTranslationOptionsSrt(BinaryData file) + { + Argument.AssertNotNull(file, nameof(file)); + + File = file; + } + + /// Initializes a new instance of AudioTranslationOptionsSrt. + /// The audio file object to transcribe. + /// An optional text to guide the model's style or continue a previous audio segment. The prompt should match the audio language. + /// + /// The sampling temperature, between 0 and 1. + /// Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + /// If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit. + /// + /// + /// The model name to provide as part of this transcription request. + /// Not applicable to Azure OpenAI, where deployment information should be included in the Azure + /// resource URI that's connected to. + /// + /// The format of the transcription output, in one of these options: json, text, srt, verbose_json, or vtt. + internal AudioTranslationOptionsSrt(BinaryData file, string prompt, float? temperature, string internalNonAzureModelName, AudioTranscriptionFormat? responseFormat) + { + File = file; + Prompt = prompt; + Temperature = temperature; + InternalNonAzureModelName = internalNonAzureModelName; + ResponseFormat = responseFormat; + } + + /// + /// The audio file object to transcribe. + /// + /// To assign a byte[] to this property use . + /// The byte[] will be serialized to a Base64 encoded string. + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromBytes(new byte[] { 1, 2, 3 }) + /// Creates a payload of "AQID". + /// + /// + /// + /// + public BinaryData File { get; } + /// An optional text to guide the model's style or continue a previous audio segment. The prompt should match the audio language. + public string Prompt { get; set; } + /// + /// The sampling temperature, between 0 and 1. + /// Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + /// If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit. + /// + public float? Temperature { get; set; } + /// + /// The model name to provide as part of this transcription request. + /// Not applicable to Azure OpenAI, where deployment information should be included in the Azure + /// resource URI that's connected to. + /// + public string InternalNonAzureModelName { get; set; } + /// The format of the transcription output, in one of these options: json, text, srt, verbose_json, or vtt. + public AudioTranscriptionFormat? ResponseFormat { get; set; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranslationOptionsVerboseJson.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranslationOptionsVerboseJson.Serialization.cs new file mode 100644 index 000000000000..01d6ab0db395 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranslationOptionsVerboseJson.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 AudioTranslationOptionsVerboseJson : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("file"u8); + writer.WriteBase64StringValue(File.ToArray(), "D"); + if (Optional.IsDefined(Prompt)) + { + writer.WritePropertyName("prompt"u8); + writer.WriteStringValue(Prompt); + } + if (Optional.IsDefined(Temperature)) + { + writer.WritePropertyName("temperature"u8); + writer.WriteNumberValue(Temperature.Value); + } + if (Optional.IsDefined(InternalNonAzureModelName)) + { + writer.WritePropertyName("model"u8); + writer.WriteStringValue(InternalNonAzureModelName); + } + if (Optional.IsDefined(ResponseFormat)) + { + writer.WritePropertyName("response_format"u8); + writer.WriteStringValue(ResponseFormat.Value.ToString()); + } + 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/AudioTranslationOptionsVerboseJson.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranslationOptionsVerboseJson.cs new file mode 100644 index 000000000000..1d57d15d1fbf --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranslationOptionsVerboseJson.cs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; + +namespace Azure.AI.OpenAI +{ + /// This format will return an JSON structure containing an enriched structure with the translation. + internal partial class AudioTranslationOptionsVerboseJson + { + /// Initializes a new instance of AudioTranslationOptionsVerboseJson. + /// The audio file object to transcribe. + /// is null. + public AudioTranslationOptionsVerboseJson(BinaryData file) + { + Argument.AssertNotNull(file, nameof(file)); + + File = file; + } + + /// Initializes a new instance of AudioTranslationOptionsVerboseJson. + /// The audio file object to transcribe. + /// An optional text to guide the model's style or continue a previous audio segment. The prompt should match the audio language. + /// + /// The sampling temperature, between 0 and 1. + /// Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + /// If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit. + /// + /// + /// The model name to provide as part of this transcription request. + /// Not applicable to Azure OpenAI, where deployment information should be included in the Azure + /// resource URI that's connected to. + /// + /// The format of the transcription output, in one of these options: json, text, srt, verbose_json, or vtt. + internal AudioTranslationOptionsVerboseJson(BinaryData file, string prompt, float? temperature, string internalNonAzureModelName, AudioTranscriptionFormat? responseFormat) + { + File = file; + Prompt = prompt; + Temperature = temperature; + InternalNonAzureModelName = internalNonAzureModelName; + ResponseFormat = responseFormat; + } + + /// + /// The audio file object to transcribe. + /// + /// To assign a byte[] to this property use . + /// The byte[] will be serialized to a Base64 encoded string. + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromBytes(new byte[] { 1, 2, 3 }) + /// Creates a payload of "AQID". + /// + /// + /// + /// + public BinaryData File { get; } + /// An optional text to guide the model's style or continue a previous audio segment. The prompt should match the audio language. + public string Prompt { get; set; } + /// + /// The sampling temperature, between 0 and 1. + /// Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + /// If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit. + /// + public float? Temperature { get; set; } + /// + /// The model name to provide as part of this transcription request. + /// Not applicable to Azure OpenAI, where deployment information should be included in the Azure + /// resource URI that's connected to. + /// + public string InternalNonAzureModelName { get; set; } + /// The format of the transcription output, in one of these options: json, text, srt, verbose_json, or vtt. + public AudioTranscriptionFormat? ResponseFormat { get; set; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranslationOptionsVtt.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranslationOptionsVtt.Serialization.cs new file mode 100644 index 000000000000..99ac6d1fb412 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranslationOptionsVtt.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 AudioTranslationOptionsVtt : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + writer.WritePropertyName("file"u8); + writer.WriteBase64StringValue(File.ToArray(), "D"); + if (Optional.IsDefined(Prompt)) + { + writer.WritePropertyName("prompt"u8); + writer.WriteStringValue(Prompt); + } + if (Optional.IsDefined(Temperature)) + { + writer.WritePropertyName("temperature"u8); + writer.WriteNumberValue(Temperature.Value); + } + if (Optional.IsDefined(InternalNonAzureModelName)) + { + writer.WritePropertyName("model"u8); + writer.WriteStringValue(InternalNonAzureModelName); + } + if (Optional.IsDefined(ResponseFormat)) + { + writer.WritePropertyName("response_format"u8); + writer.WriteStringValue(ResponseFormat.Value.ToString()); + } + 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/AudioTranslationOptionsVtt.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranslationOptionsVtt.cs new file mode 100644 index 000000000000..527c5bdff083 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AudioTranslationOptionsVtt.cs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; + +namespace Azure.AI.OpenAI +{ + /// The translation will be provided in VTT format (Web Video Text Tracks) in the form of plain/text. + internal partial class AudioTranslationOptionsVtt + { + /// Initializes a new instance of AudioTranslationOptionsVtt. + /// The audio file object to transcribe. + /// is null. + public AudioTranslationOptionsVtt(BinaryData file) + { + Argument.AssertNotNull(file, nameof(file)); + + File = file; + } + + /// Initializes a new instance of AudioTranslationOptionsVtt. + /// The audio file object to transcribe. + /// An optional text to guide the model's style or continue a previous audio segment. The prompt should match the audio language. + /// + /// The sampling temperature, between 0 and 1. + /// Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + /// If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit. + /// + /// + /// The model name to provide as part of this transcription request. + /// Not applicable to Azure OpenAI, where deployment information should be included in the Azure + /// resource URI that's connected to. + /// + /// The format of the transcription output, in one of these options: json, text, srt, verbose_json, or vtt. + internal AudioTranslationOptionsVtt(BinaryData file, string prompt, float? temperature, string internalNonAzureModelName, AudioTranscriptionFormat? responseFormat) + { + File = file; + Prompt = prompt; + Temperature = temperature; + InternalNonAzureModelName = internalNonAzureModelName; + ResponseFormat = responseFormat; + } + + /// + /// The audio file object to transcribe. + /// + /// To assign a byte[] to this property use . + /// The byte[] will be serialized to a Base64 encoded string. + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromBytes(new byte[] { 1, 2, 3 }) + /// Creates a payload of "AQID". + /// + /// + /// + /// + public BinaryData File { get; } + /// An optional text to guide the model's style or continue a previous audio segment. The prompt should match the audio language. + public string Prompt { get; set; } + /// + /// The sampling temperature, between 0 and 1. + /// Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + /// If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit. + /// + public float? Temperature { get; set; } + /// + /// The model name to provide as part of this transcription request. + /// Not applicable to Azure OpenAI, where deployment information should be included in the Azure + /// resource URI that's connected to. + /// + public string InternalNonAzureModelName { get; set; } + /// The format of the transcription output, in one of these options: json, text, srt, verbose_json, or vtt. + public AudioTranscriptionFormat? ResponseFormat { get; set; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIModelFactory.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIModelFactory.cs index 8f507b54d557..99178a850cc2 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIModelFactory.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIModelFactory.cs @@ -15,40 +15,6 @@ namespace Azure.AI.OpenAI /// Model factory for models. public static partial class AzureOpenAIModelFactory { - /// Initializes a new instance of Embeddings. - /// Embedding values for the prompts submitted in the request. - /// Usage counts for tokens input using the embeddings API. - /// A new instance for mocking. - public static Embeddings Embeddings(IEnumerable data = null, EmbeddingsUsage usage = null) - { - data ??= new List(); - - return new Embeddings(data?.ToList(), usage); - } - - /// Initializes a new instance of EmbeddingItem. - /// - /// List of embeddings value for the input prompt. These represent a measurement of the - /// vector-based relatedness of the provided input. - /// - /// Index of the prompt to which the EmbeddingItem corresponds. - /// A new instance for mocking. - public static EmbeddingItem EmbeddingItem(IEnumerable embedding = null, int index = default) - { - embedding ??= new List(); - - return new EmbeddingItem(embedding?.ToList(), index); - } - - /// Initializes a new instance of EmbeddingsUsage. - /// Number of tokens sent in the original request. - /// Total number of tokens transacted in this request/response. - /// A new instance for mocking. - public static EmbeddingsUsage EmbeddingsUsage(int promptTokens = default, int totalTokens = default) - { - return new EmbeddingsUsage(promptTokens, totalTokens); - } - /// Initializes a new instance of Completions. /// A unique identifier associated with this completions response. /// @@ -105,10 +71,14 @@ public static PromptFilterResult PromptFilterResult(int promptIndex = default, C /// Describes language related to physical actions intended to purposely hurt, injure, /// or damage one’s body, or kill oneself. /// + /// + /// Describes an error returned if the content filtering system is + /// down or otherwise unable to complete the operation in time. + /// /// A new instance for mocking. - public static ContentFilterResults ContentFilterResults(ContentFilterResult sexual = null, ContentFilterResult violence = null, ContentFilterResult hate = null, ContentFilterResult selfHarm = null) + public static ContentFilterResults ContentFilterResults(ContentFilterResult sexual = null, ContentFilterResult violence = null, ContentFilterResult hate = null, ContentFilterResult selfHarm = null, ResponseError error = null) { - return new ContentFilterResults(sexual, violence, hate, selfHarm); + return new ContentFilterResults(sexual, violence, hate, selfHarm, error); } /// Initializes a new instance of ContentFilterResult. @@ -187,6 +157,40 @@ public static ChatCompletions ChatCompletions(string id = null, DateTimeOffset c return new ChatCompletions(id, created, choices?.ToList(), promptFilterResults?.ToList(), usage); } + /// Initializes a new instance of Embeddings. + /// Embedding values for the prompts submitted in the request. + /// Usage counts for tokens input using the embeddings API. + /// A new instance for mocking. + public static Embeddings Embeddings(IEnumerable data = null, EmbeddingsUsage usage = null) + { + data ??= new List(); + + return new Embeddings(data?.ToList(), usage); + } + + /// Initializes a new instance of EmbeddingItem. + /// + /// List of embeddings value for the input prompt. These represent a measurement of the + /// vector-based relatedness of the provided input. + /// + /// Index of the prompt to which the EmbeddingItem corresponds. + /// A new instance for mocking. + public static EmbeddingItem EmbeddingItem(IEnumerable embedding = null, int index = default) + { + embedding ??= new List(); + + return new EmbeddingItem(embedding?.ToList(), index); + } + + /// Initializes a new instance of EmbeddingsUsage. + /// Number of tokens sent in the original request. + /// Total number of tokens transacted in this request/response. + /// A new instance for mocking. + public static EmbeddingsUsage EmbeddingsUsage(int promptTokens = default, int totalTokens = default) + { + return new EmbeddingsUsage(promptTokens, totalTokens); + } + /// Initializes a new instance of ImageGenerations. /// A timestamp when this job or item was created (in unix epochs). /// The images generated by the operator. diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterResults.Serialization.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterResults.Serialization.cs index 4e5b1cc62ad8..1a030b9cff66 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterResults.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterResults.Serialization.cs @@ -23,6 +23,7 @@ internal static ContentFilterResults DeserializeContentFilterResults(JsonElement Optional violence = default; Optional hate = default; Optional selfHarm = default; + Optional error = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("sexual"u8)) @@ -61,8 +62,17 @@ internal static ContentFilterResults DeserializeContentFilterResults(JsonElement selfHarm = ContentFilterResult.DeserializeContentFilterResult(property.Value); continue; } + if (property.NameEquals("error"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + error = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } } - return new ContentFilterResults(sexual.Value, violence.Value, hate.Value, selfHarm.Value); + return new ContentFilterResults(sexual.Value, violence.Value, hate.Value, selfHarm.Value, error.Value); } /// Deserializes the model from a raw response. diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterResults.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterResults.cs index 1132a5df81df..bdb621d2b261 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterResults.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterResults.cs @@ -5,6 +5,8 @@ #nullable disable +using Azure; + namespace Azure.AI.OpenAI { /// Information about the content filtering category, if it has been detected. @@ -37,12 +39,17 @@ internal ContentFilterResults() /// 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) + /// + /// Describes an error returned if the content filtering system is + /// down or otherwise unable to complete the operation in time. + /// + internal ContentFilterResults(ContentFilterResult sexual, ContentFilterResult violence, ContentFilterResult hate, ContentFilterResult selfHarm, ResponseError error) { Sexual = sexual; Violence = violence; Hate = hate; SelfHarm = selfHarm; + Error = error; } /// @@ -70,5 +77,10 @@ internal ContentFilterResults(ContentFilterResult sexual, ContentFilterResult vi /// or damage one’s body, or kill oneself. /// public ContentFilterResult SelfHarm { get; } + /// + /// Describes an error returned if the content filtering system is + /// down or otherwise unable to complete the operation in time. + /// + public ResponseError Error { get; } } } 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 5e9ad80022d6..08f90b1cc74a 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/Docs/OpenAIClient.xml +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/Docs/OpenAIClient.xml @@ -1,43 +1,85 @@ - - -This sample shows how to call GetEmbeddingsAsync with required parameters. -"); - -var embeddingsOptions = new EmbeddingsOptions(new string[] -{ - "" -}) -{ - User = "", -}; -var result = await client.GetEmbeddingsAsync("", embeddingsOptions); -]]> - + - - -This sample shows how to call GetEmbeddings with required parameters. -"); - -var embeddingsOptions = new EmbeddingsOptions(new string[] -{ - "" -}) -{ - User = "", -}; -var result = client.GetEmbeddings("", embeddingsOptions); -]]> - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -119,6 +161,44 @@ var result = client.GetCompletions("", completionsOptions); + + +This sample shows how to call GetEmbeddingsAsync with required parameters. +"); + +var embeddingsOptions = new EmbeddingsOptions(new string[] +{ + "" +}) +{ + User = "", +}; +var result = await client.GetEmbeddingsAsync("", embeddingsOptions); +]]> + + + + +This sample shows how to call GetEmbeddings with required parameters. +"); + +var embeddingsOptions = new EmbeddingsOptions(new string[] +{ + "" +}) +{ + User = "", +}; +var result = client.GetEmbeddings("", embeddingsOptions); +]]> + + + + + + diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/OpenAIClient.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/OpenAIClient.cs index b13ec0d48646..4efb4d1150d5 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/OpenAIClient.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/OpenAIClient.cs @@ -37,6 +37,1226 @@ protected OpenAIClient() { } + /// Transcribes audio into the input language. + /// Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request. + /// The content length of the operation. This needs to be provided by the caller. + /// This format will return an JSON structure containing a single "text" with the transcription. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// + internal virtual async Task> GetAudioTranscriptionSimpleJsonAsync(string deploymentId, long contentLength, AudioTranscriptionOptionsSimpleJson audioTranscriptionOptionsSimpleJson, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(deploymentId, nameof(deploymentId)); + Argument.AssertNotNull(audioTranscriptionOptionsSimpleJson, nameof(audioTranscriptionOptionsSimpleJson)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetAudioTranscriptionSimpleJsonAsync(deploymentId, contentLength, audioTranscriptionOptionsSimpleJson.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(AudioTranscriptionSimpleJson.FromResponse(response), response); + } + + /// Transcribes audio into the input language. + /// Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request. + /// The content length of the operation. This needs to be provided by the caller. + /// This format will return an JSON structure containing a single "text" with the transcription. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// + internal virtual Response GetAudioTranscriptionSimpleJson(string deploymentId, long contentLength, AudioTranscriptionOptionsSimpleJson audioTranscriptionOptionsSimpleJson, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(deploymentId, nameof(deploymentId)); + Argument.AssertNotNull(audioTranscriptionOptionsSimpleJson, nameof(audioTranscriptionOptionsSimpleJson)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetAudioTranscriptionSimpleJson(deploymentId, contentLength, audioTranscriptionOptionsSimpleJson.ToRequestContent(), context); + return Response.FromValue(AudioTranscriptionSimpleJson.FromResponse(response), response); + } + + /// + /// [Protocol Method] Transcribes audio into the input language. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request. + /// The content length of the operation. This needs to be provided by the caller. + /// 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. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + internal virtual async Task GetAudioTranscriptionSimpleJsonAsync(string deploymentId, long contentLength, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(deploymentId, nameof(deploymentId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("OpenAIClient.GetAudioTranscriptionSimpleJson"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAudioTranscriptionSimpleJsonRequest(deploymentId, contentLength, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Transcribes audio into the input language. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request. + /// The content length of the operation. This needs to be provided by the caller. + /// 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. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + internal virtual Response GetAudioTranscriptionSimpleJson(string deploymentId, long contentLength, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(deploymentId, nameof(deploymentId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("OpenAIClient.GetAudioTranscriptionSimpleJson"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAudioTranscriptionSimpleJsonRequest(deploymentId, contentLength, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Transcribes audio into the input language. + /// Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request. + /// The content length of the operation. This needs to be provided by the caller. + /// This format will return an JSON structure containing an enriched structure with the transcription. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// + internal virtual async Task> GetAudioTranscriptionVerboseJsonAsync(string deploymentId, long contentLength, AudioTranscriptionOptionsVerboseJson audioTranscriptionOptionsVerboseJson, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(deploymentId, nameof(deploymentId)); + Argument.AssertNotNull(audioTranscriptionOptionsVerboseJson, nameof(audioTranscriptionOptionsVerboseJson)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetAudioTranscriptionVerboseJsonAsync(deploymentId, contentLength, audioTranscriptionOptionsVerboseJson.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(AudioTranscriptionVerboseJson.FromResponse(response), response); + } + + /// Transcribes audio into the input language. + /// Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request. + /// The content length of the operation. This needs to be provided by the caller. + /// This format will return an JSON structure containing an enriched structure with the transcription. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// + internal virtual Response GetAudioTranscriptionVerboseJson(string deploymentId, long contentLength, AudioTranscriptionOptionsVerboseJson audioTranscriptionOptionsVerboseJson, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(deploymentId, nameof(deploymentId)); + Argument.AssertNotNull(audioTranscriptionOptionsVerboseJson, nameof(audioTranscriptionOptionsVerboseJson)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetAudioTranscriptionVerboseJson(deploymentId, contentLength, audioTranscriptionOptionsVerboseJson.ToRequestContent(), context); + return Response.FromValue(AudioTranscriptionVerboseJson.FromResponse(response), response); + } + + /// + /// [Protocol Method] Transcribes audio into the input language. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request. + /// The content length of the operation. This needs to be provided by the caller. + /// 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. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + internal virtual async Task GetAudioTranscriptionVerboseJsonAsync(string deploymentId, long contentLength, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(deploymentId, nameof(deploymentId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("OpenAIClient.GetAudioTranscriptionVerboseJson"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAudioTranscriptionVerboseJsonRequest(deploymentId, contentLength, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Transcribes audio into the input language. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request. + /// The content length of the operation. This needs to be provided by the caller. + /// 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. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + internal virtual Response GetAudioTranscriptionVerboseJson(string deploymentId, long contentLength, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(deploymentId, nameof(deploymentId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("OpenAIClient.GetAudioTranscriptionVerboseJson"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAudioTranscriptionVerboseJsonRequest(deploymentId, contentLength, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Transcribes audio into the input language. + /// Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request. + /// The content length of the operation. This needs to be provided by the caller. + /// This will make the response return the transcription as plain/text. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// + internal virtual async Task> GetAudioTranscriptionPlainTextAsync(string deploymentId, long contentLength, AudioTranscriptionOptionsPlainText audioTranscriptionOptionsPlainText, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(deploymentId, nameof(deploymentId)); + Argument.AssertNotNull(audioTranscriptionOptionsPlainText, nameof(audioTranscriptionOptionsPlainText)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetAudioTranscriptionPlainTextAsync(deploymentId, contentLength, audioTranscriptionOptionsPlainText.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(response.Content.ToObjectFromJson(), response); + } + + /// Transcribes audio into the input language. + /// Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request. + /// The content length of the operation. This needs to be provided by the caller. + /// This will make the response return the transcription as plain/text. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// + internal virtual Response GetAudioTranscriptionPlainText(string deploymentId, long contentLength, AudioTranscriptionOptionsPlainText audioTranscriptionOptionsPlainText, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(deploymentId, nameof(deploymentId)); + Argument.AssertNotNull(audioTranscriptionOptionsPlainText, nameof(audioTranscriptionOptionsPlainText)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetAudioTranscriptionPlainText(deploymentId, contentLength, audioTranscriptionOptionsPlainText.ToRequestContent(), context); + return Response.FromValue(response.Content.ToObjectFromJson(), response); + } + + /// + /// [Protocol Method] Transcribes audio into the input language. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request. + /// The content length of the operation. This needs to be provided by the caller. + /// 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. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + internal virtual async Task GetAudioTranscriptionPlainTextAsync(string deploymentId, long contentLength, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(deploymentId, nameof(deploymentId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("OpenAIClient.GetAudioTranscriptionPlainText"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAudioTranscriptionPlainTextRequest(deploymentId, contentLength, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Transcribes audio into the input language. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request. + /// The content length of the operation. This needs to be provided by the caller. + /// 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. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + internal virtual Response GetAudioTranscriptionPlainText(string deploymentId, long contentLength, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(deploymentId, nameof(deploymentId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("OpenAIClient.GetAudioTranscriptionPlainText"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAudioTranscriptionPlainTextRequest(deploymentId, contentLength, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Transcribes audio into the input language. + /// Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request. + /// The content length of the operation. This needs to be provided by the caller. + /// The transcription will be provided in SRT format (SubRip Text) in the form of plain/text. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// + internal virtual async Task> GetAudioTranscriptionSrtAsync(string deploymentId, long contentLength, AudioTranscriptionOptionsSrt audioTranscriptionOptionsSrt, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(deploymentId, nameof(deploymentId)); + Argument.AssertNotNull(audioTranscriptionOptionsSrt, nameof(audioTranscriptionOptionsSrt)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetAudioTranscriptionSrtAsync(deploymentId, contentLength, audioTranscriptionOptionsSrt.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(response.Content.ToObjectFromJson(), response); + } + + /// Transcribes audio into the input language. + /// Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request. + /// The content length of the operation. This needs to be provided by the caller. + /// The transcription will be provided in SRT format (SubRip Text) in the form of plain/text. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// + internal virtual Response GetAudioTranscriptionSrt(string deploymentId, long contentLength, AudioTranscriptionOptionsSrt audioTranscriptionOptionsSrt, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(deploymentId, nameof(deploymentId)); + Argument.AssertNotNull(audioTranscriptionOptionsSrt, nameof(audioTranscriptionOptionsSrt)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetAudioTranscriptionSrt(deploymentId, contentLength, audioTranscriptionOptionsSrt.ToRequestContent(), context); + return Response.FromValue(response.Content.ToObjectFromJson(), response); + } + + /// + /// [Protocol Method] Transcribes audio into the input language. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request. + /// The content length of the operation. This needs to be provided by the caller. + /// 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. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + internal virtual async Task GetAudioTranscriptionSrtAsync(string deploymentId, long contentLength, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(deploymentId, nameof(deploymentId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("OpenAIClient.GetAudioTranscriptionSrt"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAudioTranscriptionSrtRequest(deploymentId, contentLength, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Transcribes audio into the input language. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request. + /// The content length of the operation. This needs to be provided by the caller. + /// 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. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + internal virtual Response GetAudioTranscriptionSrt(string deploymentId, long contentLength, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(deploymentId, nameof(deploymentId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("OpenAIClient.GetAudioTranscriptionSrt"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAudioTranscriptionSrtRequest(deploymentId, contentLength, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Transcribes audio into the input language. + /// Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request. + /// The content length of the operation. This needs to be provided by the caller. + /// The transcription will be provided in VTT format (Web Video Text Tracks) in the form of plain/text. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// + internal virtual async Task> GetAudioTranscriptionVttAsync(string deploymentId, long contentLength, AudioTranscriptionOptionsVtt audioTranscriptionOptionsVtt, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(deploymentId, nameof(deploymentId)); + Argument.AssertNotNull(audioTranscriptionOptionsVtt, nameof(audioTranscriptionOptionsVtt)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetAudioTranscriptionVttAsync(deploymentId, contentLength, audioTranscriptionOptionsVtt.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(response.Content.ToObjectFromJson(), response); + } + + /// Transcribes audio into the input language. + /// Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request. + /// The content length of the operation. This needs to be provided by the caller. + /// The transcription will be provided in VTT format (Web Video Text Tracks) in the form of plain/text. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// + internal virtual Response GetAudioTranscriptionVtt(string deploymentId, long contentLength, AudioTranscriptionOptionsVtt audioTranscriptionOptionsVtt, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(deploymentId, nameof(deploymentId)); + Argument.AssertNotNull(audioTranscriptionOptionsVtt, nameof(audioTranscriptionOptionsVtt)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetAudioTranscriptionVtt(deploymentId, contentLength, audioTranscriptionOptionsVtt.ToRequestContent(), context); + return Response.FromValue(response.Content.ToObjectFromJson(), response); + } + + /// + /// [Protocol Method] Transcribes audio into the input language. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request. + /// The content length of the operation. This needs to be provided by the caller. + /// 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. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + internal virtual async Task GetAudioTranscriptionVttAsync(string deploymentId, long contentLength, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(deploymentId, nameof(deploymentId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("OpenAIClient.GetAudioTranscriptionVtt"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAudioTranscriptionVttRequest(deploymentId, contentLength, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Transcribes audio into the input language. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request. + /// The content length of the operation. This needs to be provided by the caller. + /// 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. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + internal virtual Response GetAudioTranscriptionVtt(string deploymentId, long contentLength, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(deploymentId, nameof(deploymentId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("OpenAIClient.GetAudioTranscriptionVtt"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAudioTranscriptionVttRequest(deploymentId, contentLength, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Transcribes and translates input audio into English text. + /// Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request. + /// The content length of the operation. This needs to be provided by the caller. + /// This format will return an JSON structure containing a single "text" with the translation. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// + internal virtual async Task> GetAudioTranslationSimpleJsonAsync(string deploymentId, long contentLength, AudioTranslationOptionsSimpleJson audioTranslationOptionsSimpleJson, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(deploymentId, nameof(deploymentId)); + Argument.AssertNotNull(audioTranslationOptionsSimpleJson, nameof(audioTranslationOptionsSimpleJson)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetAudioTranslationSimpleJsonAsync(deploymentId, contentLength, audioTranslationOptionsSimpleJson.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(AudioTranscriptionSimpleJson.FromResponse(response), response); + } + + /// Transcribes and translates input audio into English text. + /// Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request. + /// The content length of the operation. This needs to be provided by the caller. + /// This format will return an JSON structure containing a single "text" with the translation. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// + internal virtual Response GetAudioTranslationSimpleJson(string deploymentId, long contentLength, AudioTranslationOptionsSimpleJson audioTranslationOptionsSimpleJson, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(deploymentId, nameof(deploymentId)); + Argument.AssertNotNull(audioTranslationOptionsSimpleJson, nameof(audioTranslationOptionsSimpleJson)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetAudioTranslationSimpleJson(deploymentId, contentLength, audioTranslationOptionsSimpleJson.ToRequestContent(), context); + return Response.FromValue(AudioTranscriptionSimpleJson.FromResponse(response), response); + } + + /// + /// [Protocol Method] Transcribes and translates input audio into English text. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request. + /// The content length of the operation. This needs to be provided by the caller. + /// 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. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + internal virtual async Task GetAudioTranslationSimpleJsonAsync(string deploymentId, long contentLength, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(deploymentId, nameof(deploymentId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("OpenAIClient.GetAudioTranslationSimpleJson"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAudioTranslationSimpleJsonRequest(deploymentId, contentLength, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Transcribes and translates input audio into English text. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request. + /// The content length of the operation. This needs to be provided by the caller. + /// 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. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + internal virtual Response GetAudioTranslationSimpleJson(string deploymentId, long contentLength, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(deploymentId, nameof(deploymentId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("OpenAIClient.GetAudioTranslationSimpleJson"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAudioTranslationSimpleJsonRequest(deploymentId, contentLength, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Transcribes and translates input audio into English text. + /// Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request. + /// The content length of the operation. This needs to be provided by the caller. + /// This format will return an JSON structure containing an enriched structure with the translation. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// + internal virtual async Task> GetAudioTranslationVerboseJsonAsync(string deploymentId, long contentLength, AudioTranslationOptionsVerboseJson audioTranslationOptionsVerboseJson, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(deploymentId, nameof(deploymentId)); + Argument.AssertNotNull(audioTranslationOptionsVerboseJson, nameof(audioTranslationOptionsVerboseJson)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetAudioTranslationVerboseJsonAsync(deploymentId, contentLength, audioTranslationOptionsVerboseJson.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(AudioTranscriptionVerboseJson.FromResponse(response), response); + } + + /// Transcribes and translates input audio into English text. + /// Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request. + /// The content length of the operation. This needs to be provided by the caller. + /// This format will return an JSON structure containing an enriched structure with the translation. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// + internal virtual Response GetAudioTranslationVerboseJson(string deploymentId, long contentLength, AudioTranslationOptionsVerboseJson audioTranslationOptionsVerboseJson, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(deploymentId, nameof(deploymentId)); + Argument.AssertNotNull(audioTranslationOptionsVerboseJson, nameof(audioTranslationOptionsVerboseJson)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetAudioTranslationVerboseJson(deploymentId, contentLength, audioTranslationOptionsVerboseJson.ToRequestContent(), context); + return Response.FromValue(AudioTranscriptionVerboseJson.FromResponse(response), response); + } + + /// + /// [Protocol Method] Transcribes and translates input audio into English text. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request. + /// The content length of the operation. This needs to be provided by the caller. + /// 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. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + internal virtual async Task GetAudioTranslationVerboseJsonAsync(string deploymentId, long contentLength, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(deploymentId, nameof(deploymentId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("OpenAIClient.GetAudioTranslationVerboseJson"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAudioTranslationVerboseJsonRequest(deploymentId, contentLength, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Transcribes and translates input audio into English text. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request. + /// The content length of the operation. This needs to be provided by the caller. + /// 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. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + internal virtual Response GetAudioTranslationVerboseJson(string deploymentId, long contentLength, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(deploymentId, nameof(deploymentId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("OpenAIClient.GetAudioTranslationVerboseJson"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAudioTranslationVerboseJsonRequest(deploymentId, contentLength, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Transcribes and translates input audio into English text. + /// Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request. + /// The content length of the operation. This needs to be provided by the caller. + /// This will make the response return the translation as plain/text. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// + internal virtual async Task> GetAudioTranslationPlainTextAsync(string deploymentId, long contentLength, AudioTranslationOptionsPlainText audioTranslationOptionsPlainText, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(deploymentId, nameof(deploymentId)); + Argument.AssertNotNull(audioTranslationOptionsPlainText, nameof(audioTranslationOptionsPlainText)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetAudioTranslationPlainTextAsync(deploymentId, contentLength, audioTranslationOptionsPlainText.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(response.Content.ToObjectFromJson(), response); + } + + /// Transcribes and translates input audio into English text. + /// Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request. + /// The content length of the operation. This needs to be provided by the caller. + /// This will make the response return the translation as plain/text. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// + internal virtual Response GetAudioTranslationPlainText(string deploymentId, long contentLength, AudioTranslationOptionsPlainText audioTranslationOptionsPlainText, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(deploymentId, nameof(deploymentId)); + Argument.AssertNotNull(audioTranslationOptionsPlainText, nameof(audioTranslationOptionsPlainText)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetAudioTranslationPlainText(deploymentId, contentLength, audioTranslationOptionsPlainText.ToRequestContent(), context); + return Response.FromValue(response.Content.ToObjectFromJson(), response); + } + + /// + /// [Protocol Method] Transcribes and translates input audio into English text. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request. + /// The content length of the operation. This needs to be provided by the caller. + /// 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. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + internal virtual async Task GetAudioTranslationPlainTextAsync(string deploymentId, long contentLength, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(deploymentId, nameof(deploymentId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("OpenAIClient.GetAudioTranslationPlainText"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAudioTranslationPlainTextRequest(deploymentId, contentLength, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Transcribes and translates input audio into English text. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request. + /// The content length of the operation. This needs to be provided by the caller. + /// 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. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + internal virtual Response GetAudioTranslationPlainText(string deploymentId, long contentLength, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(deploymentId, nameof(deploymentId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("OpenAIClient.GetAudioTranslationPlainText"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAudioTranslationPlainTextRequest(deploymentId, contentLength, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Transcribes and translates input audio into English text. + /// Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request. + /// The content length of the operation. This needs to be provided by the caller. + /// The translation will be provided in SRT format (SubRip Text) in the form of plain/text. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// + internal virtual async Task> GetAudioTranslationSrtAsync(string deploymentId, long contentLength, AudioTranslationOptionsSrt audioTranslationOptionsSrt, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(deploymentId, nameof(deploymentId)); + Argument.AssertNotNull(audioTranslationOptionsSrt, nameof(audioTranslationOptionsSrt)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetAudioTranslationSrtAsync(deploymentId, contentLength, audioTranslationOptionsSrt.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(response.Content.ToObjectFromJson(), response); + } + + /// Transcribes and translates input audio into English text. + /// Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request. + /// The content length of the operation. This needs to be provided by the caller. + /// The translation will be provided in SRT format (SubRip Text) in the form of plain/text. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// + internal virtual Response GetAudioTranslationSrt(string deploymentId, long contentLength, AudioTranslationOptionsSrt audioTranslationOptionsSrt, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(deploymentId, nameof(deploymentId)); + Argument.AssertNotNull(audioTranslationOptionsSrt, nameof(audioTranslationOptionsSrt)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetAudioTranslationSrt(deploymentId, contentLength, audioTranslationOptionsSrt.ToRequestContent(), context); + return Response.FromValue(response.Content.ToObjectFromJson(), response); + } + + /// + /// [Protocol Method] Transcribes and translates input audio into English text. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request. + /// The content length of the operation. This needs to be provided by the caller. + /// 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. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + internal virtual async Task GetAudioTranslationSrtAsync(string deploymentId, long contentLength, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(deploymentId, nameof(deploymentId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("OpenAIClient.GetAudioTranslationSrt"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAudioTranslationSrtRequest(deploymentId, contentLength, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Transcribes and translates input audio into English text. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request. + /// The content length of the operation. This needs to be provided by the caller. + /// 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. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + internal virtual Response GetAudioTranslationSrt(string deploymentId, long contentLength, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(deploymentId, nameof(deploymentId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("OpenAIClient.GetAudioTranslationSrt"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAudioTranslationSrtRequest(deploymentId, contentLength, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Transcribes and translates input audio into English text. + /// Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request. + /// The content length of the operation. This needs to be provided by the caller. + /// The translation will be provided in VTT format (Web Video Text Tracks) in the form of plain/text. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// + internal virtual async Task> GetAudioTranslationVttAsync(string deploymentId, long contentLength, AudioTranslationOptionsVtt audioTranslationOptionsVtt, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(deploymentId, nameof(deploymentId)); + Argument.AssertNotNull(audioTranslationOptionsVtt, nameof(audioTranslationOptionsVtt)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetAudioTranslationVttAsync(deploymentId, contentLength, audioTranslationOptionsVtt.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(response.Content.ToObjectFromJson(), response); + } + + /// Transcribes and translates input audio into English text. + /// Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request. + /// The content length of the operation. This needs to be provided by the caller. + /// The translation will be provided in VTT format (Web Video Text Tracks) in the form of plain/text. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// + internal virtual Response GetAudioTranslationVtt(string deploymentId, long contentLength, AudioTranslationOptionsVtt audioTranslationOptionsVtt, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(deploymentId, nameof(deploymentId)); + Argument.AssertNotNull(audioTranslationOptionsVtt, nameof(audioTranslationOptionsVtt)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetAudioTranslationVtt(deploymentId, contentLength, audioTranslationOptionsVtt.ToRequestContent(), context); + return Response.FromValue(response.Content.ToObjectFromJson(), response); + } + + /// + /// [Protocol Method] Transcribes and translates input audio into English text. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request. + /// The content length of the operation. This needs to be provided by the caller. + /// 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. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + internal virtual async Task GetAudioTranslationVttAsync(string deploymentId, long contentLength, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(deploymentId, nameof(deploymentId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("OpenAIClient.GetAudioTranslationVtt"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAudioTranslationVttRequest(deploymentId, contentLength, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Transcribes and translates input audio into English text. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// Specifies either the model deployment name (when using Azure OpenAI) or model name (when using non-Azure OpenAI) to use for this request. + /// The content length of the operation. This needs to be provided by the caller. + /// 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. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + internal virtual Response GetAudioTranslationVtt(string deploymentId, long contentLength, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(deploymentId, nameof(deploymentId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("OpenAIClient.GetAudioTranslationVtt"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAudioTranslationVttRequest(deploymentId, contentLength, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + /// /// Gets chat completions for the provided chat messages. /// This is an Azure-specific version of chat completions that supports integration with configured data sources and @@ -289,6 +1509,206 @@ internal virtual Operation BeginAzureBatchImageGeneration(WaitUntil } } + internal HttpMessage CreateGetAudioTranscriptionSimpleJsonRequest(string deploymentId, long contentLength, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRaw("/openai", false); + uri.AppendPath("/deployments/", false); + uri.AppendPath(deploymentId, true); + uri.AppendPath("/audio/transcriptions", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("content-length", contentLength); + request.Headers.Add("content-type", "multipart/form-data;"); + request.Content = content; + return message; + } + + internal HttpMessage CreateGetAudioTranscriptionVerboseJsonRequest(string deploymentId, long contentLength, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRaw("/openai", false); + uri.AppendPath("/deployments/", false); + uri.AppendPath(deploymentId, true); + uri.AppendPath("/audio/transcriptions", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("content-length", contentLength); + request.Headers.Add("content-type", "multipart/form-data;"); + request.Content = content; + return message; + } + + internal HttpMessage CreateGetAudioTranscriptionPlainTextRequest(string deploymentId, long contentLength, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRaw("/openai", false); + uri.AppendPath("/deployments/", false); + uri.AppendPath(deploymentId, true); + uri.AppendPath("/audio/transcriptions", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("content-length", contentLength); + request.Headers.Add("content-type", "multipart/form-data;"); + request.Content = content; + return message; + } + + internal HttpMessage CreateGetAudioTranscriptionSrtRequest(string deploymentId, long contentLength, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRaw("/openai", false); + uri.AppendPath("/deployments/", false); + uri.AppendPath(deploymentId, true); + uri.AppendPath("/audio/transcriptions", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("content-length", contentLength); + request.Headers.Add("content-type", "multipart/form-data;"); + request.Content = content; + return message; + } + + internal HttpMessage CreateGetAudioTranscriptionVttRequest(string deploymentId, long contentLength, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRaw("/openai", false); + uri.AppendPath("/deployments/", false); + uri.AppendPath(deploymentId, true); + uri.AppendPath("/audio/transcriptions", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("content-length", contentLength); + request.Headers.Add("content-type", "multipart/form-data;"); + request.Content = content; + return message; + } + + internal HttpMessage CreateGetAudioTranslationSimpleJsonRequest(string deploymentId, long contentLength, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRaw("/openai", false); + uri.AppendPath("/deployments/", false); + uri.AppendPath(deploymentId, true); + uri.AppendPath("/audio/translations", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("content-length", contentLength); + request.Headers.Add("content-type", "multipart/form-data;"); + request.Content = content; + return message; + } + + internal HttpMessage CreateGetAudioTranslationVerboseJsonRequest(string deploymentId, long contentLength, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRaw("/openai", false); + uri.AppendPath("/deployments/", false); + uri.AppendPath(deploymentId, true); + uri.AppendPath("/audio/translations", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("content-length", contentLength); + request.Headers.Add("content-type", "multipart/form-data;"); + request.Content = content; + return message; + } + + internal HttpMessage CreateGetAudioTranslationPlainTextRequest(string deploymentId, long contentLength, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRaw("/openai", false); + uri.AppendPath("/deployments/", false); + uri.AppendPath(deploymentId, true); + uri.AppendPath("/audio/translations", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("content-length", contentLength); + request.Headers.Add("content-type", "multipart/form-data;"); + request.Content = content; + return message; + } + + internal HttpMessage CreateGetAudioTranslationSrtRequest(string deploymentId, long contentLength, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRaw("/openai", false); + uri.AppendPath("/deployments/", false); + uri.AppendPath(deploymentId, true); + uri.AppendPath("/audio/translations", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("content-length", contentLength); + request.Headers.Add("content-type", "multipart/form-data;"); + request.Content = content; + return message; + } + + internal HttpMessage CreateGetAudioTranslationVttRequest(string deploymentId, long contentLength, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRaw("/openai", false); + uri.AppendPath("/deployments/", false); + uri.AppendPath(deploymentId, true); + uri.AppendPath("/audio/translations", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("content-length", contentLength); + request.Headers.Add("content-type", "multipart/form-data;"); + request.Content = content; + return message; + } + internal HttpMessage CreateGetChatCompletionsWithAzureExtensionsRequest(string deploymentId, RequestContent content, RequestContext context) { var message = _pipeline.CreateMessage(context, ResponseClassifier200); diff --git a/sdk/openai/Azure.AI.OpenAI/src/Generated/OpenAIClientOptions.cs b/sdk/openai/Azure.AI.OpenAI/src/Generated/OpenAIClientOptions.cs index 87efb20e9fd4..6726ebc738e1 100644 --- a/sdk/openai/Azure.AI.OpenAI/src/Generated/OpenAIClientOptions.cs +++ b/sdk/openai/Azure.AI.OpenAI/src/Generated/OpenAIClientOptions.cs @@ -13,7 +13,7 @@ namespace Azure.AI.OpenAI /// Client options for OpenAIClient. public partial class OpenAIClientOptions : ClientOptions { - private const ServiceVersion LatestVersion = ServiceVersion.V2023_08_01_Preview; + private const ServiceVersion LatestVersion = ServiceVersion.V2023_09_01_Preview; /// The version of the service to use. public enum ServiceVersion @@ -28,6 +28,8 @@ public enum ServiceVersion V2023_07_01_Preview = 4, /// Service version "2023-08-01-preview". V2023_08_01_Preview = 5, + /// Service version "2023-09-01-preview". + V2023_09_01_Preview = 6, } internal string Version { get; } @@ -42,6 +44,7 @@ public OpenAIClientOptions(ServiceVersion version = LatestVersion) ServiceVersion.V2023_06_01_Preview => "2023-06-01-preview", ServiceVersion.V2023_07_01_Preview => "2023-07-01-preview", ServiceVersion.V2023_08_01_Preview => "2023-08-01-preview", + ServiceVersion.V2023_09_01_Preview => "2023-09-01-preview", _ => throw new NotSupportedException() }; } 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 461671ba7684..2b2f3f25f2da 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 @@ -19,22 +19,6 @@ namespace Azure.AI.OpenAI.Samples { public class Samples_OpenAIClient { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_GetEmbeddings_Convenience_Async() - { - var client = new OpenAIClient(""); - - var embeddingsOptions = new EmbeddingsOptions(new string[] - { - "" - }) - { - User = "", - }; - var result = await client.GetEmbeddingsAsync("", embeddingsOptions); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Example_GetCompletions_Convenience_Async() @@ -63,5 +47,21 @@ public async Task Example_GetCompletions_Convenience_Async() }; var result = await client.GetCompletionsAsync("", completionsOptions); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_GetEmbeddings_Convenience_Async() + { + var client = new OpenAIClient(""); + + var embeddingsOptions = new EmbeddingsOptions(new string[] + { + "" + }) + { + User = "", + }; + var result = await client.GetEmbeddingsAsync("", embeddingsOptions); + } } } diff --git a/sdk/openai/Azure.AI.OpenAI/tsp-location.yaml b/sdk/openai/Azure.AI.OpenAI/tsp-location.yaml index 2246c7155e2f..0f36b4fb2f77 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: b646a42aa3b7a0ce488d05f1724827ea41d12cf1 +additionalDirectories: [] repo: Azure/azure-rest-api-specs +directory: specification/cognitiveservices/OpenAI.Inference +commit: 843f0beacfc01cdcd102cc52fd39f881d5aa402a +