diff --git a/.dotnet.azure/.gitignore b/.dotnet.azure/.gitignore new file mode 100644 index 000000000..f72a03698 --- /dev/null +++ b/.dotnet.azure/.gitignore @@ -0,0 +1,3 @@ +# Artifacts from the generator +sdk/openai/Azure.AI.OpenAI/tspCodeModel.json +sdk/openai/Azure.AI.OpenAI/Configuration.json diff --git a/.dotnet.azure/sdk/openai/.gitignore b/.dotnet.azure/sdk/openai/.gitignore deleted file mode 100644 index 5e5364f16..000000000 --- a/.dotnet.azure/sdk/openai/.gitignore +++ /dev/null @@ -1 +0,0 @@ -#Azure.AI.OpenAI/Directory.Build.props \ No newline at end of file diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/Internal/InternalElasticsearchChatDataSourceParameters.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/Internal/InternalElasticsearchChatDataSourceParameters.cs index 6849475ba..83490d49d 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/Internal/InternalElasticsearchChatDataSourceParameters.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/Internal/InternalElasticsearchChatDataSourceParameters.cs @@ -11,17 +11,17 @@ namespace Azure.AI.OpenAI.Chat; internal partial class InternalElasticsearchChatDataSourceParameters { [CodeGenMember("IncludeContexts")] - private IList _internalIncludeContexts = new ChangeTrackingList(); + private IList InternalIncludeContexts { get; set; } = new ChangeTrackingList(); private DataSourceOutputContexts? _outputContexts; /// public DataSourceOutputContexts? OutputContexts { - get => DataSourceOutputContextsExtensions.FromStringList(_internalIncludeContexts); + get => DataSourceOutputContextsExtensions.FromStringList(InternalIncludeContexts); internal set { _outputContexts = value; - _internalIncludeContexts = _outputContexts?.ToStringList(); + InternalIncludeContexts = _outputContexts?.ToStringList(); } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/OnYourData/AzureAISearchChatDataSource.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/OnYourData/AzureAISearchChatDataSource.cs index 6bd1abc36..395d1e9e2 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/OnYourData/AzureAISearchChatDataSource.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/OnYourData/AzureAISearchChatDataSource.cs @@ -115,7 +115,7 @@ public DataSourceVectorizer VectorizationSource /// /// Creates a new instance of . /// - public AzureSearchChatDataSource() : base(type: "azure_search", serializedAdditionalRawData: null) + public AzureSearchChatDataSource() : base(type: "azure_search", additionalBinaryDataProperties: null) { InternalParameters = new(); } @@ -132,11 +132,11 @@ internal AzureSearchChatDataSource(InternalAzureSearchChatDataSourceParameters i /// Initializes a new instance of . /// - /// Keeps track of any properties unknown to the library. + /// Keeps track of any properties unknown to the library. /// The parameter information to control the use of the Azure Search data source. [SetsRequiredMembers] - internal AzureSearchChatDataSource(string type, IDictionary serializedAdditionalRawData, InternalAzureSearchChatDataSourceParameters internalParameters) - : base(type, serializedAdditionalRawData) + internal AzureSearchChatDataSource(string type, IDictionary additionalBinaryDataProperties, InternalAzureSearchChatDataSourceParameters internalParameters) + : base(type, additionalBinaryDataProperties) { InternalParameters = internalParameters; } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/OnYourData/CosmosChatDataSource.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/OnYourData/CosmosChatDataSource.cs index 26d8f3d53..5e1442726 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/OnYourData/CosmosChatDataSource.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/OnYourData/CosmosChatDataSource.cs @@ -101,7 +101,7 @@ public DataSourceOutputContexts? OutputContexts /// /// Initializes a new instance of . /// - public CosmosChatDataSource() : base(type: "azure_cosmos_db", serializedAdditionalRawData: null) + public CosmosChatDataSource() : base(type: "azure_cosmos_db", additionalBinaryDataProperties: null) { InternalParameters = new(); } @@ -118,11 +118,11 @@ internal CosmosChatDataSource(InternalAzureCosmosDBChatDataSourceParameters inte /// Initializes a new instance of . /// - /// Keeps track of any properties unknown to the library. + /// Keeps track of any properties unknown to the library. /// The parameter information to control the use of the Azure Search data source. [SetsRequiredMembers] - internal CosmosChatDataSource(string type, IDictionary serializedAdditionalRawData, InternalAzureCosmosDBChatDataSourceParameters internalParameters) - : base(type, serializedAdditionalRawData) + internal CosmosChatDataSource(string type, IDictionary additionalBinaryDataProperties, InternalAzureCosmosDBChatDataSourceParameters internalParameters) + : base(type, additionalBinaryDataProperties) { InternalParameters = internalParameters; } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/OnYourData/ElasticsearchChatDataSource.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/OnYourData/ElasticsearchChatDataSource.cs index fca284581..384ad4730 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/OnYourData/ElasticsearchChatDataSource.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/OnYourData/ElasticsearchChatDataSource.cs @@ -104,7 +104,7 @@ public DataSourceVectorizer VectorizationSource set => InternalParameters.VectorizationSource = value; } - public ElasticsearchChatDataSource() : base(type: "elasticsearch", serializedAdditionalRawData: null) + public ElasticsearchChatDataSource() : base(type: "elasticsearch", additionalBinaryDataProperties: null) { InternalParameters = new(); } @@ -129,11 +129,11 @@ internal ElasticsearchChatDataSource(InternalElasticsearchChatDataSourceParamete /// Initializes a new instance of . /// - /// Keeps track of any properties unknown to the library. + /// Keeps track of any properties unknown to the library. /// The parameter information to control the use of the Azure Search data source. [SetsRequiredMembers] - internal ElasticsearchChatDataSource(string type, IDictionary serializedAdditionalRawData, InternalElasticsearchChatDataSourceParameters internalParameters) - : base(type, serializedAdditionalRawData) + internal ElasticsearchChatDataSource(string type, IDictionary additionalBinaryDataProperties, InternalElasticsearchChatDataSourceParameters internalParameters) + : base(type, additionalBinaryDataProperties) { InternalParameters = internalParameters; } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/OnYourData/MongoDBChatDataSource.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/OnYourData/MongoDBChatDataSource.cs index e3fb59e1d..e9232b32d 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/OnYourData/MongoDBChatDataSource.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/OnYourData/MongoDBChatDataSource.cs @@ -106,7 +106,7 @@ public DataSourceVectorizer VectorizationSource /// /// Creates a new instance of . /// - public MongoDBChatDataSource() : base(type: "mongo_db", serializedAdditionalRawData: null) + public MongoDBChatDataSource() : base(type: "mongo_db", additionalBinaryDataProperties: null) { InternalParameters = new(); } @@ -131,11 +131,11 @@ internal MongoDBChatDataSource(InternalMongoDBChatDataSourceParameters internalP /// Initializes a new instance of . /// - /// Keeps track of any properties unknown to the library. + /// Keeps track of any properties unknown to the library. /// The parameter information to control the use of the Azure Search data source. [SetsRequiredMembers] - internal MongoDBChatDataSource(string type, IDictionary serializedAdditionalRawData, InternalMongoDBChatDataSourceParameters internalParameters) - : base(type, serializedAdditionalRawData) + internal MongoDBChatDataSource(string type, IDictionary additionalBinaryDataProperties, InternalMongoDBChatDataSourceParameters internalParameters) + : base(type, additionalBinaryDataProperties) { InternalParameters = internalParameters; } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/OnYourData/PineconeChatDataSource.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/OnYourData/PineconeChatDataSource.cs index 33c2cb95e..67f42132c 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/OnYourData/PineconeChatDataSource.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Chat/OnYourData/PineconeChatDataSource.cs @@ -97,7 +97,7 @@ public DataSourceOutputContexts? OutputContexts set => InternalParameters.OutputContexts = value; } - public PineconeChatDataSource() : base(type: "pinecone", serializedAdditionalRawData: null) + public PineconeChatDataSource() : base(type: "pinecone", additionalBinaryDataProperties: null) { InternalParameters = new(); } @@ -122,11 +122,11 @@ internal PineconeChatDataSource(InternalPineconeChatDataSourceParameters interna /// Initializes a new instance of . /// - /// Keeps track of any properties unknown to the library. + /// Keeps track of any properties unknown to the library. /// The parameter information to control the use of the Azure Search data source. [SetsRequiredMembers] - internal PineconeChatDataSource(string type, IDictionary serializedAdditionalRawData, InternalPineconeChatDataSourceParameters internalParameters) - : base(type, serializedAdditionalRawData) + internal PineconeChatDataSource(string type, IDictionary additionalBinaryDataProperties, InternalPineconeChatDataSourceParameters internalParameters) + : base(type, additionalBinaryDataProperties) { InternalParameters = internalParameters; } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Common/AdditionalPropertyHelpers.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Common/AdditionalPropertyHelpers.cs index 2658db88a..b724d26f2 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Common/AdditionalPropertyHelpers.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Common/AdditionalPropertyHelpers.cs @@ -20,7 +20,7 @@ private static T GetAdditionalProperty(IDictionary additi } using JsonDocument document = JsonDocument.Parse(additionalPropertyValue); - return deserializeFunction(document.RootElement, null); + return deserializeFunction(document.RootElement, ModelSerializationExtensions.WireOptions); } private static IList GetAdditionalPropertyAsList(IDictionary additionalProperties, string additionalPropertyKey, Func deserializeFunction) where T : class, IJsonModel @@ -35,7 +35,7 @@ private static IList GetAdditionalPropertyAsList(IDictionary serializedAdditionalRawData = default; + IDictionary additionalBinaryDataProperties = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { @@ -47,7 +47,7 @@ internal static RequestContentFilterResult DeserializeContentFilterResultForProm rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new RequestContentFilterResult(promptIndex, contentFilterResults, serializedAdditionalRawData); + additionalBinaryDataProperties = rawDataDictionary; + return new RequestContentFilterResult(promptIndex, contentFilterResults, additionalBinaryDataProperties); } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Files/AzureFileClient.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Files/AzureFileClient.cs index 5948dbd4f..dc68a126d 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Files/AzureFileClient.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Files/AzureFileClient.cs @@ -47,7 +47,7 @@ public override ClientResult UploadFile(Stream file, string filename Argument.AssertNotNull(file, "file"); Argument.AssertNotNullOrEmpty(filename, "filename"); - using MultipartFormDataBinaryContent content = CreateMultiPartContentWithMimeType(file, filename, purpose); + using MultiPartFormDataBinaryContent content = CreateMultiPartContentWithMimeType(file, filename, purpose); ClientResult clientResult = UploadFile(content, content.ContentType, new() { CancellationToken = cancellationToken }); return GetAzureFileResult(clientResult); @@ -66,7 +66,7 @@ public override async Task> UploadFileAsync(Stream file Argument.AssertNotNull(file, "file"); Argument.AssertNotNullOrEmpty(filename, "filename"); - using MultipartFormDataBinaryContent content = CreateMultiPartContentWithMimeType(file, filename, purpose); + using MultiPartFormDataBinaryContent content = CreateMultiPartContentWithMimeType(file, filename, purpose); ClientResult result = await UploadFileAsync(content, content.ContentType, new() { CancellationToken = cancellationToken }) .ConfigureAwait(continueOnCapturedContext: false); return GetAzureFileResult(result); @@ -108,9 +108,9 @@ public override ClientResult GetFiles(FilePurpose purpose, return GetTypedResult(protocolResult, AzureOpenAIFileCollection.FromResponse); } - private MultipartFormDataBinaryContent CreateMultiPartContentWithMimeType(Stream file, string filename, FileUploadPurpose purpose) + private MultiPartFormDataBinaryContent CreateMultiPartContentWithMimeType(Stream file, string filename, FileUploadPurpose purpose) { - MultipartFormDataBinaryContent multipartFormDataBinaryContent = new MultipartFormDataBinaryContent(); + MultiPartFormDataBinaryContent multipartFormDataBinaryContent = new(); string contentType = "text/plain"; if (purpose == FileUploadPurpose.Batch) { diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Files/AzureOpenAIFile.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Files/AzureOpenAIFile.Serialization.cs index bbed5e234..629c0afbc 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Files/AzureOpenAIFile.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Files/AzureOpenAIFile.Serialization.cs @@ -97,7 +97,7 @@ internal static AzureOpenAIFile DeserializeAzureOpenAIFile(JsonElement element, string purpose = default; string statusDetails = default; AzureOpenAIFileStatus status = default; - IDictionary serializedAdditionalRawData = default; + IDictionary additionalBinaryDataProperties = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { @@ -152,7 +152,7 @@ internal static AzureOpenAIFile DeserializeAzureOpenAIFile(JsonElement element, rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; + additionalBinaryDataProperties = rawDataDictionary; return new AzureOpenAIFile( id, bytes, @@ -162,7 +162,7 @@ internal static AzureOpenAIFile DeserializeAzureOpenAIFile(JsonElement element, purpose, statusDetails, status, - serializedAdditionalRawData); + additionalBinaryDataProperties); } void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Files/AzureOpenAIFile.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Files/AzureOpenAIFile.cs index e911e77d3..c4c26e6ce 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Files/AzureOpenAIFile.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Files/AzureOpenAIFile.cs @@ -75,9 +75,9 @@ internal AzureOpenAIFile(string id, int? bytes, DateTimeOffset createdAt, string /// The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results` and `vision`. /// Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`. /// - /// Keeps track of any properties unknown to the library. - internal AzureOpenAIFile(string id, int? bytes, DateTimeOffset createdAt, string filename, InternalOpenAIFileObject @object, string purpose, string statusDetails, AzureOpenAIFileStatus azureStatus, IDictionary serializedAdditionalRawData) - : base(id, createdAt, filename, purpose.ToFilePurpose(), @object, bytes, azureStatus.ToFileStatus(), statusDetails, serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal AzureOpenAIFile(string id, int? bytes, DateTimeOffset createdAt, string filename, InternalOpenAIFileObject @object, string purpose, string statusDetails, AzureOpenAIFileStatus azureStatus, IDictionary additionalBinaryDataProperties) + : base(id, createdAt, filename, purpose.ToFilePurpose(), @object, bytes, azureStatus.ToFileStatus(), statusDetails, additionalBinaryDataProperties) { _object = @object.ToString(); _purpose = purpose; diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Internal/AzureOpenAIChatError.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Internal/AzureOpenAIChatError.cs index 0940684db..7bb381e75 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Internal/AzureOpenAIChatError.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Internal/AzureOpenAIChatError.cs @@ -18,7 +18,7 @@ internal static AzureOpenAIChatError TryCreateFromResponse(PipelineResponse resp { using JsonDocument errorDocument = JsonDocument.Parse(response.Content); AzureOpenAIChatErrorResponse errorResponse - = AzureOpenAIChatErrorResponse.DeserializeAzureOpenAIChatErrorResponse(errorDocument.RootElement); + = AzureOpenAIChatErrorResponse.DeserializeAzureOpenAIChatErrorResponse(errorDocument.RootElement, ModelSerializationExtensions.WireOptions); return errorResponse.Error; } catch (InvalidOperationException) diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Internal/AzureOpenAIDalleError.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Internal/AzureOpenAIDalleError.cs index a6bdb5975..bc0988c81 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Internal/AzureOpenAIDalleError.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Custom/Internal/AzureOpenAIDalleError.cs @@ -18,7 +18,7 @@ internal static AzureOpenAIDalleError TryCreateFromResponse(PipelineResponse res { using JsonDocument errorDocument = JsonDocument.Parse(response.Content); AzureOpenAIDalleErrorResponse errorResponse - = AzureOpenAIDalleErrorResponse.DeserializeAzureOpenAIDalleErrorResponse(errorDocument.RootElement); + = AzureOpenAIDalleErrorResponse.DeserializeAzureOpenAIDalleErrorResponse(errorDocument.RootElement, ModelSerializationExtensions.WireOptions); return errorResponse.Error; } catch (InvalidOperationException) diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIChatError.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIChatError.cs deleted file mode 100644 index b379c88ac..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIChatError.cs +++ /dev/null @@ -1,77 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI -{ - /// The structured representation of an error from an Azure OpenAI chat completion request. - internal partial class AzureOpenAIChatError - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - internal IDictionary SerializedAdditionalRawData { get; set; } - /// Initializes a new instance of . - internal AzureOpenAIChatError() - { - } - - /// Initializes a new instance of . - /// The distinct, machine-generated identifier for the error. - /// A human-readable message associated with the error. - /// If applicable, the request input parameter associated with the error. - /// If applicable, the input line number associated with the error. - /// If applicable, an upstream error that originated this error. - /// Keeps track of any properties unknown to the library. - internal AzureOpenAIChatError(string code, string message, string param, string type, InternalAzureOpenAIChatErrorInnerError innerError, IDictionary serializedAdditionalRawData) - { - Code = code; - Message = message; - Param = param; - Type = type; - InnerError = innerError; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - /// The distinct, machine-generated identifier for the error. - public string Code { get; } - /// A human-readable message associated with the error. - public string Message { get; } - /// If applicable, the request input parameter associated with the error. - public string Param { get; } - /// If applicable, the input line number associated with the error. - public string Type { get; } - /// If applicable, an upstream error that originated this error. - public InternalAzureOpenAIChatErrorInnerError InnerError { get; } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIChatErrorResponse.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIChatErrorResponse.cs deleted file mode 100644 index 767fce2b0..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIChatErrorResponse.cs +++ /dev/null @@ -1,61 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI -{ - /// A structured representation of an error an Azure OpenAI request. - internal partial class AzureOpenAIChatErrorResponse - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - internal IDictionary SerializedAdditionalRawData { get; set; } - /// Initializes a new instance of . - internal AzureOpenAIChatErrorResponse() - { - } - - /// Initializes a new instance of . - /// - /// Keeps track of any properties unknown to the library. - internal AzureOpenAIChatErrorResponse(AzureOpenAIChatError error, IDictionary serializedAdditionalRawData) - { - Error = error; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Gets the error. - public AzureOpenAIChatError Error { get; } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIDalleError.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIDalleError.cs deleted file mode 100644 index 7dfb2de16..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIDalleError.cs +++ /dev/null @@ -1,77 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI -{ - /// The structured representation of an error from an Azure OpenAI image generation request. - internal partial class AzureOpenAIDalleError - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - internal IDictionary SerializedAdditionalRawData { get; set; } - /// Initializes a new instance of . - internal AzureOpenAIDalleError() - { - } - - /// Initializes a new instance of . - /// The distinct, machine-generated identifier for the error. - /// A human-readable message associated with the error. - /// If applicable, the request input parameter associated with the error. - /// If applicable, the input line number associated with the error. - /// If applicable, an upstream error that originated this error. - /// Keeps track of any properties unknown to the library. - internal AzureOpenAIDalleError(string code, string message, string param, string type, InternalAzureOpenAIDalleErrorInnerError innerError, IDictionary serializedAdditionalRawData) - { - Code = code; - Message = message; - Param = param; - Type = type; - InnerError = innerError; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - /// The distinct, machine-generated identifier for the error. - public string Code { get; } - /// A human-readable message associated with the error. - public string Message { get; } - /// If applicable, the request input parameter associated with the error. - public string Param { get; } - /// If applicable, the input line number associated with the error. - public string Type { get; } - /// If applicable, an upstream error that originated this error. - public InternalAzureOpenAIDalleErrorInnerError InnerError { get; } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIDalleErrorResponse.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIDalleErrorResponse.cs deleted file mode 100644 index 6aafb0c3d..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIDalleErrorResponse.cs +++ /dev/null @@ -1,61 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI -{ - /// A structured representation of an error an Azure OpenAI request. - internal partial class AzureOpenAIDalleErrorResponse - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - internal IDictionary SerializedAdditionalRawData { get; set; } - /// Initializes a new instance of . - internal AzureOpenAIDalleErrorResponse() - { - } - - /// Initializes a new instance of . - /// - /// Keeps track of any properties unknown to the library. - internal AzureOpenAIDalleErrorResponse(AzureOpenAIDalleError error, IDictionary serializedAdditionalRawData) - { - Error = error; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Gets the error. - public AzureOpenAIDalleError Error { get; } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureSearchChatDataSource.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureSearchChatDataSource.Serialization.cs deleted file mode 100644 index b19eb9d33..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureSearchChatDataSource.Serialization.cs +++ /dev/null @@ -1,131 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; - -namespace Azure.AI.OpenAI.Chat -{ - public partial class AzureSearchChatDataSource : IJsonModel - { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - /// The JSON writer. - /// The client options for reading and writing models. - protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(AzureSearchChatDataSource)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - if (SerializedAdditionalRawData?.ContainsKey("parameters") != true) - { - writer.WritePropertyName("parameters"u8); - writer.WriteObjectValue(InternalParameters, options); - } - } - - AzureSearchChatDataSource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(AzureSearchChatDataSource)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeAzureSearchChatDataSource(document.RootElement, options); - } - - internal static AzureSearchChatDataSource DeserializeAzureSearchChatDataSource(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - InternalAzureSearchChatDataSourceParameters parameters = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("parameters"u8)) - { - parameters = InternalAzureSearchChatDataSourceParameters.DeserializeInternalAzureSearchChatDataSourceParameters(property.Value, options); - continue; - } - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new AzureSearchChatDataSource(type, serializedAdditionalRawData, parameters); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(AzureSearchChatDataSource)} does not support writing '{options.Format}' format."); - } - } - - AzureSearchChatDataSource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeAzureSearchChatDataSource(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(AzureSearchChatDataSource)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static new AzureSearchChatDataSource FromResponse(PipelineResponse response) - { - using var document = JsonDocument.Parse(response.Content); - return DeserializeAzureSearchChatDataSource(document.RootElement); - } - - /// Convert into a . - internal override BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatCitation.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatCitation.cs deleted file mode 100644 index 74cd97091..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatCitation.cs +++ /dev/null @@ -1,89 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI.Chat -{ - /// The AzureChatMessageContextCitation. - public partial class ChatCitation - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - internal IDictionary SerializedAdditionalRawData { get; set; } - /// Initializes a new instance of . - /// The content of the citation. - /// is null. - internal ChatCitation(string content) - { - Argument.AssertNotNull(content, nameof(content)); - - Content = content; - } - - /// Initializes a new instance of . - /// The content of the citation. - /// The title for the citation. - /// The URL of the citation. - /// The file path for the citation. - /// The chunk ID for the citation. - /// The rerank score for the retrieval. - /// Keeps track of any properties unknown to the library. - internal ChatCitation(string content, string title, string url, string filePath, string chunkId, double? rerankScore, IDictionary serializedAdditionalRawData) - { - Content = content; - Title = title; - Url = url; - FilePath = filePath; - ChunkId = chunkId; - RerankScore = rerankScore; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal ChatCitation() - { - } - - /// The content of the citation. - public string Content { get; } - /// The title for the citation. - public string Title { get; } - /// The URL of the citation. - public string Url { get; } - /// The chunk ID for the citation. - public string ChunkId { get; } - /// The rerank score for the retrieval. - public double? RerankScore { get; } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatDataSource.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatDataSource.Serialization.cs deleted file mode 100644 index 944c06cd3..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatDataSource.Serialization.cs +++ /dev/null @@ -1,137 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Text.Json; - -namespace Azure.AI.OpenAI.Chat -{ - [PersistableModelProxy(typeof(InternalUnknownAzureChatDataSource))] - public partial class ChatDataSource : IJsonModel - { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - /// The JSON writer. - /// The client options for reading and writing models. - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ChatDataSource)} does not support writing '{format}' format."); - } - - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - } - - ChatDataSource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ChatDataSource)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeChatDataSource(document.RootElement, options); - } - - internal static ChatDataSource DeserializeChatDataSource(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - if (element.TryGetProperty("type", out JsonElement discriminator)) - { - switch (discriminator.GetString()) - { - case "azure_cosmos_db": return CosmosChatDataSource.DeserializeCosmosChatDataSource(element, options); - case "azure_search": return AzureSearchChatDataSource.DeserializeAzureSearchChatDataSource(element, options); - case "elasticsearch": return ElasticsearchChatDataSource.DeserializeElasticsearchChatDataSource(element, options); - case "mongo_db": return MongoDBChatDataSource.DeserializeMongoDBChatDataSource(element, options); - case "pinecone": return PineconeChatDataSource.DeserializePineconeChatDataSource(element, options); - } - } - return InternalUnknownAzureChatDataSource.DeserializeInternalUnknownAzureChatDataSource(element, options); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(ChatDataSource)} does not support writing '{options.Format}' format."); - } - } - - ChatDataSource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeChatDataSource(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ChatDataSource)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static ChatDataSource FromResponse(PipelineResponse response) - { - using var document = JsonDocument.Parse(response.Content); - return DeserializeChatDataSource(document.RootElement); - } - - /// Convert into a . - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatDataSource.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatDataSource.cs deleted file mode 100644 index 35988a26e..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatDataSource.cs +++ /dev/null @@ -1,68 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI.Chat -{ - /// - /// A representation of configuration data for a single Azure OpenAI chat data source. - /// This will be used by a chat completions request that should use Azure OpenAI chat extensions to augment the - /// response behavior. - /// The use of this configuration is compatible only with Azure OpenAI. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , , , and . - /// - public abstract partial class ChatDataSource - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - internal IDictionary SerializedAdditionalRawData { get; set; } - /// Initializes a new instance of . - protected ChatDataSource() - { - } - - /// Initializes a new instance of . - /// The differentiating type identifier for the data source. - /// Keeps track of any properties unknown to the library. - internal ChatDataSource(string type, IDictionary serializedAdditionalRawData) - { - Type = type; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - /// The differentiating type identifier for the data source. - internal string Type { get; set; } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatMessageContext.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatMessageContext.cs deleted file mode 100644 index 7a117a45c..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatMessageContext.cs +++ /dev/null @@ -1,71 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI.Chat -{ - /// - /// An additional property, added to chat completion response messages, produced by the Azure OpenAI service when using - /// extension behavior. This includes intent and citation information from the On Your Data feature. - /// - public partial class ChatMessageContext - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - internal IDictionary SerializedAdditionalRawData { get; set; } - /// Initializes a new instance of . - internal ChatMessageContext() - { - Citations = new ChangeTrackingList(); - } - - /// Initializes a new instance of . - /// The detected intent from the chat history, which is used to carry conversation context between interactions. - /// The citations produced by the data retrieval. - /// Summary information about documents retrieved by the data retrieval operation. - /// Keeps track of any properties unknown to the library. - internal ChatMessageContext(string intent, IReadOnlyList citations, ChatRetrievedDocument retrievedDocuments, IDictionary serializedAdditionalRawData) - { - Intent = intent; - Citations = citations; - RetrievedDocuments = retrievedDocuments; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - /// The detected intent from the chat history, which is used to carry conversation context between interactions. - public string Intent { get; } - /// The citations produced by the data retrieval. - public IReadOnlyList Citations { get; } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatRetrievedDocument.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatRetrievedDocument.cs deleted file mode 100644 index 145d0be9a..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatRetrievedDocument.cs +++ /dev/null @@ -1,111 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; -using System.Linq; - -namespace Azure.AI.OpenAI.Chat -{ - /// The AzureChatMessageContextAllRetrievedDocuments. - public partial class ChatRetrievedDocument - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - internal IDictionary SerializedAdditionalRawData { get; set; } - /// Initializes a new instance of . - /// The content of the citation. - /// The search queries executed to retrieve documents. - /// The index of the data source used for retrieval. - /// or is null. - internal ChatRetrievedDocument(string content, IEnumerable searchQueries, int dataSourceIndex) - { - Argument.AssertNotNull(content, nameof(content)); - Argument.AssertNotNull(searchQueries, nameof(searchQueries)); - - Content = content; - SearchQueries = searchQueries.ToList(); - DataSourceIndex = dataSourceIndex; - } - - /// Initializes a new instance of . - /// The content of the citation. - /// The title for the citation. - /// The URL of the citation. - /// The file path for the citation. - /// The chunk ID for the citation. - /// The rerank score for the retrieval. - /// The search queries executed to retrieve documents. - /// The index of the data source used for retrieval. - /// The original search score for the retrieval. - /// If applicable, an indication of why the document was filtered. - /// Keeps track of any properties unknown to the library. - internal ChatRetrievedDocument(string content, string title, string url, string filePath, string chunkId, double? rerankScore, IReadOnlyList searchQueries, int dataSourceIndex, double? originalSearchScore, ChatDocumentFilterReason? filterReason, IDictionary serializedAdditionalRawData) - { - Content = content; - Title = title; - Url = url; - FilePath = filePath; - ChunkId = chunkId; - RerankScore = rerankScore; - SearchQueries = searchQueries; - DataSourceIndex = dataSourceIndex; - OriginalSearchScore = originalSearchScore; - FilterReason = filterReason; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal ChatRetrievedDocument() - { - } - - /// The content of the citation. - public string Content { get; } - /// The title for the citation. - public string Title { get; } - /// The URL of the citation. - public string Url { get; } - /// The chunk ID for the citation. - public string ChunkId { get; } - /// The rerank score for the retrieval. - public double? RerankScore { get; } - /// The search queries executed to retrieve documents. - public IReadOnlyList SearchQueries { get; } - /// The index of the data source used for retrieval. - public int DataSourceIndex { get; } - /// The original search score for the retrieval. - public double? OriginalSearchScore { get; } - /// If applicable, an indication of why the document was filtered. - public ChatDocumentFilterReason? FilterReason { get; } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterBlocklistResult.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterBlocklistResult.cs deleted file mode 100644 index d033e0e34..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterBlocklistResult.cs +++ /dev/null @@ -1,71 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI -{ - /// A collection of true/false filtering results for configured custom blocklists. - public partial class ContentFilterBlocklistResult - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - internal IDictionary SerializedAdditionalRawData { get; set; } - /// Initializes a new instance of . - /// A value indicating whether any of the detailed blocklists resulted in a filtering action. - internal ContentFilterBlocklistResult(bool filtered) - { - Filtered = filtered; - InternalDetails = new ChangeTrackingList(); - } - - /// Initializes a new instance of . - /// A value indicating whether any of the detailed blocklists resulted in a filtering action. - /// The pairs of individual blocklist IDs and whether they resulted in a filtering action. - /// Keeps track of any properties unknown to the library. - internal ContentFilterBlocklistResult(bool filtered, IReadOnlyList internalDetails, IDictionary serializedAdditionalRawData) - { - Filtered = filtered; - InternalDetails = internalDetails; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal ContentFilterBlocklistResult() - { - } - - /// A value indicating whether any of the detailed blocklists resulted in a filtering action. - public bool Filtered { get; } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterDetectionResult.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterDetectionResult.cs deleted file mode 100644 index 34aab2400..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterDetectionResult.cs +++ /dev/null @@ -1,77 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI -{ - /// - /// A labeled content filter result item that indicates whether the content was detected and whether the content was - /// filtered. - /// - public partial class ContentFilterDetectionResult - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - internal IDictionary SerializedAdditionalRawData { get; set; } - /// Initializes a new instance of . - /// Whether the content detection resulted in a content filtering action. - /// Whether the labeled content category was detected in the content. - internal ContentFilterDetectionResult(bool filtered, bool detected) - { - Filtered = filtered; - Detected = detected; - } - - /// Initializes a new instance of . - /// Whether the content detection resulted in a content filtering action. - /// Whether the labeled content category was detected in the content. - /// Keeps track of any properties unknown to the library. - internal ContentFilterDetectionResult(bool filtered, bool detected, IDictionary serializedAdditionalRawData) - { - Filtered = filtered; - Detected = detected; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal ContentFilterDetectionResult() - { - } - - /// Whether the content detection resulted in a content filtering action. - public bool Filtered { get; } - /// Whether the labeled content category was detected in the content. - public bool Detected { get; } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterProtectedMaterialCitationResult.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterProtectedMaterialCitationResult.cs deleted file mode 100644 index 155740c21..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterProtectedMaterialCitationResult.cs +++ /dev/null @@ -1,63 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI -{ - /// The AzureContentFilterResultForChoiceProtectedMaterialCodeCitation. - public partial class ContentFilterProtectedMaterialCitationResult - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - internal IDictionary SerializedAdditionalRawData { get; set; } - /// Initializes a new instance of . - internal ContentFilterProtectedMaterialCitationResult() - { - } - - /// Initializes a new instance of . - /// The name or identifier of the license associated with the detection. - /// The URL associated with the license. - /// Keeps track of any properties unknown to the library. - internal ContentFilterProtectedMaterialCitationResult(string license, Uri uri, IDictionary serializedAdditionalRawData) - { - License = license; - Uri = uri; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - /// The name or identifier of the license associated with the detection. - public string License { get; } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterProtectedMaterialResult.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterProtectedMaterialResult.cs deleted file mode 100644 index 533e4b11b..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterProtectedMaterialResult.cs +++ /dev/null @@ -1,78 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI -{ - /// The AzureContentFilterResultForChoiceProtectedMaterialCode. - public partial class ContentFilterProtectedMaterialResult - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - internal IDictionary SerializedAdditionalRawData { get; set; } - /// Initializes a new instance of . - /// Whether the content detection resulted in a content filtering action. - /// Whether the labeled content category was detected in the content. - internal ContentFilterProtectedMaterialResult(bool filtered, bool detected) - { - Filtered = filtered; - Detected = detected; - } - - /// Initializes a new instance of . - /// Whether the content detection resulted in a content filtering action. - /// Whether the labeled content category was detected in the content. - /// If available, the citation details describing the associated license and its location. - /// Keeps track of any properties unknown to the library. - internal ContentFilterProtectedMaterialResult(bool filtered, bool detected, ContentFilterProtectedMaterialCitationResult citation, IDictionary serializedAdditionalRawData) - { - Filtered = filtered; - Detected = detected; - Citation = citation; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal ContentFilterProtectedMaterialResult() - { - } - - /// Whether the content detection resulted in a content filtering action. - public bool Filtered { get; } - /// Whether the labeled content category was detected in the content. - public bool Detected { get; } - /// If available, the citation details describing the associated license and its location. - public ContentFilterProtectedMaterialCitationResult Citation { get; } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterSeverityResult.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterSeverityResult.cs deleted file mode 100644 index 95f0fa1bc..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterSeverityResult.cs +++ /dev/null @@ -1,75 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI -{ - /// - /// A labeled content filter result item that indicates whether the content was filtered and what the qualitative - /// severity level of the content was, as evaluated against content filter configuration for the category. - /// - public partial class ContentFilterSeverityResult - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - internal IDictionary SerializedAdditionalRawData { get; set; } - /// Initializes a new instance of . - /// Whether the content severity resulted in a content filtering action. - /// The labeled severity of the content. - internal ContentFilterSeverityResult(bool filtered, ContentFilterSeverity severity) - { - Filtered = filtered; - Severity = severity; - } - - /// Initializes a new instance of . - /// Whether the content severity resulted in a content filtering action. - /// The labeled severity of the content. - /// Keeps track of any properties unknown to the library. - internal ContentFilterSeverityResult(bool filtered, ContentFilterSeverity severity, IDictionary serializedAdditionalRawData) - { - Filtered = filtered; - Severity = severity; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal ContentFilterSeverityResult() - { - } - - /// Whether the content severity resulted in a content filtering action. - public bool Filtered { get; } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterTextSpan.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterTextSpan.cs deleted file mode 100644 index 2b04de8d0..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterTextSpan.cs +++ /dev/null @@ -1,74 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI -{ - /// A representation of a span of completion text as used by Azure OpenAI content filter results. - public partial class ContentFilterTextSpan - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - internal IDictionary SerializedAdditionalRawData { get; set; } - /// Initializes a new instance of . - /// Offset of the UTF32 code point which begins the span. - /// Offset of the first UTF32 code point which is excluded from the span. This field is always equal to completion_start_offset for empty spans. This field is always larger than completion_start_offset for non-empty spans. - internal ContentFilterTextSpan(int completionStartOffset, int completionEndOffset) - { - CompletionStartOffset = completionStartOffset; - CompletionEndOffset = completionEndOffset; - } - - /// Initializes a new instance of . - /// Offset of the UTF32 code point which begins the span. - /// Offset of the first UTF32 code point which is excluded from the span. This field is always equal to completion_start_offset for empty spans. This field is always larger than completion_start_offset for non-empty spans. - /// Keeps track of any properties unknown to the library. - internal ContentFilterTextSpan(int completionStartOffset, int completionEndOffset, IDictionary serializedAdditionalRawData) - { - CompletionStartOffset = completionStartOffset; - CompletionEndOffset = completionEndOffset; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal ContentFilterTextSpan() - { - } - - /// Offset of the UTF32 code point which begins the span. - public int CompletionStartOffset { get; } - /// Offset of the first UTF32 code point which is excluded from the span. This field is always equal to completion_start_offset for empty spans. This field is always larger than completion_start_offset for non-empty spans. - public int CompletionEndOffset { get; } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterTextSpanResult.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterTextSpanResult.cs deleted file mode 100644 index 9f7a3dba1..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterTextSpanResult.cs +++ /dev/null @@ -1,84 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; -using System.Linq; - -namespace Azure.AI.OpenAI -{ - /// The AzureContentFilterCompletionTextSpanDetectionResult. - public partial class ContentFilterTextSpanResult - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - internal IDictionary SerializedAdditionalRawData { get; set; } - /// Initializes a new instance of . - /// Whether the content detection resulted in a content filtering action. - /// Whether the labeled content category was detected in the content. - /// Detailed information about the detected completion text spans. - /// is null. - internal ContentFilterTextSpanResult(bool filtered, bool detected, IEnumerable details) - { - Argument.AssertNotNull(details, nameof(details)); - - Filtered = filtered; - Detected = detected; - Details = details.ToList(); - } - - /// Initializes a new instance of . - /// Whether the content detection resulted in a content filtering action. - /// Whether the labeled content category was detected in the content. - /// Detailed information about the detected completion text spans. - /// Keeps track of any properties unknown to the library. - internal ContentFilterTextSpanResult(bool filtered, bool detected, IReadOnlyList details, IDictionary serializedAdditionalRawData) - { - Filtered = filtered; - Detected = detected; - Details = details; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal ContentFilterTextSpanResult() - { - } - - /// Whether the content detection resulted in a content filtering action. - public bool Filtered { get; } - /// Whether the labeled content category was detected in the content. - public bool Detected { get; } - /// Detailed information about the detected completion text spans. - public IReadOnlyList Details { get; } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/CosmosChatDataSource.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/CosmosChatDataSource.Serialization.cs deleted file mode 100644 index e492d76ae..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/CosmosChatDataSource.Serialization.cs +++ /dev/null @@ -1,131 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; - -namespace Azure.AI.OpenAI.Chat -{ - public partial class CosmosChatDataSource : IJsonModel - { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - /// The JSON writer. - /// The client options for reading and writing models. - protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(CosmosChatDataSource)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - if (SerializedAdditionalRawData?.ContainsKey("parameters") != true) - { - writer.WritePropertyName("parameters"u8); - writer.WriteObjectValue(InternalParameters, options); - } - } - - CosmosChatDataSource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(CosmosChatDataSource)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeCosmosChatDataSource(document.RootElement, options); - } - - internal static CosmosChatDataSource DeserializeCosmosChatDataSource(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - InternalAzureCosmosDBChatDataSourceParameters parameters = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("parameters"u8)) - { - parameters = InternalAzureCosmosDBChatDataSourceParameters.DeserializeInternalAzureCosmosDBChatDataSourceParameters(property.Value, options); - continue; - } - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new CosmosChatDataSource(type, serializedAdditionalRawData, parameters); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(CosmosChatDataSource)} does not support writing '{options.Format}' format."); - } - } - - CosmosChatDataSource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeCosmosChatDataSource(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(CosmosChatDataSource)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static new CosmosChatDataSource FromResponse(PipelineResponse response) - { - using var document = JsonDocument.Parse(response.Content); - return DeserializeCosmosChatDataSource(document.RootElement); - } - - /// Convert into a . - internal override BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/DataSourceAuthentication.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/DataSourceAuthentication.Serialization.cs deleted file mode 100644 index d823d3ed9..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/DataSourceAuthentication.Serialization.cs +++ /dev/null @@ -1,140 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Text.Json; - -namespace Azure.AI.OpenAI.Chat -{ - [PersistableModelProxy(typeof(InternalUnknownAzureChatDataSourceAuthenticationOptions))] - public partial class DataSourceAuthentication : IJsonModel - { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - /// The JSON writer. - /// The client options for reading and writing models. - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(DataSourceAuthentication)} does not support writing '{format}' format."); - } - - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - } - - DataSourceAuthentication IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(DataSourceAuthentication)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeDataSourceAuthentication(document.RootElement, options); - } - - internal static DataSourceAuthentication DeserializeDataSourceAuthentication(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - if (element.TryGetProperty("type", out JsonElement discriminator)) - { - switch (discriminator.GetString()) - { - case "access_token": return InternalAzureChatDataSourceAccessTokenAuthenticationOptions.DeserializeInternalAzureChatDataSourceAccessTokenAuthenticationOptions(element, options); - case "api_key": return InternalAzureChatDataSourceApiKeyAuthenticationOptions.DeserializeInternalAzureChatDataSourceApiKeyAuthenticationOptions(element, options); - case "connection_string": return InternalAzureChatDataSourceConnectionStringAuthenticationOptions.DeserializeInternalAzureChatDataSourceConnectionStringAuthenticationOptions(element, options); - case "encoded_api_key": return InternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions.DeserializeInternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions(element, options); - case "key_and_key_id": return InternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions.DeserializeInternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions(element, options); - case "system_assigned_managed_identity": return InternalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions.DeserializeInternalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions(element, options); - case "user_assigned_managed_identity": return InternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions.DeserializeInternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions(element, options); - case "username_and_password": return InternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions.DeserializeInternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions(element, options); - } - } - return InternalUnknownAzureChatDataSourceAuthenticationOptions.DeserializeInternalUnknownAzureChatDataSourceAuthenticationOptions(element, options); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(DataSourceAuthentication)} does not support writing '{options.Format}' format."); - } - } - - DataSourceAuthentication IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeDataSourceAuthentication(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(DataSourceAuthentication)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static DataSourceAuthentication FromResponse(PipelineResponse response) - { - using var document = JsonDocument.Parse(response.Content); - return DeserializeDataSourceAuthentication(document.RootElement); - } - - /// Convert into a . - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/DataSourceAuthentication.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/DataSourceAuthentication.cs deleted file mode 100644 index 6ef59cc56..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/DataSourceAuthentication.cs +++ /dev/null @@ -1,64 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI.Chat -{ - /// - /// The AzureChatDataSourceAuthenticationOptions. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.. - /// - public abstract partial class DataSourceAuthentication - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - internal IDictionary SerializedAdditionalRawData { get; set; } - /// Initializes a new instance of . - protected DataSourceAuthentication() - { - } - - /// Initializes a new instance of . - /// - /// Keeps track of any properties unknown to the library. - internal DataSourceAuthentication(string type, IDictionary serializedAdditionalRawData) - { - Type = type; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Gets or sets the type. - internal string Type { get; set; } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/DataSourceFieldMappings.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/DataSourceFieldMappings.Serialization.cs deleted file mode 100644 index 710c70afe..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/DataSourceFieldMappings.Serialization.cs +++ /dev/null @@ -1,259 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; - -namespace Azure.AI.OpenAI.Chat -{ - public partial class DataSourceFieldMappings : IJsonModel - { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - /// The JSON writer. - /// The client options for reading and writing models. - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(DataSourceFieldMappings)} does not support writing '{format}' format."); - } - - if (SerializedAdditionalRawData?.ContainsKey("title_field") != true && Optional.IsDefined(TitleFieldName)) - { - writer.WritePropertyName("title_field"u8); - writer.WriteStringValue(TitleFieldName); - } - if (SerializedAdditionalRawData?.ContainsKey("url_field") != true && Optional.IsDefined(UrlFieldName)) - { - writer.WritePropertyName("url_field"u8); - writer.WriteStringValue(UrlFieldName); - } - if (SerializedAdditionalRawData?.ContainsKey("filepath_field") != true && Optional.IsDefined(FilePathFieldName)) - { - writer.WritePropertyName("filepath_field"u8); - writer.WriteStringValue(FilePathFieldName); - } - if (SerializedAdditionalRawData?.ContainsKey("content_fields") != true && Optional.IsCollectionDefined(ContentFieldNames)) - { - writer.WritePropertyName("content_fields"u8); - writer.WriteStartArray(); - foreach (var item in ContentFieldNames) - { - writer.WriteStringValue(item); - } - writer.WriteEndArray(); - } - if (SerializedAdditionalRawData?.ContainsKey("content_fields_separator") != true && Optional.IsDefined(ContentFieldSeparator)) - { - writer.WritePropertyName("content_fields_separator"u8); - writer.WriteStringValue(ContentFieldSeparator); - } - if (SerializedAdditionalRawData?.ContainsKey("vector_fields") != true && Optional.IsCollectionDefined(VectorFieldNames)) - { - writer.WritePropertyName("vector_fields"u8); - writer.WriteStartArray(); - foreach (var item in VectorFieldNames) - { - writer.WriteStringValue(item); - } - writer.WriteEndArray(); - } - if (SerializedAdditionalRawData?.ContainsKey("image_vector_fields") != true && Optional.IsCollectionDefined(ImageVectorFieldNames)) - { - writer.WritePropertyName("image_vector_fields"u8); - writer.WriteStartArray(); - foreach (var item in ImageVectorFieldNames) - { - writer.WriteStringValue(item); - } - writer.WriteEndArray(); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - } - - DataSourceFieldMappings IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(DataSourceFieldMappings)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeDataSourceFieldMappings(document.RootElement, options); - } - - internal static DataSourceFieldMappings DeserializeDataSourceFieldMappings(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - string titleField = default; - string urlField = default; - string filepathField = default; - IList contentFields = default; - string contentFieldsSeparator = default; - IList vectorFields = default; - IList imageVectorFields = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("title_field"u8)) - { - titleField = property.Value.GetString(); - continue; - } - if (property.NameEquals("url_field"u8)) - { - urlField = property.Value.GetString(); - continue; - } - if (property.NameEquals("filepath_field"u8)) - { - filepathField = property.Value.GetString(); - continue; - } - if (property.NameEquals("content_fields"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - contentFields = array; - continue; - } - if (property.NameEquals("content_fields_separator"u8)) - { - contentFieldsSeparator = property.Value.GetString(); - continue; - } - if (property.NameEquals("vector_fields"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - vectorFields = array; - continue; - } - if (property.NameEquals("image_vector_fields"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - imageVectorFields = array; - continue; - } - if (options.Format != "W") - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new DataSourceFieldMappings( - titleField, - urlField, - filepathField, - contentFields ?? new ChangeTrackingList(), - contentFieldsSeparator, - vectorFields ?? new ChangeTrackingList(), - imageVectorFields ?? new ChangeTrackingList(), - serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(DataSourceFieldMappings)} does not support writing '{options.Format}' format."); - } - } - - DataSourceFieldMappings IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeDataSourceFieldMappings(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(DataSourceFieldMappings)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static DataSourceFieldMappings FromResponse(PipelineResponse response) - { - using var document = JsonDocument.Parse(response.Content); - return DeserializeDataSourceFieldMappings(document.RootElement); - } - - /// Convert into a . - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/DataSourceFieldMappings.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/DataSourceFieldMappings.cs deleted file mode 100644 index 7a7d02231..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/DataSourceFieldMappings.cs +++ /dev/null @@ -1,66 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI.Chat -{ - /// The AzureSearchChatDataSourceParametersFieldsMapping. - public partial class DataSourceFieldMappings - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - internal IDictionary SerializedAdditionalRawData { get; set; } - - /// Initializes a new instance of . - /// The name of the index field to use as a title. - /// The name of the index field to use as a URL. - /// The name of the index field to use as a filepath. - /// The names of index fields that should be treated as content. - /// The separator pattern that content fields should use. - /// The names of fields that represent vector data. - /// The names of fields that represent image vector data. - /// Keeps track of any properties unknown to the library. - internal DataSourceFieldMappings(string titleFieldName, string urlFieldName, string filePathFieldName, IList contentFieldNames, string contentFieldSeparator, IList vectorFieldNames, IList imageVectorFieldNames, IDictionary serializedAdditionalRawData) - { - TitleFieldName = titleFieldName; - UrlFieldName = urlFieldName; - FilePathFieldName = filePathFieldName; - ContentFieldNames = contentFieldNames; - ContentFieldSeparator = contentFieldSeparator; - VectorFieldNames = vectorFieldNames; - ImageVectorFieldNames = imageVectorFieldNames; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/DataSourceVectorizer.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/DataSourceVectorizer.Serialization.cs deleted file mode 100644 index 44e5c7909..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/DataSourceVectorizer.Serialization.cs +++ /dev/null @@ -1,136 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Text.Json; - -namespace Azure.AI.OpenAI.Chat -{ - [PersistableModelProxy(typeof(InternalUnknownAzureChatDataSourceVectorizationSource))] - public partial class DataSourceVectorizer : IJsonModel - { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - /// The JSON writer. - /// The client options for reading and writing models. - protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(DataSourceVectorizer)} does not support writing '{format}' format."); - } - - if (SerializedAdditionalRawData?.ContainsKey("type") != true) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(Type); - } - if (SerializedAdditionalRawData != null) - { - foreach (var item in SerializedAdditionalRawData) - { - if (ModelSerializationExtensions.IsSentinelValue(item.Value)) - { - continue; - } - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - } - - DataSourceVectorizer IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(DataSourceVectorizer)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeDataSourceVectorizer(document.RootElement, options); - } - - internal static DataSourceVectorizer DeserializeDataSourceVectorizer(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - if (element.TryGetProperty("type", out JsonElement discriminator)) - { - switch (discriminator.GetString()) - { - case "deployment_name": return InternalAzureChatDataSourceDeploymentNameVectorizationSource.DeserializeInternalAzureChatDataSourceDeploymentNameVectorizationSource(element, options); - case "endpoint": return InternalAzureChatDataSourceEndpointVectorizationSource.DeserializeInternalAzureChatDataSourceEndpointVectorizationSource(element, options); - case "integrated": return InternalAzureChatDataSourceIntegratedVectorizationSource.DeserializeInternalAzureChatDataSourceIntegratedVectorizationSource(element, options); - case "model_id": return InternalAzureChatDataSourceModelIdVectorizationSource.DeserializeInternalAzureChatDataSourceModelIdVectorizationSource(element, options); - } - } - return InternalUnknownAzureChatDataSourceVectorizationSource.DeserializeInternalUnknownAzureChatDataSourceVectorizationSource(element, options); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(DataSourceVectorizer)} does not support writing '{options.Format}' format."); - } - } - - DataSourceVectorizer IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeDataSourceVectorizer(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(DataSourceVectorizer)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static DataSourceVectorizer FromResponse(PipelineResponse response) - { - using var document = JsonDocument.Parse(response.Content); - return DeserializeDataSourceVectorizer(document.RootElement); - } - - /// Convert into a . - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/DataSourceVectorizer.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/DataSourceVectorizer.cs deleted file mode 100644 index 474c24590..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/DataSourceVectorizer.cs +++ /dev/null @@ -1,64 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI.Chat -{ - /// - /// A representation of a data vectorization source usable as an embedding resource with a data source. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.. - /// - public abstract partial class DataSourceVectorizer - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - internal IDictionary SerializedAdditionalRawData { get; set; } - /// Initializes a new instance of . - protected DataSourceVectorizer() - { - } - - /// Initializes a new instance of . - /// The differentiating identifier for the concrete vectorization source. - /// Keeps track of any properties unknown to the library. - internal DataSourceVectorizer(string type, IDictionary serializedAdditionalRawData) - { - Type = type; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - /// The differentiating identifier for the concrete vectorization source. - internal string Type { get; set; } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ElasticsearchChatDataSource.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ElasticsearchChatDataSource.Serialization.cs deleted file mode 100644 index 3a9a20cda..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ElasticsearchChatDataSource.Serialization.cs +++ /dev/null @@ -1,131 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; - -namespace Azure.AI.OpenAI.Chat -{ - public partial class ElasticsearchChatDataSource : IJsonModel - { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - /// The JSON writer. - /// The client options for reading and writing models. - protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ElasticsearchChatDataSource)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - if (SerializedAdditionalRawData?.ContainsKey("parameters") != true) - { - writer.WritePropertyName("parameters"u8); - writer.WriteObjectValue(InternalParameters, options); - } - } - - ElasticsearchChatDataSource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(ElasticsearchChatDataSource)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeElasticsearchChatDataSource(document.RootElement, options); - } - - internal static ElasticsearchChatDataSource DeserializeElasticsearchChatDataSource(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - InternalElasticsearchChatDataSourceParameters parameters = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("parameters"u8)) - { - parameters = InternalElasticsearchChatDataSourceParameters.DeserializeInternalElasticsearchChatDataSourceParameters(property.Value, options); - continue; - } - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new ElasticsearchChatDataSource(type, serializedAdditionalRawData, parameters); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(ElasticsearchChatDataSource)} does not support writing '{options.Format}' format."); - } - } - - ElasticsearchChatDataSource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeElasticsearchChatDataSource(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(ElasticsearchChatDataSource)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static new ElasticsearchChatDataSource FromResponse(PipelineResponse response) - { - using var document = JsonDocument.Parse(response.Content); - return DeserializeElasticsearchChatDataSource(document.RootElement); - } - - /// Convert into a . - internal override BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/Argument.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/Argument.cs index 5a8ab138b..a7187a745 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/Argument.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/Argument.cs @@ -8,7 +8,7 @@ namespace Azure.AI.OpenAI { - internal static class Argument + internal static partial class Argument { public static void AssertNotNull(T value, string name) { @@ -19,7 +19,7 @@ public static void AssertNotNull(T value, string name) } public static void AssertNotNull(T? value, string name) - where T : struct + where T : struct { if (!value.HasValue) { @@ -73,7 +73,7 @@ public static void AssertNotNullOrWhiteSpace(string value, string name) } public static void AssertNotDefault(ref T value, string name) - where T : struct, IEquatable + where T : struct, IEquatable { if (value.Equals(default)) { @@ -82,7 +82,7 @@ public static void AssertNotDefault(ref T value, string name) } public static void AssertInRange(T value, T minimum, T maximum, string name) - where T : notnull, IComparable + where T : notnull, IComparable { if (minimum.CompareTo(value) > 0) { @@ -103,7 +103,7 @@ public static void AssertEnumDefined(Type enumType, object value, string name) } public static T CheckNotNull(T value, string name) - where T : class + where T : class { AssertNotNull(value, name); return value; diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/BinaryContentHelper.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/BinaryContentHelper.cs index 94ae48ee4..e5fd4d33e 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/BinaryContentHelper.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/BinaryContentHelper.cs @@ -9,10 +9,10 @@ namespace Azure.AI.OpenAI { - internal static class BinaryContentHelper + internal static partial class BinaryContentHelper { public static BinaryContent FromEnumerable(IEnumerable enumerable) - where T : notnull + where T : notnull { Utf8JsonBinaryContent content = new Utf8JsonBinaryContent(); content.JsonWriter.WriteStartArray(); @@ -38,7 +38,7 @@ public static BinaryContent FromEnumerable(IEnumerable enumerable) else { #if NET6_0_OR_GREATER - content.JsonWriter.WriteRawValue(item); + content.JsonWriter.WriteRawValue(item); #else using (JsonDocument document = JsonDocument.Parse(item)) { @@ -53,11 +53,12 @@ public static BinaryContent FromEnumerable(IEnumerable enumerable) } public static BinaryContent FromEnumerable(ReadOnlySpan span) - where T : notnull + where T : notnull { Utf8JsonBinaryContent content = new Utf8JsonBinaryContent(); content.JsonWriter.WriteStartArray(); - for (int i = 0; i < span.Length; i++) + int i = 0; + for (; i < span.Length; i++) { content.JsonWriter.WriteObjectValue(span[i], ModelSerializationExtensions.WireOptions); } @@ -67,7 +68,7 @@ public static BinaryContent FromEnumerable(ReadOnlySpan span) } public static BinaryContent FromDictionary(IDictionary dictionary) - where TValue : notnull + where TValue : notnull { Utf8JsonBinaryContent content = new Utf8JsonBinaryContent(); content.JsonWriter.WriteStartObject(); @@ -95,7 +96,7 @@ public static BinaryContent FromDictionary(IDictionary dicti else { #if NET6_0_OR_GREATER - content.JsonWriter.WriteRawValue(item.Value); + content.JsonWriter.WriteRawValue(item.Value); #else using (JsonDocument document = JsonDocument.Parse(item.Value)) { @@ -120,7 +121,7 @@ public static BinaryContent FromObject(BinaryData value) { Utf8JsonBinaryContent content = new Utf8JsonBinaryContent(); #if NET6_0_OR_GREATER - content.JsonWriter.WriteRawValue(value); + content.JsonWriter.WriteRawValue(value); #else using (JsonDocument document = JsonDocument.Parse(value)) { diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/ChangeTrackingDictionary.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/ChangeTrackingDictionary.cs index 058e71abe..df2c9dea1 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/ChangeTrackingDictionary.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/ChangeTrackingDictionary.cs @@ -8,7 +8,8 @@ namespace Azure.AI.OpenAI { - internal class ChangeTrackingDictionary : IDictionary, IReadOnlyDictionary where TKey : notnull + internal partial class ChangeTrackingDictionary : IDictionary, IReadOnlyDictionary + where TKey : notnull { private IDictionary _innerDictionary; diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/ChangeTrackingList.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/ChangeTrackingList.cs index 9c6986a3a..033bc49c6 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/ChangeTrackingList.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/ChangeTrackingList.cs @@ -9,7 +9,7 @@ namespace Azure.AI.OpenAI { - internal class ChangeTrackingList : IList, IReadOnlyList + internal partial class ChangeTrackingList : IList, IReadOnlyList { private IList _innerList; diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/ClientUriBuilder.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/ClientUriBuilder.cs index aa2ae4da3..5e8571d1e 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/ClientUriBuilder.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/ClientUriBuilder.cs @@ -19,11 +19,11 @@ public ClientUriBuilder() { } - private UriBuilder UriBuilder => _uriBuilder ??= new UriBuilder(); + private UriBuilder UriBuilder => _uriBuilder ??= new UriBuilder(); - private StringBuilder PathBuilder => _pathBuilder ??= new StringBuilder(UriBuilder.Path); + private StringBuilder PathBuilder => _pathBuilder ??= new StringBuilder(UriBuilder.Path); - private StringBuilder QueryBuilder => _queryBuilder ??= new StringBuilder(UriBuilder.Query); + private StringBuilder QueryBuilder => _queryBuilder ??= new StringBuilder(UriBuilder.Query); public void Reset(Uri uri) { @@ -34,156 +34,84 @@ public void Reset(Uri uri) public void AppendPath(string value, bool escape) { - Argument.AssertNotNullOrWhiteSpace(value, nameof(value)); - if (escape) { value = Uri.EscapeDataString(value); } - if (PathBuilder.Length > 0 && PathBuilder[PathBuilder.Length - 1] == '/' && value[0] == '/') { PathBuilder.Remove(PathBuilder.Length - 1, 1); } - PathBuilder.Append(value); UriBuilder.Path = PathBuilder.ToString(); } - public void AppendPath(bool value, bool escape = false) - { - AppendPath(ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); - } + public void AppendPath(bool value, bool escape = false) => AppendPath(TypeFormatters.ConvertToString(value), escape); - public void AppendPath(float value, bool escape = true) - { - AppendPath(ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); - } + public void AppendPath(float value, bool escape = true) => AppendPath(TypeFormatters.ConvertToString(value), escape); - public void AppendPath(double value, bool escape = true) - { - AppendPath(ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); - } + public void AppendPath(double value, bool escape = true) => AppendPath(TypeFormatters.ConvertToString(value), escape); - public void AppendPath(int value, bool escape = true) - { - AppendPath(ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); - } + public void AppendPath(int value, bool escape = true) => AppendPath(TypeFormatters.ConvertToString(value), escape); - public void AppendPath(byte[] value, string format, bool escape = true) - { - AppendPath(ModelSerializationExtensions.TypeFormatters.ConvertToString(value, format), escape); - } + public void AppendPath(byte[] value, string format, bool escape = true) => AppendPath(TypeFormatters.ConvertToString(value, format), escape); - public void AppendPath(IEnumerable value, bool escape = true) - { - AppendPath(ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); - } + public void AppendPath(DateTimeOffset value, string format, bool escape = true) => AppendPath(TypeFormatters.ConvertToString(value, format), escape); - public void AppendPath(DateTimeOffset value, string format, bool escape = true) - { - AppendPath(ModelSerializationExtensions.TypeFormatters.ConvertToString(value, format), escape); - } + public void AppendPath(TimeSpan value, string format, bool escape = true) => AppendPath(TypeFormatters.ConvertToString(value, format), escape); - public void AppendPath(TimeSpan value, string format, bool escape = true) - { - AppendPath(ModelSerializationExtensions.TypeFormatters.ConvertToString(value, format), escape); - } + public void AppendPath(Guid value, bool escape = true) => AppendPath(TypeFormatters.ConvertToString(value), escape); - public void AppendPath(Guid value, bool escape = true) - { - AppendPath(ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); - } + public void AppendPath(long value, bool escape = true) => AppendPath(TypeFormatters.ConvertToString(value), escape); - public void AppendPath(long value, bool escape = true) + public void AppendPathDelimited(IEnumerable value, string delimiter, string format = null, bool escape = true) { - AppendPath(ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); + delimiter ??= ","; + IEnumerable stringValues = value.Select(v => TypeFormatters.ConvertToString(v, format)); + AppendPath(string.Join(delimiter, stringValues), escape); } public void AppendQuery(string name, string value, bool escape) { - Argument.AssertNotNullOrWhiteSpace(name, nameof(name)); - Argument.AssertNotNullOrWhiteSpace(value, nameof(value)); - if (QueryBuilder.Length > 0) { QueryBuilder.Append('&'); } - if (escape) { value = Uri.EscapeDataString(value); } - QueryBuilder.Append(name); QueryBuilder.Append('='); QueryBuilder.Append(value); } - public void AppendQuery(string name, bool value, bool escape = false) - { - AppendQuery(name, ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); - } - - public void AppendQuery(string name, float value, bool escape = true) - { - AppendQuery(name, ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); - } + public void AppendQuery(string name, bool value, bool escape = false) => AppendQuery(name, TypeFormatters.ConvertToString(value), escape); - public void AppendQuery(string name, DateTimeOffset value, string format, bool escape = true) - { - AppendQuery(name, ModelSerializationExtensions.TypeFormatters.ConvertToString(value, format), escape); - } + public void AppendQuery(string name, float value, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value), escape); - public void AppendQuery(string name, TimeSpan value, string format, bool escape = true) - { - AppendQuery(name, ModelSerializationExtensions.TypeFormatters.ConvertToString(value, format), escape); - } + public void AppendQuery(string name, DateTimeOffset value, string format, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value, format), escape); - public void AppendQuery(string name, double value, bool escape = true) - { - AppendQuery(name, ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); - } + public void AppendQuery(string name, TimeSpan value, string format, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value, format), escape); - public void AppendQuery(string name, decimal value, bool escape = true) - { - AppendQuery(name, ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); - } + public void AppendQuery(string name, double value, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value), escape); - public void AppendQuery(string name, int value, bool escape = true) - { - AppendQuery(name, ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); - } + public void AppendQuery(string name, decimal value, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value), escape); - public void AppendQuery(string name, long value, bool escape = true) - { - AppendQuery(name, ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); - } + public void AppendQuery(string name, int value, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value), escape); - public void AppendQuery(string name, TimeSpan value, bool escape = true) - { - AppendQuery(name, ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); - } + public void AppendQuery(string name, long value, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value), escape); - public void AppendQuery(string name, byte[] value, string format, bool escape = true) - { - AppendQuery(name, ModelSerializationExtensions.TypeFormatters.ConvertToString(value, format), escape); - } + public void AppendQuery(string name, TimeSpan value, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value), escape); - public void AppendQuery(string name, Guid value, bool escape = true) - { - AppendQuery(name, ModelSerializationExtensions.TypeFormatters.ConvertToString(value), escape); - } + public void AppendQuery(string name, byte[] value, string format, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value, format), escape); - public void AppendQueryDelimited(string name, IEnumerable value, string delimiter, bool escape = true) - { - var stringValues = value.Select(v => ModelSerializationExtensions.TypeFormatters.ConvertToString(v)); - AppendQuery(name, string.Join(delimiter, stringValues), escape); - } + public void AppendQuery(string name, Guid value, bool escape = true) => AppendQuery(name, TypeFormatters.ConvertToString(value), escape); - public void AppendQueryDelimited(string name, IEnumerable value, string delimiter, string format, bool escape = true) + public void AppendQueryDelimited(string name, IEnumerable value, string delimiter, string format = null, bool escape = true) { - var stringValues = value.Select(v => ModelSerializationExtensions.TypeFormatters.ConvertToString(v, format)); + delimiter ??= ","; + IEnumerable stringValues = value.Select(v => TypeFormatters.ConvertToString(v, format)); AppendQuery(name, string.Join(delimiter, stringValues), escape); } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/ErrorResult.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/ErrorResult.cs index f9ea3276e..8f71d7aff 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/ErrorResult.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/ErrorResult.cs @@ -7,7 +7,7 @@ namespace Azure.AI.OpenAI { - internal class ErrorResult : ClientResult + internal partial class ErrorResult : ClientResult { private readonly PipelineResponse _response; private readonly ClientResultException _exception; diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/ModelSerializationExtensions.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/ModelSerializationExtensions.cs index f6ab935f1..a5ecbaef5 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/ModelSerializationExtensions.cs @@ -8,14 +8,14 @@ using System.Diagnostics; using System.Globalization; using System.Text.Json; -using System.Xml; namespace Azure.AI.OpenAI { - internal static class ModelSerializationExtensions + internal static partial class ModelSerializationExtensions { internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); - internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); + /// + private static readonly BinaryData _sentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); public static object GetObject(this JsonElement element) { @@ -41,14 +41,14 @@ public static object GetObject(this JsonElement element) case JsonValueKind.Null: return null; case JsonValueKind.Object: - var dictionary = new Dictionary(); + Dictionary dictionary = new Dictionary(); foreach (var jsonProperty in element.EnumerateObject()) { dictionary.Add(jsonProperty.Name, jsonProperty.Value.GetObject()); } return dictionary; case JsonValueKind.Array: - var list = new List(); + List list = new List(); foreach (var item in element.EnumerateArray()) { list.Add(item.GetObject()); @@ -86,7 +86,7 @@ public static char GetChar(this JsonElement element) { if (element.ValueKind == JsonValueKind.String) { - var text = element.GetString(); + string text = element.GetString(); if (text == null || text.Length != 1) { throw new NotSupportedException($"Cannot convert \"{text}\" to a char"); @@ -100,14 +100,14 @@ public static char GetChar(this JsonElement element) } [Conditional("DEBUG")] - public static void ThrowNonNullablePropertyIsNull(this JsonProperty property) + public static void ThrowNonNullablePropertyIsNull(this JsonProperty @property) { - throw new JsonException($"A property '{property.Name}' defined as non-nullable but received as null from the service. This exception only happens in DEBUG builds of the library and would be ignored in the release build"); + throw new JsonException($"A property '{@property.Name}' defined as non-nullable but received as null from the service. This exception only happens in DEBUG builds of the library and would be ignored in the release build"); } public static string GetRequiredString(this JsonElement element) { - var value = element.GetString(); + string value = element.GetString(); if (value == null) { throw new InvalidOperationException($"The requested operation requires an element of type 'String', but the target element has type '{element.ValueKind}'."); @@ -252,148 +252,9 @@ public static void WriteObjectValue(this Utf8JsonWriter writer, object value, Mo internal static bool IsSentinelValue(BinaryData value) { - ReadOnlySpan sentinelSpan = SentinelValue.ToMemory().Span; + ReadOnlySpan sentinelSpan = _sentinelValue.ToMemory().Span; ReadOnlySpan valueSpan = value.ToMemory().Span; return sentinelSpan.SequenceEqual(valueSpan); } - - internal static class TypeFormatters - { - private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; - public const string DefaultNumberFormat = "G"; - - public static string ToString(bool value) => value ? "true" : "false"; - - public static string ToString(DateTime value, string format) => value.Kind switch - { - DateTimeKind.Utc => ToString((DateTimeOffset)value, format), - _ => throw new NotSupportedException($"DateTime {value} has a Kind of {value.Kind}. Generated clients require it to be UTC. You can call DateTime.SpecifyKind to change Kind property value to DateTimeKind.Utc.") - }; - - public static string ToString(DateTimeOffset value, string format) => format switch - { - "D" => value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), - "U" => value.ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture), - "O" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), - "o" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), - "R" => value.ToString("r", CultureInfo.InvariantCulture), - _ => value.ToString(format, CultureInfo.InvariantCulture) - }; - - public static string ToString(TimeSpan value, string format) => format switch - { - "P" => XmlConvert.ToString(value), - _ => value.ToString(format, CultureInfo.InvariantCulture) - }; - - public static string ToString(byte[] value, string format) => format switch - { - "U" => ToBase64UrlString(value), - "D" => Convert.ToBase64String(value), - _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) - }; - - public static string ToBase64UrlString(byte[] value) - { - int numWholeOrPartialInputBlocks = checked(value.Length + 2) / 3; - int size = checked(numWholeOrPartialInputBlocks * 4); - char[] output = new char[size]; - - int numBase64Chars = Convert.ToBase64CharArray(value, 0, value.Length, output, 0); - - int i = 0; - for (; i < numBase64Chars; i++) - { - char ch = output[i]; - if (ch == '+') - { - output[i] = '-'; - } - else - { - if (ch == '/') - { - output[i] = '_'; - } - else - { - if (ch == '=') - { - break; - } - } - } - } - - return new string(output, 0, i); - } - - public static byte[] FromBase64UrlString(string value) - { - int paddingCharsToAdd = (value.Length % 4) switch - { - 0 => 0, - 2 => 2, - 3 => 1, - _ => throw new InvalidOperationException("Malformed input") - }; - char[] output = new char[(value.Length + paddingCharsToAdd)]; - int i = 0; - for (; i < value.Length; i++) - { - char ch = value[i]; - if (ch == '-') - { - output[i] = '+'; - } - else - { - if (ch == '_') - { - output[i] = '/'; - } - else - { - output[i] = ch; - } - } - } - - for (; i < output.Length; i++) - { - output[i] = '='; - } - - return Convert.FromBase64CharArray(output, 0, output.Length); - } - - public static DateTimeOffset ParseDateTimeOffset(string value, string format) => format switch - { - "U" => DateTimeOffset.FromUnixTimeSeconds(long.Parse(value, CultureInfo.InvariantCulture)), - _ => DateTimeOffset.Parse(value, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal) - }; - - public static TimeSpan ParseTimeSpan(string value, string format) => format switch - { - "P" => XmlConvert.ToTimeSpan(value), - _ => TimeSpan.ParseExact(value, format, CultureInfo.InvariantCulture) - }; - - public static string ConvertToString(object value, string format = null) => value switch - { - null => "null", - string s => s, - bool b => ToString(b), - int or float or double or long or decimal => ((IFormattable)value).ToString(DefaultNumberFormat, CultureInfo.InvariantCulture), - byte[] b0 when format != null => ToString(b0, format), - IEnumerable s0 => string.Join(",", s0), - DateTimeOffset dateTime when format != null => ToString(dateTime, format), - TimeSpan timeSpan when format != null => ToString(timeSpan, format), - TimeSpan timeSpan0 => XmlConvert.ToString(timeSpan0), - Guid guid => guid.ToString(), - BinaryData binaryData => ConvertToString(binaryData.ToArray(), format), - _ => value.ToString() - }; - } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/MultipartFormDataBinaryContent.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/MultipartFormDataBinaryContent.cs deleted file mode 100644 index 43825f6b4..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/MultipartFormDataBinaryContent.cs +++ /dev/null @@ -1,197 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.Globalization; -using System.IO; -using System.Net.Http; -using System.Net.Http.Headers; -using System.Threading; -using System.Threading.Tasks; - -namespace Azure.AI.OpenAI -{ - internal class MultipartFormDataBinaryContent : BinaryContent - { - private readonly MultipartFormDataContent _multipartContent; - private static readonly Random _random = new Random(); - private static readonly char[] _boundaryValues = "0123456789=ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz".ToCharArray(); - - public MultipartFormDataBinaryContent() - { - _multipartContent = new MultipartFormDataContent(CreateBoundary()); - } - - public string ContentType - { - get - { - return _multipartContent.Headers.ContentType.ToString(); - } - } - - internal HttpContent HttpContent => _multipartContent; - - private static string CreateBoundary() - { - Span chars = new char[70]; - byte[] random = new byte[70]; - _random.NextBytes(random); - int mask = 255 >> 2; - for (int i = 0; i < 70; i++) - { - chars[i] = _boundaryValues[random[i] & mask]; - } - return chars.ToString(); - } - - public void Add(string content, string name, string filename = null, string contentType = null) - { - Argument.AssertNotNull(content, nameof(content)); - Argument.AssertNotNullOrEmpty(name, nameof(name)); - - Add(new StringContent(content), name, filename, contentType); - } - - public void Add(int content, string name, string filename = null, string contentType = null) - { - Argument.AssertNotNull(content, nameof(content)); - Argument.AssertNotNullOrEmpty(name, nameof(name)); - - string value = content.ToString("G", CultureInfo.InvariantCulture); - Add(new StringContent(value), name, filename, contentType); - } - - public void Add(long content, string name, string filename = null, string contentType = null) - { - Argument.AssertNotNull(content, nameof(content)); - Argument.AssertNotNullOrEmpty(name, nameof(name)); - - string value = content.ToString("G", CultureInfo.InvariantCulture); - Add(new StringContent(value), name, filename, contentType); - } - - public void Add(float content, string name, string filename = null, string contentType = null) - { - Argument.AssertNotNull(content, nameof(content)); - Argument.AssertNotNullOrEmpty(name, nameof(name)); - - string value = content.ToString("G", CultureInfo.InvariantCulture); - Add(new StringContent(value), name, filename, contentType); - } - - public void Add(double content, string name, string filename = null, string contentType = null) - { - Argument.AssertNotNull(content, nameof(content)); - Argument.AssertNotNullOrEmpty(name, nameof(name)); - - string value = content.ToString("G", CultureInfo.InvariantCulture); - Add(new StringContent(value), name, filename, contentType); - } - - public void Add(decimal content, string name, string filename = null, string contentType = null) - { - Argument.AssertNotNull(content, nameof(content)); - Argument.AssertNotNullOrEmpty(name, nameof(name)); - - string value = content.ToString("G", CultureInfo.InvariantCulture); - Add(new StringContent(value), name, filename, contentType); - } - - public void Add(bool content, string name, string filename = null, string contentType = null) - { - Argument.AssertNotNull(content, nameof(content)); - Argument.AssertNotNullOrEmpty(name, nameof(name)); - - string value = content ? "true" : "false"; - Add(new StringContent(value), name, filename, contentType); - } - - public void Add(Stream content, string name, string filename = null, string contentType = null) - { - Argument.AssertNotNull(content, nameof(content)); - Argument.AssertNotNullOrEmpty(name, nameof(name)); - - Add(new StreamContent(content), name, filename, contentType); - } - - public void Add(byte[] content, string name, string filename = null, string contentType = null) - { - Argument.AssertNotNull(content, nameof(content)); - Argument.AssertNotNullOrEmpty(name, nameof(name)); - - Add(new ByteArrayContent(content), name, filename, contentType); - } - - public void Add(BinaryData content, string name, string filename = null, string contentType = null) - { - Argument.AssertNotNull(content, nameof(content)); - Argument.AssertNotNullOrEmpty(name, nameof(name)); - - Add(new ByteArrayContent(content.ToArray()), name, filename, contentType); - } - - private void Add(HttpContent content, string name, string filename, string contentType) - { - if (filename != null) - { - Argument.AssertNotNullOrEmpty(filename, nameof(filename)); - AddFilenameHeader(content, name, filename); - } - if (contentType != null) - { - Argument.AssertNotNullOrEmpty(contentType, nameof(contentType)); - AddContentTypeHeader(content, contentType); - } - _multipartContent.Add(content, name); - } - - public static void AddFilenameHeader(HttpContent content, string name, string filename) - { - ContentDispositionHeaderValue header = new ContentDispositionHeaderValue("form-data") { Name = name, FileName = filename }; - content.Headers.ContentDisposition = header; - } - - public static void AddContentTypeHeader(HttpContent content, string contentType) - { - MediaTypeHeaderValue header = new MediaTypeHeaderValue(contentType); - content.Headers.ContentType = header; - } - - public override bool TryComputeLength(out long length) - { - if (_multipartContent.Headers.ContentLength is long contentLength) - { - length = contentLength; - return true; - } - length = 0; - return false; - } - - public override void WriteTo(Stream stream, CancellationToken cancellationToken = default) - { -#if NET6_0_OR_GREATER - _multipartContent.CopyTo(stream, default, cancellationToken); -#else - _multipartContent.CopyToAsync(stream).GetAwaiter().GetResult(); -#endif - } - - public override async Task WriteToAsync(Stream stream, CancellationToken cancellationToken = default) - { -#if NET6_0_OR_GREATER - await _multipartContent.CopyToAsync(stream, cancellationToken).ConfigureAwait(false); -#else - await _multipartContent.CopyToAsync(stream).ConfigureAwait(false); -#endif - } - - public override void Dispose() - { - _multipartContent.Dispose(); - } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/Optional.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/Optional.cs index 56bba5f65..4ea4dafd0 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/Optional.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/Optional.cs @@ -7,7 +7,7 @@ namespace Azure.AI.OpenAI { - internal static class Optional + internal static partial class Optional { public static bool IsCollectionDefined(IEnumerable collection) { @@ -25,7 +25,7 @@ public static bool IsCollectionDefined(IReadOnlyDictionary(T? value) - where T : struct + where T : struct { return value.HasValue; } @@ -35,14 +35,14 @@ public static bool IsDefined(object value) return value != null; } - public static bool IsDefined(JsonElement value) + public static bool IsDefined(string value) { - return value.ValueKind != JsonValueKind.Undefined; + return value != null; } - public static bool IsDefined(string value) + public static bool IsDefined(JsonElement value) { - return value != null; + return value.ValueKind != JsonValueKind.Undefined; } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/PipelineRequestHeadersExtensions.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/PipelineRequestHeadersExtensions.cs new file mode 100644 index 000000000..1fbb4104a --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/PipelineRequestHeadersExtensions.cs @@ -0,0 +1,25 @@ +// + +#nullable disable + +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.OpenAI +{ + internal static partial class PipelineRequestHeadersExtensions + { + public static void SetDelimited(this PipelineRequestHeaders headers, string name, IEnumerable value, string delimiter) + { + IEnumerable stringValues = value.Select(v => TypeFormatters.ConvertToString(v)); + headers.Set(name, string.Join(delimiter, stringValues)); + } + + public static void SetDelimited(this PipelineRequestHeaders headers, string name, IEnumerable value, string delimiter, string format) + { + IEnumerable stringValues = value.Select(v => TypeFormatters.ConvertToString(v, format)); + headers.Set(name, string.Join(delimiter, stringValues)); + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/TypeFormatters.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/TypeFormatters.cs new file mode 100644 index 000000000..c2d0f67ca --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/TypeFormatters.cs @@ -0,0 +1,150 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Xml; + +namespace Azure.AI.OpenAI +{ + internal static partial class TypeFormatters + { + private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; + public const string DefaultNumberFormat = "G"; + + public static string ToString(bool value) => value ? "true" : "false"; + + public static string ToString(DateTime value, string format) => value.Kind switch + { + DateTimeKind.Utc => ToString((DateTimeOffset)value, format), + _ => throw new NotSupportedException($"DateTime {value} has a Kind of {value.Kind}. Generated clients require it to be UTC. You can call DateTime.SpecifyKind to change Kind property value to DateTimeKind.Utc.") + }; + + public static string ToString(DateTimeOffset value, string format) => format switch + { + "D" => value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), + "U" => value.ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture), + "O" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "o" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "R" => value.ToString("r", CultureInfo.InvariantCulture), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(TimeSpan value, string format) => format switch + { + "P" => System.Xml.XmlConvert.ToString(value), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(byte[] value, string format) => format switch + { + "U" => ToBase64UrlString(value), + "D" => Convert.ToBase64String(value), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + + public static string ToBase64UrlString(byte[] value) + { + int numWholeOrPartialInputBlocks = checked (value.Length + 2) / 3; + int size = checked (numWholeOrPartialInputBlocks * 4); + char[] output = new char[size]; + + int numBase64Chars = Convert.ToBase64CharArray(value, 0, value.Length, output, 0); + + int i = 0; + for (; i < numBase64Chars; i++) + { + char ch = output[i]; + if (ch == '+') + { + output[i] = '-'; + } + else + { + if (ch == '/') + { + output[i] = '_'; + } + else + { + if (ch == '=') + { + break; + } + } + } + } + + return new string(output, 0, i); + } + + public static byte[] FromBase64UrlString(string value) + { + int paddingCharsToAdd = (value.Length % 4) switch + { + 0 => 0, + 2 => 2, + 3 => 1, + _ => throw new InvalidOperationException("Malformed input") + }; + char[] output = new char[(value.Length + paddingCharsToAdd)]; + int i = 0; + for (; i < value.Length; i++) + { + char ch = value[i]; + if (ch == '-') + { + output[i] = '+'; + } + else + { + if (ch == '_') + { + output[i] = '/'; + } + else + { + output[i] = ch; + } + } + } + + for (; i < output.Length; i++) + { + output[i] = '='; + } + + return Convert.FromBase64CharArray(output, 0, output.Length); + } + + public static DateTimeOffset ParseDateTimeOffset(string value, string format) => format switch + { + "U" => DateTimeOffset.FromUnixTimeSeconds(long.Parse(value, CultureInfo.InvariantCulture)), + _ => DateTimeOffset.Parse(value, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal) + }; + + public static TimeSpan ParseTimeSpan(string value, string format) => format switch + { + "P" => System.Xml.XmlConvert.ToTimeSpan(value), + _ => TimeSpan.ParseExact(value, format, CultureInfo.InvariantCulture) + }; + + public static string ConvertToString(object value, string format = null) => value switch + { + null => "null", + string s => s, + bool b => ToString(b), + int or float or double or long or decimal => ((IFormattable)value).ToString(DefaultNumberFormat, CultureInfo.InvariantCulture), + byte[] b0 when format != null => ToString(b0, format), + IEnumerable s0 => string.Join(",", s0), + DateTimeOffset dateTime when format != null => ToString(dateTime, format), + TimeSpan timeSpan when format != null => ToString(timeSpan, format), + TimeSpan timeSpan0 => System.Xml.XmlConvert.ToString(timeSpan0), + Guid guid => guid.ToString(), + BinaryData binaryData => ConvertToString(binaryData.ToArray(), format), + _ => value.ToString() + }; + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/Utf8JsonBinaryContent.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/Utf8JsonBinaryContent.cs index 7f70307bf..46857c303 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/Utf8JsonBinaryContent.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Internal/Utf8JsonBinaryContent.cs @@ -10,7 +10,7 @@ namespace Azure.AI.OpenAI { - internal class Utf8JsonBinaryContent : BinaryContent + internal partial class Utf8JsonBinaryContent : BinaryContent { private readonly MemoryStream _stream; private readonly BinaryContent _content; diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceAccessTokenAuthenticationOptions.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceAccessTokenAuthenticationOptions.cs deleted file mode 100644 index f112ad6ad..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceAccessTokenAuthenticationOptions.cs +++ /dev/null @@ -1,41 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI.Chat -{ - /// The AzureChatDataSourceAccessTokenAuthenticationOptions. - internal partial class InternalAzureChatDataSourceAccessTokenAuthenticationOptions : DataSourceAuthentication - { - /// Initializes a new instance of . - /// - /// is null. - public InternalAzureChatDataSourceAccessTokenAuthenticationOptions(string accessToken) - { - Argument.AssertNotNull(accessToken, nameof(accessToken)); - - Type = "access_token"; - AccessToken = accessToken; - } - - /// Initializes a new instance of . - /// - /// Keeps track of any properties unknown to the library. - /// - internal InternalAzureChatDataSourceAccessTokenAuthenticationOptions(string type, IDictionary serializedAdditionalRawData, string accessToken) : base(type, serializedAdditionalRawData) - { - AccessToken = accessToken; - } - - /// Initializes a new instance of for deserialization. - internal InternalAzureChatDataSourceAccessTokenAuthenticationOptions() - { - } - - /// Gets the access token. - internal string AccessToken { get; set; } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceApiKeyAuthenticationOptions.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceApiKeyAuthenticationOptions.cs deleted file mode 100644 index 30da6760d..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceApiKeyAuthenticationOptions.cs +++ /dev/null @@ -1,41 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI.Chat -{ - /// The AzureChatDataSourceApiKeyAuthenticationOptions. - internal partial class InternalAzureChatDataSourceApiKeyAuthenticationOptions : DataSourceAuthentication - { - /// Initializes a new instance of . - /// - /// is null. - public InternalAzureChatDataSourceApiKeyAuthenticationOptions(string key) - { - Argument.AssertNotNull(key, nameof(key)); - - Type = "api_key"; - Key = key; - } - - /// Initializes a new instance of . - /// - /// Keeps track of any properties unknown to the library. - /// - internal InternalAzureChatDataSourceApiKeyAuthenticationOptions(string type, IDictionary serializedAdditionalRawData, string key) : base(type, serializedAdditionalRawData) - { - Key = key; - } - - /// Initializes a new instance of for deserialization. - internal InternalAzureChatDataSourceApiKeyAuthenticationOptions() - { - } - - /// Gets the key. - internal string Key { get; set; } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceConnectionStringAuthenticationOptions.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceConnectionStringAuthenticationOptions.cs deleted file mode 100644 index 33a3b61f0..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceConnectionStringAuthenticationOptions.cs +++ /dev/null @@ -1,41 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI.Chat -{ - /// The AzureChatDataSourceConnectionStringAuthenticationOptions. - internal partial class InternalAzureChatDataSourceConnectionStringAuthenticationOptions : DataSourceAuthentication - { - /// Initializes a new instance of . - /// - /// is null. - public InternalAzureChatDataSourceConnectionStringAuthenticationOptions(string connectionString) - { - Argument.AssertNotNull(connectionString, nameof(connectionString)); - - Type = "connection_string"; - ConnectionString = connectionString; - } - - /// Initializes a new instance of . - /// - /// Keeps track of any properties unknown to the library. - /// - internal InternalAzureChatDataSourceConnectionStringAuthenticationOptions(string type, IDictionary serializedAdditionalRawData, string connectionString) : base(type, serializedAdditionalRawData) - { - ConnectionString = connectionString; - } - - /// Initializes a new instance of for deserialization. - internal InternalAzureChatDataSourceConnectionStringAuthenticationOptions() - { - } - - /// Gets the connection string. - internal string ConnectionString { get; set; } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceDeploymentNameVectorizationSource.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceDeploymentNameVectorizationSource.cs deleted file mode 100644 index f900a3451..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceDeploymentNameVectorizationSource.cs +++ /dev/null @@ -1,64 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI.Chat -{ - /// - /// Represents a vectorization source that makes internal service calls against an Azure OpenAI embedding model - /// deployment. In contrast with the endpoint-based vectorization source, a deployment-name-based vectorization source - /// must be part of the same Azure OpenAI resource but can be used even in private networks. - /// - internal partial class InternalAzureChatDataSourceDeploymentNameVectorizationSource : DataSourceVectorizer - { - /// Initializes a new instance of . - /// - /// The embedding model deployment to use for vectorization. This deployment must exist within the same Azure OpenAI - /// resource as the model deployment being used for chat completions. - /// - /// is null. - public InternalAzureChatDataSourceDeploymentNameVectorizationSource(string deploymentName) - { - Argument.AssertNotNull(deploymentName, nameof(deploymentName)); - - Type = "deployment_name"; - DeploymentName = deploymentName; - } - - /// Initializes a new instance of . - /// The differentiating identifier for the concrete vectorization source. - /// Keeps track of any properties unknown to the library. - /// - /// The embedding model deployment to use for vectorization. This deployment must exist within the same Azure OpenAI - /// resource as the model deployment being used for chat completions. - /// - /// - /// The number of dimensions to request on embeddings. - /// Only supported in 'text-embedding-3' and later models. - /// - internal InternalAzureChatDataSourceDeploymentNameVectorizationSource(string type, IDictionary serializedAdditionalRawData, string deploymentName, int? dimensions) : base(type, serializedAdditionalRawData) - { - DeploymentName = deploymentName; - Dimensions = dimensions; - } - - /// Initializes a new instance of for deserialization. - internal InternalAzureChatDataSourceDeploymentNameVectorizationSource() - { - } - - /// - /// The embedding model deployment to use for vectorization. This deployment must exist within the same Azure OpenAI - /// resource as the model deployment being used for chat completions. - /// - internal string DeploymentName { get; set; } - /// - /// The number of dimensions to request on embeddings. - /// Only supported in 'text-embedding-3' and later models. - /// - public int? Dimensions { get; set; } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions.cs deleted file mode 100644 index 19b3e45dd..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions.cs +++ /dev/null @@ -1,41 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI.Chat -{ - /// The AzureChatDataSourceEncodedApiKeyAuthenticationOptions. - internal partial class InternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions : DataSourceAuthentication - { - /// Initializes a new instance of . - /// - /// is null. - public InternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions(string encodedApiKey) - { - Argument.AssertNotNull(encodedApiKey, nameof(encodedApiKey)); - - Type = "encoded_api_key"; - EncodedApiKey = encodedApiKey; - } - - /// Initializes a new instance of . - /// - /// Keeps track of any properties unknown to the library. - /// - internal InternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions(string type, IDictionary serializedAdditionalRawData, string encodedApiKey) : base(type, serializedAdditionalRawData) - { - EncodedApiKey = encodedApiKey; - } - - /// Initializes a new instance of for deserialization. - internal InternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions() - { - } - - /// Gets the encoded api key. - internal string EncodedApiKey { get; set; } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceEndpointVectorizationSource.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceEndpointVectorizationSource.cs deleted file mode 100644 index c66ca6f73..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceEndpointVectorizationSource.cs +++ /dev/null @@ -1,79 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI.Chat -{ - /// Represents a vectorization source that makes public service calls against an Azure OpenAI embedding model deployment. - internal partial class InternalAzureChatDataSourceEndpointVectorizationSource : DataSourceVectorizer - { - /// Initializes a new instance of . - /// - /// Specifies the resource endpoint URL from which embeddings should be retrieved. - /// It should be in the format of: - /// https://YOUR_RESOURCE_NAME.openai.azure.com/openai/deployments/YOUR_DEPLOYMENT_NAME/embeddings. - /// The api-version query parameter is not allowed. - /// - /// - /// The authentication mechanism to use with the endpoint-based vectorization source. - /// Endpoint authentication supports API key and access token mechanisms. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.. - /// - /// or is null. - public InternalAzureChatDataSourceEndpointVectorizationSource(Uri endpoint, DataSourceAuthentication authentication) - { - Argument.AssertNotNull(endpoint, nameof(endpoint)); - Argument.AssertNotNull(authentication, nameof(authentication)); - - Type = "endpoint"; - Endpoint = endpoint; - Authentication = authentication; - } - - /// Initializes a new instance of . - /// The differentiating identifier for the concrete vectorization source. - /// Keeps track of any properties unknown to the library. - /// - /// Specifies the resource endpoint URL from which embeddings should be retrieved. - /// It should be in the format of: - /// https://YOUR_RESOURCE_NAME.openai.azure.com/openai/deployments/YOUR_DEPLOYMENT_NAME/embeddings. - /// The api-version query parameter is not allowed. - /// - /// - /// The authentication mechanism to use with the endpoint-based vectorization source. - /// Endpoint authentication supports API key and access token mechanisms. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.. - /// - /// - /// The number of dimensions to request on embeddings. - /// Only supported in 'text-embedding-3' and later models. - /// - internal InternalAzureChatDataSourceEndpointVectorizationSource(string type, IDictionary serializedAdditionalRawData, Uri endpoint, DataSourceAuthentication authentication, int? dimensions) : base(type, serializedAdditionalRawData) - { - Endpoint = endpoint; - Authentication = authentication; - Dimensions = dimensions; - } - - /// Initializes a new instance of for deserialization. - internal InternalAzureChatDataSourceEndpointVectorizationSource() - { - } - - /// - /// Specifies the resource endpoint URL from which embeddings should be retrieved. - /// It should be in the format of: - /// https://YOUR_RESOURCE_NAME.openai.azure.com/openai/deployments/YOUR_DEPLOYMENT_NAME/embeddings. - /// The api-version query parameter is not allowed. - /// - internal Uri Endpoint { get; set; } - /// - /// The number of dimensions to request on embeddings. - /// Only supported in 'text-embedding-3' and later models. - /// - public int? Dimensions { get; set; } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceIntegratedVectorizationSource.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceIntegratedVectorizationSource.cs deleted file mode 100644 index d72e6eda8..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceIntegratedVectorizationSource.cs +++ /dev/null @@ -1,26 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI.Chat -{ - /// Represents an integrated vectorization source as defined within the supporting search resource. - internal partial class InternalAzureChatDataSourceIntegratedVectorizationSource : DataSourceVectorizer - { - /// Initializes a new instance of . - public InternalAzureChatDataSourceIntegratedVectorizationSource() - { - Type = "integrated"; - } - - /// Initializes a new instance of . - /// The differentiating identifier for the concrete vectorization source. - /// Keeps track of any properties unknown to the library. - internal InternalAzureChatDataSourceIntegratedVectorizationSource(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions.cs deleted file mode 100644 index c25b1144c..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions.cs +++ /dev/null @@ -1,48 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI.Chat -{ - /// The AzureChatDataSourceKeyAndKeyIdAuthenticationOptions. - internal partial class InternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions : DataSourceAuthentication - { - /// Initializes a new instance of . - /// - /// - /// or is null. - public InternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions(string key, string keyId) - { - Argument.AssertNotNull(key, nameof(key)); - Argument.AssertNotNull(keyId, nameof(keyId)); - - Type = "key_and_key_id"; - Key = key; - KeyId = keyId; - } - - /// Initializes a new instance of . - /// - /// Keeps track of any properties unknown to the library. - /// - /// - internal InternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions(string type, IDictionary serializedAdditionalRawData, string key, string keyId) : base(type, serializedAdditionalRawData) - { - Key = key; - KeyId = keyId; - } - - /// Initializes a new instance of for deserialization. - internal InternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions() - { - } - - /// Gets the key. - internal string Key { get; set; } - /// Gets the key id. - internal string KeyId { get; set; } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceModelIdVectorizationSource.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceModelIdVectorizationSource.cs deleted file mode 100644 index cfc74a0b9..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceModelIdVectorizationSource.cs +++ /dev/null @@ -1,44 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI.Chat -{ - /// - /// Represents a vectorization source that makes service calls based on a search service model ID. - /// This source type is currently only supported by Elasticsearch. - /// - internal partial class InternalAzureChatDataSourceModelIdVectorizationSource : DataSourceVectorizer - { - /// Initializes a new instance of . - /// The embedding model build ID to use for vectorization. - /// is null. - public InternalAzureChatDataSourceModelIdVectorizationSource(string modelId) - { - Argument.AssertNotNull(modelId, nameof(modelId)); - - Type = "model_id"; - ModelId = modelId; - } - - /// Initializes a new instance of . - /// The differentiating identifier for the concrete vectorization source. - /// Keeps track of any properties unknown to the library. - /// The embedding model build ID to use for vectorization. - internal InternalAzureChatDataSourceModelIdVectorizationSource(string type, IDictionary serializedAdditionalRawData, string modelId) : base(type, serializedAdditionalRawData) - { - ModelId = modelId; - } - - /// Initializes a new instance of for deserialization. - internal InternalAzureChatDataSourceModelIdVectorizationSource() - { - } - - /// The embedding model build ID to use for vectorization. - internal string ModelId { get; set; } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions.cs deleted file mode 100644 index c895b5b4f..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions.cs +++ /dev/null @@ -1,26 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI.Chat -{ - /// The AzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions. - internal partial class InternalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions : DataSourceAuthentication - { - /// Initializes a new instance of . - public InternalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions() - { - Type = "system_assigned_managed_identity"; - } - - /// Initializes a new instance of . - /// - /// Keeps track of any properties unknown to the library. - internal InternalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions.cs deleted file mode 100644 index 041e0145d..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions.cs +++ /dev/null @@ -1,41 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI.Chat -{ - /// The AzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions. - internal partial class InternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions : DataSourceAuthentication - { - /// Initializes a new instance of . - /// - /// is null. - public InternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions(string managedIdentityResourceId) - { - Argument.AssertNotNull(managedIdentityResourceId, nameof(managedIdentityResourceId)); - - Type = "user_assigned_managed_identity"; - ManagedIdentityResourceId = managedIdentityResourceId; - } - - /// Initializes a new instance of . - /// - /// Keeps track of any properties unknown to the library. - /// - internal InternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions(string type, IDictionary serializedAdditionalRawData, string managedIdentityResourceId) : base(type, serializedAdditionalRawData) - { - ManagedIdentityResourceId = managedIdentityResourceId; - } - - /// Initializes a new instance of for deserialization. - internal InternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions() - { - } - - /// Gets the managed identity resource id. - internal string ManagedIdentityResourceId { get; set; } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions.cs deleted file mode 100644 index 2c5af490f..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions.cs +++ /dev/null @@ -1,48 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI.Chat -{ - /// The AzureChatDataSourceUsernameAndPasswordAuthenticationOptions. - internal partial class InternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions : DataSourceAuthentication - { - /// Initializes a new instance of . - /// - /// - /// or is null. - public InternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions(string username, string password) - { - Argument.AssertNotNull(username, nameof(username)); - Argument.AssertNotNull(password, nameof(password)); - - Type = "username_and_password"; - Username = username; - Password = password; - } - - /// Initializes a new instance of . - /// - /// Keeps track of any properties unknown to the library. - /// - /// - internal InternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions(string type, IDictionary serializedAdditionalRawData, string username, string password) : base(type, serializedAdditionalRawData) - { - Username = username; - Password = password; - } - - /// Initializes a new instance of for deserialization. - internal InternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions() - { - } - - /// Gets the username. - internal string Username { get; set; } - /// Gets the password. - internal string Password { get; set; } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterBlocklistIdResult.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterBlocklistIdResult.cs deleted file mode 100644 index 6a0b6cacc..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterBlocklistIdResult.cs +++ /dev/null @@ -1,80 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI -{ - /// - /// A content filter result item that associates an existing custom blocklist ID with a value indicating whether or not - /// the corresponding blocklist resulted in content being filtered. - /// - internal partial class InternalAzureContentFilterBlocklistIdResult - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - internal IDictionary SerializedAdditionalRawData { get; set; } - /// Initializes a new instance of . - /// The ID of the custom blocklist associated with the filtered status. - /// Whether the associated blocklist resulted in the content being filtered. - /// is null. - internal InternalAzureContentFilterBlocklistIdResult(string id, bool filtered) - { - Argument.AssertNotNull(id, nameof(id)); - - Id = id; - Filtered = filtered; - } - - /// Initializes a new instance of . - /// The ID of the custom blocklist associated with the filtered status. - /// Whether the associated blocklist resulted in the content being filtered. - /// Keeps track of any properties unknown to the library. - internal InternalAzureContentFilterBlocklistIdResult(string id, bool filtered, IDictionary serializedAdditionalRawData) - { - Id = id; - Filtered = filtered; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal InternalAzureContentFilterBlocklistIdResult() - { - } - - /// The ID of the custom blocklist associated with the filtered status. - internal string Id { get; set; } - /// Whether the associated blocklist resulted in the content being filtered. - internal bool Filtered { get; set; } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterBlocklistResultDetail.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterBlocklistResultDetail.cs deleted file mode 100644 index 57e5e5ea6..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterBlocklistResultDetail.cs +++ /dev/null @@ -1,77 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI -{ - /// The AzureContentFilterBlocklistResultDetail. - internal partial class InternalAzureContentFilterBlocklistResultDetail - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - internal IDictionary SerializedAdditionalRawData { get; set; } - /// Initializes a new instance of . - /// A value indicating whether the blocklist produced a filtering action. - /// The ID of the custom blocklist evaluated. - /// is null. - internal InternalAzureContentFilterBlocklistResultDetail(bool filtered, string id) - { - Argument.AssertNotNull(id, nameof(id)); - - Filtered = filtered; - Id = id; - } - - /// Initializes a new instance of . - /// A value indicating whether the blocklist produced a filtering action. - /// The ID of the custom blocklist evaluated. - /// Keeps track of any properties unknown to the library. - internal InternalAzureContentFilterBlocklistResultDetail(bool filtered, string id, IDictionary serializedAdditionalRawData) - { - Filtered = filtered; - Id = id; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal InternalAzureContentFilterBlocklistResultDetail() - { - } - - /// A value indicating whether the blocklist produced a filtering action. - internal bool Filtered { get; set; } - /// The ID of the custom blocklist evaluated. - internal string Id { get; set; } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterResultForChoiceError.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterResultForChoiceError.cs deleted file mode 100644 index a31195cb6..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterResultForChoiceError.cs +++ /dev/null @@ -1,77 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI -{ - /// The AzureContentFilterResultForChoiceError. - internal partial class InternalAzureContentFilterResultForChoiceError - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - internal IDictionary SerializedAdditionalRawData { get; set; } - /// Initializes a new instance of . - /// A distinct, machine-readable code associated with the error. - /// A human-readable message associated with the error. - /// is null. - internal InternalAzureContentFilterResultForChoiceError(int code, string message) - { - Argument.AssertNotNull(message, nameof(message)); - - Code = code; - Message = message; - } - - /// Initializes a new instance of . - /// A distinct, machine-readable code associated with the error. - /// A human-readable message associated with the error. - /// Keeps track of any properties unknown to the library. - internal InternalAzureContentFilterResultForChoiceError(int code, string message, IDictionary serializedAdditionalRawData) - { - Code = code; - Message = message; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal InternalAzureContentFilterResultForChoiceError() - { - } - - /// A distinct, machine-readable code associated with the error. - internal int Code { get; set; } - /// A human-readable message associated with the error. - internal string Message { get; set; } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterResultForPromptContentFilterResults.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterResultForPromptContentFilterResults.cs deleted file mode 100644 index 4887bb919..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterResultForPromptContentFilterResults.cs +++ /dev/null @@ -1,168 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI -{ - /// The AzureContentFilterResultForPromptContentFilterResults. - internal partial class InternalAzureContentFilterResultForPromptContentFilterResults - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - internal IDictionary SerializedAdditionalRawData { get; set; } - /// Initializes a new instance of . - /// - /// A detection result that describes user prompt injection attacks, where malicious users deliberately exploit - /// system vulnerabilities to elicit unauthorized behavior from the LLM. This could lead to inappropriate content - /// generation or violations of system-imposed restrictions. - /// - /// - /// A detection result that describes attacks on systems powered by Generative AI models that can happen every time - /// an application processes information that wasn’t directly authored by either the developer of the application or - /// the user. - /// - /// or is null. - internal InternalAzureContentFilterResultForPromptContentFilterResults(ContentFilterDetectionResult jailbreak, ContentFilterDetectionResult indirectAttack) - { - Argument.AssertNotNull(jailbreak, nameof(jailbreak)); - Argument.AssertNotNull(indirectAttack, nameof(indirectAttack)); - - Jailbreak = jailbreak; - IndirectAttack = indirectAttack; - } - - /// Initializes a new instance of . - /// - /// A content filter category for language related to anatomical organs and genitals, romantic relationships, acts - /// portrayed in erotic or affectionate terms, pregnancy, physical sexual acts, including those portrayed as an - /// assault or a forced sexual violent act against one's will, prostitution, pornography, and abuse. - /// - /// - /// A content filter category that can refer to any content that attacks or uses pejorative or discriminatory - /// language with reference to a person or identity group based on certain differentiating attributes of these groups - /// including but not limited to race, ethnicity, nationality, gender identity and expression, sexual orientation, - /// religion, immigration status, ability status, personal appearance, and body size. - /// - /// - /// A content filter category for language related to physical actions intended to hurt, injure, damage, or kill - /// someone or something; describes weapons, guns and related entities, such as manufactures, associations, - /// legislation, and so on. - /// - /// - /// A content filter category that describes language related to physical actions intended to purposely hurt, injure, - /// damage one's body or kill oneself. - /// - /// - /// A detection result that identifies whether crude, vulgar, or otherwise objection language is present in the - /// content. - /// - /// A collection of binary filtering outcomes for configured custom blocklists. - /// If present, details about an error that prevented content filtering from completing its evaluation. - /// - /// A detection result that describes user prompt injection attacks, where malicious users deliberately exploit - /// system vulnerabilities to elicit unauthorized behavior from the LLM. This could lead to inappropriate content - /// generation or violations of system-imposed restrictions. - /// - /// - /// A detection result that describes attacks on systems powered by Generative AI models that can happen every time - /// an application processes information that wasn’t directly authored by either the developer of the application or - /// the user. - /// - /// Keeps track of any properties unknown to the library. - internal InternalAzureContentFilterResultForPromptContentFilterResults(ContentFilterSeverityResult sexual, ContentFilterSeverityResult hate, ContentFilterSeverityResult violence, ContentFilterSeverityResult selfHarm, ContentFilterDetectionResult profanity, ContentFilterBlocklistResult customBlocklists, InternalAzureContentFilterResultForChoiceError error, ContentFilterDetectionResult jailbreak, ContentFilterDetectionResult indirectAttack, IDictionary serializedAdditionalRawData) - { - Sexual = sexual; - Hate = hate; - Violence = violence; - SelfHarm = selfHarm; - Profanity = profanity; - CustomBlocklists = customBlocklists; - Error = error; - Jailbreak = jailbreak; - IndirectAttack = indirectAttack; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal InternalAzureContentFilterResultForPromptContentFilterResults() - { - } - - /// - /// A content filter category for language related to anatomical organs and genitals, romantic relationships, acts - /// portrayed in erotic or affectionate terms, pregnancy, physical sexual acts, including those portrayed as an - /// assault or a forced sexual violent act against one's will, prostitution, pornography, and abuse. - /// - internal ContentFilterSeverityResult Sexual { get; set; } - /// - /// A content filter category that can refer to any content that attacks or uses pejorative or discriminatory - /// language with reference to a person or identity group based on certain differentiating attributes of these groups - /// including but not limited to race, ethnicity, nationality, gender identity and expression, sexual orientation, - /// religion, immigration status, ability status, personal appearance, and body size. - /// - internal ContentFilterSeverityResult Hate { get; set; } - /// - /// A content filter category for language related to physical actions intended to hurt, injure, damage, or kill - /// someone or something; describes weapons, guns and related entities, such as manufactures, associations, - /// legislation, and so on. - /// - internal ContentFilterSeverityResult Violence { get; set; } - /// - /// A content filter category that describes language related to physical actions intended to purposely hurt, injure, - /// damage one's body or kill oneself. - /// - internal ContentFilterSeverityResult SelfHarm { get; set; } - /// - /// A detection result that identifies whether crude, vulgar, or otherwise objection language is present in the - /// content. - /// - internal ContentFilterDetectionResult Profanity { get; set; } - /// A collection of binary filtering outcomes for configured custom blocklists. - internal ContentFilterBlocklistResult CustomBlocklists { get; set; } - /// If present, details about an error that prevented content filtering from completing its evaluation. - internal InternalAzureContentFilterResultForChoiceError Error { get; set; } - /// - /// A detection result that describes user prompt injection attacks, where malicious users deliberately exploit - /// system vulnerabilities to elicit unauthorized behavior from the LLM. This could lead to inappropriate content - /// generation or violations of system-imposed restrictions. - /// - internal ContentFilterDetectionResult Jailbreak { get; set; } - /// - /// A detection result that describes attacks on systems powered by Generative AI models that can happen every time - /// an application processes information that wasn’t directly authored by either the developer of the application or - /// the user. - /// - internal ContentFilterDetectionResult IndirectAttack { get; set; } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureCosmosDBChatDataSourceParameters.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureCosmosDBChatDataSourceParameters.cs deleted file mode 100644 index 766b29fbd..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureCosmosDBChatDataSourceParameters.cs +++ /dev/null @@ -1,152 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI.Chat -{ - /// The AzureCosmosDBChatDataSourceParameters. - internal partial class InternalAzureCosmosDBChatDataSourceParameters - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - internal IDictionary SerializedAdditionalRawData { get; set; } - /// Initializes a new instance of . - /// - /// - /// - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.. - /// - /// - /// - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.. - /// - /// - /// , , , , or is null. - public InternalAzureCosmosDBChatDataSourceParameters(string containerName, string databaseName, DataSourceVectorizer vectorizationSource, string indexName, DataSourceAuthentication authentication, DataSourceFieldMappings fieldMappings) - { - Argument.AssertNotNull(containerName, nameof(containerName)); - Argument.AssertNotNull(databaseName, nameof(databaseName)); - Argument.AssertNotNull(vectorizationSource, nameof(vectorizationSource)); - Argument.AssertNotNull(indexName, nameof(indexName)); - Argument.AssertNotNull(authentication, nameof(authentication)); - Argument.AssertNotNull(fieldMappings, nameof(fieldMappings)); - - _internalIncludeContexts = new ChangeTrackingList(); - ContainerName = containerName; - DatabaseName = databaseName; - VectorizationSource = vectorizationSource; - IndexName = indexName; - Authentication = authentication; - FieldMappings = fieldMappings; - } - - /// Initializes a new instance of . - /// The configured number of documents to feature in the query. - /// Whether queries should be restricted to use of the indexed data. - /// - /// The configured strictness of the search relevance filtering. - /// Higher strictness will increase precision but lower recall of the answer. - /// - /// - /// The maximum number of rewritten queries that should be sent to the search provider for a single user message. - /// By default, the system will make an automatic determination. - /// - /// - /// If set to true, the system will allow partial search results to be used and the request will fail if all - /// partial queries fail. If not specified or specified as false, the request will fail if any search query fails. - /// - /// - /// The output context properties to include on the response. - /// By default, citations and intent will be requested. - /// - /// - /// - /// - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.. - /// - /// - /// - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.. - /// - /// - /// Keeps track of any properties unknown to the library. - internal InternalAzureCosmosDBChatDataSourceParameters(int? topNDocuments, bool? inScope, int? strictness, int? maxSearchQueries, bool? allowPartialResult, IList internalIncludeContexts, string containerName, string databaseName, DataSourceVectorizer vectorizationSource, string indexName, DataSourceAuthentication authentication, DataSourceFieldMappings fieldMappings, IDictionary serializedAdditionalRawData) - { - TopNDocuments = topNDocuments; - InScope = inScope; - Strictness = strictness; - MaxSearchQueries = maxSearchQueries; - AllowPartialResult = allowPartialResult; - _internalIncludeContexts = internalIncludeContexts; - ContainerName = containerName; - DatabaseName = databaseName; - VectorizationSource = vectorizationSource; - IndexName = indexName; - Authentication = authentication; - FieldMappings = fieldMappings; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal InternalAzureCosmosDBChatDataSourceParameters() - { - } - - /// The configured number of documents to feature in the query. - public int? TopNDocuments { get; set; } - /// Whether queries should be restricted to use of the indexed data. - public bool? InScope { get; set; } - /// - /// The configured strictness of the search relevance filtering. - /// Higher strictness will increase precision but lower recall of the answer. - /// - public int? Strictness { get; set; } - /// - /// The maximum number of rewritten queries that should be sent to the search provider for a single user message. - /// By default, the system will make an automatic determination. - /// - public int? MaxSearchQueries { get; set; } - /// - /// If set to true, the system will allow partial search results to be used and the request will fail if all - /// partial queries fail. If not specified or specified as false, the request will fail if any search query fails. - /// - public bool? AllowPartialResult { get; set; } - /// Gets the container name. - internal string ContainerName { get; set; } - /// Gets the database name. - internal string DatabaseName { get; set; } - /// Gets the index name. - internal string IndexName { get; set; } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureOpenAIChatErrorInnerError.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureOpenAIChatErrorInnerError.cs deleted file mode 100644 index 94f1da0eb..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureOpenAIChatErrorInnerError.cs +++ /dev/null @@ -1,69 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI -{ - /// The AzureOpenAIChatErrorInnerError. - internal partial class InternalAzureOpenAIChatErrorInnerError - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - internal IDictionary SerializedAdditionalRawData { get; set; } - /// Initializes a new instance of . - internal InternalAzureOpenAIChatErrorInnerError() - { - } - - /// Initializes a new instance of . - /// The code associated with the inner error. - /// If applicable, the modified prompt used for generation. - /// The content filter result details associated with the inner error. - /// Keeps track of any properties unknown to the library. - internal InternalAzureOpenAIChatErrorInnerError(InternalAzureOpenAIChatErrorInnerErrorCode? code, string revisedPrompt, RequestContentFilterResult contentFilterResults, IDictionary serializedAdditionalRawData) - { - Code = code; - RevisedPrompt = revisedPrompt; - ContentFilterResults = contentFilterResults; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - /// The code associated with the inner error. - internal InternalAzureOpenAIChatErrorInnerErrorCode? Code { get; set; } - /// If applicable, the modified prompt used for generation. - internal string RevisedPrompt { get; set; } - /// The content filter result details associated with the inner error. - internal RequestContentFilterResult ContentFilterResults { get; set; } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureOpenAIDalleErrorInnerError.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureOpenAIDalleErrorInnerError.cs deleted file mode 100644 index d600b81cf..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureOpenAIDalleErrorInnerError.cs +++ /dev/null @@ -1,69 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI -{ - /// The AzureOpenAIDalleErrorInnerError. - internal partial class InternalAzureOpenAIDalleErrorInnerError - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - internal IDictionary SerializedAdditionalRawData { get; set; } - /// Initializes a new instance of . - internal InternalAzureOpenAIDalleErrorInnerError() - { - } - - /// Initializes a new instance of . - /// The code associated with the inner error. - /// If applicable, the modified prompt used for generation. - /// The content filter result details associated with the inner error. - /// Keeps track of any properties unknown to the library. - internal InternalAzureOpenAIDalleErrorInnerError(InternalAzureOpenAIDalleErrorInnerErrorCode? code, string revisedPrompt, RequestImageContentFilterResult contentFilterResults, IDictionary serializedAdditionalRawData) - { - Code = code; - RevisedPrompt = revisedPrompt; - ContentFilterResults = contentFilterResults; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - /// The code associated with the inner error. - internal InternalAzureOpenAIDalleErrorInnerErrorCode? Code { get; set; } - /// If applicable, the modified prompt used for generation. - internal string RevisedPrompt { get; set; } - /// The content filter result details associated with the inner error. - internal RequestImageContentFilterResult ContentFilterResults { get; set; } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureSearchChatDataSourceParameters.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureSearchChatDataSourceParameters.cs deleted file mode 100644 index cbd3f5dcc..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureSearchChatDataSourceParameters.cs +++ /dev/null @@ -1,151 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI.Chat -{ - /// The AzureSearchChatDataSourceParameters. - internal partial class InternalAzureSearchChatDataSourceParameters - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - internal IDictionary SerializedAdditionalRawData { get; set; } - /// Initializes a new instance of . - /// The absolute endpoint path for the Azure Search resource to use. - /// The name of the index to use, as specified in the Azure Search resource. - /// - /// The authentication mechanism to use with Azure Search. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.. - /// - /// , or is null. - public InternalAzureSearchChatDataSourceParameters(Uri endpoint, string indexName, DataSourceAuthentication authentication) - { - Argument.AssertNotNull(endpoint, nameof(endpoint)); - Argument.AssertNotNull(indexName, nameof(indexName)); - Argument.AssertNotNull(authentication, nameof(authentication)); - - _internalIncludeContexts = new ChangeTrackingList(); - Endpoint = endpoint; - IndexName = indexName; - Authentication = authentication; - } - - /// Initializes a new instance of . - /// The configured number of documents to feature in the query. - /// Whether queries should be restricted to use of the indexed data. - /// - /// The configured strictness of the search relevance filtering. - /// Higher strictness will increase precision but lower recall of the answer. - /// - /// - /// The maximum number of rewritten queries that should be sent to the search provider for a single user message. - /// By default, the system will make an automatic determination. - /// - /// - /// If set to true, the system will allow partial search results to be used and the request will fail if all - /// partial queries fail. If not specified or specified as false, the request will fail if any search query fails. - /// - /// - /// The output context properties to include on the response. - /// By default, citations and intent will be requested. - /// - /// The absolute endpoint path for the Azure Search resource to use. - /// The name of the index to use, as specified in the Azure Search resource. - /// - /// The authentication mechanism to use with Azure Search. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.. - /// - /// The field mappings to use with the Azure Search resource. - /// The query type for the Azure Search resource to use. - /// Additional semantic configuration for the query. - /// A filter to apply to the search. - /// - /// The vectorization source to use with Azure Search. - /// Supported sources for Azure Search include endpoint, deployment name, and integrated. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.. - /// - /// Keeps track of any properties unknown to the library. - internal InternalAzureSearchChatDataSourceParameters(int? topNDocuments, bool? inScope, int? strictness, int? maxSearchQueries, bool? allowPartialResult, IList internalIncludeContexts, Uri endpoint, string indexName, DataSourceAuthentication authentication, DataSourceFieldMappings fieldMappings, DataSourceQueryType? queryType, string semanticConfiguration, string filter, DataSourceVectorizer vectorizationSource, IDictionary serializedAdditionalRawData) - { - TopNDocuments = topNDocuments; - InScope = inScope; - Strictness = strictness; - MaxSearchQueries = maxSearchQueries; - AllowPartialResult = allowPartialResult; - _internalIncludeContexts = internalIncludeContexts; - Endpoint = endpoint; - IndexName = indexName; - Authentication = authentication; - FieldMappings = fieldMappings; - QueryType = queryType; - SemanticConfiguration = semanticConfiguration; - Filter = filter; - VectorizationSource = vectorizationSource; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal InternalAzureSearchChatDataSourceParameters() - { - } - - /// The configured number of documents to feature in the query. - public int? TopNDocuments { get; set; } - /// Whether queries should be restricted to use of the indexed data. - public bool? InScope { get; set; } - /// - /// The configured strictness of the search relevance filtering. - /// Higher strictness will increase precision but lower recall of the answer. - /// - public int? Strictness { get; set; } - /// - /// The maximum number of rewritten queries that should be sent to the search provider for a single user message. - /// By default, the system will make an automatic determination. - /// - public int? MaxSearchQueries { get; set; } - /// - /// If set to true, the system will allow partial search results to be used and the request will fail if all - /// partial queries fail. If not specified or specified as false, the request will fail if any search query fails. - /// - public bool? AllowPartialResult { get; set; } - /// The absolute endpoint path for the Azure Search resource to use. - internal Uri Endpoint { get; set; } - /// The name of the index to use, as specified in the Azure Search resource. - internal string IndexName { get; set; } - /// Additional semantic configuration for the query. - public string SemanticConfiguration { get; set; } - /// A filter to apply to the search. - public string Filter { get; set; } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalElasticsearchChatDataSourceParameters.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalElasticsearchChatDataSourceParameters.cs deleted file mode 100644 index f82b1889d..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalElasticsearchChatDataSourceParameters.cs +++ /dev/null @@ -1,139 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI.Chat -{ - /// The ElasticsearchChatDataSourceParameters. - internal partial class InternalElasticsearchChatDataSourceParameters - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - internal IDictionary SerializedAdditionalRawData { get; set; } - /// Initializes a new instance of . - /// - /// - /// - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.. - /// - /// , or is null. - public InternalElasticsearchChatDataSourceParameters(Uri endpoint, string indexName, DataSourceAuthentication authentication) - { - Argument.AssertNotNull(endpoint, nameof(endpoint)); - Argument.AssertNotNull(indexName, nameof(indexName)); - Argument.AssertNotNull(authentication, nameof(authentication)); - - _internalIncludeContexts = new ChangeTrackingList(); - Endpoint = endpoint; - IndexName = indexName; - Authentication = authentication; - } - - /// Initializes a new instance of . - /// The configured number of documents to feature in the query. - /// Whether queries should be restricted to use of the indexed data. - /// - /// The configured strictness of the search relevance filtering. - /// Higher strictness will increase precision but lower recall of the answer. - /// - /// - /// The maximum number of rewritten queries that should be sent to the search provider for a single user message. - /// By default, the system will make an automatic determination. - /// - /// - /// If set to true, the system will allow partial search results to be used and the request will fail if all - /// partial queries fail. If not specified or specified as false, the request will fail if any search query fails. - /// - /// - /// The output context properties to include on the response. - /// By default, citations and intent will be requested. - /// - /// - /// - /// - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.. - /// - /// - /// - /// - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.. - /// - /// Keeps track of any properties unknown to the library. - internal InternalElasticsearchChatDataSourceParameters(int? topNDocuments, bool? inScope, int? strictness, int? maxSearchQueries, bool? allowPartialResult, IList internalIncludeContexts, Uri endpoint, string indexName, DataSourceAuthentication authentication, DataSourceFieldMappings fieldMappings, DataSourceQueryType? queryType, DataSourceVectorizer vectorizationSource, IDictionary serializedAdditionalRawData) - { - TopNDocuments = topNDocuments; - InScope = inScope; - Strictness = strictness; - MaxSearchQueries = maxSearchQueries; - AllowPartialResult = allowPartialResult; - _internalIncludeContexts = internalIncludeContexts; - Endpoint = endpoint; - IndexName = indexName; - Authentication = authentication; - FieldMappings = fieldMappings; - QueryType = queryType; - VectorizationSource = vectorizationSource; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal InternalElasticsearchChatDataSourceParameters() - { - } - - /// The configured number of documents to feature in the query. - public int? TopNDocuments { get; set; } - /// Whether queries should be restricted to use of the indexed data. - public bool? InScope { get; set; } - /// - /// The configured strictness of the search relevance filtering. - /// Higher strictness will increase precision but lower recall of the answer. - /// - public int? Strictness { get; set; } - /// - /// The maximum number of rewritten queries that should be sent to the search provider for a single user message. - /// By default, the system will make an automatic determination. - /// - public int? MaxSearchQueries { get; set; } - /// - /// If set to true, the system will allow partial search results to be used and the request will fail if all - /// partial queries fail. If not specified or specified as false, the request will fail if any search query fails. - /// - public bool? AllowPartialResult { get; set; } - /// Gets the endpoint. - internal Uri Endpoint { get; set; } - /// Gets the index name. - internal string IndexName { get; set; } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalMongoDBChatDataSourceParameters.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalMongoDBChatDataSourceParameters.cs deleted file mode 100644 index 5b79c3c25..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalMongoDBChatDataSourceParameters.cs +++ /dev/null @@ -1,180 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI.Chat -{ - /// The MongoDBChatDataSourceParameters. - internal partial class InternalMongoDBChatDataSourceParameters - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - internal IDictionary SerializedAdditionalRawData { get; set; } - /// Initializes a new instance of . - /// The name of the MongoDB cluster endpoint. - /// The name of the MongoDB database. - /// The name of the MongoDB collection. - /// The name of the MongoDB application. - /// The name of the MongoDB index. - /// - /// The authentication mechanism to use with Pinecone. - /// Supported authentication mechanisms for Pinecone include: username and password. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.. - /// - /// - /// The vectorization source to use as an embedding dependency for the MongoDB data source. - /// Supported vectorization sources for MongoDB include: endpoint, deployment name. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.. - /// - /// - /// Field mappings to apply to data used by the MongoDB data source. - /// Note that content and vector field mappings are required for MongoDB. - /// - /// , , , , , , or is null. - public InternalMongoDBChatDataSourceParameters(string endpoint, string databaseName, string collectionName, string appName, string indexName, DataSourceAuthentication authentication, DataSourceVectorizer embeddingDependency, DataSourceFieldMappings fieldMappings) - { - Argument.AssertNotNull(endpoint, nameof(endpoint)); - Argument.AssertNotNull(databaseName, nameof(databaseName)); - Argument.AssertNotNull(collectionName, nameof(collectionName)); - Argument.AssertNotNull(appName, nameof(appName)); - Argument.AssertNotNull(indexName, nameof(indexName)); - Argument.AssertNotNull(authentication, nameof(authentication)); - Argument.AssertNotNull(embeddingDependency, nameof(embeddingDependency)); - Argument.AssertNotNull(fieldMappings, nameof(fieldMappings)); - - _internalIncludeContexts = new ChangeTrackingList(); - Endpoint = endpoint; - DatabaseName = databaseName; - CollectionName = collectionName; - AppName = appName; - IndexName = indexName; - Authentication = authentication; - EmbeddingDependency = embeddingDependency; - FieldMappings = fieldMappings; - } - - /// Initializes a new instance of . - /// The configured number of documents to feature in the query. - /// Whether queries should be restricted to use of the indexed data. - /// - /// The configured strictness of the search relevance filtering. - /// Higher strictness will increase precision but lower recall of the answer. - /// - /// - /// The maximum number of rewritten queries that should be sent to the search provider for a single user message. - /// By default, the system will make an automatic determination. - /// - /// - /// If set to true, the system will allow partial search results to be used and the request will fail if all - /// partial queries fail. If not specified or specified as false, the request will fail if any search query fails. - /// - /// - /// The output context properties to include on the response. - /// By default, citations and intent will be requested. - /// - /// The name of the MongoDB cluster endpoint. - /// The name of the MongoDB database. - /// The name of the MongoDB collection. - /// The name of the MongoDB application. - /// The name of the MongoDB index. - /// - /// The authentication mechanism to use with Pinecone. - /// Supported authentication mechanisms for Pinecone include: username and password. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.. - /// - /// - /// The vectorization source to use as an embedding dependency for the MongoDB data source. - /// Supported vectorization sources for MongoDB include: endpoint, deployment name. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.. - /// - /// - /// Field mappings to apply to data used by the MongoDB data source. - /// Note that content and vector field mappings are required for MongoDB. - /// - /// Keeps track of any properties unknown to the library. - internal InternalMongoDBChatDataSourceParameters(int? topNDocuments, bool? inScope, int? strictness, int? maxSearchQueries, bool? allowPartialResult, IList internalIncludeContexts, string endpoint, string databaseName, string collectionName, string appName, string indexName, DataSourceAuthentication authentication, DataSourceVectorizer embeddingDependency, DataSourceFieldMappings fieldMappings, IDictionary serializedAdditionalRawData) - { - TopNDocuments = topNDocuments; - InScope = inScope; - Strictness = strictness; - MaxSearchQueries = maxSearchQueries; - AllowPartialResult = allowPartialResult; - _internalIncludeContexts = internalIncludeContexts; - Endpoint = endpoint; - DatabaseName = databaseName; - CollectionName = collectionName; - AppName = appName; - IndexName = indexName; - Authentication = authentication; - EmbeddingDependency = embeddingDependency; - FieldMappings = fieldMappings; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal InternalMongoDBChatDataSourceParameters() - { - } - - /// The configured number of documents to feature in the query. - public int? TopNDocuments { get; set; } - /// Whether queries should be restricted to use of the indexed data. - public bool? InScope { get; set; } - /// - /// The configured strictness of the search relevance filtering. - /// Higher strictness will increase precision but lower recall of the answer. - /// - public int? Strictness { get; set; } - /// - /// The maximum number of rewritten queries that should be sent to the search provider for a single user message. - /// By default, the system will make an automatic determination. - /// - public int? MaxSearchQueries { get; set; } - /// - /// If set to true, the system will allow partial search results to be used and the request will fail if all - /// partial queries fail. If not specified or specified as false, the request will fail if any search query fails. - /// - public bool? AllowPartialResult { get; set; } - /// The name of the MongoDB cluster endpoint. - internal string Endpoint { get; set; } - /// The name of the MongoDB database. - internal string DatabaseName { get; set; } - /// The name of the MongoDB collection. - internal string CollectionName { get; set; } - /// The name of the MongoDB application. - internal string AppName { get; set; } - /// The name of the MongoDB index. - internal string IndexName { get; set; } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalPineconeChatDataSourceParameters.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalPineconeChatDataSourceParameters.cs deleted file mode 100644 index a559fbb2e..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalPineconeChatDataSourceParameters.cs +++ /dev/null @@ -1,159 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI.Chat -{ - /// The PineconeChatDataSourceParameters. - internal partial class InternalPineconeChatDataSourceParameters - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - internal IDictionary SerializedAdditionalRawData { get; set; } - /// Initializes a new instance of . - /// The environment name to use with Pinecone. - /// The name of the Pinecone database index to use. - /// - /// The authentication mechanism to use with Pinecone. - /// Supported authentication mechanisms for Pinecone include: API key. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.. - /// - /// - /// The vectorization source to use as an embedding dependency for the Pinecone data source. - /// Supported vectorization sources for Pinecone include: deployment name. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.. - /// - /// - /// Field mappings to apply to data used by the Pinecone data source. - /// Note that content field mappings are required for Pinecone. - /// - /// , , , or is null. - public InternalPineconeChatDataSourceParameters(string environment, string indexName, DataSourceAuthentication authentication, DataSourceVectorizer vectorizationSource, DataSourceFieldMappings fieldMappings) - { - Argument.AssertNotNull(environment, nameof(environment)); - Argument.AssertNotNull(indexName, nameof(indexName)); - Argument.AssertNotNull(authentication, nameof(authentication)); - Argument.AssertNotNull(vectorizationSource, nameof(vectorizationSource)); - Argument.AssertNotNull(fieldMappings, nameof(fieldMappings)); - - _internalIncludeContexts = new ChangeTrackingList(); - Environment = environment; - IndexName = indexName; - Authentication = authentication; - VectorizationSource = vectorizationSource; - FieldMappings = fieldMappings; - } - - /// Initializes a new instance of . - /// The configured number of documents to feature in the query. - /// Whether queries should be restricted to use of the indexed data. - /// - /// The configured strictness of the search relevance filtering. - /// Higher strictness will increase precision but lower recall of the answer. - /// - /// - /// The maximum number of rewritten queries that should be sent to the search provider for a single user message. - /// By default, the system will make an automatic determination. - /// - /// - /// If set to true, the system will allow partial search results to be used and the request will fail if all - /// partial queries fail. If not specified or specified as false, the request will fail if any search query fails. - /// - /// - /// The output context properties to include on the response. - /// By default, citations and intent will be requested. - /// - /// The environment name to use with Pinecone. - /// The name of the Pinecone database index to use. - /// - /// The authentication mechanism to use with Pinecone. - /// Supported authentication mechanisms for Pinecone include: API key. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.. - /// - /// - /// The vectorization source to use as an embedding dependency for the Pinecone data source. - /// Supported vectorization sources for Pinecone include: deployment name. - /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes.. - /// - /// - /// Field mappings to apply to data used by the Pinecone data source. - /// Note that content field mappings are required for Pinecone. - /// - /// Keeps track of any properties unknown to the library. - internal InternalPineconeChatDataSourceParameters(int? topNDocuments, bool? inScope, int? strictness, int? maxSearchQueries, bool? allowPartialResult, IList internalIncludeContexts, string environment, string indexName, DataSourceAuthentication authentication, DataSourceVectorizer vectorizationSource, DataSourceFieldMappings fieldMappings, IDictionary serializedAdditionalRawData) - { - TopNDocuments = topNDocuments; - InScope = inScope; - Strictness = strictness; - MaxSearchQueries = maxSearchQueries; - AllowPartialResult = allowPartialResult; - _internalIncludeContexts = internalIncludeContexts; - Environment = environment; - IndexName = indexName; - Authentication = authentication; - VectorizationSource = vectorizationSource; - FieldMappings = fieldMappings; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal InternalPineconeChatDataSourceParameters() - { - } - - /// The configured number of documents to feature in the query. - public int? TopNDocuments { get; set; } - /// Whether queries should be restricted to use of the indexed data. - public bool? InScope { get; set; } - /// - /// The configured strictness of the search relevance filtering. - /// Higher strictness will increase precision but lower recall of the answer. - /// - public int? Strictness { get; set; } - /// - /// The maximum number of rewritten queries that should be sent to the search provider for a single user message. - /// By default, the system will make an automatic determination. - /// - public int? MaxSearchQueries { get; set; } - /// - /// If set to true, the system will allow partial search results to be used and the request will fail if all - /// partial queries fail. If not specified or specified as false, the request will fail if any search query fails. - /// - public bool? AllowPartialResult { get; set; } - /// The environment name to use with Pinecone. - internal string Environment { get; set; } - /// The name of the Pinecone database index to use. - internal string IndexName { get; set; } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalUnknownAzureChatDataSource.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalUnknownAzureChatDataSource.cs deleted file mode 100644 index 4d8d34f5d..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalUnknownAzureChatDataSource.cs +++ /dev/null @@ -1,25 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI.Chat -{ - /// Unknown version of AzureChatDataSource. - internal partial class InternalUnknownAzureChatDataSource : ChatDataSource - { - /// Initializes a new instance of . - /// The differentiating type identifier for the data source. - /// Keeps track of any properties unknown to the library. - internal InternalUnknownAzureChatDataSource(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } - - /// Initializes a new instance of for deserialization. - internal InternalUnknownAzureChatDataSource() - { - } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalUnknownAzureChatDataSourceAuthenticationOptions.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalUnknownAzureChatDataSourceAuthenticationOptions.cs deleted file mode 100644 index df4ea2dad..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalUnknownAzureChatDataSourceAuthenticationOptions.cs +++ /dev/null @@ -1,25 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI.Chat -{ - /// Unknown version of AzureChatDataSourceAuthenticationOptions. - internal partial class InternalUnknownAzureChatDataSourceAuthenticationOptions : DataSourceAuthentication - { - /// Initializes a new instance of . - /// - /// Keeps track of any properties unknown to the library. - internal InternalUnknownAzureChatDataSourceAuthenticationOptions(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } - - /// Initializes a new instance of for deserialization. - internal InternalUnknownAzureChatDataSourceAuthenticationOptions() - { - } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalUnknownAzureChatDataSourceVectorizationSource.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalUnknownAzureChatDataSourceVectorizationSource.cs deleted file mode 100644 index 6b9910a12..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalUnknownAzureChatDataSourceVectorizationSource.cs +++ /dev/null @@ -1,25 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI.Chat -{ - /// Unknown version of AzureChatDataSourceVectorizationSource. - internal partial class InternalUnknownAzureChatDataSourceVectorizationSource : DataSourceVectorizer - { - /// Initializes a new instance of . - /// The differentiating identifier for the concrete vectorization source. - /// Keeps track of any properties unknown to the library. - internal InternalUnknownAzureChatDataSourceVectorizationSource(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } - - /// Initializes a new instance of for deserialization. - internal InternalUnknownAzureChatDataSourceVectorizationSource() - { - } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIChatError.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/AzureOpenAIChatError.Serialization.cs similarity index 56% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIChatError.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/AzureOpenAIChatError.Serialization.cs index b81a78292..8ad0d6ac7 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIChatError.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/AzureOpenAIChatError.Serialization.cs @@ -19,44 +19,41 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWr writer.WriteEndObject(); } - /// The JSON writer. - /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(AzureOpenAIChatError)} does not support writing '{format}' format."); } - - if (SerializedAdditionalRawData?.ContainsKey("code") != true && Optional.IsDefined(Code)) + if (Optional.IsDefined(Code) && _additionalBinaryDataProperties?.ContainsKey("code") != true) { writer.WritePropertyName("code"u8); writer.WriteStringValue(Code); } - if (SerializedAdditionalRawData?.ContainsKey("message") != true && Optional.IsDefined(Message)) + if (Optional.IsDefined(Message) && _additionalBinaryDataProperties?.ContainsKey("message") != true) { writer.WritePropertyName("message"u8); writer.WriteStringValue(Message); } - if (SerializedAdditionalRawData?.ContainsKey("param") != true && Optional.IsDefined(Param)) + if (Optional.IsDefined(Param) && _additionalBinaryDataProperties?.ContainsKey("param") != true) { writer.WritePropertyName("param"u8); writer.WriteStringValue(Param); } - if (SerializedAdditionalRawData?.ContainsKey("type") != true && Optional.IsDefined(Type)) + if (Optional.IsDefined(Type) && _additionalBinaryDataProperties?.ContainsKey("type") != true) { writer.WritePropertyName("type"u8); writer.WriteStringValue(Type); } - if (SerializedAdditionalRawData?.ContainsKey("inner_error") != true && Optional.IsDefined(InnerError)) + if (Optional.IsDefined(InnerError) && _additionalBinaryDataProperties?.ContainsKey("inner_error") != true) { writer.WritePropertyName("inner_error"u8); writer.WriteObjectValue(InnerError, options); } - if (SerializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in SerializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { @@ -64,7 +61,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else using (JsonDocument document = JsonDocument.Parse(item.Value)) { @@ -75,84 +72,81 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - AzureOpenAIChatError IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + AzureOpenAIChatError IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + protected virtual AzureOpenAIChatError JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(AzureOpenAIChatError)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeAzureOpenAIChatError(document.RootElement, options); } - internal static AzureOpenAIChatError DeserializeAzureOpenAIChatError(JsonElement element, ModelReaderWriterOptions options = null) + internal static AzureOpenAIChatError DeserializeAzureOpenAIChatError(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } string code = default; string message = default; - string param = default; - string type = default; + string @param = default; + string @type = default; InternalAzureOpenAIChatErrorInnerError innerError = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("code"u8)) + if (prop.NameEquals("code"u8)) { - code = property.Value.GetString(); + code = prop.Value.GetString(); continue; } - if (property.NameEquals("message"u8)) + if (prop.NameEquals("message"u8)) { - message = property.Value.GetString(); + message = prop.Value.GetString(); continue; } - if (property.NameEquals("param"u8)) + if (prop.NameEquals("param"u8)) { - param = property.Value.GetString(); + @param = prop.Value.GetString(); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("type"u8)) { - type = property.Value.GetString(); + @type = prop.Value.GetString(); continue; } - if (property.NameEquals("inner_error"u8)) + if (prop.NameEquals("inner_error"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - innerError = InternalAzureOpenAIChatErrorInnerError.DeserializeInternalAzureOpenAIChatErrorInnerError(property.Value, options); + innerError = InternalAzureOpenAIChatErrorInnerError.DeserializeInternalAzureOpenAIChatErrorInnerError(prop.Value, options); continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new AzureOpenAIChatError( code, message, - param, - type, + @param, + @type, innerError, - serializedAdditionalRawData); + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -162,15 +156,16 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOption } } - AzureOpenAIChatError IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + AzureOpenAIChatError IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + protected virtual AzureOpenAIChatError PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeAzureOpenAIChatError(document.RootElement, options); } default: @@ -180,18 +175,20 @@ AzureOpenAIChatError IPersistableModel.Create(BinaryData d string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static AzureOpenAIChatError FromResponse(PipelineResponse response) + public static implicit operator BinaryContent(AzureOpenAIChatError azureOpenAIChatError) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeAzureOpenAIChatError(document.RootElement); + if (azureOpenAIChatError == null) + { + return null; + } + return BinaryContent.Create(azureOpenAIChatError, ModelSerializationExtensions.WireOptions); } - /// Convert into a . - internal virtual BinaryContent ToBinaryContent() + public static explicit operator AzureOpenAIChatError(ClientResult result) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeAzureOpenAIChatError(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/AzureOpenAIChatError.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/AzureOpenAIChatError.cs new file mode 100644 index 000000000..62c077fcd --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/AzureOpenAIChatError.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI +{ + internal partial class AzureOpenAIChatError + { + /// Keeps track of any properties unknown to the library. + private protected IDictionary _additionalBinaryDataProperties; + + internal AzureOpenAIChatError() + { + } + + internal AzureOpenAIChatError(string code, string message, string @param, string @type, InternalAzureOpenAIChatErrorInnerError innerError, IDictionary additionalBinaryDataProperties) + { + Code = code; + Message = message; + Param = @param; + Type = @type; + InnerError = innerError; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + public string Code { get; } + + public string Message { get; } + + public string Param { get; } + + public string Type { get; } + + public InternalAzureOpenAIChatErrorInnerError InnerError { get; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIChatErrorResponse.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/AzureOpenAIChatErrorResponse.Serialization.cs similarity index 58% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIChatErrorResponse.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/AzureOpenAIChatErrorResponse.Serialization.cs index 18d3d9b78..47804130d 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIChatErrorResponse.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/AzureOpenAIChatErrorResponse.Serialization.cs @@ -19,24 +19,21 @@ void IJsonModel.Write(Utf8JsonWriter writer, Model writer.WriteEndObject(); } - /// The JSON writer. - /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(AzureOpenAIChatErrorResponse)} does not support writing '{format}' format."); } - - if (SerializedAdditionalRawData?.ContainsKey("error") != true && Optional.IsDefined(Error)) + if (Optional.IsDefined(Error) && _additionalBinaryDataProperties?.ContainsKey("error") != true) { writer.WritePropertyName("error"u8); writer.WriteObjectValue(Error, options); } - if (SerializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in SerializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { @@ -44,7 +41,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else using (JsonDocument document = JsonDocument.Parse(item.Value)) { @@ -55,54 +52,51 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - AzureOpenAIChatErrorResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + AzureOpenAIChatErrorResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + protected virtual AzureOpenAIChatErrorResponse JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(AzureOpenAIChatErrorResponse)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeAzureOpenAIChatErrorResponse(document.RootElement, options); } - internal static AzureOpenAIChatErrorResponse DeserializeAzureOpenAIChatErrorResponse(JsonElement element, ModelReaderWriterOptions options = null) + internal static AzureOpenAIChatErrorResponse DeserializeAzureOpenAIChatErrorResponse(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } AzureOpenAIChatError error = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("error"u8)) + if (prop.NameEquals("error"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - error = AzureOpenAIChatError.DeserializeAzureOpenAIChatError(property.Value, options); + error = AzureOpenAIChatError.DeserializeAzureOpenAIChatError(prop.Value, options); continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new AzureOpenAIChatErrorResponse(error, serializedAdditionalRawData); + return new AzureOpenAIChatErrorResponse(error, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -112,15 +106,16 @@ BinaryData IPersistableModel.Write(ModelReaderWrit } } - AzureOpenAIChatErrorResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + AzureOpenAIChatErrorResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + protected virtual AzureOpenAIChatErrorResponse PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeAzureOpenAIChatErrorResponse(document.RootElement, options); } default: @@ -130,18 +125,20 @@ AzureOpenAIChatErrorResponse IPersistableModel.Cre string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static AzureOpenAIChatErrorResponse FromResponse(PipelineResponse response) + public static implicit operator BinaryContent(AzureOpenAIChatErrorResponse azureOpenAIChatErrorResponse) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeAzureOpenAIChatErrorResponse(document.RootElement); + if (azureOpenAIChatErrorResponse == null) + { + return null; + } + return BinaryContent.Create(azureOpenAIChatErrorResponse, ModelSerializationExtensions.WireOptions); } - /// Convert into a . - internal virtual BinaryContent ToBinaryContent() + public static explicit operator AzureOpenAIChatErrorResponse(ClientResult result) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeAzureOpenAIChatErrorResponse(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/AzureOpenAIChatErrorResponse.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/AzureOpenAIChatErrorResponse.cs new file mode 100644 index 000000000..1cc1c60f8 --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/AzureOpenAIChatErrorResponse.cs @@ -0,0 +1,33 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI +{ + internal partial class AzureOpenAIChatErrorResponse + { + /// Keeps track of any properties unknown to the library. + private protected IDictionary _additionalBinaryDataProperties; + + internal AzureOpenAIChatErrorResponse() + { + } + + internal AzureOpenAIChatErrorResponse(AzureOpenAIChatError error, IDictionary additionalBinaryDataProperties) + { + Error = error; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + public AzureOpenAIChatError Error { get; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIDalleError.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/AzureOpenAIDalleError.Serialization.cs similarity index 57% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIDalleError.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/AzureOpenAIDalleError.Serialization.cs index ce364c570..7eb6d9501 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIDalleError.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/AzureOpenAIDalleError.Serialization.cs @@ -19,44 +19,41 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderW writer.WriteEndObject(); } - /// The JSON writer. - /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(AzureOpenAIDalleError)} does not support writing '{format}' format."); } - - if (SerializedAdditionalRawData?.ContainsKey("code") != true && Optional.IsDefined(Code)) + if (Optional.IsDefined(Code) && _additionalBinaryDataProperties?.ContainsKey("code") != true) { writer.WritePropertyName("code"u8); writer.WriteStringValue(Code); } - if (SerializedAdditionalRawData?.ContainsKey("message") != true && Optional.IsDefined(Message)) + if (Optional.IsDefined(Message) && _additionalBinaryDataProperties?.ContainsKey("message") != true) { writer.WritePropertyName("message"u8); writer.WriteStringValue(Message); } - if (SerializedAdditionalRawData?.ContainsKey("param") != true && Optional.IsDefined(Param)) + if (Optional.IsDefined(Param) && _additionalBinaryDataProperties?.ContainsKey("param") != true) { writer.WritePropertyName("param"u8); writer.WriteStringValue(Param); } - if (SerializedAdditionalRawData?.ContainsKey("type") != true && Optional.IsDefined(Type)) + if (Optional.IsDefined(Type) && _additionalBinaryDataProperties?.ContainsKey("type") != true) { writer.WritePropertyName("type"u8); writer.WriteStringValue(Type); } - if (SerializedAdditionalRawData?.ContainsKey("inner_error") != true && Optional.IsDefined(InnerError)) + if (Optional.IsDefined(InnerError) && _additionalBinaryDataProperties?.ContainsKey("inner_error") != true) { writer.WritePropertyName("inner_error"u8); writer.WriteObjectValue(InnerError, options); } - if (SerializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in SerializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { @@ -64,7 +61,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else using (JsonDocument document = JsonDocument.Parse(item.Value)) { @@ -75,84 +72,81 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - AzureOpenAIDalleError IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + AzureOpenAIDalleError IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + protected virtual AzureOpenAIDalleError JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(AzureOpenAIDalleError)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeAzureOpenAIDalleError(document.RootElement, options); } - internal static AzureOpenAIDalleError DeserializeAzureOpenAIDalleError(JsonElement element, ModelReaderWriterOptions options = null) + internal static AzureOpenAIDalleError DeserializeAzureOpenAIDalleError(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } string code = default; string message = default; - string param = default; - string type = default; + string @param = default; + string @type = default; InternalAzureOpenAIDalleErrorInnerError innerError = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("code"u8)) + if (prop.NameEquals("code"u8)) { - code = property.Value.GetString(); + code = prop.Value.GetString(); continue; } - if (property.NameEquals("message"u8)) + if (prop.NameEquals("message"u8)) { - message = property.Value.GetString(); + message = prop.Value.GetString(); continue; } - if (property.NameEquals("param"u8)) + if (prop.NameEquals("param"u8)) { - param = property.Value.GetString(); + @param = prop.Value.GetString(); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("type"u8)) { - type = property.Value.GetString(); + @type = prop.Value.GetString(); continue; } - if (property.NameEquals("inner_error"u8)) + if (prop.NameEquals("inner_error"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - innerError = InternalAzureOpenAIDalleErrorInnerError.DeserializeInternalAzureOpenAIDalleErrorInnerError(property.Value, options); + innerError = InternalAzureOpenAIDalleErrorInnerError.DeserializeInternalAzureOpenAIDalleErrorInnerError(prop.Value, options); continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new AzureOpenAIDalleError( code, message, - param, - type, + @param, + @type, innerError, - serializedAdditionalRawData); + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -162,15 +156,16 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptio } } - AzureOpenAIDalleError IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + AzureOpenAIDalleError IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + protected virtual AzureOpenAIDalleError PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeAzureOpenAIDalleError(document.RootElement, options); } default: @@ -180,18 +175,20 @@ AzureOpenAIDalleError IPersistableModel.Create(BinaryData string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static AzureOpenAIDalleError FromResponse(PipelineResponse response) + public static implicit operator BinaryContent(AzureOpenAIDalleError azureOpenAIDalleError) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeAzureOpenAIDalleError(document.RootElement); + if (azureOpenAIDalleError == null) + { + return null; + } + return BinaryContent.Create(azureOpenAIDalleError, ModelSerializationExtensions.WireOptions); } - /// Convert into a . - internal virtual BinaryContent ToBinaryContent() + public static explicit operator AzureOpenAIDalleError(ClientResult result) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeAzureOpenAIDalleError(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/AzureOpenAIDalleError.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/AzureOpenAIDalleError.cs new file mode 100644 index 000000000..840c31402 --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/AzureOpenAIDalleError.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI +{ + internal partial class AzureOpenAIDalleError + { + /// Keeps track of any properties unknown to the library. + private protected IDictionary _additionalBinaryDataProperties; + + internal AzureOpenAIDalleError() + { + } + + internal AzureOpenAIDalleError(string code, string message, string @param, string @type, InternalAzureOpenAIDalleErrorInnerError innerError, IDictionary additionalBinaryDataProperties) + { + Code = code; + Message = message; + Param = @param; + Type = @type; + InnerError = innerError; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + public string Code { get; } + + public string Message { get; } + + public string Param { get; } + + public string Type { get; } + + public InternalAzureOpenAIDalleErrorInnerError InnerError { get; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIDalleErrorResponse.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/AzureOpenAIDalleErrorResponse.Serialization.cs similarity index 58% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIDalleErrorResponse.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/AzureOpenAIDalleErrorResponse.Serialization.cs index 8c44690cc..d82f217b9 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureOpenAIDalleErrorResponse.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/AzureOpenAIDalleErrorResponse.Serialization.cs @@ -19,24 +19,21 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mode writer.WriteEndObject(); } - /// The JSON writer. - /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(AzureOpenAIDalleErrorResponse)} does not support writing '{format}' format."); } - - if (SerializedAdditionalRawData?.ContainsKey("error") != true && Optional.IsDefined(Error)) + if (Optional.IsDefined(Error) && _additionalBinaryDataProperties?.ContainsKey("error") != true) { writer.WritePropertyName("error"u8); writer.WriteObjectValue(Error, options); } - if (SerializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in SerializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { @@ -44,7 +41,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else using (JsonDocument document = JsonDocument.Parse(item.Value)) { @@ -55,54 +52,51 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - AzureOpenAIDalleErrorResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + AzureOpenAIDalleErrorResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + protected virtual AzureOpenAIDalleErrorResponse JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(AzureOpenAIDalleErrorResponse)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeAzureOpenAIDalleErrorResponse(document.RootElement, options); } - internal static AzureOpenAIDalleErrorResponse DeserializeAzureOpenAIDalleErrorResponse(JsonElement element, ModelReaderWriterOptions options = null) + internal static AzureOpenAIDalleErrorResponse DeserializeAzureOpenAIDalleErrorResponse(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } AzureOpenAIDalleError error = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("error"u8)) + if (prop.NameEquals("error"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - error = AzureOpenAIDalleError.DeserializeAzureOpenAIDalleError(property.Value, options); + error = AzureOpenAIDalleError.DeserializeAzureOpenAIDalleError(prop.Value, options); continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new AzureOpenAIDalleErrorResponse(error, serializedAdditionalRawData); + return new AzureOpenAIDalleErrorResponse(error, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -112,15 +106,16 @@ BinaryData IPersistableModel.Write(ModelReaderWri } } - AzureOpenAIDalleErrorResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + AzureOpenAIDalleErrorResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + protected virtual AzureOpenAIDalleErrorResponse PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeAzureOpenAIDalleErrorResponse(document.RootElement, options); } default: @@ -130,18 +125,20 @@ AzureOpenAIDalleErrorResponse IPersistableModel.C string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static AzureOpenAIDalleErrorResponse FromResponse(PipelineResponse response) + public static implicit operator BinaryContent(AzureOpenAIDalleErrorResponse azureOpenAIDalleErrorResponse) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeAzureOpenAIDalleErrorResponse(document.RootElement); + if (azureOpenAIDalleErrorResponse == null) + { + return null; + } + return BinaryContent.Create(azureOpenAIDalleErrorResponse, ModelSerializationExtensions.WireOptions); } - /// Convert into a . - internal virtual BinaryContent ToBinaryContent() + public static explicit operator AzureOpenAIDalleErrorResponse(ClientResult result) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeAzureOpenAIDalleErrorResponse(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/AzureOpenAIDalleErrorResponse.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/AzureOpenAIDalleErrorResponse.cs new file mode 100644 index 000000000..a0d91b3fc --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/AzureOpenAIDalleErrorResponse.cs @@ -0,0 +1,33 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI +{ + internal partial class AzureOpenAIDalleErrorResponse + { + /// Keeps track of any properties unknown to the library. + private protected IDictionary _additionalBinaryDataProperties; + + internal AzureOpenAIDalleErrorResponse() + { + } + + internal AzureOpenAIDalleErrorResponse(AzureOpenAIDalleError error, IDictionary additionalBinaryDataProperties) + { + Error = error; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + public AzureOpenAIDalleError Error { get; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/AzureSearchChatDataSource.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/AzureSearchChatDataSource.Serialization.cs new file mode 100644 index 000000000..0da6eca1b --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/AzureSearchChatDataSource.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.OpenAI; + +namespace Azure.AI.OpenAI.Chat +{ + /// + public partial class AzureSearchChatDataSource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureSearchChatDataSource)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (_additionalBinaryDataProperties?.ContainsKey("parameters") != true) + { + writer.WritePropertyName("parameters"u8); + writer.WriteObjectValue(InternalParameters, options); + } + } + + AzureSearchChatDataSource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (AzureSearchChatDataSource)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override ChatDataSource JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AzureSearchChatDataSource)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAzureSearchChatDataSource(document.RootElement, options); + } + + internal static AzureSearchChatDataSource DeserializeAzureSearchChatDataSource(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string @type = "azure_search"; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + InternalAzureSearchChatDataSourceParameters internalParameters = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("parameters"u8)) + { + internalParameters = InternalAzureSearchChatDataSourceParameters.DeserializeInternalAzureSearchChatDataSourceParameters(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new AzureSearchChatDataSource(@type, additionalBinaryDataProperties, internalParameters); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(AzureSearchChatDataSource)} does not support writing '{options.Format}' format."); + } + } + + AzureSearchChatDataSource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (AzureSearchChatDataSource)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override ChatDataSource PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeAzureSearchChatDataSource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AzureSearchChatDataSource)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + public static implicit operator BinaryContent(AzureSearchChatDataSource azureSearchChatDataSource) + { + if (azureSearchChatDataSource == null) + { + return null; + } + return BinaryContent.Create(azureSearchChatDataSource, ModelSerializationExtensions.WireOptions); + } + + /// The to deserialize the from. + public static explicit operator AzureSearchChatDataSource(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeAzureSearchChatDataSource(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureSearchChatDataSource.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/AzureSearchChatDataSource.cs similarity index 84% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureSearchChatDataSource.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/AzureSearchChatDataSource.cs index 417a6abd7..98028c7fe 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/AzureSearchChatDataSource.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/AzureSearchChatDataSource.cs @@ -2,9 +2,6 @@ #nullable disable -using System; -using System.Collections.Generic; - namespace Azure.AI.OpenAI.Chat { /// Represents a data source configuration that will use an Azure Search resource. diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatCitation.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ChatCitation.Serialization.cs similarity index 51% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatCitation.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ChatCitation.Serialization.cs index a9ee56a9e..739dbc3ce 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatCitation.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ChatCitation.Serialization.cs @@ -7,11 +7,17 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.AI.OpenAI; namespace Azure.AI.OpenAI.Chat { + /// public partial class ChatCitation : IJsonModel { + internal ChatCitation() + { + } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -23,45 +29,44 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpti /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(ChatCitation)} does not support writing '{format}' format."); } - - if (SerializedAdditionalRawData?.ContainsKey("content") != true) + if (_additionalBinaryDataProperties?.ContainsKey("content") != true) { writer.WritePropertyName("content"u8); writer.WriteStringValue(Content); } - if (SerializedAdditionalRawData?.ContainsKey("title") != true && Optional.IsDefined(Title)) + if (Optional.IsDefined(Title) && _additionalBinaryDataProperties?.ContainsKey("title") != true) { writer.WritePropertyName("title"u8); writer.WriteStringValue(Title); } - if (SerializedAdditionalRawData?.ContainsKey("url") != true && Optional.IsDefined(Url)) + if (Optional.IsDefined(Url) && _additionalBinaryDataProperties?.ContainsKey("url") != true) { writer.WritePropertyName("url"u8); writer.WriteStringValue(Url); } - if (SerializedAdditionalRawData?.ContainsKey("filepath") != true && Optional.IsDefined(FilePath)) - { - writer.WritePropertyName("filepath"u8); - writer.WriteStringValue(FilePath); - } - if (SerializedAdditionalRawData?.ContainsKey("chunk_id") != true && Optional.IsDefined(ChunkId)) + if (Optional.IsDefined(ChunkId) && _additionalBinaryDataProperties?.ContainsKey("chunk_id") != true) { writer.WritePropertyName("chunk_id"u8); writer.WriteStringValue(ChunkId); } - if (SerializedAdditionalRawData?.ContainsKey("rerank_score") != true && Optional.IsDefined(RerankScore)) + if (Optional.IsDefined(RerankScore) && _additionalBinaryDataProperties?.ContainsKey("rerank_score") != true) { writer.WritePropertyName("rerank_score"u8); writer.WriteNumberValue(RerankScore.Value); } - if (SerializedAdditionalRawData != null) + if (Optional.IsDefined(FilePath) && _additionalBinaryDataProperties?.ContainsKey("filepath") != true) { - foreach (var item in SerializedAdditionalRawData) + writer.WritePropertyName("filepath"u8); + writer.WriteStringValue(FilePath); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) { if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { @@ -69,7 +74,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else using (JsonDocument document = JsonDocument.Parse(item.Value)) { @@ -80,22 +85,23 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - ChatCitation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + ChatCitation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ChatCitation JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(ChatCitation)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeChatCitation(document.RootElement, options); } - internal static ChatCitation DeserializeChatCitation(JsonElement element, ModelReaderWriterOptions options = null) + internal static ChatCitation DeserializeChatCitation(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -103,68 +109,67 @@ internal static ChatCitation DeserializeChatCitation(JsonElement element, ModelR string content = default; string title = default; string url = default; - string filepath = default; string chunkId = default; double? rerankScore = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + string filePath = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("content"u8)) + if (prop.NameEquals("content"u8)) { - content = property.Value.GetString(); + content = prop.Value.GetString(); continue; } - if (property.NameEquals("title"u8)) + if (prop.NameEquals("title"u8)) { - title = property.Value.GetString(); + title = prop.Value.GetString(); continue; } - if (property.NameEquals("url"u8)) + if (prop.NameEquals("url"u8)) { - url = property.Value.GetString(); + url = prop.Value.GetString(); continue; } - if (property.NameEquals("filepath"u8)) + if (prop.NameEquals("chunk_id"u8)) { - filepath = property.Value.GetString(); + chunkId = prop.Value.GetString(); continue; } - if (property.NameEquals("chunk_id"u8)) + if (prop.NameEquals("rerank_score"u8)) { - chunkId = property.Value.GetString(); - continue; - } - if (property.NameEquals("rerank_score"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - rerankScore = property.Value.GetDouble(); + rerankScore = prop.Value.GetDouble(); + continue; + } + if (prop.NameEquals("filepath"u8)) + { + filePath = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new ChatCitation( content, title, url, - filepath, chunkId, rerankScore, - serializedAdditionalRawData); + filePath, + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -174,15 +179,18 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions option } } - ChatCitation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + ChatCitation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ChatCitation PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeChatCitation(document.RootElement, options); } default: @@ -192,18 +200,22 @@ ChatCitation IPersistableModel.Create(BinaryData data, ModelReader string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static ChatCitation FromResponse(PipelineResponse response) + /// The to serialize into . + public static implicit operator BinaryContent(ChatCitation chatCitation) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeChatCitation(document.RootElement); + if (chatCitation == null) + { + return null; + } + return BinaryContent.Create(chatCitation, ModelSerializationExtensions.WireOptions); } - /// Convert into a . - internal virtual BinaryContent ToBinaryContent() + /// The to deserialize the from. + public static explicit operator ChatCitation(ClientResult result) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeChatCitation(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ChatCitation.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ChatCitation.cs new file mode 100644 index 000000000..f30bd799c --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ChatCitation.cs @@ -0,0 +1,53 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Chat +{ + /// The ChatCitation. + public partial class ChatCitation + { + /// Keeps track of any properties unknown to the library. + private protected IDictionary _additionalBinaryDataProperties; + + internal ChatCitation(string content) + { + Content = content; + } + + internal ChatCitation(string content, string title, string url, string chunkId, double? rerankScore, string filePath, IDictionary additionalBinaryDataProperties) + { + Content = content; + Title = title; + Url = url; + ChunkId = chunkId; + RerankScore = rerankScore; + FilePath = filePath; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The content of the citation. + public string Content { get; } + + /// The title for the citation. + public string Title { get; } + + /// The URL of the citation. + public string Url { get; } + + /// The chunk ID for the citation. + public string ChunkId { get; } + + /// The rerank score for the retrieval. + public double? RerankScore { get; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ChatDataSource.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ChatDataSource.Serialization.cs new file mode 100644 index 000000000..603be85a6 --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ChatDataSource.Serialization.cs @@ -0,0 +1,157 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.AI.OpenAI; + +namespace Azure.AI.OpenAI.Chat +{ + /// + [PersistableModelProxy(typeof(InternalUnknownAzureChatDataSource))] + public abstract partial class ChatDataSource : IJsonModel + { + internal ChatDataSource() + { + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ChatDataSource)} does not support writing '{format}' format."); + } + if (_additionalBinaryDataProperties?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) + { + continue; + } + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ChatDataSource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ChatDataSource JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ChatDataSource)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChatDataSource(document.RootElement, options); + } + + internal static ChatDataSource DeserializeChatDataSource(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "azure_search": + return AzureSearchChatDataSource.DeserializeAzureSearchChatDataSource(element, options); + case "azure_cosmos_db": + return CosmosChatDataSource.DeserializeCosmosChatDataSource(element, options); + case "elasticsearch": + return ElasticsearchChatDataSource.DeserializeElasticsearchChatDataSource(element, options); + case "pinecone": + return PineconeChatDataSource.DeserializePineconeChatDataSource(element, options); + case "mongo_db": + return MongoDBChatDataSource.DeserializeMongoDBChatDataSource(element, options); + } + } + return InternalUnknownAzureChatDataSource.DeserializeInternalUnknownAzureChatDataSource(element, options); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ChatDataSource)} does not support writing '{options.Format}' format."); + } + } + + ChatDataSource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ChatDataSource PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeChatDataSource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChatDataSource)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + public static implicit operator BinaryContent(ChatDataSource chatDataSource) + { + if (chatDataSource == null) + { + return null; + } + return BinaryContent.Create(chatDataSource, ModelSerializationExtensions.WireOptions); + } + + /// The to deserialize the from. + public static explicit operator ChatDataSource(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeChatDataSource(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ChatDataSource.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ChatDataSource.cs new file mode 100644 index 000000000..055435963 --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ChatDataSource.cs @@ -0,0 +1,40 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Chat +{ + /// + /// A representation of configuration data for a single Azure OpenAI chat data source. + /// This will be used by a chat completions request that should use Azure OpenAI chat extensions to augment the + /// response behavior. + /// The use of this configuration is compatible only with Azure OpenAI. + /// + public abstract partial class ChatDataSource + { + /// Keeps track of any properties unknown to the library. + private protected IDictionary _additionalBinaryDataProperties; + + private protected ChatDataSource(string @type) + { + Type = @type; + } + + internal ChatDataSource(string @type, IDictionary additionalBinaryDataProperties) + { + Type = @type; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + internal string Type { get; set; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatDocumentFilterReason.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ChatDocumentFilterReason.cs similarity index 69% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatDocumentFilterReason.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ChatDocumentFilterReason.cs index 705d6a45f..7702be0f4 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatDocumentFilterReason.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ChatDocumentFilterReason.cs @@ -4,45 +4,59 @@ using System; using System.ComponentModel; +using Azure.AI.OpenAI; namespace Azure.AI.OpenAI.Chat { - /// The AzureChatMessageContextAllRetrievedDocumentsFilterReason. + /// public readonly partial struct ChatDocumentFilterReason : IEquatable { private readonly string _value; + private const string ScoreValue = "score"; + private const string RerankValue = "rerank"; /// Initializes a new instance of . + /// The value. /// is null. public ChatDocumentFilterReason(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string ScoreValue = "score"; - private const string RerankValue = "rerank"; + _value = value; + } - /// score. + /// Gets the Score. public static ChatDocumentFilterReason Score { get; } = new ChatDocumentFilterReason(ScoreValue); - /// rerank. + + /// Gets the Rerank. public static ChatDocumentFilterReason Rerank { get; } = new ChatDocumentFilterReason(RerankValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(ChatDocumentFilterReason left, ChatDocumentFilterReason right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(ChatDocumentFilterReason left, ChatDocumentFilterReason right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator ChatDocumentFilterReason(string value) => new ChatDocumentFilterReason(value); - /// + /// The object to compare. [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is ChatDocumentFilterReason other && Equals(other); - /// + + /// The instance to compare. public bool Equals(ChatDocumentFilterReason other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - /// + /// [EditorBrowsable(EditorBrowsableState.Never)] public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - /// + + /// public override string ToString() => _value; } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatMessageContext.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ChatMessageContext.Serialization.cs similarity index 52% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatMessageContext.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ChatMessageContext.Serialization.cs index 8df66fa4f..2998b71fa 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatMessageContext.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ChatMessageContext.Serialization.cs @@ -7,9 +7,11 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.AI.OpenAI; namespace Azure.AI.OpenAI.Chat { + /// public partial class ChatMessageContext : IJsonModel { void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) @@ -23,35 +25,34 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(ChatMessageContext)} does not support writing '{format}' format."); } - - if (SerializedAdditionalRawData?.ContainsKey("intent") != true && Optional.IsDefined(Intent)) + if (Optional.IsDefined(Intent) && _additionalBinaryDataProperties?.ContainsKey("intent") != true) { writer.WritePropertyName("intent"u8); writer.WriteStringValue(Intent); } - if (SerializedAdditionalRawData?.ContainsKey("citations") != true && Optional.IsCollectionDefined(Citations)) + if (Optional.IsCollectionDefined(Citations) && _additionalBinaryDataProperties?.ContainsKey("citations") != true) { writer.WritePropertyName("citations"u8); writer.WriteStartArray(); - foreach (var item in Citations) + foreach (ChatCitation item in Citations) { writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } - if (SerializedAdditionalRawData?.ContainsKey("all_retrieved_documents") != true && Optional.IsDefined(RetrievedDocuments)) + if (Optional.IsDefined(RetrievedDocuments) && _additionalBinaryDataProperties?.ContainsKey("all_retrieved_documents") != true) { writer.WritePropertyName("all_retrieved_documents"u8); writer.WriteObjectValue(RetrievedDocuments, options); } - if (SerializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in SerializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { @@ -59,7 +60,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else using (JsonDocument document = JsonDocument.Parse(item.Value)) { @@ -70,75 +71,75 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - ChatMessageContext IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + ChatMessageContext IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ChatMessageContext JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(ChatMessageContext)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeChatMessageContext(document.RootElement, options); } - internal static ChatMessageContext DeserializeChatMessageContext(JsonElement element, ModelReaderWriterOptions options = null) + internal static ChatMessageContext DeserializeChatMessageContext(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } string intent = default; - IReadOnlyList citations = default; - ChatRetrievedDocument allRetrievedDocuments = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IList citations = default; + ChatRetrievedDocument retrievedDocuments = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("intent"u8)) + if (prop.NameEquals("intent"u8)) { - intent = property.Value.GetString(); + intent = prop.Value.GetString(); continue; } - if (property.NameEquals("citations"u8)) + if (prop.NameEquals("citations"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(ChatCitation.DeserializeChatCitation(item, options)); } citations = array; continue; } - if (property.NameEquals("all_retrieved_documents"u8)) + if (prop.NameEquals("all_retrieved_documents"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - allRetrievedDocuments = ChatRetrievedDocument.DeserializeChatRetrievedDocument(property.Value, options); + retrievedDocuments = ChatRetrievedDocument.DeserializeChatRetrievedDocument(prop.Value, options); continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new ChatMessageContext(intent, citations ?? new ChangeTrackingList(), allRetrievedDocuments, serializedAdditionalRawData); + return new ChatMessageContext(intent, citations ?? new ChangeTrackingList(), retrievedDocuments, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -148,15 +149,18 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions } } - ChatMessageContext IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + ChatMessageContext IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ChatMessageContext PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeChatMessageContext(document.RootElement, options); } default: @@ -166,18 +170,22 @@ ChatMessageContext IPersistableModel.Create(BinaryData data, string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static ChatMessageContext FromResponse(PipelineResponse response) + /// The to serialize into . + public static implicit operator BinaryContent(ChatMessageContext chatMessageContext) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeChatMessageContext(document.RootElement); + if (chatMessageContext == null) + { + return null; + } + return BinaryContent.Create(chatMessageContext, ModelSerializationExtensions.WireOptions); } - /// Convert into a . - internal virtual BinaryContent ToBinaryContent() + /// The to deserialize the from. + public static explicit operator ChatMessageContext(ClientResult result) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeChatMessageContext(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ChatMessageContext.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ChatMessageContext.cs new file mode 100644 index 000000000..9b9b84359 --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ChatMessageContext.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.OpenAI; + +namespace Azure.AI.OpenAI.Chat +{ + /// + /// An additional property, added to chat completion response messages, produced by the Azure OpenAI service when using + /// extension behavior. This includes intent and citation information from the On Your Data feature. + /// + public partial class ChatMessageContext + { + /// Keeps track of any properties unknown to the library. + private protected IDictionary _additionalBinaryDataProperties; + + internal ChatMessageContext() + { + Citations = new ChangeTrackingList(); + } + + internal ChatMessageContext(string intent, IList citations, ChatRetrievedDocument retrievedDocuments, IDictionary additionalBinaryDataProperties) + { + Intent = intent; + Citations = citations; + RetrievedDocuments = retrievedDocuments; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The detected intent from the chat history, which is used to carry conversation context between interactions. + public string Intent { get; } + + /// The citations produced by the data retrieval. + public IList Citations { get; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatRetrievedDocument.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ChatRetrievedDocument.Serialization.cs similarity index 52% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatRetrievedDocument.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ChatRetrievedDocument.Serialization.cs index 14db8c20b..7bfb3fcee 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ChatRetrievedDocument.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ChatRetrievedDocument.Serialization.cs @@ -7,11 +7,17 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.AI.OpenAI; namespace Azure.AI.OpenAI.Chat { + /// public partial class ChatRetrievedDocument : IJsonModel { + internal ChatRetrievedDocument() + { + } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -23,70 +29,74 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderW /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(ChatRetrievedDocument)} does not support writing '{format}' format."); } - - if (SerializedAdditionalRawData?.ContainsKey("content") != true) + if (_additionalBinaryDataProperties?.ContainsKey("content") != true) { writer.WritePropertyName("content"u8); writer.WriteStringValue(Content); } - if (SerializedAdditionalRawData?.ContainsKey("title") != true && Optional.IsDefined(Title)) + if (Optional.IsDefined(Title) && _additionalBinaryDataProperties?.ContainsKey("title") != true) { writer.WritePropertyName("title"u8); writer.WriteStringValue(Title); } - if (SerializedAdditionalRawData?.ContainsKey("url") != true && Optional.IsDefined(Url)) + if (Optional.IsDefined(Url) && _additionalBinaryDataProperties?.ContainsKey("url") != true) { writer.WritePropertyName("url"u8); writer.WriteStringValue(Url); } - if (SerializedAdditionalRawData?.ContainsKey("filepath") != true && Optional.IsDefined(FilePath)) - { - writer.WritePropertyName("filepath"u8); - writer.WriteStringValue(FilePath); - } - if (SerializedAdditionalRawData?.ContainsKey("chunk_id") != true && Optional.IsDefined(ChunkId)) + if (Optional.IsDefined(ChunkId) && _additionalBinaryDataProperties?.ContainsKey("chunk_id") != true) { writer.WritePropertyName("chunk_id"u8); writer.WriteStringValue(ChunkId); } - if (SerializedAdditionalRawData?.ContainsKey("rerank_score") != true && Optional.IsDefined(RerankScore)) + if (Optional.IsDefined(RerankScore) && _additionalBinaryDataProperties?.ContainsKey("rerank_score") != true) { writer.WritePropertyName("rerank_score"u8); writer.WriteNumberValue(RerankScore.Value); } - if (SerializedAdditionalRawData?.ContainsKey("search_queries") != true) + if (_additionalBinaryDataProperties?.ContainsKey("search_queries") != true) { writer.WritePropertyName("search_queries"u8); writer.WriteStartArray(); - foreach (var item in SearchQueries) + foreach (string item in SearchQueries) { + if (item == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item); } writer.WriteEndArray(); } - if (SerializedAdditionalRawData?.ContainsKey("data_source_index") != true) + if (_additionalBinaryDataProperties?.ContainsKey("data_source_index") != true) { writer.WritePropertyName("data_source_index"u8); writer.WriteNumberValue(DataSourceIndex); } - if (SerializedAdditionalRawData?.ContainsKey("original_search_score") != true && Optional.IsDefined(OriginalSearchScore)) + if (Optional.IsDefined(OriginalSearchScore) && _additionalBinaryDataProperties?.ContainsKey("original_search_score") != true) { writer.WritePropertyName("original_search_score"u8); writer.WriteNumberValue(OriginalSearchScore.Value); } - if (SerializedAdditionalRawData?.ContainsKey("filter_reason") != true && Optional.IsDefined(FilterReason)) + if (Optional.IsDefined(FilterReason) && _additionalBinaryDataProperties?.ContainsKey("filter_reason") != true) { writer.WritePropertyName("filter_reason"u8); writer.WriteStringValue(FilterReason.Value.ToString()); } - if (SerializedAdditionalRawData != null) + if (Optional.IsDefined(FilePath) && _additionalBinaryDataProperties?.ContainsKey("filepath") != true) + { + writer.WritePropertyName("filepath"u8); + writer.WriteStringValue(FilePath); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in SerializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { @@ -94,7 +104,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else using (JsonDocument document = JsonDocument.Parse(item.Value)) { @@ -105,22 +115,23 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - ChatRetrievedDocument IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + ChatRetrievedDocument IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ChatRetrievedDocument JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(ChatRetrievedDocument)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeChatRetrievedDocument(document.RootElement, options); } - internal static ChatRetrievedDocument DeserializeChatRetrievedDocument(JsonElement element, ModelReaderWriterOptions options = null) + internal static ChatRetrievedDocument DeserializeChatRetrievedDocument(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -128,109 +139,115 @@ internal static ChatRetrievedDocument DeserializeChatRetrievedDocument(JsonEleme string content = default; string title = default; string url = default; - string filepath = default; string chunkId = default; double? rerankScore = default; - IReadOnlyList searchQueries = default; + IList searchQueries = default; int dataSourceIndex = default; double? originalSearchScore = default; ChatDocumentFilterReason? filterReason = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + string filePath = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("content"u8)) - { - content = property.Value.GetString(); - continue; - } - if (property.NameEquals("title"u8)) + if (prop.NameEquals("content"u8)) { - title = property.Value.GetString(); + content = prop.Value.GetString(); continue; } - if (property.NameEquals("url"u8)) + if (prop.NameEquals("title"u8)) { - url = property.Value.GetString(); + title = prop.Value.GetString(); continue; } - if (property.NameEquals("filepath"u8)) + if (prop.NameEquals("url"u8)) { - filepath = property.Value.GetString(); + url = prop.Value.GetString(); continue; } - if (property.NameEquals("chunk_id"u8)) + if (prop.NameEquals("chunk_id"u8)) { - chunkId = property.Value.GetString(); + chunkId = prop.Value.GetString(); continue; } - if (property.NameEquals("rerank_score"u8)) + if (prop.NameEquals("rerank_score"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - rerankScore = property.Value.GetDouble(); + rerankScore = prop.Value.GetDouble(); continue; } - if (property.NameEquals("search_queries"u8)) + if (prop.NameEquals("search_queries"u8)) { List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { - array.Add(item.GetString()); + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } } searchQueries = array; continue; } - if (property.NameEquals("data_source_index"u8)) + if (prop.NameEquals("data_source_index"u8)) { - dataSourceIndex = property.Value.GetInt32(); + dataSourceIndex = prop.Value.GetInt32(); continue; } - if (property.NameEquals("original_search_score"u8)) + if (prop.NameEquals("original_search_score"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - originalSearchScore = property.Value.GetDouble(); + originalSearchScore = prop.Value.GetDouble(); continue; } - if (property.NameEquals("filter_reason"u8)) + if (prop.NameEquals("filter_reason"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - filterReason = new ChatDocumentFilterReason(property.Value.GetString()); + filterReason = new ChatDocumentFilterReason(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("filepath"u8)) + { + filePath = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new ChatRetrievedDocument( content, title, url, - filepath, chunkId, rerankScore, searchQueries, dataSourceIndex, originalSearchScore, filterReason, - serializedAdditionalRawData); + filePath, + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -240,15 +257,18 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptio } } - ChatRetrievedDocument IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + ChatRetrievedDocument IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ChatRetrievedDocument PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeChatRetrievedDocument(document.RootElement, options); } default: @@ -258,18 +278,22 @@ ChatRetrievedDocument IPersistableModel.Create(BinaryData string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static ChatRetrievedDocument FromResponse(PipelineResponse response) + /// The to serialize into . + public static implicit operator BinaryContent(ChatRetrievedDocument chatRetrievedDocument) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeChatRetrievedDocument(document.RootElement); + if (chatRetrievedDocument == null) + { + return null; + } + return BinaryContent.Create(chatRetrievedDocument, ModelSerializationExtensions.WireOptions); } - /// Convert into a . - internal virtual BinaryContent ToBinaryContent() + /// The to deserialize the from. + public static explicit operator ChatRetrievedDocument(ClientResult result) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeChatRetrievedDocument(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ChatRetrievedDocument.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ChatRetrievedDocument.cs new file mode 100644 index 000000000..f085ea01e --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ChatRetrievedDocument.cs @@ -0,0 +1,72 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.OpenAI.Chat +{ + /// The ChatRetrievedDocument. + public partial class ChatRetrievedDocument + { + /// Keeps track of any properties unknown to the library. + private protected IDictionary _additionalBinaryDataProperties; + + internal ChatRetrievedDocument(string content, IEnumerable searchQueries, int dataSourceIndex) + { + Content = content; + SearchQueries = searchQueries.ToList(); + DataSourceIndex = dataSourceIndex; + } + + internal ChatRetrievedDocument(string content, string title, string url, string chunkId, double? rerankScore, IList searchQueries, int dataSourceIndex, double? originalSearchScore, ChatDocumentFilterReason? filterReason, string filePath, IDictionary additionalBinaryDataProperties) + { + Content = content; + Title = title; + Url = url; + ChunkId = chunkId; + RerankScore = rerankScore; + SearchQueries = searchQueries; + DataSourceIndex = dataSourceIndex; + OriginalSearchScore = originalSearchScore; + FilterReason = filterReason; + FilePath = filePath; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The content of the citation. + public string Content { get; } + + /// The title for the citation. + public string Title { get; } + + /// The URL of the citation. + public string Url { get; } + + /// The chunk ID for the citation. + public string ChunkId { get; } + + /// The rerank score for the retrieval. + public double? RerankScore { get; } + + /// The search queries executed to retrieve documents. + public IList SearchQueries { get; } + + /// The index of the data source used for retrieval. + public int DataSourceIndex { get; } + + /// The original search score for the retrieval. + public double? OriginalSearchScore { get; } + + /// If applicable, an indication of why the document was filtered. + public ChatDocumentFilterReason? FilterReason { get; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterBlocklistResult.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterBlocklistResult.Serialization.cs similarity index 52% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterBlocklistResult.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterBlocklistResult.Serialization.cs index fd200aad3..8f858a40c 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterBlocklistResult.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterBlocklistResult.Serialization.cs @@ -10,8 +10,13 @@ namespace Azure.AI.OpenAI { + /// public partial class ContentFilterBlocklistResult : IJsonModel { + internal ContentFilterBlocklistResult() + { + } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -23,30 +28,29 @@ void IJsonModel.Write(Utf8JsonWriter writer, Model /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(ContentFilterBlocklistResult)} does not support writing '{format}' format."); } - - if (SerializedAdditionalRawData?.ContainsKey("filtered") != true) + if (_additionalBinaryDataProperties?.ContainsKey("filtered") != true) { writer.WritePropertyName("filtered"u8); writer.WriteBooleanValue(Filtered); } - if (SerializedAdditionalRawData?.ContainsKey("details") != true && Optional.IsCollectionDefined(InternalDetails)) + if (Optional.IsCollectionDefined(InternalDetails) && _additionalBinaryDataProperties?.ContainsKey("details") != true) { writer.WritePropertyName("details"u8); writer.WriteStartArray(); - foreach (var item in InternalDetails) + foreach (InternalAzureContentFilterBlocklistResultDetail item in InternalDetails) { - writer.WriteObjectValue(item, options); + writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } - if (SerializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in SerializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { @@ -54,7 +58,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else using (JsonDocument document = JsonDocument.Parse(item.Value)) { @@ -65,65 +69,65 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - ContentFilterBlocklistResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + ContentFilterBlocklistResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ContentFilterBlocklistResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(ContentFilterBlocklistResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeContentFilterBlocklistResult(document.RootElement, options); } - internal static ContentFilterBlocklistResult DeserializeContentFilterBlocklistResult(JsonElement element, ModelReaderWriterOptions options = null) + internal static ContentFilterBlocklistResult DeserializeContentFilterBlocklistResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } bool filtered = default; - IReadOnlyList details = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IReadOnlyList internalDetails = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("filtered"u8)) + if (prop.NameEquals("filtered"u8)) { - filtered = property.Value.GetBoolean(); + filtered = prop.Value.GetBoolean(); continue; } - if (property.NameEquals("details"u8)) + if (prop.NameEquals("details"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(InternalAzureContentFilterBlocklistResultDetail.DeserializeInternalAzureContentFilterBlocklistResultDetail(item, options)); } - details = array; + internalDetails = array; continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new ContentFilterBlocklistResult(filtered, details ?? new ChangeTrackingList(), serializedAdditionalRawData); + return new ContentFilterBlocklistResult(filtered, internalDetails ?? new ChangeTrackingList(), additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -133,15 +137,18 @@ BinaryData IPersistableModel.Write(ModelReaderWrit } } - ContentFilterBlocklistResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + ContentFilterBlocklistResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ContentFilterBlocklistResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeContentFilterBlocklistResult(document.RootElement, options); } default: @@ -151,18 +158,22 @@ ContentFilterBlocklistResult IPersistableModel.Cre string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static ContentFilterBlocklistResult FromResponse(PipelineResponse response) + /// The to serialize into . + public static implicit operator BinaryContent(ContentFilterBlocklistResult contentFilterBlocklistResult) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeContentFilterBlocklistResult(document.RootElement); + if (contentFilterBlocklistResult == null) + { + return null; + } + return BinaryContent.Create(contentFilterBlocklistResult, ModelSerializationExtensions.WireOptions); } - /// Convert into a . - internal virtual BinaryContent ToBinaryContent() + /// The to deserialize the from. + public static explicit operator ContentFilterBlocklistResult(ClientResult result) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeContentFilterBlocklistResult(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterBlocklistResult.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterBlocklistResult.cs new file mode 100644 index 000000000..4a8a0e0b6 --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterBlocklistResult.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI +{ + /// A collection of true/false filtering results for configured custom blocklists. + public partial class ContentFilterBlocklistResult + { + /// Keeps track of any properties unknown to the library. + private protected IDictionary _additionalBinaryDataProperties; + + internal ContentFilterBlocklistResult(bool filtered) + { + Filtered = filtered; + InternalDetails = new ChangeTrackingList(); + } + + internal ContentFilterBlocklistResult(bool filtered, IReadOnlyList internalDetails, IDictionary additionalBinaryDataProperties) + { + Filtered = filtered; + InternalDetails = internalDetails; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// A value indicating whether any of the detailed blocklists resulted in a filtering action. + public bool Filtered { get; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterDetectionResult.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterDetectionResult.Serialization.cs similarity index 53% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterDetectionResult.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterDetectionResult.Serialization.cs index 637de281c..81ac3f45f 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterDetectionResult.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterDetectionResult.Serialization.cs @@ -10,8 +10,13 @@ namespace Azure.AI.OpenAI { + /// public partial class ContentFilterDetectionResult : IJsonModel { + internal ContentFilterDetectionResult() + { + } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -23,25 +28,24 @@ void IJsonModel.Write(Utf8JsonWriter writer, Model /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(ContentFilterDetectionResult)} does not support writing '{format}' format."); } - - if (SerializedAdditionalRawData?.ContainsKey("filtered") != true) + if (_additionalBinaryDataProperties?.ContainsKey("filtered") != true) { writer.WritePropertyName("filtered"u8); writer.WriteBooleanValue(Filtered); } - if (SerializedAdditionalRawData?.ContainsKey("detected") != true) + if (_additionalBinaryDataProperties?.ContainsKey("detected") != true) { writer.WritePropertyName("detected"u8); writer.WriteBooleanValue(Detected); } - if (SerializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in SerializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { @@ -49,7 +53,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else using (JsonDocument document = JsonDocument.Parse(item.Value)) { @@ -60,56 +64,56 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - ContentFilterDetectionResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + ContentFilterDetectionResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ContentFilterDetectionResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(ContentFilterDetectionResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeContentFilterDetectionResult(document.RootElement, options); } - internal static ContentFilterDetectionResult DeserializeContentFilterDetectionResult(JsonElement element, ModelReaderWriterOptions options = null) + internal static ContentFilterDetectionResult DeserializeContentFilterDetectionResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } bool filtered = default; bool detected = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("filtered"u8)) + if (prop.NameEquals("filtered"u8)) { - filtered = property.Value.GetBoolean(); + filtered = prop.Value.GetBoolean(); continue; } - if (property.NameEquals("detected"u8)) + if (prop.NameEquals("detected"u8)) { - detected = property.Value.GetBoolean(); + detected = prop.Value.GetBoolean(); continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new ContentFilterDetectionResult(filtered, detected, serializedAdditionalRawData); + return new ContentFilterDetectionResult(filtered, detected, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -119,15 +123,18 @@ BinaryData IPersistableModel.Write(ModelReaderWrit } } - ContentFilterDetectionResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + ContentFilterDetectionResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ContentFilterDetectionResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeContentFilterDetectionResult(document.RootElement, options); } default: @@ -137,18 +144,22 @@ ContentFilterDetectionResult IPersistableModel.Cre string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static ContentFilterDetectionResult FromResponse(PipelineResponse response) + /// The to serialize into . + public static implicit operator BinaryContent(ContentFilterDetectionResult contentFilterDetectionResult) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeContentFilterDetectionResult(document.RootElement); + if (contentFilterDetectionResult == null) + { + return null; + } + return BinaryContent.Create(contentFilterDetectionResult, ModelSerializationExtensions.WireOptions); } - /// Convert into a . - internal virtual BinaryContent ToBinaryContent() + /// The to deserialize the from. + public static explicit operator ContentFilterDetectionResult(ClientResult result) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeContentFilterDetectionResult(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterDetectionResult.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterDetectionResult.cs new file mode 100644 index 000000000..4e1aff0ed --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterDetectionResult.cs @@ -0,0 +1,44 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI +{ + /// + /// A labeled content filter result item that indicates whether the content was detected and whether the content was + /// filtered. + /// + public partial class ContentFilterDetectionResult + { + /// Keeps track of any properties unknown to the library. + private protected IDictionary _additionalBinaryDataProperties; + + internal ContentFilterDetectionResult(bool filtered, bool detected) + { + Filtered = filtered; + Detected = detected; + } + + internal ContentFilterDetectionResult(bool filtered, bool detected, IDictionary additionalBinaryDataProperties) + { + Filtered = filtered; + Detected = detected; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Whether the content detection resulted in a content filtering action. + public bool Filtered { get; } + + /// Whether the labeled content category was detected in the content. + public bool Detected { get; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterProtectedMaterialCitationResult.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterProtectedMaterialCitationResult.Serialization.cs similarity index 51% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterProtectedMaterialCitationResult.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterProtectedMaterialCitationResult.Serialization.cs index 57c0e41d7..b9c36fc45 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterProtectedMaterialCitationResult.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterProtectedMaterialCitationResult.Serialization.cs @@ -10,6 +10,7 @@ namespace Azure.AI.OpenAI { + /// public partial class ContentFilterProtectedMaterialCitationResult : IJsonModel { void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) @@ -23,25 +24,24 @@ void IJsonModel.Write(Utf8JsonWrit /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(ContentFilterProtectedMaterialCitationResult)} does not support writing '{format}' format."); } - - if (SerializedAdditionalRawData?.ContainsKey("license") != true && Optional.IsDefined(License)) + if (Optional.IsDefined(License) && _additionalBinaryDataProperties?.ContainsKey("license") != true) { writer.WritePropertyName("license"u8); writer.WriteStringValue(License); } - if (SerializedAdditionalRawData?.ContainsKey("URL") != true && Optional.IsDefined(Uri)) + if (Optional.IsDefined(Uri) && _additionalBinaryDataProperties?.ContainsKey("URL") != true) { writer.WritePropertyName("URL"u8); writer.WriteStringValue(Uri.AbsoluteUri); } - if (SerializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in SerializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { @@ -49,7 +49,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else using (JsonDocument document = JsonDocument.Parse(item.Value)) { @@ -60,60 +60,60 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - ContentFilterProtectedMaterialCitationResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + ContentFilterProtectedMaterialCitationResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ContentFilterProtectedMaterialCitationResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(ContentFilterProtectedMaterialCitationResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeContentFilterProtectedMaterialCitationResult(document.RootElement, options); } - internal static ContentFilterProtectedMaterialCitationResult DeserializeContentFilterProtectedMaterialCitationResult(JsonElement element, ModelReaderWriterOptions options = null) + internal static ContentFilterProtectedMaterialCitationResult DeserializeContentFilterProtectedMaterialCitationResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } string license = default; - Uri url = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + Uri uri = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("license"u8)) + if (prop.NameEquals("license"u8)) { - license = property.Value.GetString(); + license = prop.Value.GetString(); continue; } - if (property.NameEquals("URL"u8)) + if (prop.NameEquals("URL"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - url = new Uri(property.Value.GetString()); + uri = new Uri(prop.Value.GetString()); continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new ContentFilterProtectedMaterialCitationResult(license, url, serializedAdditionalRawData); + return new ContentFilterProtectedMaterialCitationResult(license, uri, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -123,15 +123,18 @@ BinaryData IPersistableModel.Write } } - ContentFilterProtectedMaterialCitationResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + ContentFilterProtectedMaterialCitationResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ContentFilterProtectedMaterialCitationResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeContentFilterProtectedMaterialCitationResult(document.RootElement, options); } default: @@ -141,18 +144,22 @@ ContentFilterProtectedMaterialCitationResult IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static ContentFilterProtectedMaterialCitationResult FromResponse(PipelineResponse response) + /// The to serialize into . + public static implicit operator BinaryContent(ContentFilterProtectedMaterialCitationResult contentFilterProtectedMaterialCitationResult) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeContentFilterProtectedMaterialCitationResult(document.RootElement); + if (contentFilterProtectedMaterialCitationResult == null) + { + return null; + } + return BinaryContent.Create(contentFilterProtectedMaterialCitationResult, ModelSerializationExtensions.WireOptions); } - /// Convert into a . - internal virtual BinaryContent ToBinaryContent() + /// The to deserialize the from. + public static explicit operator ContentFilterProtectedMaterialCitationResult(ClientResult result) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeContentFilterProtectedMaterialCitationResult(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterProtectedMaterialCitationResult.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterProtectedMaterialCitationResult.cs new file mode 100644 index 000000000..4cf6e5c5b --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterProtectedMaterialCitationResult.cs @@ -0,0 +1,36 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI +{ + /// The ContentFilterProtectedMaterialCitationResult. + public partial class ContentFilterProtectedMaterialCitationResult + { + /// Keeps track of any properties unknown to the library. + private protected IDictionary _additionalBinaryDataProperties; + + internal ContentFilterProtectedMaterialCitationResult() + { + } + + internal ContentFilterProtectedMaterialCitationResult(string license, Uri uri, IDictionary additionalBinaryDataProperties) + { + License = license; + Uri = uri; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// The name or identifier of the license associated with the detection. + public string License { get; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterProtectedMaterialResult.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterProtectedMaterialResult.Serialization.cs similarity index 54% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterProtectedMaterialResult.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterProtectedMaterialResult.Serialization.cs index 78e4b5f54..77ccd8be7 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterProtectedMaterialResult.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterProtectedMaterialResult.Serialization.cs @@ -10,8 +10,13 @@ namespace Azure.AI.OpenAI { + /// public partial class ContentFilterProtectedMaterialResult : IJsonModel { + internal ContentFilterProtectedMaterialResult() + { + } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -23,30 +28,29 @@ void IJsonModel.Write(Utf8JsonWriter write /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(ContentFilterProtectedMaterialResult)} does not support writing '{format}' format."); } - - if (SerializedAdditionalRawData?.ContainsKey("filtered") != true) + if (_additionalBinaryDataProperties?.ContainsKey("filtered") != true) { writer.WritePropertyName("filtered"u8); writer.WriteBooleanValue(Filtered); } - if (SerializedAdditionalRawData?.ContainsKey("detected") != true) + if (_additionalBinaryDataProperties?.ContainsKey("detected") != true) { writer.WritePropertyName("detected"u8); writer.WriteBooleanValue(Detected); } - if (SerializedAdditionalRawData?.ContainsKey("citation") != true && Optional.IsDefined(Citation)) + if (Optional.IsDefined(Citation) && _additionalBinaryDataProperties?.ContainsKey("citation") != true) { writer.WritePropertyName("citation"u8); writer.WriteObjectValue(Citation, options); } - if (SerializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in SerializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { @@ -54,7 +58,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else using (JsonDocument document = JsonDocument.Parse(item.Value)) { @@ -65,22 +69,23 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - ContentFilterProtectedMaterialResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + ContentFilterProtectedMaterialResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ContentFilterProtectedMaterialResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(ContentFilterProtectedMaterialResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeContentFilterProtectedMaterialResult(document.RootElement, options); } - internal static ContentFilterProtectedMaterialResult DeserializeContentFilterProtectedMaterialResult(JsonElement element, ModelReaderWriterOptions options = null) + internal static ContentFilterProtectedMaterialResult DeserializeContentFilterProtectedMaterialResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -88,43 +93,42 @@ internal static ContentFilterProtectedMaterialResult DeserializeContentFilterPro bool filtered = default; bool detected = default; ContentFilterProtectedMaterialCitationResult citation = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("filtered"u8)) + if (prop.NameEquals("filtered"u8)) { - filtered = property.Value.GetBoolean(); + filtered = prop.Value.GetBoolean(); continue; } - if (property.NameEquals("detected"u8)) + if (prop.NameEquals("detected"u8)) { - detected = property.Value.GetBoolean(); + detected = prop.Value.GetBoolean(); continue; } - if (property.NameEquals("citation"u8)) + if (prop.NameEquals("citation"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - citation = ContentFilterProtectedMaterialCitationResult.DeserializeContentFilterProtectedMaterialCitationResult(property.Value, options); + citation = ContentFilterProtectedMaterialCitationResult.DeserializeContentFilterProtectedMaterialCitationResult(prop.Value, options); continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new ContentFilterProtectedMaterialResult(filtered, detected, citation, serializedAdditionalRawData); + return new ContentFilterProtectedMaterialResult(filtered, detected, citation, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -134,15 +138,18 @@ BinaryData IPersistableModel.Write(ModelRe } } - ContentFilterProtectedMaterialResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + ContentFilterProtectedMaterialResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ContentFilterProtectedMaterialResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeContentFilterProtectedMaterialResult(document.RootElement, options); } default: @@ -152,18 +159,22 @@ ContentFilterProtectedMaterialResult IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static ContentFilterProtectedMaterialResult FromResponse(PipelineResponse response) + /// The to serialize into . + public static implicit operator BinaryContent(ContentFilterProtectedMaterialResult contentFilterProtectedMaterialResult) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeContentFilterProtectedMaterialResult(document.RootElement); + if (contentFilterProtectedMaterialResult == null) + { + return null; + } + return BinaryContent.Create(contentFilterProtectedMaterialResult, ModelSerializationExtensions.WireOptions); } - /// Convert into a . - internal virtual BinaryContent ToBinaryContent() + /// The to deserialize the from. + public static explicit operator ContentFilterProtectedMaterialResult(ClientResult result) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeContentFilterProtectedMaterialResult(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterProtectedMaterialResult.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterProtectedMaterialResult.cs new file mode 100644 index 000000000..d3ac9291c --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterProtectedMaterialResult.cs @@ -0,0 +1,45 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI +{ + /// The ContentFilterProtectedMaterialResult. + public partial class ContentFilterProtectedMaterialResult + { + /// Keeps track of any properties unknown to the library. + private protected IDictionary _additionalBinaryDataProperties; + + internal ContentFilterProtectedMaterialResult(bool filtered, bool detected) + { + Filtered = filtered; + Detected = detected; + } + + internal ContentFilterProtectedMaterialResult(bool filtered, bool detected, ContentFilterProtectedMaterialCitationResult citation, IDictionary additionalBinaryDataProperties) + { + Filtered = filtered; + Detected = detected; + Citation = citation; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Whether the content detection resulted in a content filtering action. + public bool Filtered { get; } + + /// Whether the labeled content category was detected in the content. + public bool Detected { get; } + + /// If available, the citation details describing the associated license and its location. + public ContentFilterProtectedMaterialCitationResult Citation { get; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterSeverity.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterSeverity.cs similarity index 69% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterSeverity.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterSeverity.cs index cbca38b68..634101bae 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterSeverity.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterSeverity.cs @@ -7,48 +7,63 @@ namespace Azure.AI.OpenAI { - /// The AzureContentFilterSeverityResultSeverity. + /// public readonly partial struct ContentFilterSeverity : IEquatable { private readonly string _value; + private const string SafeValue = "safe"; + private const string LowValue = "low"; + private const string MediumValue = "medium"; + private const string HighValue = "high"; /// Initializes a new instance of . + /// The value. /// is null. public ContentFilterSeverity(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string SafeValue = "safe"; - private const string LowValue = "low"; - private const string MediumValue = "medium"; - private const string HighValue = "high"; + _value = value; + } - /// safe. + /// Gets the Safe. public static ContentFilterSeverity Safe { get; } = new ContentFilterSeverity(SafeValue); - /// low. + + /// Gets the Low. public static ContentFilterSeverity Low { get; } = new ContentFilterSeverity(LowValue); - /// medium. + + /// Gets the Medium. public static ContentFilterSeverity Medium { get; } = new ContentFilterSeverity(MediumValue); - /// high. + + /// Gets the High. public static ContentFilterSeverity High { get; } = new ContentFilterSeverity(HighValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(ContentFilterSeverity left, ContentFilterSeverity right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(ContentFilterSeverity left, ContentFilterSeverity right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator ContentFilterSeverity(string value) => new ContentFilterSeverity(value); - /// + /// The object to compare. [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is ContentFilterSeverity other && Equals(other); - /// + + /// The instance to compare. public bool Equals(ContentFilterSeverity other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - /// + /// [EditorBrowsable(EditorBrowsableState.Never)] public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - /// + + /// public override string ToString() => _value; } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterSeverityResult.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterSeverityResult.Serialization.cs similarity index 53% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterSeverityResult.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterSeverityResult.Serialization.cs index 92c48c5d2..39ccf9c5a 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterSeverityResult.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterSeverityResult.Serialization.cs @@ -10,8 +10,13 @@ namespace Azure.AI.OpenAI { + /// public partial class ContentFilterSeverityResult : IJsonModel { + internal ContentFilterSeverityResult() + { + } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -23,25 +28,24 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelR /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(ContentFilterSeverityResult)} does not support writing '{format}' format."); } - - if (SerializedAdditionalRawData?.ContainsKey("filtered") != true) + if (_additionalBinaryDataProperties?.ContainsKey("filtered") != true) { writer.WritePropertyName("filtered"u8); writer.WriteBooleanValue(Filtered); } - if (SerializedAdditionalRawData?.ContainsKey("severity") != true) + if (_additionalBinaryDataProperties?.ContainsKey("severity") != true) { writer.WritePropertyName("severity"u8); writer.WriteStringValue(Severity.ToString()); } - if (SerializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in SerializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { @@ -49,7 +53,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else using (JsonDocument document = JsonDocument.Parse(item.Value)) { @@ -60,56 +64,56 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - ContentFilterSeverityResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + ContentFilterSeverityResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ContentFilterSeverityResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(ContentFilterSeverityResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeContentFilterSeverityResult(document.RootElement, options); } - internal static ContentFilterSeverityResult DeserializeContentFilterSeverityResult(JsonElement element, ModelReaderWriterOptions options = null) + internal static ContentFilterSeverityResult DeserializeContentFilterSeverityResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } bool filtered = default; ContentFilterSeverity severity = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("filtered"u8)) + if (prop.NameEquals("filtered"u8)) { - filtered = property.Value.GetBoolean(); + filtered = prop.Value.GetBoolean(); continue; } - if (property.NameEquals("severity"u8)) + if (prop.NameEquals("severity"u8)) { - severity = new ContentFilterSeverity(property.Value.GetString()); + severity = new ContentFilterSeverity(prop.Value.GetString()); continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new ContentFilterSeverityResult(filtered, severity, serializedAdditionalRawData); + return new ContentFilterSeverityResult(filtered, severity, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -119,15 +123,18 @@ BinaryData IPersistableModel.Write(ModelReaderWrite } } - ContentFilterSeverityResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + ContentFilterSeverityResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ContentFilterSeverityResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeContentFilterSeverityResult(document.RootElement, options); } default: @@ -137,18 +144,22 @@ ContentFilterSeverityResult IPersistableModel.Creat string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static ContentFilterSeverityResult FromResponse(PipelineResponse response) + /// The to serialize into . + public static implicit operator BinaryContent(ContentFilterSeverityResult contentFilterSeverityResult) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeContentFilterSeverityResult(document.RootElement); + if (contentFilterSeverityResult == null) + { + return null; + } + return BinaryContent.Create(contentFilterSeverityResult, ModelSerializationExtensions.WireOptions); } - /// Convert into a . - internal virtual BinaryContent ToBinaryContent() + /// The to deserialize the from. + public static explicit operator ContentFilterSeverityResult(ClientResult result) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeContentFilterSeverityResult(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterSeverityResult.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterSeverityResult.cs new file mode 100644 index 000000000..934f8b086 --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterSeverityResult.cs @@ -0,0 +1,41 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI +{ + /// + /// A labeled content filter result item that indicates whether the content was filtered and what the qualitative + /// severity level of the content was, as evaluated against content filter configuration for the category. + /// + public partial class ContentFilterSeverityResult + { + /// Keeps track of any properties unknown to the library. + private protected IDictionary _additionalBinaryDataProperties; + + internal ContentFilterSeverityResult(bool filtered, ContentFilterSeverity severity) + { + Filtered = filtered; + Severity = severity; + } + + internal ContentFilterSeverityResult(bool filtered, ContentFilterSeverity severity, IDictionary additionalBinaryDataProperties) + { + Filtered = filtered; + Severity = severity; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Whether the content severity resulted in a content filtering action. + public bool Filtered { get; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterTextSpan.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterTextSpan.Serialization.cs similarity index 54% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterTextSpan.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterTextSpan.Serialization.cs index effcd8aea..4d8345ec0 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterTextSpan.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterTextSpan.Serialization.cs @@ -10,8 +10,13 @@ namespace Azure.AI.OpenAI { + /// public partial class ContentFilterTextSpan : IJsonModel { + internal ContentFilterTextSpan() + { + } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -23,25 +28,24 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderW /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(ContentFilterTextSpan)} does not support writing '{format}' format."); } - - if (SerializedAdditionalRawData?.ContainsKey("completion_start_offset") != true) + if (_additionalBinaryDataProperties?.ContainsKey("completion_start_offset") != true) { writer.WritePropertyName("completion_start_offset"u8); writer.WriteNumberValue(CompletionStartOffset); } - if (SerializedAdditionalRawData?.ContainsKey("completion_end_offset") != true) + if (_additionalBinaryDataProperties?.ContainsKey("completion_end_offset") != true) { writer.WritePropertyName("completion_end_offset"u8); writer.WriteNumberValue(CompletionEndOffset); } - if (SerializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in SerializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { @@ -49,7 +53,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else using (JsonDocument document = JsonDocument.Parse(item.Value)) { @@ -60,56 +64,56 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - ContentFilterTextSpan IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + ContentFilterTextSpan IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ContentFilterTextSpan JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(ContentFilterTextSpan)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeContentFilterTextSpan(document.RootElement, options); } - internal static ContentFilterTextSpan DeserializeContentFilterTextSpan(JsonElement element, ModelReaderWriterOptions options = null) + internal static ContentFilterTextSpan DeserializeContentFilterTextSpan(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } int completionStartOffset = default; int completionEndOffset = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("completion_start_offset"u8)) + if (prop.NameEquals("completion_start_offset"u8)) { - completionStartOffset = property.Value.GetInt32(); + completionStartOffset = prop.Value.GetInt32(); continue; } - if (property.NameEquals("completion_end_offset"u8)) + if (prop.NameEquals("completion_end_offset"u8)) { - completionEndOffset = property.Value.GetInt32(); + completionEndOffset = prop.Value.GetInt32(); continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new ContentFilterTextSpan(completionStartOffset, completionEndOffset, serializedAdditionalRawData); + return new ContentFilterTextSpan(completionStartOffset, completionEndOffset, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -119,15 +123,18 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptio } } - ContentFilterTextSpan IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + ContentFilterTextSpan IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ContentFilterTextSpan PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeContentFilterTextSpan(document.RootElement, options); } default: @@ -137,18 +144,22 @@ ContentFilterTextSpan IPersistableModel.Create(BinaryData string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static ContentFilterTextSpan FromResponse(PipelineResponse response) + /// The to serialize into . + public static implicit operator BinaryContent(ContentFilterTextSpan contentFilterTextSpan) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeContentFilterTextSpan(document.RootElement); + if (contentFilterTextSpan == null) + { + return null; + } + return BinaryContent.Create(contentFilterTextSpan, ModelSerializationExtensions.WireOptions); } - /// Convert into a . - internal virtual BinaryContent ToBinaryContent() + /// The to deserialize the from. + public static explicit operator ContentFilterTextSpan(ClientResult result) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeContentFilterTextSpan(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterTextSpan.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterTextSpan.cs new file mode 100644 index 000000000..b4579e6c0 --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterTextSpan.cs @@ -0,0 +1,41 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI +{ + /// A representation of a span of completion text as used by Azure OpenAI content filter results. + public partial class ContentFilterTextSpan + { + /// Keeps track of any properties unknown to the library. + private protected IDictionary _additionalBinaryDataProperties; + + internal ContentFilterTextSpan(int completionStartOffset, int completionEndOffset) + { + CompletionStartOffset = completionStartOffset; + CompletionEndOffset = completionEndOffset; + } + + internal ContentFilterTextSpan(int completionStartOffset, int completionEndOffset, IDictionary additionalBinaryDataProperties) + { + CompletionStartOffset = completionStartOffset; + CompletionEndOffset = completionEndOffset; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Offset of the UTF32 code point which begins the span. + public int CompletionStartOffset { get; } + + /// Offset of the first UTF32 code point which is excluded from the span. This field is always equal to completion_start_offset for empty spans. This field is always larger than completion_start_offset for non-empty spans. + public int CompletionEndOffset { get; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterTextSpanResult.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterTextSpanResult.Serialization.cs similarity index 54% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterTextSpanResult.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterTextSpanResult.Serialization.cs index 598694d7d..bdf88d163 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ContentFilterTextSpanResult.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterTextSpanResult.Serialization.cs @@ -10,8 +10,13 @@ namespace Azure.AI.OpenAI { + /// public partial class ContentFilterTextSpanResult : IJsonModel { + internal ContentFilterTextSpanResult() + { + } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -23,35 +28,34 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelR /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(ContentFilterTextSpanResult)} does not support writing '{format}' format."); } - - if (SerializedAdditionalRawData?.ContainsKey("filtered") != true) + if (_additionalBinaryDataProperties?.ContainsKey("filtered") != true) { writer.WritePropertyName("filtered"u8); writer.WriteBooleanValue(Filtered); } - if (SerializedAdditionalRawData?.ContainsKey("detected") != true) + if (_additionalBinaryDataProperties?.ContainsKey("detected") != true) { writer.WritePropertyName("detected"u8); writer.WriteBooleanValue(Detected); } - if (SerializedAdditionalRawData?.ContainsKey("details") != true) + if (_additionalBinaryDataProperties?.ContainsKey("details") != true) { writer.WritePropertyName("details"u8); writer.WriteStartArray(); - foreach (var item in Details) + foreach (ContentFilterTextSpan item in Details) { writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } - if (SerializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in SerializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { @@ -59,7 +63,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else using (JsonDocument document = JsonDocument.Parse(item.Value)) { @@ -70,47 +74,47 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - ContentFilterTextSpanResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + ContentFilterTextSpanResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ContentFilterTextSpanResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(ContentFilterTextSpanResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeContentFilterTextSpanResult(document.RootElement, options); } - internal static ContentFilterTextSpanResult DeserializeContentFilterTextSpanResult(JsonElement element, ModelReaderWriterOptions options = null) + internal static ContentFilterTextSpanResult DeserializeContentFilterTextSpanResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } bool filtered = default; bool detected = default; - IReadOnlyList details = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IList details = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("filtered"u8)) + if (prop.NameEquals("filtered"u8)) { - filtered = property.Value.GetBoolean(); + filtered = prop.Value.GetBoolean(); continue; } - if (property.NameEquals("detected"u8)) + if (prop.NameEquals("detected"u8)) { - detected = property.Value.GetBoolean(); + detected = prop.Value.GetBoolean(); continue; } - if (property.NameEquals("details"u8)) + if (prop.NameEquals("details"u8)) { List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(ContentFilterTextSpan.DeserializeContentFilterTextSpan(item, options)); } @@ -119,18 +123,18 @@ internal static ContentFilterTextSpanResult DeserializeContentFilterTextSpanResu } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new ContentFilterTextSpanResult(filtered, detected, details, serializedAdditionalRawData); + return new ContentFilterTextSpanResult(filtered, detected, details, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -140,15 +144,18 @@ BinaryData IPersistableModel.Write(ModelReaderWrite } } - ContentFilterTextSpanResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + ContentFilterTextSpanResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ContentFilterTextSpanResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeContentFilterTextSpanResult(document.RootElement, options); } default: @@ -158,18 +165,22 @@ ContentFilterTextSpanResult IPersistableModel.Creat string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static ContentFilterTextSpanResult FromResponse(PipelineResponse response) + /// The to serialize into . + public static implicit operator BinaryContent(ContentFilterTextSpanResult contentFilterTextSpanResult) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeContentFilterTextSpanResult(document.RootElement); + if (contentFilterTextSpanResult == null) + { + return null; + } + return BinaryContent.Create(contentFilterTextSpanResult, ModelSerializationExtensions.WireOptions); } - /// Convert into a . - internal virtual BinaryContent ToBinaryContent() + /// The to deserialize the from. + public static explicit operator ContentFilterTextSpanResult(ClientResult result) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeContentFilterTextSpanResult(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterTextSpanResult.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterTextSpanResult.cs new file mode 100644 index 000000000..a1c7e1c0b --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ContentFilterTextSpanResult.cs @@ -0,0 +1,47 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.OpenAI +{ + /// The ContentFilterTextSpanResult. + public partial class ContentFilterTextSpanResult + { + /// Keeps track of any properties unknown to the library. + private protected IDictionary _additionalBinaryDataProperties; + + internal ContentFilterTextSpanResult(bool filtered, bool detected, IEnumerable details) + { + Filtered = filtered; + Detected = detected; + Details = details.ToList(); + } + + internal ContentFilterTextSpanResult(bool filtered, bool detected, IList details, IDictionary additionalBinaryDataProperties) + { + Filtered = filtered; + Detected = detected; + Details = details; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// Whether the content detection resulted in a content filtering action. + public bool Filtered { get; } + + /// Whether the labeled content category was detected in the content. + public bool Detected { get; } + + /// Detailed information about the detected completion text spans. + public IList Details { get; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/CosmosChatDataSource.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/CosmosChatDataSource.Serialization.cs new file mode 100644 index 000000000..62a069964 --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/CosmosChatDataSource.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.OpenAI; + +namespace Azure.AI.OpenAI.Chat +{ + /// + public partial class CosmosChatDataSource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CosmosChatDataSource)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (_additionalBinaryDataProperties?.ContainsKey("parameters") != true) + { + writer.WritePropertyName("parameters"u8); + writer.WriteObjectValue(InternalParameters, options); + } + } + + CosmosChatDataSource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (CosmosChatDataSource)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override ChatDataSource JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CosmosChatDataSource)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCosmosChatDataSource(document.RootElement, options); + } + + internal static CosmosChatDataSource DeserializeCosmosChatDataSource(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string @type = "azure_cosmos_db"; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + InternalAzureCosmosDBChatDataSourceParameters internalParameters = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("parameters"u8)) + { + internalParameters = InternalAzureCosmosDBChatDataSourceParameters.DeserializeInternalAzureCosmosDBChatDataSourceParameters(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new CosmosChatDataSource(@type, additionalBinaryDataProperties, internalParameters); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(CosmosChatDataSource)} does not support writing '{options.Format}' format."); + } + } + + CosmosChatDataSource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (CosmosChatDataSource)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override ChatDataSource PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeCosmosChatDataSource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CosmosChatDataSource)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + public static implicit operator BinaryContent(CosmosChatDataSource cosmosChatDataSource) + { + if (cosmosChatDataSource == null) + { + return null; + } + return BinaryContent.Create(cosmosChatDataSource, ModelSerializationExtensions.WireOptions); + } + + /// The to deserialize the from. + public static explicit operator CosmosChatDataSource(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeCosmosChatDataSource(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/CosmosChatDataSource.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/CosmosChatDataSource.cs similarity index 84% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/CosmosChatDataSource.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/CosmosChatDataSource.cs index 779961ba9..58f84cf9e 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/CosmosChatDataSource.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/CosmosChatDataSource.cs @@ -2,9 +2,6 @@ #nullable disable -using System; -using System.Collections.Generic; - namespace Azure.AI.OpenAI.Chat { /// Represents a data source configuration that will use an Azure CosmosDB resource. diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/DataSourceAuthentication.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/DataSourceAuthentication.Serialization.cs new file mode 100644 index 000000000..08a200a07 --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/DataSourceAuthentication.Serialization.cs @@ -0,0 +1,163 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.AI.OpenAI; + +namespace Azure.AI.OpenAI.Chat +{ + /// + [PersistableModelProxy(typeof(InternalUnknownAzureChatDataSourceAuthenticationOptions))] + public abstract partial class DataSourceAuthentication : IJsonModel + { + internal DataSourceAuthentication() + { + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataSourceAuthentication)} does not support writing '{format}' format."); + } + if (_additionalBinaryDataProperties?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) + { + continue; + } + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + DataSourceAuthentication IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DataSourceAuthentication JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataSourceAuthentication)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataSourceAuthentication(document.RootElement, options); + } + + internal static DataSourceAuthentication DeserializeDataSourceAuthentication(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "api_key": + return InternalAzureChatDataSourceApiKeyAuthenticationOptions.DeserializeInternalAzureChatDataSourceApiKeyAuthenticationOptions(element, options); + case "connection_string": + return InternalAzureChatDataSourceConnectionStringAuthenticationOptions.DeserializeInternalAzureChatDataSourceConnectionStringAuthenticationOptions(element, options); + case "system_assigned_managed_identity": + return InternalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions.DeserializeInternalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions(element, options); + case "user_assigned_managed_identity": + return InternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions.DeserializeInternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions(element, options); + case "key_and_key_id": + return InternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions.DeserializeInternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions(element, options); + case "encoded_api_key": + return InternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions.DeserializeInternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions(element, options); + case "access_token": + return InternalAzureChatDataSourceAccessTokenAuthenticationOptions.DeserializeInternalAzureChatDataSourceAccessTokenAuthenticationOptions(element, options); + case "username_and_password": + return InternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions.DeserializeInternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions(element, options); + } + } + return InternalUnknownAzureChatDataSourceAuthenticationOptions.DeserializeInternalUnknownAzureChatDataSourceAuthenticationOptions(element, options); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(DataSourceAuthentication)} does not support writing '{options.Format}' format."); + } + } + + DataSourceAuthentication IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DataSourceAuthentication PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeDataSourceAuthentication(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataSourceAuthentication)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + public static implicit operator BinaryContent(DataSourceAuthentication dataSourceAuthentication) + { + if (dataSourceAuthentication == null) + { + return null; + } + return BinaryContent.Create(dataSourceAuthentication, ModelSerializationExtensions.WireOptions); + } + + /// The to deserialize the from. + public static explicit operator DataSourceAuthentication(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeDataSourceAuthentication(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/DataSourceAuthentication.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/DataSourceAuthentication.cs new file mode 100644 index 000000000..b4166f59f --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/DataSourceAuthentication.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Chat +{ + /// The DataSourceAuthentication. + public abstract partial class DataSourceAuthentication + { + /// Keeps track of any properties unknown to the library. + private protected IDictionary _additionalBinaryDataProperties; + + private protected DataSourceAuthentication(string @type) + { + Type = @type; + } + + internal DataSourceAuthentication(string @type, IDictionary additionalBinaryDataProperties) + { + Type = @type; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + internal string Type { get; set; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/DataSourceFieldMappings.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/DataSourceFieldMappings.Serialization.cs new file mode 100644 index 000000000..74cd1284b --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/DataSourceFieldMappings.Serialization.cs @@ -0,0 +1,303 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.OpenAI; + +namespace Azure.AI.OpenAI.Chat +{ + /// + public partial class DataSourceFieldMappings : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataSourceFieldMappings)} does not support writing '{format}' format."); + } + if (Optional.IsDefined(TitleFieldName) && _additionalBinaryDataProperties?.ContainsKey("title_field") != true) + { + writer.WritePropertyName("title_field"u8); + writer.WriteStringValue(TitleFieldName); + } + if (Optional.IsDefined(UrlFieldName) && _additionalBinaryDataProperties?.ContainsKey("url_field") != true) + { + writer.WritePropertyName("url_field"u8); + writer.WriteStringValue(UrlFieldName); + } + if (Optional.IsDefined(FilePathFieldName) && _additionalBinaryDataProperties?.ContainsKey("filepath_field") != true) + { + writer.WritePropertyName("filepath_field"u8); + writer.WriteStringValue(FilePathFieldName); + } + if (Optional.IsCollectionDefined(ContentFieldNames) && _additionalBinaryDataProperties?.ContainsKey("content_fields") != true) + { + writer.WritePropertyName("content_fields"u8); + writer.WriteStartArray(); + foreach (string item in ContentFieldNames) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(ContentFieldSeparator) && _additionalBinaryDataProperties?.ContainsKey("content_fields_separator") != true) + { + writer.WritePropertyName("content_fields_separator"u8); + writer.WriteStringValue(ContentFieldSeparator); + } + if (Optional.IsCollectionDefined(VectorFieldNames) && _additionalBinaryDataProperties?.ContainsKey("vector_fields") != true) + { + writer.WritePropertyName("vector_fields"u8); + writer.WriteStartArray(); + foreach (string item in VectorFieldNames) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(ImageVectorFieldNames) && _additionalBinaryDataProperties?.ContainsKey("image_vector_fields") != true) + { + writer.WritePropertyName("image_vector_fields"u8); + writer.WriteStartArray(); + foreach (string item in ImageVectorFieldNames) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) + { + continue; + } + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + DataSourceFieldMappings IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DataSourceFieldMappings JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataSourceFieldMappings)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataSourceFieldMappings(document.RootElement, options); + } + + internal static DataSourceFieldMappings DeserializeDataSourceFieldMappings(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string titleFieldName = default; + string urlFieldName = default; + string filePathFieldName = default; + IList contentFieldNames = default; + string contentFieldSeparator = default; + IList vectorFieldNames = default; + IList imageVectorFieldNames = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("title_field"u8)) + { + titleFieldName = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("url_field"u8)) + { + urlFieldName = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("filepath_field"u8)) + { + filePathFieldName = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("content_fields"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + contentFieldNames = array; + continue; + } + if (prop.NameEquals("content_fields_separator"u8)) + { + contentFieldSeparator = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("vector_fields"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + vectorFieldNames = array; + continue; + } + if (prop.NameEquals("image_vector_fields"u8)) + { + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + imageVectorFieldNames = array; + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new DataSourceFieldMappings( + titleFieldName, + urlFieldName, + filePathFieldName, + contentFieldNames ?? new ChangeTrackingList(), + contentFieldSeparator, + vectorFieldNames ?? new ChangeTrackingList(), + imageVectorFieldNames ?? new ChangeTrackingList(), + additionalBinaryDataProperties); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(DataSourceFieldMappings)} does not support writing '{options.Format}' format."); + } + } + + DataSourceFieldMappings IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DataSourceFieldMappings PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeDataSourceFieldMappings(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataSourceFieldMappings)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + public static implicit operator BinaryContent(DataSourceFieldMappings dataSourceFieldMappings) + { + if (dataSourceFieldMappings == null) + { + return null; + } + return BinaryContent.Create(dataSourceFieldMappings, ModelSerializationExtensions.WireOptions); + } + + /// The to deserialize the from. + public static explicit operator DataSourceFieldMappings(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeDataSourceFieldMappings(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/DataSourceFieldMappings.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/DataSourceFieldMappings.cs new file mode 100644 index 000000000..55140853a --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/DataSourceFieldMappings.cs @@ -0,0 +1,34 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Chat +{ + /// The DataSourceFieldMappings. + public partial class DataSourceFieldMappings + { + /// Keeps track of any properties unknown to the library. + private protected IDictionary _additionalBinaryDataProperties; + + internal DataSourceFieldMappings(string titleFieldName, string urlFieldName, string filePathFieldName, IList contentFieldNames, string contentFieldSeparator, IList vectorFieldNames, IList imageVectorFieldNames, IDictionary additionalBinaryDataProperties) + { + TitleFieldName = titleFieldName; + UrlFieldName = urlFieldName; + FilePathFieldName = filePathFieldName; + ContentFieldNames = contentFieldNames; + ContentFieldSeparator = contentFieldSeparator; + VectorFieldNames = vectorFieldNames; + ImageVectorFieldNames = imageVectorFieldNames; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/DataSourceQueryType.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/DataSourceQueryType.cs similarity index 69% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/DataSourceQueryType.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/DataSourceQueryType.cs index 90515d076..f21996d9a 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/DataSourceQueryType.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/DataSourceQueryType.cs @@ -4,54 +4,71 @@ using System; using System.ComponentModel; +using Azure.AI.OpenAI; namespace Azure.AI.OpenAI.Chat { - /// The AzureSearchChatDataSourceParametersQueryType. + /// public readonly partial struct DataSourceQueryType : IEquatable { private readonly string _value; + private const string SimpleValue = "simple"; + private const string SemanticValue = "semantic"; + private const string VectorValue = "vector"; + private const string VectorSimpleHybridValue = "vector_simple_hybrid"; + private const string VectorSemanticHybridValue = "vector_semantic_hybrid"; /// Initializes a new instance of . + /// The value. /// is null. public DataSourceQueryType(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } + Argument.AssertNotNull(value, nameof(value)); - private const string SimpleValue = "simple"; - private const string SemanticValue = "semantic"; - private const string VectorValue = "vector"; - private const string VectorSimpleHybridValue = "vector_simple_hybrid"; - private const string VectorSemanticHybridValue = "vector_semantic_hybrid"; + _value = value; + } - /// simple. + /// Gets the Simple. public static DataSourceQueryType Simple { get; } = new DataSourceQueryType(SimpleValue); - /// semantic. + + /// Gets the Semantic. public static DataSourceQueryType Semantic { get; } = new DataSourceQueryType(SemanticValue); - /// vector. + + /// Gets the Vector. public static DataSourceQueryType Vector { get; } = new DataSourceQueryType(VectorValue); - /// vector_simple_hybrid. + + /// Gets the VectorSimpleHybrid. public static DataSourceQueryType VectorSimpleHybrid { get; } = new DataSourceQueryType(VectorSimpleHybridValue); - /// vector_semantic_hybrid. + + /// Gets the VectorSemanticHybrid. public static DataSourceQueryType VectorSemanticHybrid { get; } = new DataSourceQueryType(VectorSemanticHybridValue); + /// Determines if two values are the same. + /// The left value to compare. + /// The right value to compare. public static bool operator ==(DataSourceQueryType left, DataSourceQueryType right) => left.Equals(right); + /// Determines if two values are not the same. + /// The left value to compare. + /// The right value to compare. public static bool operator !=(DataSourceQueryType left, DataSourceQueryType right) => !left.Equals(right); - /// Converts a to a . + + /// Converts a string to a . + /// The value. public static implicit operator DataSourceQueryType(string value) => new DataSourceQueryType(value); - /// + /// The object to compare. [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is DataSourceQueryType other && Equals(other); - /// + + /// The instance to compare. public bool Equals(DataSourceQueryType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - /// + /// [EditorBrowsable(EditorBrowsableState.Never)] public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - /// + + /// public override string ToString() => _value; } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/DataSourceVectorizer.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/DataSourceVectorizer.Serialization.cs new file mode 100644 index 000000000..40cb27bd4 --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/DataSourceVectorizer.Serialization.cs @@ -0,0 +1,155 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.AI.OpenAI; + +namespace Azure.AI.OpenAI.Chat +{ + /// + [PersistableModelProxy(typeof(InternalUnknownAzureChatDataSourceVectorizationSource))] + public abstract partial class DataSourceVectorizer : IJsonModel + { + internal DataSourceVectorizer() + { + } + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataSourceVectorizer)} does not support writing '{format}' format."); + } + if (_additionalBinaryDataProperties?.ContainsKey("type") != true) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) + { + if (ModelSerializationExtensions.IsSentinelValue(item.Value)) + { + continue; + } + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + DataSourceVectorizer IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual DataSourceVectorizer JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DataSourceVectorizer)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDataSourceVectorizer(document.RootElement, options); + } + + internal static DataSourceVectorizer DeserializeDataSourceVectorizer(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type"u8, out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "endpoint": + return InternalAzureChatDataSourceEndpointVectorizationSource.DeserializeInternalAzureChatDataSourceEndpointVectorizationSource(element, options); + case "deployment_name": + return InternalAzureChatDataSourceDeploymentNameVectorizationSource.DeserializeInternalAzureChatDataSourceDeploymentNameVectorizationSource(element, options); + case "model_id": + return InternalAzureChatDataSourceModelIdVectorizationSource.DeserializeInternalAzureChatDataSourceModelIdVectorizationSource(element, options); + case "integrated": + return InternalAzureChatDataSourceIntegratedVectorizationSource.DeserializeInternalAzureChatDataSourceIntegratedVectorizationSource(element, options); + } + } + return InternalUnknownAzureChatDataSourceVectorizationSource.DeserializeInternalUnknownAzureChatDataSourceVectorizationSource(element, options); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(DataSourceVectorizer)} does not support writing '{options.Format}' format."); + } + } + + DataSourceVectorizer IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected virtual DataSourceVectorizer PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeDataSourceVectorizer(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DataSourceVectorizer)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + public static implicit operator BinaryContent(DataSourceVectorizer dataSourceVectorizer) + { + if (dataSourceVectorizer == null) + { + return null; + } + return BinaryContent.Create(dataSourceVectorizer, ModelSerializationExtensions.WireOptions); + } + + /// The to deserialize the from. + public static explicit operator DataSourceVectorizer(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeDataSourceVectorizer(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/DataSourceVectorizer.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/DataSourceVectorizer.cs new file mode 100644 index 000000000..52b472d60 --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/DataSourceVectorizer.cs @@ -0,0 +1,35 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Chat +{ + /// A representation of a data vectorization source usable as an embedding resource with a data source. + public abstract partial class DataSourceVectorizer + { + /// Keeps track of any properties unknown to the library. + private protected IDictionary _additionalBinaryDataProperties; + + private protected DataSourceVectorizer(string @type) + { + Type = @type; + } + + internal DataSourceVectorizer(string @type, IDictionary additionalBinaryDataProperties) + { + Type = @type; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + internal string Type { get; set; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ElasticsearchChatDataSource.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ElasticsearchChatDataSource.Serialization.cs new file mode 100644 index 000000000..7c3ba933f --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ElasticsearchChatDataSource.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.OpenAI; + +namespace Azure.AI.OpenAI.Chat +{ + /// + public partial class ElasticsearchChatDataSource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ElasticsearchChatDataSource)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (_additionalBinaryDataProperties?.ContainsKey("parameters") != true) + { + writer.WritePropertyName("parameters"u8); + writer.WriteObjectValue(InternalParameters, options); + } + } + + ElasticsearchChatDataSource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (ElasticsearchChatDataSource)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override ChatDataSource JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ElasticsearchChatDataSource)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeElasticsearchChatDataSource(document.RootElement, options); + } + + internal static ElasticsearchChatDataSource DeserializeElasticsearchChatDataSource(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string @type = "elasticsearch"; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + InternalElasticsearchChatDataSourceParameters internalParameters = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("parameters"u8)) + { + internalParameters = InternalElasticsearchChatDataSourceParameters.DeserializeInternalElasticsearchChatDataSourceParameters(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new ElasticsearchChatDataSource(@type, additionalBinaryDataProperties, internalParameters); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ElasticsearchChatDataSource)} does not support writing '{options.Format}' format."); + } + } + + ElasticsearchChatDataSource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (ElasticsearchChatDataSource)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override ChatDataSource PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeElasticsearchChatDataSource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ElasticsearchChatDataSource)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + public static implicit operator BinaryContent(ElasticsearchChatDataSource elasticsearchChatDataSource) + { + if (elasticsearchChatDataSource == null) + { + return null; + } + return BinaryContent.Create(elasticsearchChatDataSource, ModelSerializationExtensions.WireOptions); + } + + /// The to deserialize the from. + public static explicit operator ElasticsearchChatDataSource(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeElasticsearchChatDataSource(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ElasticsearchChatDataSource.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ElasticsearchChatDataSource.cs similarity index 81% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ElasticsearchChatDataSource.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ElasticsearchChatDataSource.cs index a3c0db413..aa55edff6 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ElasticsearchChatDataSource.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ElasticsearchChatDataSource.cs @@ -2,9 +2,6 @@ #nullable disable -using System; -using System.Collections.Generic; - namespace Azure.AI.OpenAI.Chat { /// The ElasticsearchChatDataSource. diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ElasticsearchChatDataSourceParametersQueryType.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ElasticsearchChatDataSourceParametersQueryType.Serialization.cs new file mode 100644 index 000000000..f3da4e8cf --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ElasticsearchChatDataSourceParametersQueryType.Serialization.cs @@ -0,0 +1,31 @@ +// + +#nullable disable + +using System; + +namespace Azure.AI.OpenAI.Models +{ + internal static partial class ElasticsearchChatDataSourceParametersQueryTypeExtensions + { + public static string ToSerialString(this ElasticsearchChatDataSourceParametersQueryType value) => value switch + { + ElasticsearchChatDataSourceParametersQueryType.Simple => "simple", + ElasticsearchChatDataSourceParametersQueryType.Vector => "vector", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ElasticsearchChatDataSourceParametersQueryType value.") + }; + + public static ElasticsearchChatDataSourceParametersQueryType ToElasticsearchChatDataSourceParametersQueryType(this string value) + { + if (StringComparer.OrdinalIgnoreCase.Equals(value, "simple")) + { + return ElasticsearchChatDataSourceParametersQueryType.Simple; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "vector")) + { + return ElasticsearchChatDataSourceParametersQueryType.Vector; + } + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown ElasticsearchChatDataSourceParametersQueryType value."); + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ElasticsearchChatDataSourceParametersQueryType.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ElasticsearchChatDataSourceParametersQueryType.cs new file mode 100644 index 000000000..ff8508875 --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ElasticsearchChatDataSourceParametersQueryType.cs @@ -0,0 +1,15 @@ +// + +#nullable disable + +namespace Azure.AI.OpenAI.Models +{ + /// + public enum ElasticsearchChatDataSourceParametersQueryType + { + /// Simple. + Simple, + /// Vector. + Vector + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceAccessTokenAuthenticationOptions.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceAccessTokenAuthenticationOptions.Serialization.cs similarity index 55% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceAccessTokenAuthenticationOptions.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceAccessTokenAuthenticationOptions.Serialization.cs index cd0fc5e51..60d260159 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceAccessTokenAuthenticationOptions.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceAccessTokenAuthenticationOptions.Serialization.cs @@ -7,11 +7,16 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.AI.OpenAI; namespace Azure.AI.OpenAI.Chat { internal partial class InternalAzureChatDataSourceAccessTokenAuthenticationOptions : IJsonModel { + internal InternalAzureChatDataSourceAccessTokenAuthenticationOptions() + { + } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -19,74 +24,68 @@ void IJsonModel.Wri writer.WriteEndObject(); } - /// The JSON writer. - /// The client options for reading and writing models. protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalAzureChatDataSourceAccessTokenAuthenticationOptions)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); - if (SerializedAdditionalRawData?.ContainsKey("access_token") != true) + if (_additionalBinaryDataProperties?.ContainsKey("access_token") != true) { writer.WritePropertyName("access_token"u8); writer.WriteStringValue(AccessToken); } } - InternalAzureChatDataSourceAccessTokenAuthenticationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalAzureChatDataSourceAccessTokenAuthenticationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalAzureChatDataSourceAccessTokenAuthenticationOptions)JsonModelCreateCore(ref reader, options); + + protected override DataSourceAuthentication JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalAzureChatDataSourceAccessTokenAuthenticationOptions)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeInternalAzureChatDataSourceAccessTokenAuthenticationOptions(document.RootElement, options); } - internal static InternalAzureChatDataSourceAccessTokenAuthenticationOptions DeserializeInternalAzureChatDataSourceAccessTokenAuthenticationOptions(JsonElement element, ModelReaderWriterOptions options = null) + internal static InternalAzureChatDataSourceAccessTokenAuthenticationOptions DeserializeInternalAzureChatDataSourceAccessTokenAuthenticationOptions(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } + string @type = "access_token"; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); string accessToken = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("access_token"u8)) + if (prop.NameEquals("type"u8)) { - accessToken = property.Value.GetString(); + @type = prop.Value.GetString(); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("access_token"u8)) { - type = property.Value.GetString(); + accessToken = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new InternalAzureChatDataSourceAccessTokenAuthenticationOptions(type, serializedAdditionalRawData, accessToken); + return new InternalAzureChatDataSourceAccessTokenAuthenticationOptions(@type, additionalBinaryDataProperties, accessToken); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -96,15 +95,16 @@ BinaryData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + InternalAzureChatDataSourceAccessTokenAuthenticationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalAzureChatDataSourceAccessTokenAuthenticationOptions)PersistableModelCreateCore(data, options); + protected override DataSourceAuthentication PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeInternalAzureChatDataSourceAccessTokenAuthenticationOptions(document.RootElement, options); } default: @@ -114,18 +114,20 @@ InternalAzureChatDataSourceAccessTokenAuthenticationOptions IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static new InternalAzureChatDataSourceAccessTokenAuthenticationOptions FromResponse(PipelineResponse response) + public static implicit operator BinaryContent(InternalAzureChatDataSourceAccessTokenAuthenticationOptions internalAzureChatDataSourceAccessTokenAuthenticationOptions) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalAzureChatDataSourceAccessTokenAuthenticationOptions(document.RootElement); + if (internalAzureChatDataSourceAccessTokenAuthenticationOptions == null) + { + return null; + } + return BinaryContent.Create(internalAzureChatDataSourceAccessTokenAuthenticationOptions, ModelSerializationExtensions.WireOptions); } - /// Convert into a . - internal override BinaryContent ToBinaryContent() + public static explicit operator InternalAzureChatDataSourceAccessTokenAuthenticationOptions(ClientResult result) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalAzureChatDataSourceAccessTokenAuthenticationOptions(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceAccessTokenAuthenticationOptions.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceAccessTokenAuthenticationOptions.cs new file mode 100644 index 000000000..927d0cae0 --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceAccessTokenAuthenticationOptions.cs @@ -0,0 +1,27 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.OpenAI; + +namespace Azure.AI.OpenAI.Chat +{ + internal partial class InternalAzureChatDataSourceAccessTokenAuthenticationOptions : DataSourceAuthentication + { + public InternalAzureChatDataSourceAccessTokenAuthenticationOptions(string accessToken) : base("access_token") + { + Argument.AssertNotNull(accessToken, nameof(accessToken)); + + AccessToken = accessToken; + } + + internal InternalAzureChatDataSourceAccessTokenAuthenticationOptions(string @type, IDictionary additionalBinaryDataProperties, string accessToken) : base(@type, additionalBinaryDataProperties) + { + AccessToken = accessToken; + } + + public string AccessToken { get; set; } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceApiKeyAuthenticationOptions.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceApiKeyAuthenticationOptions.Serialization.cs similarity index 56% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceApiKeyAuthenticationOptions.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceApiKeyAuthenticationOptions.Serialization.cs index 38b1824ec..7b25e63c2 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceApiKeyAuthenticationOptions.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceApiKeyAuthenticationOptions.Serialization.cs @@ -7,11 +7,16 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.AI.OpenAI; namespace Azure.AI.OpenAI.Chat { internal partial class InternalAzureChatDataSourceApiKeyAuthenticationOptions : IJsonModel { + internal InternalAzureChatDataSourceApiKeyAuthenticationOptions() + { + } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -19,74 +24,68 @@ void IJsonModel.Write(Ut writer.WriteEndObject(); } - /// The JSON writer. - /// The client options for reading and writing models. protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalAzureChatDataSourceApiKeyAuthenticationOptions)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); - if (SerializedAdditionalRawData?.ContainsKey("key") != true) + if (_additionalBinaryDataProperties?.ContainsKey("key") != true) { writer.WritePropertyName("key"u8); writer.WriteStringValue(Key); } } - InternalAzureChatDataSourceApiKeyAuthenticationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalAzureChatDataSourceApiKeyAuthenticationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalAzureChatDataSourceApiKeyAuthenticationOptions)JsonModelCreateCore(ref reader, options); + + protected override DataSourceAuthentication JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalAzureChatDataSourceApiKeyAuthenticationOptions)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeInternalAzureChatDataSourceApiKeyAuthenticationOptions(document.RootElement, options); } - internal static InternalAzureChatDataSourceApiKeyAuthenticationOptions DeserializeInternalAzureChatDataSourceApiKeyAuthenticationOptions(JsonElement element, ModelReaderWriterOptions options = null) + internal static InternalAzureChatDataSourceApiKeyAuthenticationOptions DeserializeInternalAzureChatDataSourceApiKeyAuthenticationOptions(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } + string @type = "api_key"; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); string key = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("key"u8)) + if (prop.NameEquals("type"u8)) { - key = property.Value.GetString(); + @type = prop.Value.GetString(); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("key"u8)) { - type = property.Value.GetString(); + key = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new InternalAzureChatDataSourceApiKeyAuthenticationOptions(type, serializedAdditionalRawData, key); + return new InternalAzureChatDataSourceApiKeyAuthenticationOptions(@type, additionalBinaryDataProperties, key); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -96,15 +95,16 @@ BinaryData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + InternalAzureChatDataSourceApiKeyAuthenticationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalAzureChatDataSourceApiKeyAuthenticationOptions)PersistableModelCreateCore(data, options); + protected override DataSourceAuthentication PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeInternalAzureChatDataSourceApiKeyAuthenticationOptions(document.RootElement, options); } default: @@ -114,18 +114,20 @@ InternalAzureChatDataSourceApiKeyAuthenticationOptions IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static new InternalAzureChatDataSourceApiKeyAuthenticationOptions FromResponse(PipelineResponse response) + public static implicit operator BinaryContent(InternalAzureChatDataSourceApiKeyAuthenticationOptions internalAzureChatDataSourceApiKeyAuthenticationOptions) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalAzureChatDataSourceApiKeyAuthenticationOptions(document.RootElement); + if (internalAzureChatDataSourceApiKeyAuthenticationOptions == null) + { + return null; + } + return BinaryContent.Create(internalAzureChatDataSourceApiKeyAuthenticationOptions, ModelSerializationExtensions.WireOptions); } - /// Convert into a . - internal override BinaryContent ToBinaryContent() + public static explicit operator InternalAzureChatDataSourceApiKeyAuthenticationOptions(ClientResult result) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalAzureChatDataSourceApiKeyAuthenticationOptions(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceApiKeyAuthenticationOptions.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceApiKeyAuthenticationOptions.cs new file mode 100644 index 000000000..1d961aa82 --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceApiKeyAuthenticationOptions.cs @@ -0,0 +1,27 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.OpenAI; + +namespace Azure.AI.OpenAI.Chat +{ + internal partial class InternalAzureChatDataSourceApiKeyAuthenticationOptions : DataSourceAuthentication + { + public InternalAzureChatDataSourceApiKeyAuthenticationOptions(string key) : base("api_key") + { + Argument.AssertNotNull(key, nameof(key)); + + Key = key; + } + + internal InternalAzureChatDataSourceApiKeyAuthenticationOptions(string @type, IDictionary additionalBinaryDataProperties, string key) : base(@type, additionalBinaryDataProperties) + { + Key = key; + } + + public string Key { get; set; } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceConnectionStringAuthenticationOptions.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceConnectionStringAuthenticationOptions.Serialization.cs similarity index 55% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceConnectionStringAuthenticationOptions.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceConnectionStringAuthenticationOptions.Serialization.cs index c69efc08d..68b5fe909 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceConnectionStringAuthenticationOptions.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceConnectionStringAuthenticationOptions.Serialization.cs @@ -7,11 +7,16 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.AI.OpenAI; namespace Azure.AI.OpenAI.Chat { internal partial class InternalAzureChatDataSourceConnectionStringAuthenticationOptions : IJsonModel { + internal InternalAzureChatDataSourceConnectionStringAuthenticationOptions() + { + } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -19,74 +24,68 @@ void IJsonModel The JSON writer. - /// The client options for reading and writing models. protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalAzureChatDataSourceConnectionStringAuthenticationOptions)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); - if (SerializedAdditionalRawData?.ContainsKey("connection_string") != true) + if (_additionalBinaryDataProperties?.ContainsKey("connection_string") != true) { writer.WritePropertyName("connection_string"u8); writer.WriteStringValue(ConnectionString); } } - InternalAzureChatDataSourceConnectionStringAuthenticationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalAzureChatDataSourceConnectionStringAuthenticationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalAzureChatDataSourceConnectionStringAuthenticationOptions)JsonModelCreateCore(ref reader, options); + + protected override DataSourceAuthentication JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalAzureChatDataSourceConnectionStringAuthenticationOptions)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeInternalAzureChatDataSourceConnectionStringAuthenticationOptions(document.RootElement, options); } - internal static InternalAzureChatDataSourceConnectionStringAuthenticationOptions DeserializeInternalAzureChatDataSourceConnectionStringAuthenticationOptions(JsonElement element, ModelReaderWriterOptions options = null) + internal static InternalAzureChatDataSourceConnectionStringAuthenticationOptions DeserializeInternalAzureChatDataSourceConnectionStringAuthenticationOptions(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } + string @type = "connection_string"; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); string connectionString = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("connection_string"u8)) + if (prop.NameEquals("type"u8)) { - connectionString = property.Value.GetString(); + @type = prop.Value.GetString(); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("connection_string"u8)) { - type = property.Value.GetString(); + connectionString = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new InternalAzureChatDataSourceConnectionStringAuthenticationOptions(type, serializedAdditionalRawData, connectionString); + return new InternalAzureChatDataSourceConnectionStringAuthenticationOptions(@type, additionalBinaryDataProperties, connectionString); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -96,15 +95,16 @@ BinaryData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + InternalAzureChatDataSourceConnectionStringAuthenticationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalAzureChatDataSourceConnectionStringAuthenticationOptions)PersistableModelCreateCore(data, options); + protected override DataSourceAuthentication PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeInternalAzureChatDataSourceConnectionStringAuthenticationOptions(document.RootElement, options); } default: @@ -114,18 +114,20 @@ InternalAzureChatDataSourceConnectionStringAuthenticationOptions IPersistableMod string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static new InternalAzureChatDataSourceConnectionStringAuthenticationOptions FromResponse(PipelineResponse response) + public static implicit operator BinaryContent(InternalAzureChatDataSourceConnectionStringAuthenticationOptions internalAzureChatDataSourceConnectionStringAuthenticationOptions) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalAzureChatDataSourceConnectionStringAuthenticationOptions(document.RootElement); + if (internalAzureChatDataSourceConnectionStringAuthenticationOptions == null) + { + return null; + } + return BinaryContent.Create(internalAzureChatDataSourceConnectionStringAuthenticationOptions, ModelSerializationExtensions.WireOptions); } - /// Convert into a . - internal override BinaryContent ToBinaryContent() + public static explicit operator InternalAzureChatDataSourceConnectionStringAuthenticationOptions(ClientResult result) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalAzureChatDataSourceConnectionStringAuthenticationOptions(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceConnectionStringAuthenticationOptions.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceConnectionStringAuthenticationOptions.cs new file mode 100644 index 000000000..604747811 --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceConnectionStringAuthenticationOptions.cs @@ -0,0 +1,27 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.OpenAI; + +namespace Azure.AI.OpenAI.Chat +{ + internal partial class InternalAzureChatDataSourceConnectionStringAuthenticationOptions : DataSourceAuthentication + { + public InternalAzureChatDataSourceConnectionStringAuthenticationOptions(string connectionString) : base("connection_string") + { + Argument.AssertNotNull(connectionString, nameof(connectionString)); + + ConnectionString = connectionString; + } + + internal InternalAzureChatDataSourceConnectionStringAuthenticationOptions(string @type, IDictionary additionalBinaryDataProperties, string connectionString) : base(@type, additionalBinaryDataProperties) + { + ConnectionString = connectionString; + } + + public string ConnectionString { get; set; } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceDeploymentNameVectorizationSource.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceDeploymentNameVectorizationSource.Serialization.cs similarity index 55% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceDeploymentNameVectorizationSource.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceDeploymentNameVectorizationSource.Serialization.cs index 99098670d..f23f38e47 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceDeploymentNameVectorizationSource.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceDeploymentNameVectorizationSource.Serialization.cs @@ -7,11 +7,16 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.AI.OpenAI; namespace Azure.AI.OpenAI.Chat { internal partial class InternalAzureChatDataSourceDeploymentNameVectorizationSource : IJsonModel { + internal InternalAzureChatDataSourceDeploymentNameVectorizationSource() + { + } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -19,89 +24,83 @@ void IJsonModel.Wr writer.WriteEndObject(); } - /// The JSON writer. - /// The client options for reading and writing models. protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalAzureChatDataSourceDeploymentNameVectorizationSource)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); - if (SerializedAdditionalRawData?.ContainsKey("deployment_name") != true) + if (_additionalBinaryDataProperties?.ContainsKey("deployment_name") != true) { writer.WritePropertyName("deployment_name"u8); writer.WriteStringValue(DeploymentName); } - if (SerializedAdditionalRawData?.ContainsKey("dimensions") != true && Optional.IsDefined(Dimensions)) + if (Optional.IsDefined(Dimensions) && _additionalBinaryDataProperties?.ContainsKey("dimensions") != true) { writer.WritePropertyName("dimensions"u8); writer.WriteNumberValue(Dimensions.Value); } } - InternalAzureChatDataSourceDeploymentNameVectorizationSource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalAzureChatDataSourceDeploymentNameVectorizationSource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalAzureChatDataSourceDeploymentNameVectorizationSource)JsonModelCreateCore(ref reader, options); + + protected override DataSourceVectorizer JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalAzureChatDataSourceDeploymentNameVectorizationSource)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeInternalAzureChatDataSourceDeploymentNameVectorizationSource(document.RootElement, options); } - internal static InternalAzureChatDataSourceDeploymentNameVectorizationSource DeserializeInternalAzureChatDataSourceDeploymentNameVectorizationSource(JsonElement element, ModelReaderWriterOptions options = null) + internal static InternalAzureChatDataSourceDeploymentNameVectorizationSource DeserializeInternalAzureChatDataSourceDeploymentNameVectorizationSource(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } + string @type = "deployment_name"; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); string deploymentName = default; int? dimensions = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("deployment_name"u8)) + if (prop.NameEquals("type"u8)) { - deploymentName = property.Value.GetString(); + @type = prop.Value.GetString(); continue; } - if (property.NameEquals("dimensions"u8)) + if (prop.NameEquals("deployment_name"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - dimensions = property.Value.GetInt32(); + deploymentName = prop.Value.GetString(); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("dimensions"u8)) { - type = property.Value.GetString(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + dimensions = prop.Value.GetInt32(); continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new InternalAzureChatDataSourceDeploymentNameVectorizationSource(type, serializedAdditionalRawData, deploymentName, dimensions); + return new InternalAzureChatDataSourceDeploymentNameVectorizationSource(@type, additionalBinaryDataProperties, deploymentName, dimensions); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -111,15 +110,16 @@ BinaryData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + InternalAzureChatDataSourceDeploymentNameVectorizationSource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalAzureChatDataSourceDeploymentNameVectorizationSource)PersistableModelCreateCore(data, options); + protected override DataSourceVectorizer PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeInternalAzureChatDataSourceDeploymentNameVectorizationSource(document.RootElement, options); } default: @@ -129,18 +129,20 @@ InternalAzureChatDataSourceDeploymentNameVectorizationSource IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static new InternalAzureChatDataSourceDeploymentNameVectorizationSource FromResponse(PipelineResponse response) + public static implicit operator BinaryContent(InternalAzureChatDataSourceDeploymentNameVectorizationSource internalAzureChatDataSourceDeploymentNameVectorizationSource) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalAzureChatDataSourceDeploymentNameVectorizationSource(document.RootElement); + if (internalAzureChatDataSourceDeploymentNameVectorizationSource == null) + { + return null; + } + return BinaryContent.Create(internalAzureChatDataSourceDeploymentNameVectorizationSource, ModelSerializationExtensions.WireOptions); } - /// Convert into a . - internal override BinaryContent ToBinaryContent() + public static explicit operator InternalAzureChatDataSourceDeploymentNameVectorizationSource(ClientResult result) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalAzureChatDataSourceDeploymentNameVectorizationSource(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceDeploymentNameVectorizationSource.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceDeploymentNameVectorizationSource.cs new file mode 100644 index 000000000..483a2aa2e --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceDeploymentNameVectorizationSource.cs @@ -0,0 +1,30 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.OpenAI; + +namespace Azure.AI.OpenAI.Chat +{ + internal partial class InternalAzureChatDataSourceDeploymentNameVectorizationSource : DataSourceVectorizer + { + public InternalAzureChatDataSourceDeploymentNameVectorizationSource(string deploymentName) : base("deployment_name") + { + Argument.AssertNotNull(deploymentName, nameof(deploymentName)); + + DeploymentName = deploymentName; + } + + internal InternalAzureChatDataSourceDeploymentNameVectorizationSource(string @type, IDictionary additionalBinaryDataProperties, string deploymentName, int? dimensions) : base(@type, additionalBinaryDataProperties) + { + DeploymentName = deploymentName; + Dimensions = dimensions; + } + + public string DeploymentName { get; set; } + + public int? Dimensions { get; set; } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions.Serialization.cs similarity index 55% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions.Serialization.cs index 2a8cc7bd3..a51f8c9f9 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions.Serialization.cs @@ -7,11 +7,16 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.AI.OpenAI; namespace Azure.AI.OpenAI.Chat { internal partial class InternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions : IJsonModel { + internal InternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions() + { + } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -19,74 +24,68 @@ void IJsonModel.W writer.WriteEndObject(); } - /// The JSON writer. - /// The client options for reading and writing models. protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); - if (SerializedAdditionalRawData?.ContainsKey("encoded_api_key") != true) + if (_additionalBinaryDataProperties?.ContainsKey("encoded_api_key") != true) { writer.WritePropertyName("encoded_api_key"u8); writer.WriteStringValue(EncodedApiKey); } } - InternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions)JsonModelCreateCore(ref reader, options); + + protected override DataSourceAuthentication JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeInternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions(document.RootElement, options); } - internal static InternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions DeserializeInternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions(JsonElement element, ModelReaderWriterOptions options = null) + internal static InternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions DeserializeInternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } + string @type = "encoded_api_key"; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); string encodedApiKey = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("encoded_api_key"u8)) + if (prop.NameEquals("type"u8)) { - encodedApiKey = property.Value.GetString(); + @type = prop.Value.GetString(); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("encoded_api_key"u8)) { - type = property.Value.GetString(); + encodedApiKey = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new InternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions(type, serializedAdditionalRawData, encodedApiKey); + return new InternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions(@type, additionalBinaryDataProperties, encodedApiKey); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -96,15 +95,16 @@ BinaryData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + InternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions)PersistableModelCreateCore(data, options); + protected override DataSourceAuthentication PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeInternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions(document.RootElement, options); } default: @@ -114,18 +114,20 @@ InternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions IPersistableModel< string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static new InternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions FromResponse(PipelineResponse response) + public static implicit operator BinaryContent(InternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions internalAzureChatDataSourceEncodedApiKeyAuthenticationOptions) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions(document.RootElement); + if (internalAzureChatDataSourceEncodedApiKeyAuthenticationOptions == null) + { + return null; + } + return BinaryContent.Create(internalAzureChatDataSourceEncodedApiKeyAuthenticationOptions, ModelSerializationExtensions.WireOptions); } - /// Convert into a . - internal override BinaryContent ToBinaryContent() + public static explicit operator InternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions(ClientResult result) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions.cs new file mode 100644 index 000000000..d44b6a65b --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions.cs @@ -0,0 +1,27 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.OpenAI; + +namespace Azure.AI.OpenAI.Chat +{ + internal partial class InternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions : DataSourceAuthentication + { + public InternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions(string encodedApiKey) : base("encoded_api_key") + { + Argument.AssertNotNull(encodedApiKey, nameof(encodedApiKey)); + + EncodedApiKey = encodedApiKey; + } + + internal InternalAzureChatDataSourceEncodedApiKeyAuthenticationOptions(string @type, IDictionary additionalBinaryDataProperties, string encodedApiKey) : base(@type, additionalBinaryDataProperties) + { + EncodedApiKey = encodedApiKey; + } + + public string EncodedApiKey { get; set; } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceEndpointVectorizationSource.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceEndpointVectorizationSource.Serialization.cs similarity index 56% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceEndpointVectorizationSource.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceEndpointVectorizationSource.Serialization.cs index 85b3e5e7b..ebe91e98c 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceEndpointVectorizationSource.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceEndpointVectorizationSource.Serialization.cs @@ -7,11 +7,16 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.AI.OpenAI; namespace Azure.AI.OpenAI.Chat { internal partial class InternalAzureChatDataSourceEndpointVectorizationSource : IJsonModel { + internal InternalAzureChatDataSourceEndpointVectorizationSource() + { + } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -19,100 +24,94 @@ void IJsonModel.Write(Ut writer.WriteEndObject(); } - /// The JSON writer. - /// The client options for reading and writing models. protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalAzureChatDataSourceEndpointVectorizationSource)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); - if (SerializedAdditionalRawData?.ContainsKey("endpoint") != true) + if (_additionalBinaryDataProperties?.ContainsKey("endpoint") != true) { writer.WritePropertyName("endpoint"u8); writer.WriteStringValue(Endpoint.AbsoluteUri); } - if (SerializedAdditionalRawData?.ContainsKey("authentication") != true) - { - writer.WritePropertyName("authentication"u8); - writer.WriteObjectValue(Authentication, options); - } - if (SerializedAdditionalRawData?.ContainsKey("dimensions") != true && Optional.IsDefined(Dimensions)) + if (Optional.IsDefined(Dimensions) && _additionalBinaryDataProperties?.ContainsKey("dimensions") != true) { writer.WritePropertyName("dimensions"u8); writer.WriteNumberValue(Dimensions.Value); } + if (_additionalBinaryDataProperties?.ContainsKey("authentication") != true) + { + writer.WritePropertyName("authentication"u8); + writer.WriteObjectValue(Authentication, options); + } } - InternalAzureChatDataSourceEndpointVectorizationSource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalAzureChatDataSourceEndpointVectorizationSource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalAzureChatDataSourceEndpointVectorizationSource)JsonModelCreateCore(ref reader, options); + + protected override DataSourceVectorizer JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalAzureChatDataSourceEndpointVectorizationSource)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeInternalAzureChatDataSourceEndpointVectorizationSource(document.RootElement, options); } - internal static InternalAzureChatDataSourceEndpointVectorizationSource DeserializeInternalAzureChatDataSourceEndpointVectorizationSource(JsonElement element, ModelReaderWriterOptions options = null) + internal static InternalAzureChatDataSourceEndpointVectorizationSource DeserializeInternalAzureChatDataSourceEndpointVectorizationSource(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } + string @type = "endpoint"; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); Uri endpoint = default; - DataSourceAuthentication authentication = default; int? dimensions = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + DataSourceAuthentication authentication = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("endpoint"u8)) + if (prop.NameEquals("type"u8)) { - endpoint = new Uri(property.Value.GetString()); + @type = prop.Value.GetString(); continue; } - if (property.NameEquals("authentication"u8)) + if (prop.NameEquals("endpoint"u8)) { - authentication = DataSourceAuthentication.DeserializeDataSourceAuthentication(property.Value, options); + endpoint = new Uri(prop.Value.GetString()); continue; } - if (property.NameEquals("dimensions"u8)) + if (prop.NameEquals("dimensions"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - dimensions = property.Value.GetInt32(); + dimensions = prop.Value.GetInt32(); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("authentication"u8)) { - type = property.Value.GetString(); + authentication = DataSourceAuthentication.DeserializeDataSourceAuthentication(prop.Value, options); continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new InternalAzureChatDataSourceEndpointVectorizationSource(type, serializedAdditionalRawData, endpoint, authentication, dimensions); + return new InternalAzureChatDataSourceEndpointVectorizationSource(@type, additionalBinaryDataProperties, endpoint, dimensions, authentication); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -122,15 +121,16 @@ BinaryData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + InternalAzureChatDataSourceEndpointVectorizationSource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalAzureChatDataSourceEndpointVectorizationSource)PersistableModelCreateCore(data, options); + protected override DataSourceVectorizer PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeInternalAzureChatDataSourceEndpointVectorizationSource(document.RootElement, options); } default: @@ -140,18 +140,20 @@ InternalAzureChatDataSourceEndpointVectorizationSource IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static new InternalAzureChatDataSourceEndpointVectorizationSource FromResponse(PipelineResponse response) + public static implicit operator BinaryContent(InternalAzureChatDataSourceEndpointVectorizationSource internalAzureChatDataSourceEndpointVectorizationSource) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalAzureChatDataSourceEndpointVectorizationSource(document.RootElement); + if (internalAzureChatDataSourceEndpointVectorizationSource == null) + { + return null; + } + return BinaryContent.Create(internalAzureChatDataSourceEndpointVectorizationSource, ModelSerializationExtensions.WireOptions); } - /// Convert into a . - internal override BinaryContent ToBinaryContent() + public static explicit operator InternalAzureChatDataSourceEndpointVectorizationSource(ClientResult result) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalAzureChatDataSourceEndpointVectorizationSource(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceEndpointVectorizationSource.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceEndpointVectorizationSource.cs new file mode 100644 index 000000000..667c981ea --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceEndpointVectorizationSource.cs @@ -0,0 +1,33 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.OpenAI; + +namespace Azure.AI.OpenAI.Chat +{ + internal partial class InternalAzureChatDataSourceEndpointVectorizationSource : DataSourceVectorizer + { + public InternalAzureChatDataSourceEndpointVectorizationSource(Uri endpoint, DataSourceAuthentication authentication) : base("endpoint") + { + Argument.AssertNotNull(endpoint, nameof(endpoint)); + Argument.AssertNotNull(authentication, nameof(authentication)); + + Endpoint = endpoint; + Authentication = authentication; + } + + internal InternalAzureChatDataSourceEndpointVectorizationSource(string @type, IDictionary additionalBinaryDataProperties, Uri endpoint, int? dimensions, DataSourceAuthentication authentication) : base(@type, additionalBinaryDataProperties) + { + Endpoint = endpoint; + Dimensions = dimensions; + Authentication = authentication; + } + + public Uri Endpoint { get; set; } + + public int? Dimensions { get; set; } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceIntegratedVectorizationSource.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceIntegratedVectorizationSource.Serialization.cs similarity index 57% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceIntegratedVectorizationSource.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceIntegratedVectorizationSource.Serialization.cs index 6862500ff..4064a304e 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceIntegratedVectorizationSource.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceIntegratedVectorizationSource.Serialization.cs @@ -7,6 +7,7 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.AI.OpenAI; namespace Azure.AI.OpenAI.Chat { @@ -19,63 +20,57 @@ void IJsonModel.Write( writer.WriteEndObject(); } - /// The JSON writer. - /// The client options for reading and writing models. protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalAzureChatDataSourceIntegratedVectorizationSource)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); } - InternalAzureChatDataSourceIntegratedVectorizationSource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalAzureChatDataSourceIntegratedVectorizationSource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalAzureChatDataSourceIntegratedVectorizationSource)JsonModelCreateCore(ref reader, options); + + protected override DataSourceVectorizer JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalAzureChatDataSourceIntegratedVectorizationSource)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeInternalAzureChatDataSourceIntegratedVectorizationSource(document.RootElement, options); } - internal static InternalAzureChatDataSourceIntegratedVectorizationSource DeserializeInternalAzureChatDataSourceIntegratedVectorizationSource(JsonElement element, ModelReaderWriterOptions options = null) + internal static InternalAzureChatDataSourceIntegratedVectorizationSource DeserializeInternalAzureChatDataSourceIntegratedVectorizationSource(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + string @type = "integrated"; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("type"u8)) + if (prop.NameEquals("type"u8)) { - type = property.Value.GetString(); + @type = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new InternalAzureChatDataSourceIntegratedVectorizationSource(type, serializedAdditionalRawData); + return new InternalAzureChatDataSourceIntegratedVectorizationSource(@type, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -85,15 +80,16 @@ BinaryData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + InternalAzureChatDataSourceIntegratedVectorizationSource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalAzureChatDataSourceIntegratedVectorizationSource)PersistableModelCreateCore(data, options); + protected override DataSourceVectorizer PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeInternalAzureChatDataSourceIntegratedVectorizationSource(document.RootElement, options); } default: @@ -103,18 +99,20 @@ InternalAzureChatDataSourceIntegratedVectorizationSource IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static new InternalAzureChatDataSourceIntegratedVectorizationSource FromResponse(PipelineResponse response) + public static implicit operator BinaryContent(InternalAzureChatDataSourceIntegratedVectorizationSource internalAzureChatDataSourceIntegratedVectorizationSource) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalAzureChatDataSourceIntegratedVectorizationSource(document.RootElement); + if (internalAzureChatDataSourceIntegratedVectorizationSource == null) + { + return null; + } + return BinaryContent.Create(internalAzureChatDataSourceIntegratedVectorizationSource, ModelSerializationExtensions.WireOptions); } - /// Convert into a . - internal override BinaryContent ToBinaryContent() + public static explicit operator InternalAzureChatDataSourceIntegratedVectorizationSource(ClientResult result) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalAzureChatDataSourceIntegratedVectorizationSource(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceIntegratedVectorizationSource.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceIntegratedVectorizationSource.cs new file mode 100644 index 000000000..b1a7e7e61 --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceIntegratedVectorizationSource.cs @@ -0,0 +1,20 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Chat +{ + internal partial class InternalAzureChatDataSourceIntegratedVectorizationSource : DataSourceVectorizer + { + public InternalAzureChatDataSourceIntegratedVectorizationSource() : base("integrated") + { + } + + internal InternalAzureChatDataSourceIntegratedVectorizationSource(string @type, IDictionary additionalBinaryDataProperties) : base(@type, additionalBinaryDataProperties) + { + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions.Serialization.cs similarity index 55% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions.Serialization.cs index f632ed00b..b5754f58c 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions.Serialization.cs @@ -7,11 +7,16 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.AI.OpenAI; namespace Azure.AI.OpenAI.Chat { internal partial class InternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions : IJsonModel { + internal InternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions() + { + } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -19,85 +24,79 @@ void IJsonModel.Wri writer.WriteEndObject(); } - /// The JSON writer. - /// The client options for reading and writing models. protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); - if (SerializedAdditionalRawData?.ContainsKey("key") != true) + if (_additionalBinaryDataProperties?.ContainsKey("key") != true) { writer.WritePropertyName("key"u8); writer.WriteStringValue(Key); } - if (SerializedAdditionalRawData?.ContainsKey("key_id") != true) + if (_additionalBinaryDataProperties?.ContainsKey("key_id") != true) { writer.WritePropertyName("key_id"u8); writer.WriteStringValue(KeyId); } } - InternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions)JsonModelCreateCore(ref reader, options); + + protected override DataSourceAuthentication JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeInternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions(document.RootElement, options); } - internal static InternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions DeserializeInternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions(JsonElement element, ModelReaderWriterOptions options = null) + internal static InternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions DeserializeInternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } + string @type = "key_and_key_id"; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); string key = default; string keyId = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("key"u8)) + if (prop.NameEquals("type"u8)) { - key = property.Value.GetString(); + @type = prop.Value.GetString(); continue; } - if (property.NameEquals("key_id"u8)) + if (prop.NameEquals("key"u8)) { - keyId = property.Value.GetString(); + key = prop.Value.GetString(); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("key_id"u8)) { - type = property.Value.GetString(); + keyId = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new InternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions(type, serializedAdditionalRawData, key, keyId); + return new InternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions(@type, additionalBinaryDataProperties, key, keyId); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -107,15 +106,16 @@ BinaryData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + InternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions)PersistableModelCreateCore(data, options); + protected override DataSourceAuthentication PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeInternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions(document.RootElement, options); } default: @@ -125,18 +125,20 @@ InternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static new InternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions FromResponse(PipelineResponse response) + public static implicit operator BinaryContent(InternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions internalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions(document.RootElement); + if (internalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions == null) + { + return null; + } + return BinaryContent.Create(internalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions, ModelSerializationExtensions.WireOptions); } - /// Convert into a . - internal override BinaryContent ToBinaryContent() + public static explicit operator InternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions(ClientResult result) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions.cs new file mode 100644 index 000000000..c44f34cae --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions.cs @@ -0,0 +1,32 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.OpenAI; + +namespace Azure.AI.OpenAI.Chat +{ + internal partial class InternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions : DataSourceAuthentication + { + public InternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions(string key, string keyId) : base("key_and_key_id") + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(keyId, nameof(keyId)); + + Key = key; + KeyId = keyId; + } + + internal InternalAzureChatDataSourceKeyAndKeyIdAuthenticationOptions(string @type, IDictionary additionalBinaryDataProperties, string key, string keyId) : base(@type, additionalBinaryDataProperties) + { + Key = key; + KeyId = keyId; + } + + public string Key { get; set; } + + public string KeyId { get; set; } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceModelIdVectorizationSource.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceModelIdVectorizationSource.Serialization.cs similarity index 56% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceModelIdVectorizationSource.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceModelIdVectorizationSource.Serialization.cs index 740899e3c..5e19ad8de 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceModelIdVectorizationSource.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceModelIdVectorizationSource.Serialization.cs @@ -7,11 +7,16 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.AI.OpenAI; namespace Azure.AI.OpenAI.Chat { internal partial class InternalAzureChatDataSourceModelIdVectorizationSource : IJsonModel { + internal InternalAzureChatDataSourceModelIdVectorizationSource() + { + } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -19,74 +24,68 @@ void IJsonModel.Write(Utf writer.WriteEndObject(); } - /// The JSON writer. - /// The client options for reading and writing models. protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalAzureChatDataSourceModelIdVectorizationSource)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); - if (SerializedAdditionalRawData?.ContainsKey("model_id") != true) + if (_additionalBinaryDataProperties?.ContainsKey("model_id") != true) { writer.WritePropertyName("model_id"u8); writer.WriteStringValue(ModelId); } } - InternalAzureChatDataSourceModelIdVectorizationSource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalAzureChatDataSourceModelIdVectorizationSource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalAzureChatDataSourceModelIdVectorizationSource)JsonModelCreateCore(ref reader, options); + + protected override DataSourceVectorizer JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalAzureChatDataSourceModelIdVectorizationSource)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeInternalAzureChatDataSourceModelIdVectorizationSource(document.RootElement, options); } - internal static InternalAzureChatDataSourceModelIdVectorizationSource DeserializeInternalAzureChatDataSourceModelIdVectorizationSource(JsonElement element, ModelReaderWriterOptions options = null) + internal static InternalAzureChatDataSourceModelIdVectorizationSource DeserializeInternalAzureChatDataSourceModelIdVectorizationSource(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } + string @type = "model_id"; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); string modelId = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("model_id"u8)) + if (prop.NameEquals("type"u8)) { - modelId = property.Value.GetString(); + @type = prop.Value.GetString(); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("model_id"u8)) { - type = property.Value.GetString(); + modelId = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new InternalAzureChatDataSourceModelIdVectorizationSource(type, serializedAdditionalRawData, modelId); + return new InternalAzureChatDataSourceModelIdVectorizationSource(@type, additionalBinaryDataProperties, modelId); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -96,15 +95,16 @@ BinaryData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + InternalAzureChatDataSourceModelIdVectorizationSource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalAzureChatDataSourceModelIdVectorizationSource)PersistableModelCreateCore(data, options); + protected override DataSourceVectorizer PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeInternalAzureChatDataSourceModelIdVectorizationSource(document.RootElement, options); } default: @@ -114,18 +114,20 @@ InternalAzureChatDataSourceModelIdVectorizationSource IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static new InternalAzureChatDataSourceModelIdVectorizationSource FromResponse(PipelineResponse response) + public static implicit operator BinaryContent(InternalAzureChatDataSourceModelIdVectorizationSource internalAzureChatDataSourceModelIdVectorizationSource) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalAzureChatDataSourceModelIdVectorizationSource(document.RootElement); + if (internalAzureChatDataSourceModelIdVectorizationSource == null) + { + return null; + } + return BinaryContent.Create(internalAzureChatDataSourceModelIdVectorizationSource, ModelSerializationExtensions.WireOptions); } - /// Convert into a . - internal override BinaryContent ToBinaryContent() + public static explicit operator InternalAzureChatDataSourceModelIdVectorizationSource(ClientResult result) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalAzureChatDataSourceModelIdVectorizationSource(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceModelIdVectorizationSource.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceModelIdVectorizationSource.cs new file mode 100644 index 000000000..39674da9d --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceModelIdVectorizationSource.cs @@ -0,0 +1,27 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.OpenAI; + +namespace Azure.AI.OpenAI.Chat +{ + internal partial class InternalAzureChatDataSourceModelIdVectorizationSource : DataSourceVectorizer + { + public InternalAzureChatDataSourceModelIdVectorizationSource(string modelId) : base("model_id") + { + Argument.AssertNotNull(modelId, nameof(modelId)); + + ModelId = modelId; + } + + internal InternalAzureChatDataSourceModelIdVectorizationSource(string @type, IDictionary additionalBinaryDataProperties, string modelId) : base(@type, additionalBinaryDataProperties) + { + ModelId = modelId; + } + + public string ModelId { get; set; } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions.Serialization.cs similarity index 55% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions.Serialization.cs index 58c3fbc4f..4bb24ad42 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions.Serialization.cs @@ -7,6 +7,7 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.AI.OpenAI; namespace Azure.AI.OpenAI.Chat { @@ -19,63 +20,57 @@ void IJsonModel The JSON writer. - /// The client options for reading and writing models. protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); } - InternalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions)JsonModelCreateCore(ref reader, options); + + protected override DataSourceAuthentication JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeInternalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions(document.RootElement, options); } - internal static InternalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions DeserializeInternalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions(JsonElement element, ModelReaderWriterOptions options = null) + internal static InternalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions DeserializeInternalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + string @type = "system_assigned_managed_identity"; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("type"u8)) + if (prop.NameEquals("type"u8)) { - type = property.Value.GetString(); + @type = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new InternalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions(type, serializedAdditionalRawData); + return new InternalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions(@type, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -85,15 +80,16 @@ BinaryData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + InternalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions)PersistableModelCreateCore(data, options); + protected override DataSourceAuthentication PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeInternalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions(document.RootElement, options); } default: @@ -103,18 +99,20 @@ InternalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions IP string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static new InternalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions FromResponse(PipelineResponse response) + public static implicit operator BinaryContent(InternalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions internalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions(document.RootElement); + if (internalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions == null) + { + return null; + } + return BinaryContent.Create(internalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions, ModelSerializationExtensions.WireOptions); } - /// Convert into a . - internal override BinaryContent ToBinaryContent() + public static explicit operator InternalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions(ClientResult result) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions.cs new file mode 100644 index 000000000..2e6ddffbb --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions.cs @@ -0,0 +1,20 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Chat +{ + internal partial class InternalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions : DataSourceAuthentication + { + public InternalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions() : base("system_assigned_managed_identity") + { + } + + internal InternalAzureChatDataSourceSystemAssignedManagedIdentityAuthenticationOptions(string @type, IDictionary additionalBinaryDataProperties) : base(@type, additionalBinaryDataProperties) + { + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions.Serialization.cs similarity index 54% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions.Serialization.cs index 49a3ef963..d34ec6de6 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions.Serialization.cs @@ -7,11 +7,16 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.AI.OpenAI; namespace Azure.AI.OpenAI.Chat { internal partial class InternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions : IJsonModel { + internal InternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions() + { + } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -19,74 +24,68 @@ void IJsonModel The JSON writer. - /// The client options for reading and writing models. protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); - if (SerializedAdditionalRawData?.ContainsKey("managed_identity_resource_id") != true) + if (_additionalBinaryDataProperties?.ContainsKey("managed_identity_resource_id") != true) { writer.WritePropertyName("managed_identity_resource_id"u8); writer.WriteStringValue(ManagedIdentityResourceId); } } - InternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions)JsonModelCreateCore(ref reader, options); + + protected override DataSourceAuthentication JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeInternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions(document.RootElement, options); } - internal static InternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions DeserializeInternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions(JsonElement element, ModelReaderWriterOptions options = null) + internal static InternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions DeserializeInternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } + string @type = "user_assigned_managed_identity"; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); string managedIdentityResourceId = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("managed_identity_resource_id"u8)) + if (prop.NameEquals("type"u8)) { - managedIdentityResourceId = property.Value.GetString(); + @type = prop.Value.GetString(); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("managed_identity_resource_id"u8)) { - type = property.Value.GetString(); + managedIdentityResourceId = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new InternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions(type, serializedAdditionalRawData, managedIdentityResourceId); + return new InternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions(@type, additionalBinaryDataProperties, managedIdentityResourceId); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -96,15 +95,16 @@ BinaryData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + InternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions)PersistableModelCreateCore(data, options); + protected override DataSourceAuthentication PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeInternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions(document.RootElement, options); } default: @@ -114,18 +114,20 @@ InternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions IPer string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static new InternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions FromResponse(PipelineResponse response) + public static implicit operator BinaryContent(InternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions internalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions(document.RootElement); + if (internalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions == null) + { + return null; + } + return BinaryContent.Create(internalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions, ModelSerializationExtensions.WireOptions); } - /// Convert into a . - internal override BinaryContent ToBinaryContent() + public static explicit operator InternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions(ClientResult result) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions.cs new file mode 100644 index 000000000..5a652ca3c --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions.cs @@ -0,0 +1,27 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.OpenAI; + +namespace Azure.AI.OpenAI.Chat +{ + internal partial class InternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions : DataSourceAuthentication + { + public InternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions(string managedIdentityResourceId) : base("user_assigned_managed_identity") + { + Argument.AssertNotNull(managedIdentityResourceId, nameof(managedIdentityResourceId)); + + ManagedIdentityResourceId = managedIdentityResourceId; + } + + internal InternalAzureChatDataSourceUserAssignedManagedIdentityAuthenticationOptions(string @type, IDictionary additionalBinaryDataProperties, string managedIdentityResourceId) : base(@type, additionalBinaryDataProperties) + { + ManagedIdentityResourceId = managedIdentityResourceId; + } + + public string ManagedIdentityResourceId { get; set; } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions.Serialization.cs similarity index 55% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions.Serialization.cs index 8042b13b3..c9ceed3e6 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions.Serialization.cs @@ -7,11 +7,16 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.AI.OpenAI; namespace Azure.AI.OpenAI.Chat { internal partial class InternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions : IJsonModel { + internal InternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions() + { + } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -19,85 +24,79 @@ void IJsonModel The JSON writer. - /// The client options for reading and writing models. protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); - if (SerializedAdditionalRawData?.ContainsKey("username") != true) + if (_additionalBinaryDataProperties?.ContainsKey("username") != true) { writer.WritePropertyName("username"u8); writer.WriteStringValue(Username); } - if (SerializedAdditionalRawData?.ContainsKey("password") != true) + if (_additionalBinaryDataProperties?.ContainsKey("password") != true) { writer.WritePropertyName("password"u8); writer.WriteStringValue(Password); } } - InternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (InternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions)JsonModelCreateCore(ref reader, options); + + protected override DataSourceAuthentication JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeInternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions(document.RootElement, options); } - internal static InternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions DeserializeInternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions(JsonElement element, ModelReaderWriterOptions options = null) + internal static InternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions DeserializeInternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } + string @type = "username_and_password"; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); string username = default; string password = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("username"u8)) + if (prop.NameEquals("type"u8)) { - username = property.Value.GetString(); + @type = prop.Value.GetString(); continue; } - if (property.NameEquals("password"u8)) + if (prop.NameEquals("username"u8)) { - password = property.Value.GetString(); + username = prop.Value.GetString(); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("password"u8)) { - type = property.Value.GetString(); + password = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new InternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions(type, serializedAdditionalRawData, username, password); + return new InternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions(@type, additionalBinaryDataProperties, username, password); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -107,15 +106,16 @@ BinaryData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + InternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (InternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions)PersistableModelCreateCore(data, options); + protected override DataSourceAuthentication PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeInternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions(document.RootElement, options); } default: @@ -125,18 +125,20 @@ InternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions IPersistable string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static new InternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions FromResponse(PipelineResponse response) + public static implicit operator BinaryContent(InternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions internalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions(document.RootElement); + if (internalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions == null) + { + return null; + } + return BinaryContent.Create(internalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions, ModelSerializationExtensions.WireOptions); } - /// Convert into a . - internal override BinaryContent ToBinaryContent() + public static explicit operator InternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions(ClientResult result) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions.cs new file mode 100644 index 000000000..929edfffe --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions.cs @@ -0,0 +1,32 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.OpenAI; + +namespace Azure.AI.OpenAI.Chat +{ + internal partial class InternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions : DataSourceAuthentication + { + public InternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions(string username, string password) : base("username_and_password") + { + Argument.AssertNotNull(username, nameof(username)); + Argument.AssertNotNull(password, nameof(password)); + + Username = username; + Password = password; + } + + internal InternalAzureChatDataSourceUsernameAndPasswordAuthenticationOptions(string @type, IDictionary additionalBinaryDataProperties, string username, string password) : base(@type, additionalBinaryDataProperties) + { + Username = username; + Password = password; + } + + public string Username { get; set; } + + public string Password { get; set; } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterBlocklistIdResult.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureContentFilterBlocklistIdResult.Serialization.cs similarity index 56% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterBlocklistIdResult.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureContentFilterBlocklistIdResult.Serialization.cs index 62c1baf6d..d57188f99 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterBlocklistIdResult.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureContentFilterBlocklistIdResult.Serialization.cs @@ -12,6 +12,10 @@ namespace Azure.AI.OpenAI { internal partial class InternalAzureContentFilterBlocklistIdResult : IJsonModel { + internal InternalAzureContentFilterBlocklistIdResult() + { + } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -19,29 +23,26 @@ void IJsonModel.Write(Utf8JsonWrite writer.WriteEndObject(); } - /// The JSON writer. - /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalAzureContentFilterBlocklistIdResult)} does not support writing '{format}' format."); } - - if (SerializedAdditionalRawData?.ContainsKey("id") != true) + if (_additionalBinaryDataProperties?.ContainsKey("id") != true) { writer.WritePropertyName("id"u8); writer.WriteStringValue(Id); } - if (SerializedAdditionalRawData?.ContainsKey("filtered") != true) + if (_additionalBinaryDataProperties?.ContainsKey("filtered") != true) { writer.WritePropertyName("filtered"u8); writer.WriteBooleanValue(Filtered); } - if (SerializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in SerializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { @@ -49,7 +50,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else using (JsonDocument document = JsonDocument.Parse(item.Value)) { @@ -60,56 +61,53 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - InternalAzureContentFilterBlocklistIdResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalAzureContentFilterBlocklistIdResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + protected virtual InternalAzureContentFilterBlocklistIdResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalAzureContentFilterBlocklistIdResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeInternalAzureContentFilterBlocklistIdResult(document.RootElement, options); } - internal static InternalAzureContentFilterBlocklistIdResult DeserializeInternalAzureContentFilterBlocklistIdResult(JsonElement element, ModelReaderWriterOptions options = null) + internal static InternalAzureContentFilterBlocklistIdResult DeserializeInternalAzureContentFilterBlocklistIdResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } string id = default; bool filtered = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("id"u8)) + if (prop.NameEquals("id"u8)) { - id = property.Value.GetString(); + id = prop.Value.GetString(); continue; } - if (property.NameEquals("filtered"u8)) + if (prop.NameEquals("filtered"u8)) { - filtered = property.Value.GetBoolean(); + filtered = prop.Value.GetBoolean(); continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new InternalAzureContentFilterBlocklistIdResult(id, filtered, serializedAdditionalRawData); + return new InternalAzureContentFilterBlocklistIdResult(id, filtered, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -119,15 +117,16 @@ BinaryData IPersistableModel.Write( } } - InternalAzureContentFilterBlocklistIdResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + InternalAzureContentFilterBlocklistIdResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + protected virtual InternalAzureContentFilterBlocklistIdResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeInternalAzureContentFilterBlocklistIdResult(document.RootElement, options); } default: @@ -137,18 +136,20 @@ InternalAzureContentFilterBlocklistIdResult IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static InternalAzureContentFilterBlocklistIdResult FromResponse(PipelineResponse response) + public static implicit operator BinaryContent(InternalAzureContentFilterBlocklistIdResult internalAzureContentFilterBlocklistIdResult) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalAzureContentFilterBlocklistIdResult(document.RootElement); + if (internalAzureContentFilterBlocklistIdResult == null) + { + return null; + } + return BinaryContent.Create(internalAzureContentFilterBlocklistIdResult, ModelSerializationExtensions.WireOptions); } - /// Convert into a . - internal virtual BinaryContent ToBinaryContent() + public static explicit operator InternalAzureContentFilterBlocklistIdResult(ClientResult result) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalAzureContentFilterBlocklistIdResult(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureContentFilterBlocklistIdResult.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureContentFilterBlocklistIdResult.cs new file mode 100644 index 000000000..3003ef08a --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureContentFilterBlocklistIdResult.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI +{ + internal partial class InternalAzureContentFilterBlocklistIdResult + { + /// Keeps track of any properties unknown to the library. + private protected IDictionary _additionalBinaryDataProperties; + + internal InternalAzureContentFilterBlocklistIdResult(string id, bool filtered) + { + Id = id; + Filtered = filtered; + } + + internal InternalAzureContentFilterBlocklistIdResult(string id, bool filtered, IDictionary additionalBinaryDataProperties) + { + Id = id; + Filtered = filtered; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + public string Id { get; set; } + + public bool Filtered { get; set; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterBlocklistResultDetail.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureContentFilterBlocklistResultDetail.Serialization.cs similarity index 56% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterBlocklistResultDetail.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureContentFilterBlocklistResultDetail.Serialization.cs index 152fb6ead..21bd3141d 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterBlocklistResultDetail.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureContentFilterBlocklistResultDetail.Serialization.cs @@ -12,6 +12,10 @@ namespace Azure.AI.OpenAI { internal partial class InternalAzureContentFilterBlocklistResultDetail : IJsonModel { + internal InternalAzureContentFilterBlocklistResultDetail() + { + } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -19,29 +23,26 @@ void IJsonModel.Write(Utf8JsonW writer.WriteEndObject(); } - /// The JSON writer. - /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalAzureContentFilterBlocklistResultDetail)} does not support writing '{format}' format."); } - - if (SerializedAdditionalRawData?.ContainsKey("filtered") != true) + if (_additionalBinaryDataProperties?.ContainsKey("filtered") != true) { writer.WritePropertyName("filtered"u8); writer.WriteBooleanValue(Filtered); } - if (SerializedAdditionalRawData?.ContainsKey("id") != true) + if (_additionalBinaryDataProperties?.ContainsKey("id") != true) { writer.WritePropertyName("id"u8); writer.WriteStringValue(Id); } - if (SerializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in SerializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { @@ -49,7 +50,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else using (JsonDocument document = JsonDocument.Parse(item.Value)) { @@ -60,56 +61,53 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - InternalAzureContentFilterBlocklistResultDetail IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalAzureContentFilterBlocklistResultDetail IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + protected virtual InternalAzureContentFilterBlocklistResultDetail JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalAzureContentFilterBlocklistResultDetail)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeInternalAzureContentFilterBlocklistResultDetail(document.RootElement, options); } - internal static InternalAzureContentFilterBlocklistResultDetail DeserializeInternalAzureContentFilterBlocklistResultDetail(JsonElement element, ModelReaderWriterOptions options = null) + internal static InternalAzureContentFilterBlocklistResultDetail DeserializeInternalAzureContentFilterBlocklistResultDetail(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } bool filtered = default; string id = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("filtered"u8)) + if (prop.NameEquals("filtered"u8)) { - filtered = property.Value.GetBoolean(); + filtered = prop.Value.GetBoolean(); continue; } - if (property.NameEquals("id"u8)) + if (prop.NameEquals("id"u8)) { - id = property.Value.GetString(); + id = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new InternalAzureContentFilterBlocklistResultDetail(filtered, id, serializedAdditionalRawData); + return new InternalAzureContentFilterBlocklistResultDetail(filtered, id, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -119,15 +117,16 @@ BinaryData IPersistableModel.Wr } } - InternalAzureContentFilterBlocklistResultDetail IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + InternalAzureContentFilterBlocklistResultDetail IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + protected virtual InternalAzureContentFilterBlocklistResultDetail PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeInternalAzureContentFilterBlocklistResultDetail(document.RootElement, options); } default: @@ -137,18 +136,20 @@ InternalAzureContentFilterBlocklistResultDetail IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static InternalAzureContentFilterBlocklistResultDetail FromResponse(PipelineResponse response) + public static implicit operator BinaryContent(InternalAzureContentFilterBlocklistResultDetail internalAzureContentFilterBlocklistResultDetail) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalAzureContentFilterBlocklistResultDetail(document.RootElement); + if (internalAzureContentFilterBlocklistResultDetail == null) + { + return null; + } + return BinaryContent.Create(internalAzureContentFilterBlocklistResultDetail, ModelSerializationExtensions.WireOptions); } - /// Convert into a . - internal virtual BinaryContent ToBinaryContent() + public static explicit operator InternalAzureContentFilterBlocklistResultDetail(ClientResult result) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalAzureContentFilterBlocklistResultDetail(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureContentFilterBlocklistResultDetail.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureContentFilterBlocklistResultDetail.cs new file mode 100644 index 000000000..1964113da --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureContentFilterBlocklistResultDetail.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI +{ + internal partial class InternalAzureContentFilterBlocklistResultDetail + { + /// Keeps track of any properties unknown to the library. + private protected IDictionary _additionalBinaryDataProperties; + + internal InternalAzureContentFilterBlocklistResultDetail(bool filtered, string id) + { + Filtered = filtered; + Id = id; + } + + internal InternalAzureContentFilterBlocklistResultDetail(bool filtered, string id, IDictionary additionalBinaryDataProperties) + { + Filtered = filtered; + Id = id; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + public bool Filtered { get; set; } + + public string Id { get; set; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterResultForChoiceError.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureContentFilterResultForChoiceError.Serialization.cs similarity index 56% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterResultForChoiceError.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureContentFilterResultForChoiceError.Serialization.cs index 3577b2606..4abb04256 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterResultForChoiceError.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureContentFilterResultForChoiceError.Serialization.cs @@ -12,6 +12,10 @@ namespace Azure.AI.OpenAI { internal partial class InternalAzureContentFilterResultForChoiceError : IJsonModel { + internal InternalAzureContentFilterResultForChoiceError() + { + } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -19,29 +23,26 @@ void IJsonModel.Write(Utf8JsonWr writer.WriteEndObject(); } - /// The JSON writer. - /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalAzureContentFilterResultForChoiceError)} does not support writing '{format}' format."); } - - if (SerializedAdditionalRawData?.ContainsKey("code") != true) + if (_additionalBinaryDataProperties?.ContainsKey("code") != true) { writer.WritePropertyName("code"u8); writer.WriteNumberValue(Code); } - if (SerializedAdditionalRawData?.ContainsKey("message") != true) + if (_additionalBinaryDataProperties?.ContainsKey("message") != true) { writer.WritePropertyName("message"u8); writer.WriteStringValue(Message); } - if (SerializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in SerializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { @@ -49,7 +50,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else using (JsonDocument document = JsonDocument.Parse(item.Value)) { @@ -60,56 +61,53 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - InternalAzureContentFilterResultForChoiceError IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalAzureContentFilterResultForChoiceError IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + protected virtual InternalAzureContentFilterResultForChoiceError JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalAzureContentFilterResultForChoiceError)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeInternalAzureContentFilterResultForChoiceError(document.RootElement, options); } - internal static InternalAzureContentFilterResultForChoiceError DeserializeInternalAzureContentFilterResultForChoiceError(JsonElement element, ModelReaderWriterOptions options = null) + internal static InternalAzureContentFilterResultForChoiceError DeserializeInternalAzureContentFilterResultForChoiceError(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } int code = default; string message = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("code"u8)) + if (prop.NameEquals("code"u8)) { - code = property.Value.GetInt32(); + code = prop.Value.GetInt32(); continue; } - if (property.NameEquals("message"u8)) + if (prop.NameEquals("message"u8)) { - message = property.Value.GetString(); + message = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new InternalAzureContentFilterResultForChoiceError(code, message, serializedAdditionalRawData); + return new InternalAzureContentFilterResultForChoiceError(code, message, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -119,15 +117,16 @@ BinaryData IPersistableModel.Wri } } - InternalAzureContentFilterResultForChoiceError IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + InternalAzureContentFilterResultForChoiceError IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + protected virtual InternalAzureContentFilterResultForChoiceError PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeInternalAzureContentFilterResultForChoiceError(document.RootElement, options); } default: @@ -137,18 +136,20 @@ InternalAzureContentFilterResultForChoiceError IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static InternalAzureContentFilterResultForChoiceError FromResponse(PipelineResponse response) + public static implicit operator BinaryContent(InternalAzureContentFilterResultForChoiceError internalAzureContentFilterResultForChoiceError) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalAzureContentFilterResultForChoiceError(document.RootElement); + if (internalAzureContentFilterResultForChoiceError == null) + { + return null; + } + return BinaryContent.Create(internalAzureContentFilterResultForChoiceError, ModelSerializationExtensions.WireOptions); } - /// Convert into a . - internal virtual BinaryContent ToBinaryContent() + public static explicit operator InternalAzureContentFilterResultForChoiceError(ClientResult result) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalAzureContentFilterResultForChoiceError(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureContentFilterResultForChoiceError.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureContentFilterResultForChoiceError.cs new file mode 100644 index 000000000..39955abc6 --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureContentFilterResultForChoiceError.cs @@ -0,0 +1,38 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI +{ + internal partial class InternalAzureContentFilterResultForChoiceError + { + /// Keeps track of any properties unknown to the library. + private protected IDictionary _additionalBinaryDataProperties; + + internal InternalAzureContentFilterResultForChoiceError(int code, string message) + { + Code = code; + Message = message; + } + + internal InternalAzureContentFilterResultForChoiceError(int code, string message, IDictionary additionalBinaryDataProperties) + { + Code = code; + Message = message; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + public int Code { get; set; } + + public string Message { get; set; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterResultForPromptContentFilterResults.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureContentFilterResultForPromptContentFilterResults.Serialization.cs similarity index 60% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterResultForPromptContentFilterResults.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureContentFilterResultForPromptContentFilterResults.Serialization.cs index c1e393eac..2a95abe6d 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureContentFilterResultForPromptContentFilterResults.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureContentFilterResultForPromptContentFilterResults.Serialization.cs @@ -12,6 +12,10 @@ namespace Azure.AI.OpenAI { internal partial class InternalAzureContentFilterResultForPromptContentFilterResults : IJsonModel { + internal InternalAzureContentFilterResultForPromptContentFilterResults() + { + } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -19,64 +23,61 @@ void IJsonModel.W writer.WriteEndObject(); } - /// The JSON writer. - /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalAzureContentFilterResultForPromptContentFilterResults)} does not support writing '{format}' format."); } - - if (SerializedAdditionalRawData?.ContainsKey("sexual") != true && Optional.IsDefined(Sexual)) + if (Optional.IsDefined(Sexual) && _additionalBinaryDataProperties?.ContainsKey("sexual") != true) { writer.WritePropertyName("sexual"u8); writer.WriteObjectValue(Sexual, options); } - if (SerializedAdditionalRawData?.ContainsKey("hate") != true && Optional.IsDefined(Hate)) + if (Optional.IsDefined(Hate) && _additionalBinaryDataProperties?.ContainsKey("hate") != true) { writer.WritePropertyName("hate"u8); writer.WriteObjectValue(Hate, options); } - if (SerializedAdditionalRawData?.ContainsKey("violence") != true && Optional.IsDefined(Violence)) + if (Optional.IsDefined(Violence) && _additionalBinaryDataProperties?.ContainsKey("violence") != true) { writer.WritePropertyName("violence"u8); writer.WriteObjectValue(Violence, options); } - if (SerializedAdditionalRawData?.ContainsKey("self_harm") != true && Optional.IsDefined(SelfHarm)) + if (Optional.IsDefined(SelfHarm) && _additionalBinaryDataProperties?.ContainsKey("self_harm") != true) { writer.WritePropertyName("self_harm"u8); writer.WriteObjectValue(SelfHarm, options); } - if (SerializedAdditionalRawData?.ContainsKey("profanity") != true && Optional.IsDefined(Profanity)) + if (Optional.IsDefined(Profanity) && _additionalBinaryDataProperties?.ContainsKey("profanity") != true) { writer.WritePropertyName("profanity"u8); writer.WriteObjectValue(Profanity, options); } - if (SerializedAdditionalRawData?.ContainsKey("custom_blocklists") != true && Optional.IsDefined(CustomBlocklists)) + if (Optional.IsDefined(CustomBlocklists) && _additionalBinaryDataProperties?.ContainsKey("custom_blocklists") != true) { writer.WritePropertyName("custom_blocklists"u8); writer.WriteObjectValue(CustomBlocklists, options); } - if (SerializedAdditionalRawData?.ContainsKey("error") != true && Optional.IsDefined(Error)) + if (Optional.IsDefined(Error) && _additionalBinaryDataProperties?.ContainsKey("error") != true) { writer.WritePropertyName("error"u8); writer.WriteObjectValue(Error, options); } - if (SerializedAdditionalRawData?.ContainsKey("jailbreak") != true) + if (_additionalBinaryDataProperties?.ContainsKey("jailbreak") != true) { writer.WritePropertyName("jailbreak"u8); writer.WriteObjectValue(Jailbreak, options); } - if (SerializedAdditionalRawData?.ContainsKey("indirect_attack") != true) + if (_additionalBinaryDataProperties?.ContainsKey("indirect_attack") != true) { writer.WritePropertyName("indirect_attack"u8); writer.WriteObjectValue(IndirectAttack, options); } - if (SerializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in SerializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { @@ -84,7 +85,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else using (JsonDocument document = JsonDocument.Parse(item.Value)) { @@ -95,22 +96,21 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - InternalAzureContentFilterResultForPromptContentFilterResults IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalAzureContentFilterResultForPromptContentFilterResults IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + protected virtual InternalAzureContentFilterResultForPromptContentFilterResults JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalAzureContentFilterResultForPromptContentFilterResults)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeInternalAzureContentFilterResultForPromptContentFilterResults(document.RootElement, options); } - internal static InternalAzureContentFilterResultForPromptContentFilterResults DeserializeInternalAzureContentFilterResultForPromptContentFilterResults(JsonElement element, ModelReaderWriterOptions options = null) + internal static InternalAzureContentFilterResultForPromptContentFilterResults DeserializeInternalAzureContentFilterResultForPromptContentFilterResults(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -124,90 +124,87 @@ internal static InternalAzureContentFilterResultForPromptContentFilterResults De InternalAzureContentFilterResultForChoiceError error = default; ContentFilterDetectionResult jailbreak = default; ContentFilterDetectionResult indirectAttack = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("sexual"u8)) + if (prop.NameEquals("sexual"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - sexual = ContentFilterSeverityResult.DeserializeContentFilterSeverityResult(property.Value, options); + sexual = ContentFilterSeverityResult.DeserializeContentFilterSeverityResult(prop.Value, options); continue; } - if (property.NameEquals("hate"u8)) + if (prop.NameEquals("hate"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - hate = ContentFilterSeverityResult.DeserializeContentFilterSeverityResult(property.Value, options); + hate = ContentFilterSeverityResult.DeserializeContentFilterSeverityResult(prop.Value, options); continue; } - if (property.NameEquals("violence"u8)) + if (prop.NameEquals("violence"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - violence = ContentFilterSeverityResult.DeserializeContentFilterSeverityResult(property.Value, options); + violence = ContentFilterSeverityResult.DeserializeContentFilterSeverityResult(prop.Value, options); continue; } - if (property.NameEquals("self_harm"u8)) + if (prop.NameEquals("self_harm"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - selfHarm = ContentFilterSeverityResult.DeserializeContentFilterSeverityResult(property.Value, options); + selfHarm = ContentFilterSeverityResult.DeserializeContentFilterSeverityResult(prop.Value, options); continue; } - if (property.NameEquals("profanity"u8)) + if (prop.NameEquals("profanity"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - profanity = ContentFilterDetectionResult.DeserializeContentFilterDetectionResult(property.Value, options); + profanity = ContentFilterDetectionResult.DeserializeContentFilterDetectionResult(prop.Value, options); continue; } - if (property.NameEquals("custom_blocklists"u8)) + if (prop.NameEquals("custom_blocklists"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - customBlocklists = ContentFilterBlocklistResult.DeserializeContentFilterBlocklistResult(property.Value, options); + customBlocklists = ContentFilterBlocklistResult.DeserializeContentFilterBlocklistResult(prop.Value, options); continue; } - if (property.NameEquals("error"u8)) + if (prop.NameEquals("error"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - error = InternalAzureContentFilterResultForChoiceError.DeserializeInternalAzureContentFilterResultForChoiceError(property.Value, options); + error = InternalAzureContentFilterResultForChoiceError.DeserializeInternalAzureContentFilterResultForChoiceError(prop.Value, options); continue; } - if (property.NameEquals("jailbreak"u8)) + if (prop.NameEquals("jailbreak"u8)) { - jailbreak = ContentFilterDetectionResult.DeserializeContentFilterDetectionResult(property.Value, options); + jailbreak = ContentFilterDetectionResult.DeserializeContentFilterDetectionResult(prop.Value, options); continue; } - if (property.NameEquals("indirect_attack"u8)) + if (prop.NameEquals("indirect_attack"u8)) { - indirectAttack = ContentFilterDetectionResult.DeserializeContentFilterDetectionResult(property.Value, options); + indirectAttack = ContentFilterDetectionResult.DeserializeContentFilterDetectionResult(prop.Value, options); continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new InternalAzureContentFilterResultForPromptContentFilterResults( sexual, hate, @@ -218,13 +215,14 @@ internal static InternalAzureContentFilterResultForPromptContentFilterResults De error, jailbreak, indirectAttack, - serializedAdditionalRawData); + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -234,15 +232,16 @@ BinaryData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + InternalAzureContentFilterResultForPromptContentFilterResults IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + protected virtual InternalAzureContentFilterResultForPromptContentFilterResults PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeInternalAzureContentFilterResultForPromptContentFilterResults(document.RootElement, options); } default: @@ -252,18 +251,20 @@ InternalAzureContentFilterResultForPromptContentFilterResults IPersistableModel< string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static InternalAzureContentFilterResultForPromptContentFilterResults FromResponse(PipelineResponse response) + public static implicit operator BinaryContent(InternalAzureContentFilterResultForPromptContentFilterResults internalAzureContentFilterResultForPromptContentFilterResults) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalAzureContentFilterResultForPromptContentFilterResults(document.RootElement); + if (internalAzureContentFilterResultForPromptContentFilterResults == null) + { + return null; + } + return BinaryContent.Create(internalAzureContentFilterResultForPromptContentFilterResults, ModelSerializationExtensions.WireOptions); } - /// Convert into a . - internal virtual BinaryContent ToBinaryContent() + public static explicit operator InternalAzureContentFilterResultForPromptContentFilterResults(ClientResult result) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalAzureContentFilterResultForPromptContentFilterResults(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureContentFilterResultForPromptContentFilterResults.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureContentFilterResultForPromptContentFilterResults.cs new file mode 100644 index 000000000..d3f839aac --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureContentFilterResultForPromptContentFilterResults.cs @@ -0,0 +1,59 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI +{ + internal partial class InternalAzureContentFilterResultForPromptContentFilterResults + { + /// Keeps track of any properties unknown to the library. + private protected IDictionary _additionalBinaryDataProperties; + + internal InternalAzureContentFilterResultForPromptContentFilterResults(ContentFilterDetectionResult jailbreak, ContentFilterDetectionResult indirectAttack) + { + Jailbreak = jailbreak; + IndirectAttack = indirectAttack; + } + + internal InternalAzureContentFilterResultForPromptContentFilterResults(ContentFilterSeverityResult sexual, ContentFilterSeverityResult hate, ContentFilterSeverityResult violence, ContentFilterSeverityResult selfHarm, ContentFilterDetectionResult profanity, ContentFilterBlocklistResult customBlocklists, InternalAzureContentFilterResultForChoiceError error, ContentFilterDetectionResult jailbreak, ContentFilterDetectionResult indirectAttack, IDictionary additionalBinaryDataProperties) + { + Sexual = sexual; + Hate = hate; + Violence = violence; + SelfHarm = selfHarm; + Profanity = profanity; + CustomBlocklists = customBlocklists; + Error = error; + Jailbreak = jailbreak; + IndirectAttack = indirectAttack; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + public ContentFilterSeverityResult Sexual { get; set; } + + public ContentFilterSeverityResult Hate { get; set; } + + public ContentFilterSeverityResult Violence { get; set; } + + public ContentFilterSeverityResult SelfHarm { get; set; } + + public ContentFilterDetectionResult Profanity { get; set; } + + public ContentFilterBlocklistResult CustomBlocklists { get; set; } + + public InternalAzureContentFilterResultForChoiceError Error { get; set; } + + public ContentFilterDetectionResult Jailbreak { get; set; } + + public ContentFilterDetectionResult IndirectAttack { get; set; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureCosmosDBChatDataSourceParameters.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureCosmosDBChatDataSourceParameters.Serialization.cs similarity index 52% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureCosmosDBChatDataSourceParameters.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureCosmosDBChatDataSourceParameters.Serialization.cs index 9cf6d954e..b9bf23cd2 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureCosmosDBChatDataSourceParameters.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureCosmosDBChatDataSourceParameters.Serialization.cs @@ -7,11 +7,16 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.AI.OpenAI; namespace Azure.AI.OpenAI.Chat { internal partial class InternalAzureCosmosDBChatDataSourceParameters : IJsonModel { + internal InternalAzureCosmosDBChatDataSourceParameters() + { + } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -19,84 +24,86 @@ void IJsonModel.Write(Utf8JsonWri writer.WriteEndObject(); } - /// The JSON writer. - /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalAzureCosmosDBChatDataSourceParameters)} does not support writing '{format}' format."); } - - if (SerializedAdditionalRawData?.ContainsKey("top_n_documents") != true && Optional.IsDefined(TopNDocuments)) + if (Optional.IsDefined(TopNDocuments) && _additionalBinaryDataProperties?.ContainsKey("top_n_documents") != true) { writer.WritePropertyName("top_n_documents"u8); writer.WriteNumberValue(TopNDocuments.Value); } - if (SerializedAdditionalRawData?.ContainsKey("in_scope") != true && Optional.IsDefined(InScope)) + if (Optional.IsDefined(InScope) && _additionalBinaryDataProperties?.ContainsKey("in_scope") != true) { writer.WritePropertyName("in_scope"u8); writer.WriteBooleanValue(InScope.Value); } - if (SerializedAdditionalRawData?.ContainsKey("strictness") != true && Optional.IsDefined(Strictness)) + if (Optional.IsDefined(Strictness) && _additionalBinaryDataProperties?.ContainsKey("strictness") != true) { writer.WritePropertyName("strictness"u8); writer.WriteNumberValue(Strictness.Value); } - if (SerializedAdditionalRawData?.ContainsKey("max_search_queries") != true && Optional.IsDefined(MaxSearchQueries)) + if (Optional.IsDefined(MaxSearchQueries) && _additionalBinaryDataProperties?.ContainsKey("max_search_queries") != true) { writer.WritePropertyName("max_search_queries"u8); writer.WriteNumberValue(MaxSearchQueries.Value); } - if (SerializedAdditionalRawData?.ContainsKey("allow_partial_result") != true && Optional.IsDefined(AllowPartialResult)) + if (Optional.IsDefined(AllowPartialResult) && _additionalBinaryDataProperties?.ContainsKey("allow_partial_result") != true) { writer.WritePropertyName("allow_partial_result"u8); writer.WriteBooleanValue(AllowPartialResult.Value); } - if (SerializedAdditionalRawData?.ContainsKey("include_contexts") != true && Optional.IsCollectionDefined(_internalIncludeContexts)) - { - writer.WritePropertyName("include_contexts"u8); - writer.WriteStartArray(); - foreach (var item in _internalIncludeContexts) - { - writer.WriteStringValue(item); - } - writer.WriteEndArray(); - } - if (SerializedAdditionalRawData?.ContainsKey("container_name") != true) + if (_additionalBinaryDataProperties?.ContainsKey("container_name") != true) { writer.WritePropertyName("container_name"u8); writer.WriteStringValue(ContainerName); } - if (SerializedAdditionalRawData?.ContainsKey("database_name") != true) + if (_additionalBinaryDataProperties?.ContainsKey("database_name") != true) { writer.WritePropertyName("database_name"u8); writer.WriteStringValue(DatabaseName); } - if (SerializedAdditionalRawData?.ContainsKey("embedding_dependency") != true) - { - writer.WritePropertyName("embedding_dependency"u8); - writer.WriteObjectValue(VectorizationSource, options); - } - if (SerializedAdditionalRawData?.ContainsKey("index_name") != true) + if (_additionalBinaryDataProperties?.ContainsKey("index_name") != true) { writer.WritePropertyName("index_name"u8); writer.WriteStringValue(IndexName); } - if (SerializedAdditionalRawData?.ContainsKey("authentication") != true) + if (_additionalBinaryDataProperties?.ContainsKey("authentication") != true) { writer.WritePropertyName("authentication"u8); writer.WriteObjectValue(Authentication, options); } - if (SerializedAdditionalRawData?.ContainsKey("fields_mapping") != true) + if (_additionalBinaryDataProperties?.ContainsKey("fields_mapping") != true) { writer.WritePropertyName("fields_mapping"u8); writer.WriteObjectValue(FieldMappings, options); } - if (SerializedAdditionalRawData != null) + if (_additionalBinaryDataProperties?.ContainsKey("embedding_dependency") != true) { - foreach (var item in SerializedAdditionalRawData) + writer.WritePropertyName("embedding_dependency"u8); + writer.WriteObjectValue(VectorizationSource, options); + } + if (Optional.IsCollectionDefined(_internalIncludeContexts) && _additionalBinaryDataProperties?.ContainsKey("include_contexts") != true) + { + writer.WritePropertyName("include_contexts"u8); + writer.WriteStartArray(); + foreach (string item in _internalIncludeContexts) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) { if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { @@ -104,7 +111,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else using (JsonDocument document = JsonDocument.Parse(item.Value)) { @@ -115,22 +122,21 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - InternalAzureCosmosDBChatDataSourceParameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalAzureCosmosDBChatDataSourceParameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + protected virtual InternalAzureCosmosDBChatDataSourceParameters JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalAzureCosmosDBChatDataSourceParameters)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeInternalAzureCosmosDBChatDataSourceParameters(document.RootElement, options); } - internal static InternalAzureCosmosDBChatDataSourceParameters DeserializeInternalAzureCosmosDBChatDataSourceParameters(JsonElement element, ModelReaderWriterOptions options = null) + internal static InternalAzureCosmosDBChatDataSourceParameters DeserializeInternalAzureCosmosDBChatDataSourceParameters(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -140,133 +146,138 @@ internal static InternalAzureCosmosDBChatDataSourceParameters DeserializeInterna int? strictness = default; int? maxSearchQueries = default; bool? allowPartialResult = default; - IList includeContexts = default; string containerName = default; string databaseName = default; - DataSourceVectorizer embeddingDependency = default; string indexName = default; DataSourceAuthentication authentication = default; - DataSourceFieldMappings fieldsMapping = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + DataSourceFieldMappings fieldMappings = default; + DataSourceVectorizer vectorizationSource = default; + IList internalIncludeContexts = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("top_n_documents"u8)) + if (prop.NameEquals("top_n_documents"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - topNDocuments = property.Value.GetInt32(); + topNDocuments = prop.Value.GetInt32(); continue; } - if (property.NameEquals("in_scope"u8)) + if (prop.NameEquals("in_scope"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - inScope = property.Value.GetBoolean(); + inScope = prop.Value.GetBoolean(); continue; } - if (property.NameEquals("strictness"u8)) + if (prop.NameEquals("strictness"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - strictness = property.Value.GetInt32(); + strictness = prop.Value.GetInt32(); continue; } - if (property.NameEquals("max_search_queries"u8)) + if (prop.NameEquals("max_search_queries"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - maxSearchQueries = property.Value.GetInt32(); + maxSearchQueries = prop.Value.GetInt32(); continue; } - if (property.NameEquals("allow_partial_result"u8)) + if (prop.NameEquals("allow_partial_result"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - allowPartialResult = property.Value.GetBoolean(); + allowPartialResult = prop.Value.GetBoolean(); continue; } - if (property.NameEquals("include_contexts"u8)) + if (prop.NameEquals("container_name"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - includeContexts = array; + containerName = prop.Value.GetString(); continue; } - if (property.NameEquals("container_name"u8)) + if (prop.NameEquals("database_name"u8)) { - containerName = property.Value.GetString(); + databaseName = prop.Value.GetString(); continue; } - if (property.NameEquals("database_name"u8)) + if (prop.NameEquals("index_name"u8)) { - databaseName = property.Value.GetString(); + indexName = prop.Value.GetString(); continue; } - if (property.NameEquals("embedding_dependency"u8)) + if (prop.NameEquals("authentication"u8)) { - embeddingDependency = DataSourceVectorizer.DeserializeDataSourceVectorizer(property.Value, options); + authentication = DataSourceAuthentication.DeserializeDataSourceAuthentication(prop.Value, options); continue; } - if (property.NameEquals("index_name"u8)) + if (prop.NameEquals("fields_mapping"u8)) { - indexName = property.Value.GetString(); + fieldMappings = DataSourceFieldMappings.DeserializeDataSourceFieldMappings(prop.Value, options); continue; } - if (property.NameEquals("authentication"u8)) + if (prop.NameEquals("embedding_dependency"u8)) { - authentication = DataSourceAuthentication.DeserializeDataSourceAuthentication(property.Value, options); + vectorizationSource = DataSourceVectorizer.DeserializeDataSourceVectorizer(prop.Value, options); continue; } - if (property.NameEquals("fields_mapping"u8)) + if (prop.NameEquals("include_contexts"u8)) { - fieldsMapping = DataSourceFieldMappings.DeserializeDataSourceFieldMappings(property.Value, options); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + internalIncludeContexts = array; continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new InternalAzureCosmosDBChatDataSourceParameters( topNDocuments, inScope, strictness, maxSearchQueries, allowPartialResult, - includeContexts ?? new ChangeTrackingList(), containerName, databaseName, - embeddingDependency, indexName, authentication, - fieldsMapping, - serializedAdditionalRawData); + fieldMappings, + vectorizationSource, + internalIncludeContexts, + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -276,15 +287,16 @@ BinaryData IPersistableModel.Writ } } - InternalAzureCosmosDBChatDataSourceParameters IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + InternalAzureCosmosDBChatDataSourceParameters IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + protected virtual InternalAzureCosmosDBChatDataSourceParameters PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeInternalAzureCosmosDBChatDataSourceParameters(document.RootElement, options); } default: @@ -294,18 +306,20 @@ InternalAzureCosmosDBChatDataSourceParameters IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static InternalAzureCosmosDBChatDataSourceParameters FromResponse(PipelineResponse response) + public static implicit operator BinaryContent(InternalAzureCosmosDBChatDataSourceParameters internalAzureCosmosDBChatDataSourceParameters) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalAzureCosmosDBChatDataSourceParameters(document.RootElement); + if (internalAzureCosmosDBChatDataSourceParameters == null) + { + return null; + } + return BinaryContent.Create(internalAzureCosmosDBChatDataSourceParameters, ModelSerializationExtensions.WireOptions); } - /// Convert into a . - internal virtual BinaryContent ToBinaryContent() + public static explicit operator InternalAzureCosmosDBChatDataSourceParameters(ClientResult result) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalAzureCosmosDBChatDataSourceParameters(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureCosmosDBChatDataSourceParameters.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureCosmosDBChatDataSourceParameters.cs new file mode 100644 index 000000000..40fe9015b --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureCosmosDBChatDataSourceParameters.cs @@ -0,0 +1,73 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.OpenAI; + +namespace Azure.AI.OpenAI.Chat +{ + internal partial class InternalAzureCosmosDBChatDataSourceParameters + { + /// Keeps track of any properties unknown to the library. + private protected IDictionary _additionalBinaryDataProperties; + + public InternalAzureCosmosDBChatDataSourceParameters(string containerName, string databaseName, string indexName, DataSourceAuthentication authentication, DataSourceFieldMappings fieldMappings, DataSourceVectorizer vectorizationSource) + { + Argument.AssertNotNull(containerName, nameof(containerName)); + Argument.AssertNotNull(databaseName, nameof(databaseName)); + Argument.AssertNotNull(indexName, nameof(indexName)); + Argument.AssertNotNull(authentication, nameof(authentication)); + Argument.AssertNotNull(fieldMappings, nameof(fieldMappings)); + Argument.AssertNotNull(vectorizationSource, nameof(vectorizationSource)); + + ContainerName = containerName; + DatabaseName = databaseName; + IndexName = indexName; + Authentication = authentication; + FieldMappings = fieldMappings; + VectorizationSource = vectorizationSource; + _internalIncludeContexts = new ChangeTrackingList(); + } + + internal InternalAzureCosmosDBChatDataSourceParameters(int? topNDocuments, bool? inScope, int? strictness, int? maxSearchQueries, bool? allowPartialResult, string containerName, string databaseName, string indexName, DataSourceAuthentication authentication, DataSourceFieldMappings fieldMappings, DataSourceVectorizer vectorizationSource, IList internalIncludeContexts, IDictionary additionalBinaryDataProperties) + { + TopNDocuments = topNDocuments; + InScope = inScope; + Strictness = strictness; + MaxSearchQueries = maxSearchQueries; + AllowPartialResult = allowPartialResult; + ContainerName = containerName; + DatabaseName = databaseName; + IndexName = indexName; + Authentication = authentication; + FieldMappings = fieldMappings; + VectorizationSource = vectorizationSource; + _internalIncludeContexts = internalIncludeContexts; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + public int? TopNDocuments { get; set; } + + public bool? InScope { get; set; } + + public int? Strictness { get; set; } + + public int? MaxSearchQueries { get; set; } + + public bool? AllowPartialResult { get; set; } + + public string ContainerName { get; set; } + + public string DatabaseName { get; set; } + + public string IndexName { get; set; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureOpenAIChatErrorInnerError.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureOpenAIChatErrorInnerError.Serialization.cs similarity index 57% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureOpenAIChatErrorInnerError.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureOpenAIChatErrorInnerError.Serialization.cs index 8ccab130f..b52b4bf0d 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureOpenAIChatErrorInnerError.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureOpenAIChatErrorInnerError.Serialization.cs @@ -19,34 +19,31 @@ void IJsonModel.Write(Utf8JsonWriter wri writer.WriteEndObject(); } - /// The JSON writer. - /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalAzureOpenAIChatErrorInnerError)} does not support writing '{format}' format."); } - - if (SerializedAdditionalRawData?.ContainsKey("code") != true && Optional.IsDefined(Code)) + if (Optional.IsDefined(Code) && _additionalBinaryDataProperties?.ContainsKey("code") != true) { writer.WritePropertyName("code"u8); writer.WriteStringValue(Code.Value.ToString()); } - if (SerializedAdditionalRawData?.ContainsKey("revised_prompt") != true && Optional.IsDefined(RevisedPrompt)) + if (Optional.IsDefined(RevisedPrompt) && _additionalBinaryDataProperties?.ContainsKey("revised_prompt") != true) { writer.WritePropertyName("revised_prompt"u8); writer.WriteStringValue(RevisedPrompt); } - if (SerializedAdditionalRawData?.ContainsKey("content_filter_results") != true && Optional.IsDefined(ContentFilterResults)) + if (Optional.IsDefined(ContentFilterResults) && _additionalBinaryDataProperties?.ContainsKey("content_filter_results") != true) { writer.WritePropertyName("content_filter_results"u8); writer.WriteObjectValue(ContentFilterResults, options); } - if (SerializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in SerializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { @@ -54,7 +51,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else using (JsonDocument document = JsonDocument.Parse(item.Value)) { @@ -65,22 +62,21 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - InternalAzureOpenAIChatErrorInnerError IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalAzureOpenAIChatErrorInnerError IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + protected virtual InternalAzureOpenAIChatErrorInnerError JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalAzureOpenAIChatErrorInnerError)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeInternalAzureOpenAIChatErrorInnerError(document.RootElement, options); } - internal static InternalAzureOpenAIChatErrorInnerError DeserializeInternalAzureOpenAIChatErrorInnerError(JsonElement element, ModelReaderWriterOptions options = null) + internal static InternalAzureOpenAIChatErrorInnerError DeserializeInternalAzureOpenAIChatErrorInnerError(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -88,47 +84,45 @@ internal static InternalAzureOpenAIChatErrorInnerError DeserializeInternalAzureO InternalAzureOpenAIChatErrorInnerErrorCode? code = default; string revisedPrompt = default; RequestContentFilterResult contentFilterResults = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("code"u8)) + if (prop.NameEquals("code"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - code = new InternalAzureOpenAIChatErrorInnerErrorCode(property.Value.GetString()); + code = new InternalAzureOpenAIChatErrorInnerErrorCode(prop.Value.GetString()); continue; } - if (property.NameEquals("revised_prompt"u8)) + if (prop.NameEquals("revised_prompt"u8)) { - revisedPrompt = property.Value.GetString(); + revisedPrompt = prop.Value.GetString(); continue; } - if (property.NameEquals("content_filter_results"u8)) + if (prop.NameEquals("content_filter_results"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - contentFilterResults = RequestContentFilterResult.DeserializeRequestContentFilterResult(property.Value, options); + contentFilterResults = RequestContentFilterResult.DeserializeRequestContentFilterResult(prop.Value, options); continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new InternalAzureOpenAIChatErrorInnerError(code, revisedPrompt, contentFilterResults, serializedAdditionalRawData); + return new InternalAzureOpenAIChatErrorInnerError(code, revisedPrompt, contentFilterResults, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -138,15 +132,16 @@ BinaryData IPersistableModel.Write(Model } } - InternalAzureOpenAIChatErrorInnerError IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + InternalAzureOpenAIChatErrorInnerError IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + protected virtual InternalAzureOpenAIChatErrorInnerError PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeInternalAzureOpenAIChatErrorInnerError(document.RootElement, options); } default: @@ -156,18 +151,20 @@ InternalAzureOpenAIChatErrorInnerError IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static InternalAzureOpenAIChatErrorInnerError FromResponse(PipelineResponse response) + public static implicit operator BinaryContent(InternalAzureOpenAIChatErrorInnerError internalAzureOpenAIChatErrorInnerError) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalAzureOpenAIChatErrorInnerError(document.RootElement); + if (internalAzureOpenAIChatErrorInnerError == null) + { + return null; + } + return BinaryContent.Create(internalAzureOpenAIChatErrorInnerError, ModelSerializationExtensions.WireOptions); } - /// Convert into a . - internal virtual BinaryContent ToBinaryContent() + public static explicit operator InternalAzureOpenAIChatErrorInnerError(ClientResult result) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalAzureOpenAIChatErrorInnerError(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureOpenAIChatErrorInnerError.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureOpenAIChatErrorInnerError.cs new file mode 100644 index 000000000..221e6fef0 --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureOpenAIChatErrorInnerError.cs @@ -0,0 +1,39 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI +{ + internal partial class InternalAzureOpenAIChatErrorInnerError + { + /// Keeps track of any properties unknown to the library. + private protected IDictionary _additionalBinaryDataProperties; + + internal InternalAzureOpenAIChatErrorInnerError() + { + } + + internal InternalAzureOpenAIChatErrorInnerError(InternalAzureOpenAIChatErrorInnerErrorCode? code, string revisedPrompt, RequestContentFilterResult contentFilterResults, IDictionary additionalBinaryDataProperties) + { + Code = code; + RevisedPrompt = revisedPrompt; + ContentFilterResults = contentFilterResults; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + public InternalAzureOpenAIChatErrorInnerErrorCode? Code { get; set; } + + public string RevisedPrompt { get; set; } + + public RequestContentFilterResult ContentFilterResults { get; set; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureOpenAIChatErrorInnerErrorCode.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureOpenAIChatErrorInnerErrorCode.cs similarity index 60% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureOpenAIChatErrorInnerErrorCode.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureOpenAIChatErrorInnerErrorCode.cs index 84c3cb975..1f02d1c42 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureOpenAIChatErrorInnerErrorCode.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureOpenAIChatErrorInnerErrorCode.cs @@ -7,39 +7,37 @@ namespace Azure.AI.OpenAI { - /// The AzureOpenAIChatErrorInnerError_code. internal readonly partial struct InternalAzureOpenAIChatErrorInnerErrorCode : IEquatable { private readonly string _value; + /// ResponsibleAIPolicyViolation. + private const string ResponsibleAIPolicyViolationValue = "ResponsibleAIPolicyViolation"; - /// Initializes a new instance of . - /// is null. public InternalAzureOpenAIChatErrorInnerErrorCode(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); + Argument.AssertNotNull(value, nameof(value)); + + _value = value; } - private const string ResponsibleAIPolicyViolationValue = "ResponsibleAIPolicyViolation"; + public static InternalAzureOpenAIChatErrorInnerErrorCode ResponsibleAIPolicyViolation { get; set; } = new InternalAzureOpenAIChatErrorInnerErrorCode(ResponsibleAIPolicyViolationValue); - /// ResponsibleAIPolicyViolation. - internal static InternalAzureOpenAIChatErrorInnerErrorCode ResponsibleAIPolicyViolation { get; set; } = new InternalAzureOpenAIChatErrorInnerErrorCode(ResponsibleAIPolicyViolationValue); - /// Determines if two values are the same. public static bool operator ==(InternalAzureOpenAIChatErrorInnerErrorCode left, InternalAzureOpenAIChatErrorInnerErrorCode right) => left.Equals(right); - /// Determines if two values are not the same. + public static bool operator !=(InternalAzureOpenAIChatErrorInnerErrorCode left, InternalAzureOpenAIChatErrorInnerErrorCode right) => !left.Equals(right); - /// Converts a to a . + public static implicit operator InternalAzureOpenAIChatErrorInnerErrorCode(string value) => new InternalAzureOpenAIChatErrorInnerErrorCode(value); - /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is InternalAzureOpenAIChatErrorInnerErrorCode other && Equals(other); - /// + public bool Equals(InternalAzureOpenAIChatErrorInnerErrorCode other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - /// + /// [EditorBrowsable(EditorBrowsableState.Never)] public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - /// + + /// public override string ToString() => _value; } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureOpenAIDalleErrorInnerError.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureOpenAIDalleErrorInnerError.Serialization.cs similarity index 57% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureOpenAIDalleErrorInnerError.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureOpenAIDalleErrorInnerError.Serialization.cs index ee1d0be7f..38bf4ea6c 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureOpenAIDalleErrorInnerError.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureOpenAIDalleErrorInnerError.Serialization.cs @@ -19,34 +19,31 @@ void IJsonModel.Write(Utf8JsonWriter wr writer.WriteEndObject(); } - /// The JSON writer. - /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalAzureOpenAIDalleErrorInnerError)} does not support writing '{format}' format."); } - - if (SerializedAdditionalRawData?.ContainsKey("code") != true && Optional.IsDefined(Code)) + if (Optional.IsDefined(Code) && _additionalBinaryDataProperties?.ContainsKey("code") != true) { writer.WritePropertyName("code"u8); writer.WriteStringValue(Code.Value.ToString()); } - if (SerializedAdditionalRawData?.ContainsKey("revised_prompt") != true && Optional.IsDefined(RevisedPrompt)) + if (Optional.IsDefined(RevisedPrompt) && _additionalBinaryDataProperties?.ContainsKey("revised_prompt") != true) { writer.WritePropertyName("revised_prompt"u8); writer.WriteStringValue(RevisedPrompt); } - if (SerializedAdditionalRawData?.ContainsKey("content_filter_results") != true && Optional.IsDefined(ContentFilterResults)) + if (Optional.IsDefined(ContentFilterResults) && _additionalBinaryDataProperties?.ContainsKey("content_filter_results") != true) { writer.WritePropertyName("content_filter_results"u8); writer.WriteObjectValue(ContentFilterResults, options); } - if (SerializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in SerializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { @@ -54,7 +51,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else using (JsonDocument document = JsonDocument.Parse(item.Value)) { @@ -65,22 +62,21 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - InternalAzureOpenAIDalleErrorInnerError IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalAzureOpenAIDalleErrorInnerError IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + protected virtual InternalAzureOpenAIDalleErrorInnerError JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalAzureOpenAIDalleErrorInnerError)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeInternalAzureOpenAIDalleErrorInnerError(document.RootElement, options); } - internal static InternalAzureOpenAIDalleErrorInnerError DeserializeInternalAzureOpenAIDalleErrorInnerError(JsonElement element, ModelReaderWriterOptions options = null) + internal static InternalAzureOpenAIDalleErrorInnerError DeserializeInternalAzureOpenAIDalleErrorInnerError(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -88,47 +84,45 @@ internal static InternalAzureOpenAIDalleErrorInnerError DeserializeInternalAzure InternalAzureOpenAIDalleErrorInnerErrorCode? code = default; string revisedPrompt = default; RequestImageContentFilterResult contentFilterResults = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("code"u8)) + if (prop.NameEquals("code"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - code = new InternalAzureOpenAIDalleErrorInnerErrorCode(property.Value.GetString()); + code = new InternalAzureOpenAIDalleErrorInnerErrorCode(prop.Value.GetString()); continue; } - if (property.NameEquals("revised_prompt"u8)) + if (prop.NameEquals("revised_prompt"u8)) { - revisedPrompt = property.Value.GetString(); + revisedPrompt = prop.Value.GetString(); continue; } - if (property.NameEquals("content_filter_results"u8)) + if (prop.NameEquals("content_filter_results"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - contentFilterResults = RequestImageContentFilterResult.DeserializeRequestImageContentFilterResult(property.Value, options); + contentFilterResults = RequestImageContentFilterResult.DeserializeRequestImageContentFilterResult(prop.Value, options); continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new InternalAzureOpenAIDalleErrorInnerError(code, revisedPrompt, contentFilterResults, serializedAdditionalRawData); + return new InternalAzureOpenAIDalleErrorInnerError(code, revisedPrompt, contentFilterResults, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -138,15 +132,16 @@ BinaryData IPersistableModel.Write(Mode } } - InternalAzureOpenAIDalleErrorInnerError IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + InternalAzureOpenAIDalleErrorInnerError IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + protected virtual InternalAzureOpenAIDalleErrorInnerError PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeInternalAzureOpenAIDalleErrorInnerError(document.RootElement, options); } default: @@ -156,18 +151,20 @@ InternalAzureOpenAIDalleErrorInnerError IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static InternalAzureOpenAIDalleErrorInnerError FromResponse(PipelineResponse response) + public static implicit operator BinaryContent(InternalAzureOpenAIDalleErrorInnerError internalAzureOpenAIDalleErrorInnerError) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalAzureOpenAIDalleErrorInnerError(document.RootElement); + if (internalAzureOpenAIDalleErrorInnerError == null) + { + return null; + } + return BinaryContent.Create(internalAzureOpenAIDalleErrorInnerError, ModelSerializationExtensions.WireOptions); } - /// Convert into a . - internal virtual BinaryContent ToBinaryContent() + public static explicit operator InternalAzureOpenAIDalleErrorInnerError(ClientResult result) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalAzureOpenAIDalleErrorInnerError(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureOpenAIDalleErrorInnerError.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureOpenAIDalleErrorInnerError.cs new file mode 100644 index 000000000..a993030f4 --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureOpenAIDalleErrorInnerError.cs @@ -0,0 +1,39 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI +{ + internal partial class InternalAzureOpenAIDalleErrorInnerError + { + /// Keeps track of any properties unknown to the library. + private protected IDictionary _additionalBinaryDataProperties; + + internal InternalAzureOpenAIDalleErrorInnerError() + { + } + + internal InternalAzureOpenAIDalleErrorInnerError(InternalAzureOpenAIDalleErrorInnerErrorCode? code, string revisedPrompt, RequestImageContentFilterResult contentFilterResults, IDictionary additionalBinaryDataProperties) + { + Code = code; + RevisedPrompt = revisedPrompt; + ContentFilterResults = contentFilterResults; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + public InternalAzureOpenAIDalleErrorInnerErrorCode? Code { get; set; } + + public string RevisedPrompt { get; set; } + + public RequestImageContentFilterResult ContentFilterResults { get; set; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureOpenAIDalleErrorInnerErrorCode.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureOpenAIDalleErrorInnerErrorCode.cs similarity index 60% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureOpenAIDalleErrorInnerErrorCode.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureOpenAIDalleErrorInnerErrorCode.cs index 4e4a87f04..8585b396a 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureOpenAIDalleErrorInnerErrorCode.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureOpenAIDalleErrorInnerErrorCode.cs @@ -7,39 +7,37 @@ namespace Azure.AI.OpenAI { - /// The AzureOpenAIDalleErrorInnerError_code. internal readonly partial struct InternalAzureOpenAIDalleErrorInnerErrorCode : IEquatable { private readonly string _value; + /// ResponsibleAIPolicyViolation. + private const string ResponsibleAIPolicyViolationValue = "ResponsibleAIPolicyViolation"; - /// Initializes a new instance of . - /// is null. public InternalAzureOpenAIDalleErrorInnerErrorCode(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); + Argument.AssertNotNull(value, nameof(value)); + + _value = value; } - private const string ResponsibleAIPolicyViolationValue = "ResponsibleAIPolicyViolation"; + public static InternalAzureOpenAIDalleErrorInnerErrorCode ResponsibleAIPolicyViolation { get; set; } = new InternalAzureOpenAIDalleErrorInnerErrorCode(ResponsibleAIPolicyViolationValue); - /// ResponsibleAIPolicyViolation. - internal static InternalAzureOpenAIDalleErrorInnerErrorCode ResponsibleAIPolicyViolation { get; set; } = new InternalAzureOpenAIDalleErrorInnerErrorCode(ResponsibleAIPolicyViolationValue); - /// Determines if two values are the same. public static bool operator ==(InternalAzureOpenAIDalleErrorInnerErrorCode left, InternalAzureOpenAIDalleErrorInnerErrorCode right) => left.Equals(right); - /// Determines if two values are not the same. + public static bool operator !=(InternalAzureOpenAIDalleErrorInnerErrorCode left, InternalAzureOpenAIDalleErrorInnerErrorCode right) => !left.Equals(right); - /// Converts a to a . + public static implicit operator InternalAzureOpenAIDalleErrorInnerErrorCode(string value) => new InternalAzureOpenAIDalleErrorInnerErrorCode(value); - /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is InternalAzureOpenAIDalleErrorInnerErrorCode other && Equals(other); - /// + public bool Equals(InternalAzureOpenAIDalleErrorInnerErrorCode other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - /// + /// [EditorBrowsable(EditorBrowsableState.Never)] public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - /// + + /// public override string ToString() => _value; } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureSearchChatDataSourceParameters.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureSearchChatDataSourceParameters.Serialization.cs similarity index 52% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureSearchChatDataSourceParameters.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureSearchChatDataSourceParameters.Serialization.cs index 6a234efc8..fabc88269 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureSearchChatDataSourceParameters.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureSearchChatDataSourceParameters.Serialization.cs @@ -7,11 +7,16 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.AI.OpenAI; namespace Azure.AI.OpenAI.Chat { internal partial class InternalAzureSearchChatDataSourceParameters : IJsonModel { + internal InternalAzureSearchChatDataSourceParameters() + { + } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -19,94 +24,96 @@ void IJsonModel.Write(Utf8JsonWrite writer.WriteEndObject(); } - /// The JSON writer. - /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalAzureSearchChatDataSourceParameters)} does not support writing '{format}' format."); } - - if (SerializedAdditionalRawData?.ContainsKey("top_n_documents") != true && Optional.IsDefined(TopNDocuments)) + if (Optional.IsDefined(TopNDocuments) && _additionalBinaryDataProperties?.ContainsKey("top_n_documents") != true) { writer.WritePropertyName("top_n_documents"u8); writer.WriteNumberValue(TopNDocuments.Value); } - if (SerializedAdditionalRawData?.ContainsKey("in_scope") != true && Optional.IsDefined(InScope)) + if (Optional.IsDefined(InScope) && _additionalBinaryDataProperties?.ContainsKey("in_scope") != true) { writer.WritePropertyName("in_scope"u8); writer.WriteBooleanValue(InScope.Value); } - if (SerializedAdditionalRawData?.ContainsKey("strictness") != true && Optional.IsDefined(Strictness)) + if (Optional.IsDefined(Strictness) && _additionalBinaryDataProperties?.ContainsKey("strictness") != true) { writer.WritePropertyName("strictness"u8); writer.WriteNumberValue(Strictness.Value); } - if (SerializedAdditionalRawData?.ContainsKey("max_search_queries") != true && Optional.IsDefined(MaxSearchQueries)) + if (Optional.IsDefined(MaxSearchQueries) && _additionalBinaryDataProperties?.ContainsKey("max_search_queries") != true) { writer.WritePropertyName("max_search_queries"u8); writer.WriteNumberValue(MaxSearchQueries.Value); } - if (SerializedAdditionalRawData?.ContainsKey("allow_partial_result") != true && Optional.IsDefined(AllowPartialResult)) + if (Optional.IsDefined(AllowPartialResult) && _additionalBinaryDataProperties?.ContainsKey("allow_partial_result") != true) { writer.WritePropertyName("allow_partial_result"u8); writer.WriteBooleanValue(AllowPartialResult.Value); } - if (SerializedAdditionalRawData?.ContainsKey("include_contexts") != true && Optional.IsCollectionDefined(_internalIncludeContexts)) - { - writer.WritePropertyName("include_contexts"u8); - writer.WriteStartArray(); - foreach (var item in _internalIncludeContexts) - { - writer.WriteStringValue(item); - } - writer.WriteEndArray(); - } - if (SerializedAdditionalRawData?.ContainsKey("endpoint") != true) + if (_additionalBinaryDataProperties?.ContainsKey("endpoint") != true) { writer.WritePropertyName("endpoint"u8); writer.WriteStringValue(Endpoint.AbsoluteUri); } - if (SerializedAdditionalRawData?.ContainsKey("index_name") != true) + if (_additionalBinaryDataProperties?.ContainsKey("index_name") != true) { writer.WritePropertyName("index_name"u8); writer.WriteStringValue(IndexName); } - if (SerializedAdditionalRawData?.ContainsKey("authentication") != true) + if (Optional.IsDefined(SemanticConfiguration) && _additionalBinaryDataProperties?.ContainsKey("semantic_configuration") != true) + { + writer.WritePropertyName("semantic_configuration"u8); + writer.WriteStringValue(SemanticConfiguration); + } + if (Optional.IsDefined(Filter) && _additionalBinaryDataProperties?.ContainsKey("filter") != true) + { + writer.WritePropertyName("filter"u8); + writer.WriteStringValue(Filter); + } + if (_additionalBinaryDataProperties?.ContainsKey("authentication") != true) { writer.WritePropertyName("authentication"u8); writer.WriteObjectValue(Authentication, options); } - if (SerializedAdditionalRawData?.ContainsKey("fields_mapping") != true && Optional.IsDefined(FieldMappings)) + if (Optional.IsDefined(FieldMappings) && _additionalBinaryDataProperties?.ContainsKey("fields_mapping") != true) { writer.WritePropertyName("fields_mapping"u8); writer.WriteObjectValue(FieldMappings, options); } - if (SerializedAdditionalRawData?.ContainsKey("query_type") != true && Optional.IsDefined(QueryType)) + if (Optional.IsDefined(QueryType) && _additionalBinaryDataProperties?.ContainsKey("query_type") != true) { writer.WritePropertyName("query_type"u8); writer.WriteStringValue(QueryType.Value.ToString()); } - if (SerializedAdditionalRawData?.ContainsKey("semantic_configuration") != true && Optional.IsDefined(SemanticConfiguration)) - { - writer.WritePropertyName("semantic_configuration"u8); - writer.WriteStringValue(SemanticConfiguration); - } - if (SerializedAdditionalRawData?.ContainsKey("filter") != true && Optional.IsDefined(Filter)) - { - writer.WritePropertyName("filter"u8); - writer.WriteStringValue(Filter); - } - if (SerializedAdditionalRawData?.ContainsKey("embedding_dependency") != true && Optional.IsDefined(VectorizationSource)) + if (Optional.IsDefined(VectorizationSource) && _additionalBinaryDataProperties?.ContainsKey("embedding_dependency") != true) { writer.WritePropertyName("embedding_dependency"u8); writer.WriteObjectValue(VectorizationSource, options); } - if (SerializedAdditionalRawData != null) + if (Optional.IsCollectionDefined(_internalIncludeContexts) && _additionalBinaryDataProperties?.ContainsKey("include_contexts") != true) { - foreach (var item in SerializedAdditionalRawData) + writer.WritePropertyName("include_contexts"u8); + writer.WriteStartArray(); + foreach (string item in _internalIncludeContexts) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) + { + foreach (var item in _additionalBinaryDataProperties) { if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { @@ -114,7 +121,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else using (JsonDocument document = JsonDocument.Parse(item.Value)) { @@ -125,22 +132,21 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - InternalAzureSearchChatDataSourceParameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalAzureSearchChatDataSourceParameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + protected virtual InternalAzureSearchChatDataSourceParameters JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalAzureSearchChatDataSourceParameters)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeInternalAzureSearchChatDataSourceParameters(document.RootElement, options); } - internal static InternalAzureSearchChatDataSourceParameters DeserializeInternalAzureSearchChatDataSourceParameters(JsonElement element, ModelReaderWriterOptions options = null) + internal static InternalAzureSearchChatDataSourceParameters DeserializeInternalAzureSearchChatDataSourceParameters(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -150,159 +156,164 @@ internal static InternalAzureSearchChatDataSourceParameters DeserializeInternalA int? strictness = default; int? maxSearchQueries = default; bool? allowPartialResult = default; - IList includeContexts = default; Uri endpoint = default; string indexName = default; - DataSourceAuthentication authentication = default; - DataSourceFieldMappings fieldsMapping = default; - DataSourceQueryType? queryType = default; string semanticConfiguration = default; string filter = default; - DataSourceVectorizer embeddingDependency = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + DataSourceAuthentication authentication = default; + DataSourceFieldMappings fieldMappings = default; + DataSourceQueryType? queryType = default; + DataSourceVectorizer vectorizationSource = default; + IList internalIncludeContexts = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("top_n_documents"u8)) + if (prop.NameEquals("top_n_documents"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - topNDocuments = property.Value.GetInt32(); + topNDocuments = prop.Value.GetInt32(); continue; } - if (property.NameEquals("in_scope"u8)) + if (prop.NameEquals("in_scope"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - inScope = property.Value.GetBoolean(); + inScope = prop.Value.GetBoolean(); continue; } - if (property.NameEquals("strictness"u8)) + if (prop.NameEquals("strictness"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - strictness = property.Value.GetInt32(); + strictness = prop.Value.GetInt32(); continue; } - if (property.NameEquals("max_search_queries"u8)) + if (prop.NameEquals("max_search_queries"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - maxSearchQueries = property.Value.GetInt32(); + maxSearchQueries = prop.Value.GetInt32(); continue; } - if (property.NameEquals("allow_partial_result"u8)) + if (prop.NameEquals("allow_partial_result"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - allowPartialResult = property.Value.GetBoolean(); + allowPartialResult = prop.Value.GetBoolean(); continue; } - if (property.NameEquals("include_contexts"u8)) + if (prop.NameEquals("endpoint"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - includeContexts = array; + endpoint = new Uri(prop.Value.GetString()); continue; } - if (property.NameEquals("endpoint"u8)) + if (prop.NameEquals("index_name"u8)) { - endpoint = new Uri(property.Value.GetString()); + indexName = prop.Value.GetString(); continue; } - if (property.NameEquals("index_name"u8)) + if (prop.NameEquals("semantic_configuration"u8)) { - indexName = property.Value.GetString(); + semanticConfiguration = prop.Value.GetString(); continue; } - if (property.NameEquals("authentication"u8)) + if (prop.NameEquals("filter"u8)) { - authentication = DataSourceAuthentication.DeserializeDataSourceAuthentication(property.Value, options); + filter = prop.Value.GetString(); continue; } - if (property.NameEquals("fields_mapping"u8)) + if (prop.NameEquals("authentication"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - fieldsMapping = DataSourceFieldMappings.DeserializeDataSourceFieldMappings(property.Value, options); + authentication = DataSourceAuthentication.DeserializeDataSourceAuthentication(prop.Value, options); continue; } - if (property.NameEquals("query_type"u8)) + if (prop.NameEquals("fields_mapping"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - queryType = new DataSourceQueryType(property.Value.GetString()); + fieldMappings = DataSourceFieldMappings.DeserializeDataSourceFieldMappings(prop.Value, options); continue; } - if (property.NameEquals("semantic_configuration"u8)) + if (prop.NameEquals("query_type"u8)) { - semanticConfiguration = property.Value.GetString(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + queryType = new DataSourceQueryType(prop.Value.GetString()); continue; } - if (property.NameEquals("filter"u8)) + if (prop.NameEquals("embedding_dependency"u8)) { - filter = property.Value.GetString(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + vectorizationSource = DataSourceVectorizer.DeserializeDataSourceVectorizer(prop.Value, options); continue; } - if (property.NameEquals("embedding_dependency"u8)) + if (prop.NameEquals("include_contexts"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - embeddingDependency = DataSourceVectorizer.DeserializeDataSourceVectorizer(property.Value, options); + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + internalIncludeContexts = array; continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new InternalAzureSearchChatDataSourceParameters( topNDocuments, inScope, strictness, maxSearchQueries, allowPartialResult, - includeContexts ?? new ChangeTrackingList(), endpoint, indexName, - authentication, - fieldsMapping, - queryType, semanticConfiguration, filter, - embeddingDependency, - serializedAdditionalRawData); + authentication, + fieldMappings, + queryType, + vectorizationSource, + internalIncludeContexts, + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -312,15 +323,16 @@ BinaryData IPersistableModel.Write( } } - InternalAzureSearchChatDataSourceParameters IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + InternalAzureSearchChatDataSourceParameters IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + protected virtual InternalAzureSearchChatDataSourceParameters PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeInternalAzureSearchChatDataSourceParameters(document.RootElement, options); } default: @@ -330,18 +342,20 @@ InternalAzureSearchChatDataSourceParameters IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static InternalAzureSearchChatDataSourceParameters FromResponse(PipelineResponse response) + public static implicit operator BinaryContent(InternalAzureSearchChatDataSourceParameters internalAzureSearchChatDataSourceParameters) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalAzureSearchChatDataSourceParameters(document.RootElement); + if (internalAzureSearchChatDataSourceParameters == null) + { + return null; + } + return BinaryContent.Create(internalAzureSearchChatDataSourceParameters, ModelSerializationExtensions.WireOptions); } - /// Convert into a . - internal virtual BinaryContent ToBinaryContent() + public static explicit operator InternalAzureSearchChatDataSourceParameters(ClientResult result) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalAzureSearchChatDataSourceParameters(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureSearchChatDataSourceParameters.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureSearchChatDataSourceParameters.cs new file mode 100644 index 000000000..fb1d2c47c --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureSearchChatDataSourceParameters.cs @@ -0,0 +1,71 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.OpenAI; + +namespace Azure.AI.OpenAI.Chat +{ + internal partial class InternalAzureSearchChatDataSourceParameters + { + /// Keeps track of any properties unknown to the library. + private protected IDictionary _additionalBinaryDataProperties; + + public InternalAzureSearchChatDataSourceParameters(Uri endpoint, string indexName, DataSourceAuthentication authentication) + { + Argument.AssertNotNull(endpoint, nameof(endpoint)); + Argument.AssertNotNull(indexName, nameof(indexName)); + Argument.AssertNotNull(authentication, nameof(authentication)); + + Endpoint = endpoint; + IndexName = indexName; + Authentication = authentication; + _internalIncludeContexts = new ChangeTrackingList(); + } + + internal InternalAzureSearchChatDataSourceParameters(int? topNDocuments, bool? inScope, int? strictness, int? maxSearchQueries, bool? allowPartialResult, Uri endpoint, string indexName, string semanticConfiguration, string filter, DataSourceAuthentication authentication, DataSourceFieldMappings fieldMappings, DataSourceQueryType? queryType, DataSourceVectorizer vectorizationSource, IList internalIncludeContexts, IDictionary additionalBinaryDataProperties) + { + TopNDocuments = topNDocuments; + InScope = inScope; + Strictness = strictness; + MaxSearchQueries = maxSearchQueries; + AllowPartialResult = allowPartialResult; + Endpoint = endpoint; + IndexName = indexName; + SemanticConfiguration = semanticConfiguration; + Filter = filter; + Authentication = authentication; + FieldMappings = fieldMappings; + QueryType = queryType; + VectorizationSource = vectorizationSource; + _internalIncludeContexts = internalIncludeContexts; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + public int? TopNDocuments { get; set; } + + public bool? InScope { get; set; } + + public int? Strictness { get; set; } + + public int? MaxSearchQueries { get; set; } + + public bool? AllowPartialResult { get; set; } + + public Uri Endpoint { get; set; } + + public string IndexName { get; set; } + + public string SemanticConfiguration { get; set; } + + public string Filter { get; set; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureSearchChatDataSourceParametersIncludeContext.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureSearchChatDataSourceParametersIncludeContext.cs similarity index 52% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureSearchChatDataSourceParametersIncludeContext.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureSearchChatDataSourceParametersIncludeContext.cs index 1d2113e47..60c378f4b 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalAzureSearchChatDataSourceParametersIncludeContext.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalAzureSearchChatDataSourceParametersIncludeContext.cs @@ -4,48 +4,46 @@ using System; using System.ComponentModel; +using Azure.AI.OpenAI; namespace Azure.AI.OpenAI.Chat { - /// The AzureSearchChatDataSourceParametersIncludeContext. internal readonly partial struct InternalAzureSearchChatDataSourceParametersIncludeContext : IEquatable { private readonly string _value; + private const string CitationsValue = "citations"; + private const string IntentValue = "intent"; + private const string AllRetrievedDocumentsValue = "all_retrieved_documents"; - /// Initializes a new instance of . - /// is null. public InternalAzureSearchChatDataSourceParametersIncludeContext(string value) { - _value = value ?? throw new ArgumentNullException(nameof(value)); + Argument.AssertNotNull(value, nameof(value)); + + _value = value; } - private const string CitationsValue = "citations"; - private const string IntentValue = "intent"; - private const string AllRetrievedDocumentsValue = "all_retrieved_documents"; + public static InternalAzureSearchChatDataSourceParametersIncludeContext Citations { get; set; } = new InternalAzureSearchChatDataSourceParametersIncludeContext(CitationsValue); + + public static InternalAzureSearchChatDataSourceParametersIncludeContext Intent { get; set; } = new InternalAzureSearchChatDataSourceParametersIncludeContext(IntentValue); + + public static InternalAzureSearchChatDataSourceParametersIncludeContext AllRetrievedDocuments { get; set; } = new InternalAzureSearchChatDataSourceParametersIncludeContext(AllRetrievedDocumentsValue); - /// citations. - internal static InternalAzureSearchChatDataSourceParametersIncludeContext Citations { get; set; } = new InternalAzureSearchChatDataSourceParametersIncludeContext(CitationsValue); - /// intent. - internal static InternalAzureSearchChatDataSourceParametersIncludeContext Intent { get; set; } = new InternalAzureSearchChatDataSourceParametersIncludeContext(IntentValue); - /// all_retrieved_documents. - internal static InternalAzureSearchChatDataSourceParametersIncludeContext AllRetrievedDocuments { get; set; } = new InternalAzureSearchChatDataSourceParametersIncludeContext(AllRetrievedDocumentsValue); - /// Determines if two values are the same. public static bool operator ==(InternalAzureSearchChatDataSourceParametersIncludeContext left, InternalAzureSearchChatDataSourceParametersIncludeContext right) => left.Equals(right); - /// Determines if two values are not the same. + public static bool operator !=(InternalAzureSearchChatDataSourceParametersIncludeContext left, InternalAzureSearchChatDataSourceParametersIncludeContext right) => !left.Equals(right); - /// Converts a to a . + public static implicit operator InternalAzureSearchChatDataSourceParametersIncludeContext(string value) => new InternalAzureSearchChatDataSourceParametersIncludeContext(value); - /// [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) => obj is InternalAzureSearchChatDataSourceParametersIncludeContext other && Equals(other); - /// + public bool Equals(InternalAzureSearchChatDataSourceParametersIncludeContext other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - /// + /// [EditorBrowsable(EditorBrowsableState.Never)] public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - /// + + /// public override string ToString() => _value; } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalElasticsearchChatDataSourceParameters.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalElasticsearchChatDataSourceParameters.Serialization.cs similarity index 52% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalElasticsearchChatDataSourceParameters.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalElasticsearchChatDataSourceParameters.Serialization.cs index 445e3e27c..bc34bb1dd 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalElasticsearchChatDataSourceParameters.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalElasticsearchChatDataSourceParameters.Serialization.cs @@ -7,11 +7,16 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.AI.OpenAI; namespace Azure.AI.OpenAI.Chat { internal partial class InternalElasticsearchChatDataSourceParameters : IJsonModel { + internal InternalElasticsearchChatDataSourceParameters() + { + } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -19,84 +24,86 @@ void IJsonModel.Write(Utf8JsonWri writer.WriteEndObject(); } - /// The JSON writer. - /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalElasticsearchChatDataSourceParameters)} does not support writing '{format}' format."); } - - if (SerializedAdditionalRawData?.ContainsKey("top_n_documents") != true && Optional.IsDefined(TopNDocuments)) + if (Optional.IsDefined(TopNDocuments) && _additionalBinaryDataProperties?.ContainsKey("top_n_documents") != true) { writer.WritePropertyName("top_n_documents"u8); writer.WriteNumberValue(TopNDocuments.Value); } - if (SerializedAdditionalRawData?.ContainsKey("in_scope") != true && Optional.IsDefined(InScope)) + if (Optional.IsDefined(InScope) && _additionalBinaryDataProperties?.ContainsKey("in_scope") != true) { writer.WritePropertyName("in_scope"u8); writer.WriteBooleanValue(InScope.Value); } - if (SerializedAdditionalRawData?.ContainsKey("strictness") != true && Optional.IsDefined(Strictness)) + if (Optional.IsDefined(Strictness) && _additionalBinaryDataProperties?.ContainsKey("strictness") != true) { writer.WritePropertyName("strictness"u8); writer.WriteNumberValue(Strictness.Value); } - if (SerializedAdditionalRawData?.ContainsKey("max_search_queries") != true && Optional.IsDefined(MaxSearchQueries)) + if (Optional.IsDefined(MaxSearchQueries) && _additionalBinaryDataProperties?.ContainsKey("max_search_queries") != true) { writer.WritePropertyName("max_search_queries"u8); writer.WriteNumberValue(MaxSearchQueries.Value); } - if (SerializedAdditionalRawData?.ContainsKey("allow_partial_result") != true && Optional.IsDefined(AllowPartialResult)) + if (Optional.IsDefined(AllowPartialResult) && _additionalBinaryDataProperties?.ContainsKey("allow_partial_result") != true) { writer.WritePropertyName("allow_partial_result"u8); writer.WriteBooleanValue(AllowPartialResult.Value); } - if (SerializedAdditionalRawData?.ContainsKey("include_contexts") != true && Optional.IsCollectionDefined(_internalIncludeContexts)) - { - writer.WritePropertyName("include_contexts"u8); - writer.WriteStartArray(); - foreach (var item in _internalIncludeContexts) - { - writer.WriteStringValue(item); - } - writer.WriteEndArray(); - } - if (SerializedAdditionalRawData?.ContainsKey("endpoint") != true) + if (_additionalBinaryDataProperties?.ContainsKey("endpoint") != true) { writer.WritePropertyName("endpoint"u8); writer.WriteStringValue(Endpoint.AbsoluteUri); } - if (SerializedAdditionalRawData?.ContainsKey("index_name") != true) + if (_additionalBinaryDataProperties?.ContainsKey("index_name") != true) { writer.WritePropertyName("index_name"u8); writer.WriteStringValue(IndexName); } - if (SerializedAdditionalRawData?.ContainsKey("authentication") != true) + if (Optional.IsCollectionDefined(InternalIncludeContexts) && _additionalBinaryDataProperties?.ContainsKey("include_contexts") != true) + { + writer.WritePropertyName("include_contexts"u8); + writer.WriteStartArray(); + foreach (string item in InternalIncludeContexts) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (_additionalBinaryDataProperties?.ContainsKey("authentication") != true) { writer.WritePropertyName("authentication"u8); writer.WriteObjectValue(Authentication, options); } - if (SerializedAdditionalRawData?.ContainsKey("fields_mapping") != true && Optional.IsDefined(FieldMappings)) + if (Optional.IsDefined(FieldMappings) && _additionalBinaryDataProperties?.ContainsKey("fields_mapping") != true) { writer.WritePropertyName("fields_mapping"u8); writer.WriteObjectValue(FieldMappings, options); } - if (SerializedAdditionalRawData?.ContainsKey("query_type") != true && Optional.IsDefined(QueryType)) + if (Optional.IsDefined(QueryType) && _additionalBinaryDataProperties?.ContainsKey("query_type") != true) { writer.WritePropertyName("query_type"u8); writer.WriteStringValue(QueryType.Value.ToString()); } - if (SerializedAdditionalRawData?.ContainsKey("embedding_dependency") != true && Optional.IsDefined(VectorizationSource)) + if (Optional.IsDefined(VectorizationSource) && _additionalBinaryDataProperties?.ContainsKey("embedding_dependency") != true) { writer.WritePropertyName("embedding_dependency"u8); writer.WriteObjectValue(VectorizationSource, options); } - if (SerializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in SerializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { @@ -104,7 +111,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else using (JsonDocument document = JsonDocument.Parse(item.Value)) { @@ -115,22 +122,21 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - InternalElasticsearchChatDataSourceParameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalElasticsearchChatDataSourceParameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + protected virtual InternalElasticsearchChatDataSourceParameters JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalElasticsearchChatDataSourceParameters)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeInternalElasticsearchChatDataSourceParameters(document.RootElement, options); } - internal static InternalElasticsearchChatDataSourceParameters DeserializeInternalElasticsearchChatDataSourceParameters(JsonElement element, ModelReaderWriterOptions options = null) + internal static InternalElasticsearchChatDataSourceParameters DeserializeInternalElasticsearchChatDataSourceParameters(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -140,145 +146,150 @@ internal static InternalElasticsearchChatDataSourceParameters DeserializeInterna int? strictness = default; int? maxSearchQueries = default; bool? allowPartialResult = default; - IList includeContexts = default; Uri endpoint = default; string indexName = default; + IList internalIncludeContexts = default; DataSourceAuthentication authentication = default; - DataSourceFieldMappings fieldsMapping = default; + DataSourceFieldMappings fieldMappings = default; DataSourceQueryType? queryType = default; - DataSourceVectorizer embeddingDependency = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + DataSourceVectorizer vectorizationSource = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("top_n_documents"u8)) + if (prop.NameEquals("top_n_documents"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - topNDocuments = property.Value.GetInt32(); + topNDocuments = prop.Value.GetInt32(); continue; } - if (property.NameEquals("in_scope"u8)) + if (prop.NameEquals("in_scope"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - inScope = property.Value.GetBoolean(); + inScope = prop.Value.GetBoolean(); continue; } - if (property.NameEquals("strictness"u8)) + if (prop.NameEquals("strictness"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - strictness = property.Value.GetInt32(); + strictness = prop.Value.GetInt32(); continue; } - if (property.NameEquals("max_search_queries"u8)) + if (prop.NameEquals("max_search_queries"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - maxSearchQueries = property.Value.GetInt32(); + maxSearchQueries = prop.Value.GetInt32(); continue; } - if (property.NameEquals("allow_partial_result"u8)) + if (prop.NameEquals("allow_partial_result"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - allowPartialResult = property.Value.GetBoolean(); + allowPartialResult = prop.Value.GetBoolean(); continue; } - if (property.NameEquals("include_contexts"u8)) + if (prop.NameEquals("endpoint"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - includeContexts = array; + endpoint = new Uri(prop.Value.GetString()); continue; } - if (property.NameEquals("endpoint"u8)) + if (prop.NameEquals("index_name"u8)) { - endpoint = new Uri(property.Value.GetString()); + indexName = prop.Value.GetString(); continue; } - if (property.NameEquals("index_name"u8)) + if (prop.NameEquals("include_contexts"u8)) { - indexName = property.Value.GetString(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + internalIncludeContexts = array; continue; } - if (property.NameEquals("authentication"u8)) + if (prop.NameEquals("authentication"u8)) { - authentication = DataSourceAuthentication.DeserializeDataSourceAuthentication(property.Value, options); + authentication = DataSourceAuthentication.DeserializeDataSourceAuthentication(prop.Value, options); continue; } - if (property.NameEquals("fields_mapping"u8)) + if (prop.NameEquals("fields_mapping"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - fieldsMapping = DataSourceFieldMappings.DeserializeDataSourceFieldMappings(property.Value, options); + fieldMappings = DataSourceFieldMappings.DeserializeDataSourceFieldMappings(prop.Value, options); continue; } - if (property.NameEquals("query_type"u8)) + if (prop.NameEquals("query_type"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - queryType = new DataSourceQueryType(property.Value.GetString()); + queryType = new DataSourceQueryType(prop.Value.GetString()); continue; } - if (property.NameEquals("embedding_dependency"u8)) + if (prop.NameEquals("embedding_dependency"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - embeddingDependency = DataSourceVectorizer.DeserializeDataSourceVectorizer(property.Value, options); + vectorizationSource = DataSourceVectorizer.DeserializeDataSourceVectorizer(prop.Value, options); continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new InternalElasticsearchChatDataSourceParameters( topNDocuments, inScope, strictness, maxSearchQueries, allowPartialResult, - includeContexts ?? new ChangeTrackingList(), endpoint, indexName, + internalIncludeContexts ?? new ChangeTrackingList(), authentication, - fieldsMapping, + fieldMappings, queryType, - embeddingDependency, - serializedAdditionalRawData); + vectorizationSource, + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -288,15 +299,16 @@ BinaryData IPersistableModel.Writ } } - InternalElasticsearchChatDataSourceParameters IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + InternalElasticsearchChatDataSourceParameters IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + protected virtual InternalElasticsearchChatDataSourceParameters PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeInternalElasticsearchChatDataSourceParameters(document.RootElement, options); } default: @@ -306,18 +318,20 @@ InternalElasticsearchChatDataSourceParameters IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static InternalElasticsearchChatDataSourceParameters FromResponse(PipelineResponse response) + public static implicit operator BinaryContent(InternalElasticsearchChatDataSourceParameters internalElasticsearchChatDataSourceParameters) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalElasticsearchChatDataSourceParameters(document.RootElement); + if (internalElasticsearchChatDataSourceParameters == null) + { + return null; + } + return BinaryContent.Create(internalElasticsearchChatDataSourceParameters, ModelSerializationExtensions.WireOptions); } - /// Convert into a . - internal virtual BinaryContent ToBinaryContent() + public static explicit operator InternalElasticsearchChatDataSourceParameters(ClientResult result) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalElasticsearchChatDataSourceParameters(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalElasticsearchChatDataSourceParameters.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalElasticsearchChatDataSourceParameters.cs new file mode 100644 index 000000000..ec14841d8 --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalElasticsearchChatDataSourceParameters.cs @@ -0,0 +1,65 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.OpenAI; + +namespace Azure.AI.OpenAI.Chat +{ + internal partial class InternalElasticsearchChatDataSourceParameters + { + /// Keeps track of any properties unknown to the library. + private protected IDictionary _additionalBinaryDataProperties; + + public InternalElasticsearchChatDataSourceParameters(Uri endpoint, string indexName, DataSourceAuthentication authentication) + { + Argument.AssertNotNull(endpoint, nameof(endpoint)); + Argument.AssertNotNull(indexName, nameof(indexName)); + Argument.AssertNotNull(authentication, nameof(authentication)); + + Endpoint = endpoint; + IndexName = indexName; + InternalIncludeContexts = new ChangeTrackingList(); + Authentication = authentication; + } + + internal InternalElasticsearchChatDataSourceParameters(int? topNDocuments, bool? inScope, int? strictness, int? maxSearchQueries, bool? allowPartialResult, Uri endpoint, string indexName, IList internalIncludeContexts, DataSourceAuthentication authentication, DataSourceFieldMappings fieldMappings, DataSourceQueryType? queryType, DataSourceVectorizer vectorizationSource, IDictionary additionalBinaryDataProperties) + { + TopNDocuments = topNDocuments; + InScope = inScope; + Strictness = strictness; + MaxSearchQueries = maxSearchQueries; + AllowPartialResult = allowPartialResult; + Endpoint = endpoint; + IndexName = indexName; + InternalIncludeContexts = internalIncludeContexts; + Authentication = authentication; + FieldMappings = fieldMappings; + QueryType = queryType; + VectorizationSource = vectorizationSource; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + public int? TopNDocuments { get; set; } + + public bool? InScope { get; set; } + + public int? Strictness { get; set; } + + public int? MaxSearchQueries { get; set; } + + public bool? AllowPartialResult { get; set; } + + public Uri Endpoint { get; set; } + + public string IndexName { get; set; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalMongoDBChatDataSourceParameters.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalMongoDBChatDataSourceParameters.Serialization.cs similarity index 54% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalMongoDBChatDataSourceParameters.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalMongoDBChatDataSourceParameters.Serialization.cs index 30e1f6968..8ee1be5fb 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalMongoDBChatDataSourceParameters.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalMongoDBChatDataSourceParameters.Serialization.cs @@ -7,11 +7,16 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.AI.OpenAI; namespace Azure.AI.OpenAI.Chat { internal partial class InternalMongoDBChatDataSourceParameters : IJsonModel { + internal InternalMongoDBChatDataSourceParameters() + { + } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -19,94 +24,96 @@ void IJsonModel.Write(Utf8JsonWriter wr writer.WriteEndObject(); } - /// The JSON writer. - /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalMongoDBChatDataSourceParameters)} does not support writing '{format}' format."); } - - if (SerializedAdditionalRawData?.ContainsKey("top_n_documents") != true && Optional.IsDefined(TopNDocuments)) + if (Optional.IsDefined(TopNDocuments) && _additionalBinaryDataProperties?.ContainsKey("top_n_documents") != true) { writer.WritePropertyName("top_n_documents"u8); writer.WriteNumberValue(TopNDocuments.Value); } - if (SerializedAdditionalRawData?.ContainsKey("in_scope") != true && Optional.IsDefined(InScope)) + if (Optional.IsDefined(InScope) && _additionalBinaryDataProperties?.ContainsKey("in_scope") != true) { writer.WritePropertyName("in_scope"u8); writer.WriteBooleanValue(InScope.Value); } - if (SerializedAdditionalRawData?.ContainsKey("strictness") != true && Optional.IsDefined(Strictness)) + if (Optional.IsDefined(Strictness) && _additionalBinaryDataProperties?.ContainsKey("strictness") != true) { writer.WritePropertyName("strictness"u8); writer.WriteNumberValue(Strictness.Value); } - if (SerializedAdditionalRawData?.ContainsKey("max_search_queries") != true && Optional.IsDefined(MaxSearchQueries)) + if (Optional.IsDefined(MaxSearchQueries) && _additionalBinaryDataProperties?.ContainsKey("max_search_queries") != true) { writer.WritePropertyName("max_search_queries"u8); writer.WriteNumberValue(MaxSearchQueries.Value); } - if (SerializedAdditionalRawData?.ContainsKey("allow_partial_result") != true && Optional.IsDefined(AllowPartialResult)) + if (Optional.IsDefined(AllowPartialResult) && _additionalBinaryDataProperties?.ContainsKey("allow_partial_result") != true) { writer.WritePropertyName("allow_partial_result"u8); writer.WriteBooleanValue(AllowPartialResult.Value); } - if (SerializedAdditionalRawData?.ContainsKey("include_contexts") != true && Optional.IsCollectionDefined(_internalIncludeContexts)) - { - writer.WritePropertyName("include_contexts"u8); - writer.WriteStartArray(); - foreach (var item in _internalIncludeContexts) - { - writer.WriteStringValue(item); - } - writer.WriteEndArray(); - } - if (SerializedAdditionalRawData?.ContainsKey("endpoint") != true) + if (_additionalBinaryDataProperties?.ContainsKey("endpoint") != true) { writer.WritePropertyName("endpoint"u8); writer.WriteStringValue(Endpoint); } - if (SerializedAdditionalRawData?.ContainsKey("database_name") != true) + if (_additionalBinaryDataProperties?.ContainsKey("database_name") != true) { writer.WritePropertyName("database_name"u8); writer.WriteStringValue(DatabaseName); } - if (SerializedAdditionalRawData?.ContainsKey("collection_name") != true) + if (_additionalBinaryDataProperties?.ContainsKey("collection_name") != true) { writer.WritePropertyName("collection_name"u8); writer.WriteStringValue(CollectionName); } - if (SerializedAdditionalRawData?.ContainsKey("app_name") != true) + if (_additionalBinaryDataProperties?.ContainsKey("app_name") != true) { writer.WritePropertyName("app_name"u8); writer.WriteStringValue(AppName); } - if (SerializedAdditionalRawData?.ContainsKey("index_name") != true) + if (_additionalBinaryDataProperties?.ContainsKey("index_name") != true) { writer.WritePropertyName("index_name"u8); writer.WriteStringValue(IndexName); } - if (SerializedAdditionalRawData?.ContainsKey("authentication") != true) + if (_additionalBinaryDataProperties?.ContainsKey("fields_mapping") != true) + { + writer.WritePropertyName("fields_mapping"u8); + writer.WriteObjectValue(FieldMappings, options); + } + if (_additionalBinaryDataProperties?.ContainsKey("authentication") != true) { writer.WritePropertyName("authentication"u8); writer.WriteObjectValue(Authentication, options); } - if (SerializedAdditionalRawData?.ContainsKey("embedding_dependency") != true) + if (_additionalBinaryDataProperties?.ContainsKey("embedding_dependency") != true) { writer.WritePropertyName("embedding_dependency"u8); writer.WriteObjectValue(EmbeddingDependency, options); } - if (SerializedAdditionalRawData?.ContainsKey("fields_mapping") != true) + if (Optional.IsCollectionDefined(_internalIncludeContexts) && _additionalBinaryDataProperties?.ContainsKey("include_contexts") != true) { - writer.WritePropertyName("fields_mapping"u8); - writer.WriteObjectValue(FieldMappings, options); + writer.WritePropertyName("include_contexts"u8); + writer.WriteStartArray(); + foreach (string item in _internalIncludeContexts) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); } - if (SerializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in SerializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { @@ -114,7 +121,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else using (JsonDocument document = JsonDocument.Parse(item.Value)) { @@ -125,22 +132,21 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - InternalMongoDBChatDataSourceParameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalMongoDBChatDataSourceParameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + protected virtual InternalMongoDBChatDataSourceParameters JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalMongoDBChatDataSourceParameters)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeInternalMongoDBChatDataSourceParameters(document.RootElement, options); } - internal static InternalMongoDBChatDataSourceParameters DeserializeInternalMongoDBChatDataSourceParameters(JsonElement element, ModelReaderWriterOptions options = null) + internal static InternalMongoDBChatDataSourceParameters DeserializeInternalMongoDBChatDataSourceParameters(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -150,147 +156,152 @@ internal static InternalMongoDBChatDataSourceParameters DeserializeInternalMongo int? strictness = default; int? maxSearchQueries = default; bool? allowPartialResult = default; - IList includeContexts = default; string endpoint = default; string databaseName = default; string collectionName = default; string appName = default; string indexName = default; + DataSourceFieldMappings fieldMappings = default; DataSourceAuthentication authentication = default; DataSourceVectorizer embeddingDependency = default; - DataSourceFieldMappings fieldsMapping = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IList internalIncludeContexts = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("top_n_documents"u8)) + if (prop.NameEquals("top_n_documents"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - topNDocuments = property.Value.GetInt32(); + topNDocuments = prop.Value.GetInt32(); continue; } - if (property.NameEquals("in_scope"u8)) + if (prop.NameEquals("in_scope"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - inScope = property.Value.GetBoolean(); + inScope = prop.Value.GetBoolean(); continue; } - if (property.NameEquals("strictness"u8)) + if (prop.NameEquals("strictness"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - strictness = property.Value.GetInt32(); + strictness = prop.Value.GetInt32(); continue; } - if (property.NameEquals("max_search_queries"u8)) + if (prop.NameEquals("max_search_queries"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - maxSearchQueries = property.Value.GetInt32(); + maxSearchQueries = prop.Value.GetInt32(); continue; } - if (property.NameEquals("allow_partial_result"u8)) + if (prop.NameEquals("allow_partial_result"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - allowPartialResult = property.Value.GetBoolean(); + allowPartialResult = prop.Value.GetBoolean(); continue; } - if (property.NameEquals("include_contexts"u8)) + if (prop.NameEquals("endpoint"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - includeContexts = array; + endpoint = prop.Value.GetString(); continue; } - if (property.NameEquals("endpoint"u8)) + if (prop.NameEquals("database_name"u8)) { - endpoint = property.Value.GetString(); + databaseName = prop.Value.GetString(); continue; } - if (property.NameEquals("database_name"u8)) + if (prop.NameEquals("collection_name"u8)) { - databaseName = property.Value.GetString(); + collectionName = prop.Value.GetString(); continue; } - if (property.NameEquals("collection_name"u8)) + if (prop.NameEquals("app_name"u8)) { - collectionName = property.Value.GetString(); + appName = prop.Value.GetString(); continue; } - if (property.NameEquals("app_name"u8)) + if (prop.NameEquals("index_name"u8)) { - appName = property.Value.GetString(); + indexName = prop.Value.GetString(); continue; } - if (property.NameEquals("index_name"u8)) + if (prop.NameEquals("fields_mapping"u8)) { - indexName = property.Value.GetString(); + fieldMappings = DataSourceFieldMappings.DeserializeDataSourceFieldMappings(prop.Value, options); continue; } - if (property.NameEquals("authentication"u8)) + if (prop.NameEquals("authentication"u8)) { - authentication = DataSourceAuthentication.DeserializeDataSourceAuthentication(property.Value, options); + authentication = DataSourceAuthentication.DeserializeDataSourceAuthentication(prop.Value, options); continue; } - if (property.NameEquals("embedding_dependency"u8)) + if (prop.NameEquals("embedding_dependency"u8)) { - embeddingDependency = DataSourceVectorizer.DeserializeDataSourceVectorizer(property.Value, options); + embeddingDependency = DataSourceVectorizer.DeserializeDataSourceVectorizer(prop.Value, options); continue; } - if (property.NameEquals("fields_mapping"u8)) + if (prop.NameEquals("include_contexts"u8)) { - fieldsMapping = DataSourceFieldMappings.DeserializeDataSourceFieldMappings(property.Value, options); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + internalIncludeContexts = array; continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new InternalMongoDBChatDataSourceParameters( topNDocuments, inScope, strictness, maxSearchQueries, allowPartialResult, - includeContexts ?? new ChangeTrackingList(), endpoint, databaseName, collectionName, appName, indexName, + fieldMappings, authentication, embeddingDependency, - fieldsMapping, - serializedAdditionalRawData); + internalIncludeContexts, + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -300,15 +311,16 @@ BinaryData IPersistableModel.Write(Mode } } - InternalMongoDBChatDataSourceParameters IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + InternalMongoDBChatDataSourceParameters IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + protected virtual InternalMongoDBChatDataSourceParameters PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeInternalMongoDBChatDataSourceParameters(document.RootElement, options); } default: @@ -318,18 +330,20 @@ InternalMongoDBChatDataSourceParameters IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static InternalMongoDBChatDataSourceParameters FromResponse(PipelineResponse response) + public static implicit operator BinaryContent(InternalMongoDBChatDataSourceParameters internalMongoDBChatDataSourceParameters) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalMongoDBChatDataSourceParameters(document.RootElement); + if (internalMongoDBChatDataSourceParameters == null) + { + return null; + } + return BinaryContent.Create(internalMongoDBChatDataSourceParameters, ModelSerializationExtensions.WireOptions); } - /// Convert into a . - internal virtual BinaryContent ToBinaryContent() + public static explicit operator InternalMongoDBChatDataSourceParameters(ClientResult result) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalMongoDBChatDataSourceParameters(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalMongoDBChatDataSourceParameters.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalMongoDBChatDataSourceParameters.cs new file mode 100644 index 000000000..9d06bc0fa --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalMongoDBChatDataSourceParameters.cs @@ -0,0 +1,83 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.OpenAI; + +namespace Azure.AI.OpenAI.Chat +{ + internal partial class InternalMongoDBChatDataSourceParameters + { + /// Keeps track of any properties unknown to the library. + private protected IDictionary _additionalBinaryDataProperties; + + public InternalMongoDBChatDataSourceParameters(string endpoint, string databaseName, string collectionName, string appName, string indexName, DataSourceFieldMappings fieldMappings, DataSourceAuthentication authentication, DataSourceVectorizer embeddingDependency) + { + Argument.AssertNotNull(endpoint, nameof(endpoint)); + Argument.AssertNotNull(databaseName, nameof(databaseName)); + Argument.AssertNotNull(collectionName, nameof(collectionName)); + Argument.AssertNotNull(appName, nameof(appName)); + Argument.AssertNotNull(indexName, nameof(indexName)); + Argument.AssertNotNull(fieldMappings, nameof(fieldMappings)); + Argument.AssertNotNull(authentication, nameof(authentication)); + Argument.AssertNotNull(embeddingDependency, nameof(embeddingDependency)); + + Endpoint = endpoint; + DatabaseName = databaseName; + CollectionName = collectionName; + AppName = appName; + IndexName = indexName; + FieldMappings = fieldMappings; + Authentication = authentication; + EmbeddingDependency = embeddingDependency; + _internalIncludeContexts = new ChangeTrackingList(); + } + + internal InternalMongoDBChatDataSourceParameters(int? topNDocuments, bool? inScope, int? strictness, int? maxSearchQueries, bool? allowPartialResult, string endpoint, string databaseName, string collectionName, string appName, string indexName, DataSourceFieldMappings fieldMappings, DataSourceAuthentication authentication, DataSourceVectorizer embeddingDependency, IList internalIncludeContexts, IDictionary additionalBinaryDataProperties) + { + TopNDocuments = topNDocuments; + InScope = inScope; + Strictness = strictness; + MaxSearchQueries = maxSearchQueries; + AllowPartialResult = allowPartialResult; + Endpoint = endpoint; + DatabaseName = databaseName; + CollectionName = collectionName; + AppName = appName; + IndexName = indexName; + FieldMappings = fieldMappings; + Authentication = authentication; + EmbeddingDependency = embeddingDependency; + _internalIncludeContexts = internalIncludeContexts; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + public int? TopNDocuments { get; set; } + + public bool? InScope { get; set; } + + public int? Strictness { get; set; } + + public int? MaxSearchQueries { get; set; } + + public bool? AllowPartialResult { get; set; } + + public string Endpoint { get; set; } + + public string DatabaseName { get; set; } + + public string CollectionName { get; set; } + + public string AppName { get; set; } + + public string IndexName { get; set; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalPineconeChatDataSourceParameters.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalPineconeChatDataSourceParameters.Serialization.cs similarity index 52% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalPineconeChatDataSourceParameters.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalPineconeChatDataSourceParameters.Serialization.cs index d8ebc8873..7c3ffe244 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalPineconeChatDataSourceParameters.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalPineconeChatDataSourceParameters.Serialization.cs @@ -7,11 +7,16 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.AI.OpenAI; namespace Azure.AI.OpenAI.Chat { internal partial class InternalPineconeChatDataSourceParameters : IJsonModel { + internal InternalPineconeChatDataSourceParameters() + { + } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -19,79 +24,81 @@ void IJsonModel.Write(Utf8JsonWriter w writer.WriteEndObject(); } - /// The JSON writer. - /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalPineconeChatDataSourceParameters)} does not support writing '{format}' format."); } - - if (SerializedAdditionalRawData?.ContainsKey("top_n_documents") != true && Optional.IsDefined(TopNDocuments)) + if (Optional.IsDefined(TopNDocuments) && _additionalBinaryDataProperties?.ContainsKey("top_n_documents") != true) { writer.WritePropertyName("top_n_documents"u8); writer.WriteNumberValue(TopNDocuments.Value); } - if (SerializedAdditionalRawData?.ContainsKey("in_scope") != true && Optional.IsDefined(InScope)) + if (Optional.IsDefined(InScope) && _additionalBinaryDataProperties?.ContainsKey("in_scope") != true) { writer.WritePropertyName("in_scope"u8); writer.WriteBooleanValue(InScope.Value); } - if (SerializedAdditionalRawData?.ContainsKey("strictness") != true && Optional.IsDefined(Strictness)) + if (Optional.IsDefined(Strictness) && _additionalBinaryDataProperties?.ContainsKey("strictness") != true) { writer.WritePropertyName("strictness"u8); writer.WriteNumberValue(Strictness.Value); } - if (SerializedAdditionalRawData?.ContainsKey("max_search_queries") != true && Optional.IsDefined(MaxSearchQueries)) + if (Optional.IsDefined(MaxSearchQueries) && _additionalBinaryDataProperties?.ContainsKey("max_search_queries") != true) { writer.WritePropertyName("max_search_queries"u8); writer.WriteNumberValue(MaxSearchQueries.Value); } - if (SerializedAdditionalRawData?.ContainsKey("allow_partial_result") != true && Optional.IsDefined(AllowPartialResult)) + if (Optional.IsDefined(AllowPartialResult) && _additionalBinaryDataProperties?.ContainsKey("allow_partial_result") != true) { writer.WritePropertyName("allow_partial_result"u8); writer.WriteBooleanValue(AllowPartialResult.Value); } - if (SerializedAdditionalRawData?.ContainsKey("include_contexts") != true && Optional.IsCollectionDefined(_internalIncludeContexts)) - { - writer.WritePropertyName("include_contexts"u8); - writer.WriteStartArray(); - foreach (var item in _internalIncludeContexts) - { - writer.WriteStringValue(item); - } - writer.WriteEndArray(); - } - if (SerializedAdditionalRawData?.ContainsKey("environment") != true) + if (_additionalBinaryDataProperties?.ContainsKey("environment") != true) { writer.WritePropertyName("environment"u8); writer.WriteStringValue(Environment); } - if (SerializedAdditionalRawData?.ContainsKey("index_name") != true) + if (_additionalBinaryDataProperties?.ContainsKey("index_name") != true) { writer.WritePropertyName("index_name"u8); writer.WriteStringValue(IndexName); } - if (SerializedAdditionalRawData?.ContainsKey("authentication") != true) + if (_additionalBinaryDataProperties?.ContainsKey("authentication") != true) { writer.WritePropertyName("authentication"u8); writer.WriteObjectValue(Authentication, options); } - if (SerializedAdditionalRawData?.ContainsKey("embedding_dependency") != true) + if (_additionalBinaryDataProperties?.ContainsKey("fields_mapping") != true) + { + writer.WritePropertyName("fields_mapping"u8); + writer.WriteObjectValue(FieldMappings, options); + } + if (_additionalBinaryDataProperties?.ContainsKey("embedding_dependency") != true) { writer.WritePropertyName("embedding_dependency"u8); writer.WriteObjectValue(VectorizationSource, options); } - if (SerializedAdditionalRawData?.ContainsKey("fields_mapping") != true) + if (Optional.IsCollectionDefined(_internalIncludeContexts) && _additionalBinaryDataProperties?.ContainsKey("include_contexts") != true) { - writer.WritePropertyName("fields_mapping"u8); - writer.WriteObjectValue(FieldMappings, options); + writer.WritePropertyName("include_contexts"u8); + writer.WriteStartArray(); + foreach (string item in _internalIncludeContexts) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); } - if (SerializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in SerializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { @@ -99,7 +106,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else using (JsonDocument document = JsonDocument.Parse(item.Value)) { @@ -110,22 +117,21 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - InternalPineconeChatDataSourceParameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + InternalPineconeChatDataSourceParameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + protected virtual InternalPineconeChatDataSourceParameters JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(InternalPineconeChatDataSourceParameters)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeInternalPineconeChatDataSourceParameters(document.RootElement, options); } - internal static InternalPineconeChatDataSourceParameters DeserializeInternalPineconeChatDataSourceParameters(JsonElement element, ModelReaderWriterOptions options = null) + internal static InternalPineconeChatDataSourceParameters DeserializeInternalPineconeChatDataSourceParameters(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -135,126 +141,131 @@ internal static InternalPineconeChatDataSourceParameters DeserializeInternalPine int? strictness = default; int? maxSearchQueries = default; bool? allowPartialResult = default; - IList includeContexts = default; string environment = default; string indexName = default; DataSourceAuthentication authentication = default; - DataSourceVectorizer embeddingDependency = default; - DataSourceFieldMappings fieldsMapping = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + DataSourceFieldMappings fieldMappings = default; + DataSourceVectorizer vectorizationSource = default; + IList internalIncludeContexts = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("top_n_documents"u8)) + if (prop.NameEquals("top_n_documents"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - topNDocuments = property.Value.GetInt32(); + topNDocuments = prop.Value.GetInt32(); continue; } - if (property.NameEquals("in_scope"u8)) + if (prop.NameEquals("in_scope"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - inScope = property.Value.GetBoolean(); + inScope = prop.Value.GetBoolean(); continue; } - if (property.NameEquals("strictness"u8)) + if (prop.NameEquals("strictness"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - strictness = property.Value.GetInt32(); + strictness = prop.Value.GetInt32(); continue; } - if (property.NameEquals("max_search_queries"u8)) + if (prop.NameEquals("max_search_queries"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - maxSearchQueries = property.Value.GetInt32(); + maxSearchQueries = prop.Value.GetInt32(); continue; } - if (property.NameEquals("allow_partial_result"u8)) + if (prop.NameEquals("allow_partial_result"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - allowPartialResult = property.Value.GetBoolean(); + allowPartialResult = prop.Value.GetBoolean(); continue; } - if (property.NameEquals("include_contexts"u8)) + if (prop.NameEquals("environment"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - includeContexts = array; + environment = prop.Value.GetString(); continue; } - if (property.NameEquals("environment"u8)) + if (prop.NameEquals("index_name"u8)) { - environment = property.Value.GetString(); + indexName = prop.Value.GetString(); continue; } - if (property.NameEquals("index_name"u8)) + if (prop.NameEquals("authentication"u8)) { - indexName = property.Value.GetString(); + authentication = DataSourceAuthentication.DeserializeDataSourceAuthentication(prop.Value, options); continue; } - if (property.NameEquals("authentication"u8)) + if (prop.NameEquals("fields_mapping"u8)) { - authentication = DataSourceAuthentication.DeserializeDataSourceAuthentication(property.Value, options); + fieldMappings = DataSourceFieldMappings.DeserializeDataSourceFieldMappings(prop.Value, options); continue; } - if (property.NameEquals("embedding_dependency"u8)) + if (prop.NameEquals("embedding_dependency"u8)) { - embeddingDependency = DataSourceVectorizer.DeserializeDataSourceVectorizer(property.Value, options); + vectorizationSource = DataSourceVectorizer.DeserializeDataSourceVectorizer(prop.Value, options); continue; } - if (property.NameEquals("fields_mapping"u8)) + if (prop.NameEquals("include_contexts"u8)) { - fieldsMapping = DataSourceFieldMappings.DeserializeDataSourceFieldMappings(property.Value, options); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(item.GetString()); + } + } + internalIncludeContexts = array; continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new InternalPineconeChatDataSourceParameters( topNDocuments, inScope, strictness, maxSearchQueries, allowPartialResult, - includeContexts ?? new ChangeTrackingList(), environment, indexName, authentication, - embeddingDependency, - fieldsMapping, - serializedAdditionalRawData); + fieldMappings, + vectorizationSource, + internalIncludeContexts, + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -264,15 +275,16 @@ BinaryData IPersistableModel.Write(Mod } } - InternalPineconeChatDataSourceParameters IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + InternalPineconeChatDataSourceParameters IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + protected virtual InternalPineconeChatDataSourceParameters PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeInternalPineconeChatDataSourceParameters(document.RootElement, options); } default: @@ -282,18 +294,20 @@ InternalPineconeChatDataSourceParameters IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static InternalPineconeChatDataSourceParameters FromResponse(PipelineResponse response) + public static implicit operator BinaryContent(InternalPineconeChatDataSourceParameters internalPineconeChatDataSourceParameters) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalPineconeChatDataSourceParameters(document.RootElement); + if (internalPineconeChatDataSourceParameters == null) + { + return null; + } + return BinaryContent.Create(internalPineconeChatDataSourceParameters, ModelSerializationExtensions.WireOptions); } - /// Convert into a . - internal virtual BinaryContent ToBinaryContent() + public static explicit operator InternalPineconeChatDataSourceParameters(ClientResult result) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeInternalPineconeChatDataSourceParameters(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalPineconeChatDataSourceParameters.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalPineconeChatDataSourceParameters.cs new file mode 100644 index 000000000..06dec9c44 --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalPineconeChatDataSourceParameters.cs @@ -0,0 +1,68 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.AI.OpenAI; + +namespace Azure.AI.OpenAI.Chat +{ + internal partial class InternalPineconeChatDataSourceParameters + { + /// Keeps track of any properties unknown to the library. + private protected IDictionary _additionalBinaryDataProperties; + + public InternalPineconeChatDataSourceParameters(string environment, string indexName, DataSourceAuthentication authentication, DataSourceFieldMappings fieldMappings, DataSourceVectorizer vectorizationSource) + { + Argument.AssertNotNull(environment, nameof(environment)); + Argument.AssertNotNull(indexName, nameof(indexName)); + Argument.AssertNotNull(authentication, nameof(authentication)); + Argument.AssertNotNull(fieldMappings, nameof(fieldMappings)); + Argument.AssertNotNull(vectorizationSource, nameof(vectorizationSource)); + + Environment = environment; + IndexName = indexName; + Authentication = authentication; + FieldMappings = fieldMappings; + VectorizationSource = vectorizationSource; + _internalIncludeContexts = new ChangeTrackingList(); + } + + internal InternalPineconeChatDataSourceParameters(int? topNDocuments, bool? inScope, int? strictness, int? maxSearchQueries, bool? allowPartialResult, string environment, string indexName, DataSourceAuthentication authentication, DataSourceFieldMappings fieldMappings, DataSourceVectorizer vectorizationSource, IList internalIncludeContexts, IDictionary additionalBinaryDataProperties) + { + TopNDocuments = topNDocuments; + InScope = inScope; + Strictness = strictness; + MaxSearchQueries = maxSearchQueries; + AllowPartialResult = allowPartialResult; + Environment = environment; + IndexName = indexName; + Authentication = authentication; + FieldMappings = fieldMappings; + VectorizationSource = vectorizationSource; + _internalIncludeContexts = internalIncludeContexts; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + public int? TopNDocuments { get; set; } + + public bool? InScope { get; set; } + + public int? Strictness { get; set; } + + public int? MaxSearchQueries { get; set; } + + public bool? AllowPartialResult { get; set; } + + public string Environment { get; set; } + + public string IndexName { get; set; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalUnknownAzureChatDataSource.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalUnknownAzureChatDataSource.Serialization.cs similarity index 52% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalUnknownAzureChatDataSource.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalUnknownAzureChatDataSource.Serialization.cs index d1e1ef815..a07d42685 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalUnknownAzureChatDataSource.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalUnknownAzureChatDataSource.Serialization.cs @@ -3,15 +3,19 @@ #nullable disable using System; -using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.AI.OpenAI; namespace Azure.AI.OpenAI.Chat { internal partial class InternalUnknownAzureChatDataSource : IJsonModel { + internal InternalUnknownAzureChatDataSource() + { + } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -19,63 +23,57 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOp writer.WriteEndObject(); } - /// The JSON writer. - /// The client options for reading and writing models. protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(ChatDataSource)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); } - ChatDataSource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + ChatDataSource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + protected override ChatDataSource JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(ChatDataSource)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeChatDataSource(document.RootElement, options); } - internal static InternalUnknownAzureChatDataSource DeserializeInternalUnknownAzureChatDataSource(JsonElement element, ModelReaderWriterOptions options = null) + internal static InternalUnknownAzureChatDataSource DeserializeInternalUnknownAzureChatDataSource(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - string type = "Unknown"; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + string @type = "unknown"; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("type"u8)) + if (prop.NameEquals("type"u8)) { - type = property.Value.GetString(); + @type = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new InternalUnknownAzureChatDataSource(type, serializedAdditionalRawData); + return new InternalUnknownAzureChatDataSource(@type, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -85,15 +83,16 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions opti } } - ChatDataSource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + ChatDataSource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + protected override ChatDataSource PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeChatDataSource(document.RootElement, options); } default: @@ -102,19 +101,5 @@ ChatDataSource IPersistableModel.Create(BinaryData data, ModelRe } string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static new InternalUnknownAzureChatDataSource FromResponse(PipelineResponse response) - { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalUnknownAzureChatDataSource(document.RootElement); - } - - /// Convert into a . - internal override BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalUnknownAzureChatDataSource.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalUnknownAzureChatDataSource.cs new file mode 100644 index 000000000..4b8afdf9d --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalUnknownAzureChatDataSource.cs @@ -0,0 +1,16 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Chat +{ + internal partial class InternalUnknownAzureChatDataSource : ChatDataSource + { + internal InternalUnknownAzureChatDataSource(string @type, IDictionary additionalBinaryDataProperties) : base(@type ?? "unknown", additionalBinaryDataProperties) + { + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalUnknownAzureChatDataSourceAuthenticationOptions.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalUnknownAzureChatDataSourceAuthenticationOptions.Serialization.cs similarity index 56% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalUnknownAzureChatDataSourceAuthenticationOptions.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalUnknownAzureChatDataSourceAuthenticationOptions.Serialization.cs index 368b24719..21aaab7d4 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalUnknownAzureChatDataSourceAuthenticationOptions.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalUnknownAzureChatDataSourceAuthenticationOptions.Serialization.cs @@ -3,15 +3,19 @@ #nullable disable using System; -using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.AI.OpenAI; namespace Azure.AI.OpenAI.Chat { internal partial class InternalUnknownAzureChatDataSourceAuthenticationOptions : IJsonModel { + internal InternalUnknownAzureChatDataSourceAuthenticationOptions() + { + } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -19,63 +23,57 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRead writer.WriteEndObject(); } - /// The JSON writer. - /// The client options for reading and writing models. protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DataSourceAuthentication)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); } - DataSourceAuthentication IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + DataSourceAuthentication IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + protected override DataSourceAuthentication JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DataSourceAuthentication)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataSourceAuthentication(document.RootElement, options); } - internal static InternalUnknownAzureChatDataSourceAuthenticationOptions DeserializeInternalUnknownAzureChatDataSourceAuthenticationOptions(JsonElement element, ModelReaderWriterOptions options = null) + internal static InternalUnknownAzureChatDataSourceAuthenticationOptions DeserializeInternalUnknownAzureChatDataSourceAuthenticationOptions(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - string type = "Unknown"; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + string @type = "unknown"; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("type"u8)) + if (prop.NameEquals("type"u8)) { - type = property.Value.GetString(); + @type = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new InternalUnknownAzureChatDataSourceAuthenticationOptions(type, serializedAdditionalRawData); + return new InternalUnknownAzureChatDataSourceAuthenticationOptions(@type, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -85,15 +83,16 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOp } } - DataSourceAuthentication IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + DataSourceAuthentication IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + protected override DataSourceAuthentication PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeDataSourceAuthentication(document.RootElement, options); } default: @@ -102,19 +101,5 @@ DataSourceAuthentication IPersistableModel.Create(Bina } string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static new InternalUnknownAzureChatDataSourceAuthenticationOptions FromResponse(PipelineResponse response) - { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalUnknownAzureChatDataSourceAuthenticationOptions(document.RootElement); - } - - /// Convert into a . - internal override BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalUnknownAzureChatDataSourceAuthenticationOptions.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalUnknownAzureChatDataSourceAuthenticationOptions.cs new file mode 100644 index 000000000..fefb20709 --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalUnknownAzureChatDataSourceAuthenticationOptions.cs @@ -0,0 +1,16 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Chat +{ + internal partial class InternalUnknownAzureChatDataSourceAuthenticationOptions : DataSourceAuthentication + { + internal InternalUnknownAzureChatDataSourceAuthenticationOptions(string @type, IDictionary additionalBinaryDataProperties) : base(@type ?? "unknown", additionalBinaryDataProperties) + { + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalUnknownAzureChatDataSourceVectorizationSource.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalUnknownAzureChatDataSourceVectorizationSource.Serialization.cs similarity index 55% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalUnknownAzureChatDataSourceVectorizationSource.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalUnknownAzureChatDataSourceVectorizationSource.Serialization.cs index 164dcbe06..cb3a779a6 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/InternalUnknownAzureChatDataSourceVectorizationSource.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalUnknownAzureChatDataSourceVectorizationSource.Serialization.cs @@ -3,15 +3,19 @@ #nullable disable using System; -using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure.AI.OpenAI; namespace Azure.AI.OpenAI.Chat { internal partial class InternalUnknownAzureChatDataSourceVectorizationSource : IJsonModel { + internal InternalUnknownAzureChatDataSourceVectorizationSource() + { + } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -19,63 +23,57 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWr writer.WriteEndObject(); } - /// The JSON writer. - /// The client options for reading and writing models. protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DataSourceVectorizer)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); } - DataSourceVectorizer IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + DataSourceVectorizer IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + protected override DataSourceVectorizer JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(DataSourceVectorizer)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeDataSourceVectorizer(document.RootElement, options); } - internal static InternalUnknownAzureChatDataSourceVectorizationSource DeserializeInternalUnknownAzureChatDataSourceVectorizationSource(JsonElement element, ModelReaderWriterOptions options = null) + internal static InternalUnknownAzureChatDataSourceVectorizationSource DeserializeInternalUnknownAzureChatDataSourceVectorizationSource(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - string type = "Unknown"; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + string @type = "unknown"; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("type"u8)) + if (prop.NameEquals("type"u8)) { - type = property.Value.GetString(); + @type = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new InternalUnknownAzureChatDataSourceVectorizationSource(type, serializedAdditionalRawData); + return new InternalUnknownAzureChatDataSourceVectorizationSource(@type, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -85,15 +83,16 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOption } } - DataSourceVectorizer IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + DataSourceVectorizer IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + protected override DataSourceVectorizer PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeDataSourceVectorizer(document.RootElement, options); } default: @@ -102,19 +101,5 @@ DataSourceVectorizer IPersistableModel.Create(BinaryData d } string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static new InternalUnknownAzureChatDataSourceVectorizationSource FromResponse(PipelineResponse response) - { - using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalUnknownAzureChatDataSourceVectorizationSource(document.RootElement); - } - - /// Convert into a . - internal override BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalUnknownAzureChatDataSourceVectorizationSource.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalUnknownAzureChatDataSourceVectorizationSource.cs new file mode 100644 index 000000000..2f85fedc7 --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/InternalUnknownAzureChatDataSourceVectorizationSource.cs @@ -0,0 +1,16 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Chat +{ + internal partial class InternalUnknownAzureChatDataSourceVectorizationSource : DataSourceVectorizer + { + internal InternalUnknownAzureChatDataSourceVectorizationSource(string @type, IDictionary additionalBinaryDataProperties) : base(@type ?? "unknown", additionalBinaryDataProperties) + { + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/MongoDBChatDataSource.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/MongoDBChatDataSource.Serialization.cs new file mode 100644 index 000000000..e11ef4f71 --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/MongoDBChatDataSource.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.OpenAI; + +namespace Azure.AI.OpenAI.Chat +{ + /// + public partial class MongoDBChatDataSource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MongoDBChatDataSource)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (_additionalBinaryDataProperties?.ContainsKey("parameters") != true) + { + writer.WritePropertyName("parameters"u8); + writer.WriteObjectValue(InternalParameters, options); + } + } + + MongoDBChatDataSource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (MongoDBChatDataSource)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override ChatDataSource JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MongoDBChatDataSource)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMongoDBChatDataSource(document.RootElement, options); + } + + internal static MongoDBChatDataSource DeserializeMongoDBChatDataSource(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string @type = "mongo_db"; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + InternalMongoDBChatDataSourceParameters internalParameters = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("parameters"u8)) + { + internalParameters = InternalMongoDBChatDataSourceParameters.DeserializeInternalMongoDBChatDataSourceParameters(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new MongoDBChatDataSource(@type, additionalBinaryDataProperties, internalParameters); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MongoDBChatDataSource)} does not support writing '{options.Format}' format."); + } + } + + MongoDBChatDataSource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (MongoDBChatDataSource)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override ChatDataSource PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializeMongoDBChatDataSource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MongoDBChatDataSource)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + public static implicit operator BinaryContent(MongoDBChatDataSource mongoDBChatDataSource) + { + if (mongoDBChatDataSource == null) + { + return null; + } + return BinaryContent.Create(mongoDBChatDataSource, ModelSerializationExtensions.WireOptions); + } + + /// The to deserialize the from. + public static explicit operator MongoDBChatDataSource(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeMongoDBChatDataSource(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/MongoDBChatDataSource.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/MongoDBChatDataSource.cs similarity index 80% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/MongoDBChatDataSource.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/MongoDBChatDataSource.cs index 9a483cc28..ff06412c6 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/MongoDBChatDataSource.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/MongoDBChatDataSource.cs @@ -2,9 +2,6 @@ #nullable disable -using System; -using System.Collections.Generic; - namespace Azure.AI.OpenAI.Chat { /// The MongoDBChatDataSource. diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/PineconeChatDataSource.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/PineconeChatDataSource.Serialization.cs new file mode 100644 index 000000000..2c7145e34 --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/PineconeChatDataSource.Serialization.cs @@ -0,0 +1,139 @@ +// + +#nullable disable + +using System; +using System.ClientModel; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.AI.OpenAI; + +namespace Azure.AI.OpenAI.Chat +{ + /// + public partial class PineconeChatDataSource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PineconeChatDataSource)} does not support writing '{format}' format."); + } + base.JsonModelWriteCore(writer, options); + if (_additionalBinaryDataProperties?.ContainsKey("parameters") != true) + { + writer.WritePropertyName("parameters"u8); + writer.WriteObjectValue(InternalParameters, options); + } + } + + PineconeChatDataSource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (PineconeChatDataSource)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override ChatDataSource JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PineconeChatDataSource)} does not support reading '{format}' format."); + } + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePineconeChatDataSource(document.RootElement, options); + } + + internal static PineconeChatDataSource DeserializePineconeChatDataSource(JsonElement element, ModelReaderWriterOptions options) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string @type = "pinecone"; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + InternalPineconeChatDataSourceParameters internalParameters = default; + foreach (var prop in element.EnumerateObject()) + { + if (prop.NameEquals("type"u8)) + { + @type = prop.Value.GetString(); + continue; + } + if (prop.NameEquals("parameters"u8)) + { + internalParameters = InternalPineconeChatDataSourceParameters.DeserializeInternalPineconeChatDataSourceParameters(prop.Value, options); + continue; + } + if (options.Format != "W") + { + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); + } + } + return new PineconeChatDataSource(@type, additionalBinaryDataProperties, internalParameters); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(PineconeChatDataSource)} does not support writing '{options.Format}' format."); + } + } + + PineconeChatDataSource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (PineconeChatDataSource)PersistableModelCreateCore(data, options); + + /// The data to parse. + /// The client options for reading and writing models. + protected override ChatDataSource PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + switch (format) + { + case "J": + using (JsonDocument document = JsonDocument.Parse(data)) + { + return DeserializePineconeChatDataSource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PineconeChatDataSource)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + public static implicit operator BinaryContent(PineconeChatDataSource pineconeChatDataSource) + { + if (pineconeChatDataSource == null) + { + return null; + } + return BinaryContent.Create(pineconeChatDataSource, ModelSerializationExtensions.WireOptions); + } + + /// The to deserialize the from. + public static explicit operator PineconeChatDataSource(ClientResult result) + { + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializePineconeChatDataSource(document.RootElement, ModelSerializationExtensions.WireOptions); + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/PineconeChatDataSource.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/PineconeChatDataSource.cs similarity index 81% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/PineconeChatDataSource.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/PineconeChatDataSource.cs index 213c4559c..ab9f57629 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/PineconeChatDataSource.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/PineconeChatDataSource.cs @@ -2,9 +2,6 @@ #nullable disable -using System; -using System.Collections.Generic; - namespace Azure.AI.OpenAI.Chat { /// The PineconeChatDataSource. diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/RequestContentFilterResult.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/RequestContentFilterResult.Serialization.cs similarity index 52% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/RequestContentFilterResult.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/RequestContentFilterResult.Serialization.cs index d497337e1..079ba11a4 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/RequestContentFilterResult.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/RequestContentFilterResult.Serialization.cs @@ -10,6 +10,7 @@ namespace Azure.AI.OpenAI { + /// public partial class RequestContentFilterResult : IJsonModel { void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) @@ -23,25 +24,24 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRe /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(RequestContentFilterResult)} does not support writing '{format}' format."); } - - if (SerializedAdditionalRawData?.ContainsKey("prompt_index") != true && Optional.IsDefined(PromptIndex)) + if (Optional.IsDefined(PromptIndex) && _additionalBinaryDataProperties?.ContainsKey("prompt_index") != true) { writer.WritePropertyName("prompt_index"u8); writer.WriteNumberValue(PromptIndex.Value); } - if (SerializedAdditionalRawData?.ContainsKey("content_filter_results") != true && Optional.IsDefined(InternalResults)) + if (Optional.IsDefined(InternalResults) && _additionalBinaryDataProperties?.ContainsKey("content_filter_results") != true) { writer.WritePropertyName("content_filter_results"u8); writer.WriteObjectValue(InternalResults, options); } - if (SerializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in SerializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { @@ -49,7 +49,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else using (JsonDocument document = JsonDocument.Parse(item.Value)) { @@ -60,64 +60,64 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - RequestContentFilterResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + RequestContentFilterResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual RequestContentFilterResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(RequestContentFilterResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeRequestContentFilterResult(document.RootElement, options); } - internal static RequestContentFilterResult DeserializeRequestContentFilterResult(JsonElement element, ModelReaderWriterOptions options = null) + internal static RequestContentFilterResult DeserializeRequestContentFilterResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } int? promptIndex = default; - InternalAzureContentFilterResultForPromptContentFilterResults contentFilterResults = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + InternalAzureContentFilterResultForPromptContentFilterResults internalResults = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("prompt_index"u8)) + if (prop.NameEquals("prompt_index"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - promptIndex = property.Value.GetInt32(); + promptIndex = prop.Value.GetInt32(); continue; } - if (property.NameEquals("content_filter_results"u8)) + if (prop.NameEquals("content_filter_results"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - contentFilterResults = InternalAzureContentFilterResultForPromptContentFilterResults.DeserializeInternalAzureContentFilterResultForPromptContentFilterResults(property.Value, options); + internalResults = InternalAzureContentFilterResultForPromptContentFilterResults.DeserializeInternalAzureContentFilterResultForPromptContentFilterResults(prop.Value, options); continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new RequestContentFilterResult(promptIndex, contentFilterResults, serializedAdditionalRawData); + return new RequestContentFilterResult(promptIndex, internalResults, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -127,15 +127,18 @@ BinaryData IPersistableModel.Write(ModelReaderWriter } } - RequestContentFilterResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + RequestContentFilterResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual RequestContentFilterResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeRequestContentFilterResult(document.RootElement, options); } default: @@ -145,18 +148,22 @@ RequestContentFilterResult IPersistableModel.Create( string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static RequestContentFilterResult FromResponse(PipelineResponse response) + /// The to serialize into . + public static implicit operator BinaryContent(RequestContentFilterResult requestContentFilterResult) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeRequestContentFilterResult(document.RootElement); + if (requestContentFilterResult == null) + { + return null; + } + return BinaryContent.Create(requestContentFilterResult, ModelSerializationExtensions.WireOptions); } - /// Convert into a . - internal virtual BinaryContent ToBinaryContent() + /// The to deserialize the from. + public static explicit operator RequestContentFilterResult(ClientResult result) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeRequestContentFilterResult(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/RequestContentFilterResult.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/RequestContentFilterResult.cs new file mode 100644 index 000000000..6910e83fd --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/RequestContentFilterResult.cs @@ -0,0 +1,33 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI +{ + /// A content filter result associated with a single input prompt item into a generative AI system. + public partial class RequestContentFilterResult + { + /// Keeps track of any properties unknown to the library. + private protected IDictionary _additionalBinaryDataProperties; + + internal RequestContentFilterResult() + { + } + + internal RequestContentFilterResult(int? promptIndex, InternalAzureContentFilterResultForPromptContentFilterResults internalResults, IDictionary additionalBinaryDataProperties) + { + PromptIndex = promptIndex; + InternalResults = internalResults; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/RequestImageContentFilterResult.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/RequestImageContentFilterResult.Serialization.cs similarity index 54% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/RequestImageContentFilterResult.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/RequestImageContentFilterResult.Serialization.cs index 365cc7c87..844fd9b42 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/RequestImageContentFilterResult.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/RequestImageContentFilterResult.Serialization.cs @@ -10,8 +10,13 @@ namespace Azure.AI.OpenAI { + /// public partial class RequestImageContentFilterResult : IJsonModel { + internal RequestImageContentFilterResult() + { + } + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -23,142 +28,141 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mo /// The client options for reading and writing models. protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(RequestImageContentFilterResult)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); - if (SerializedAdditionalRawData?.ContainsKey("profanity") != true && Optional.IsDefined(Profanity)) + if (Optional.IsDefined(Profanity) && _additionalBinaryDataProperties?.ContainsKey("profanity") != true) { writer.WritePropertyName("profanity"u8); writer.WriteObjectValue(Profanity, options); } - if (SerializedAdditionalRawData?.ContainsKey("custom_blocklists") != true && Optional.IsDefined(CustomBlocklists)) + if (Optional.IsDefined(CustomBlocklists) && _additionalBinaryDataProperties?.ContainsKey("custom_blocklists") != true) { writer.WritePropertyName("custom_blocklists"u8); writer.WriteObjectValue(CustomBlocklists, options); } - if (SerializedAdditionalRawData?.ContainsKey("jailbreak") != true) + if (_additionalBinaryDataProperties?.ContainsKey("jailbreak") != true) { writer.WritePropertyName("jailbreak"u8); writer.WriteObjectValue(Jailbreak, options); } } - RequestImageContentFilterResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + RequestImageContentFilterResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (RequestImageContentFilterResult)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected override ResponseImageContentFilterResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(RequestImageContentFilterResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeRequestImageContentFilterResult(document.RootElement, options); } - internal static RequestImageContentFilterResult DeserializeRequestImageContentFilterResult(JsonElement element, ModelReaderWriterOptions options = null) + internal static RequestImageContentFilterResult DeserializeRequestImageContentFilterResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - ContentFilterDetectionResult profanity = default; - ContentFilterBlocklistResult customBlocklists = default; - ContentFilterDetectionResult jailbreak = default; ContentFilterSeverityResult sexual = default; ContentFilterSeverityResult violence = default; ContentFilterSeverityResult hate = default; ContentFilterSeverityResult selfHarm = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + ContentFilterDetectionResult profanity = default; + ContentFilterBlocklistResult customBlocklists = default; + ContentFilterDetectionResult jailbreak = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("profanity"u8)) + if (prop.NameEquals("sexual"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - profanity = ContentFilterDetectionResult.DeserializeContentFilterDetectionResult(property.Value, options); + sexual = ContentFilterSeverityResult.DeserializeContentFilterSeverityResult(prop.Value, options); continue; } - if (property.NameEquals("custom_blocklists"u8)) + if (prop.NameEquals("violence"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - customBlocklists = ContentFilterBlocklistResult.DeserializeContentFilterBlocklistResult(property.Value, options); + violence = ContentFilterSeverityResult.DeserializeContentFilterSeverityResult(prop.Value, options); continue; } - if (property.NameEquals("jailbreak"u8)) + if (prop.NameEquals("hate"u8)) { - jailbreak = ContentFilterDetectionResult.DeserializeContentFilterDetectionResult(property.Value, options); - continue; - } - if (property.NameEquals("sexual"u8)) - { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - sexual = ContentFilterSeverityResult.DeserializeContentFilterSeverityResult(property.Value, options); + hate = ContentFilterSeverityResult.DeserializeContentFilterSeverityResult(prop.Value, options); continue; } - if (property.NameEquals("violence"u8)) + if (prop.NameEquals("self_harm"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - violence = ContentFilterSeverityResult.DeserializeContentFilterSeverityResult(property.Value, options); + selfHarm = ContentFilterSeverityResult.DeserializeContentFilterSeverityResult(prop.Value, options); continue; } - if (property.NameEquals("hate"u8)) + if (prop.NameEquals("profanity"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - hate = ContentFilterSeverityResult.DeserializeContentFilterSeverityResult(property.Value, options); + profanity = ContentFilterDetectionResult.DeserializeContentFilterDetectionResult(prop.Value, options); continue; } - if (property.NameEquals("self_harm"u8)) + if (prop.NameEquals("custom_blocklists"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - selfHarm = ContentFilterSeverityResult.DeserializeContentFilterSeverityResult(property.Value, options); + customBlocklists = ContentFilterBlocklistResult.DeserializeContentFilterBlocklistResult(prop.Value, options); + continue; + } + if (prop.NameEquals("jailbreak"u8)) + { + jailbreak = ContentFilterDetectionResult.DeserializeContentFilterDetectionResult(prop.Value, options); continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new RequestImageContentFilterResult( sexual, violence, hate, selfHarm, - serializedAdditionalRawData, + additionalBinaryDataProperties, profanity, customBlocklists, jailbreak); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected override BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -168,15 +172,18 @@ BinaryData IPersistableModel.Write(ModelReaderW } } - RequestImageContentFilterResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + RequestImageContentFilterResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (RequestImageContentFilterResult)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected override ResponseImageContentFilterResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeRequestImageContentFilterResult(document.RootElement, options); } default: @@ -186,18 +193,22 @@ RequestImageContentFilterResult IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static new RequestImageContentFilterResult FromResponse(PipelineResponse response) + /// The to serialize into . + public static implicit operator BinaryContent(RequestImageContentFilterResult requestImageContentFilterResult) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeRequestImageContentFilterResult(document.RootElement); + if (requestImageContentFilterResult == null) + { + return null; + } + return BinaryContent.Create(requestImageContentFilterResult, ModelSerializationExtensions.WireOptions); } - /// Convert into a . - internal override BinaryContent ToBinaryContent() + /// The to deserialize the from. + public static explicit operator RequestImageContentFilterResult(ClientResult result) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeRequestImageContentFilterResult(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/RequestImageContentFilterResult.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/RequestImageContentFilterResult.cs new file mode 100644 index 000000000..7fa092e11 --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/RequestImageContentFilterResult.cs @@ -0,0 +1,41 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI +{ + /// A content filter result for an image generation operation's input request content. + public partial class RequestImageContentFilterResult : ResponseImageContentFilterResult + { + internal RequestImageContentFilterResult(ContentFilterDetectionResult jailbreak) + { + Jailbreak = jailbreak; + } + + internal RequestImageContentFilterResult(ContentFilterSeverityResult sexual, ContentFilterSeverityResult violence, ContentFilterSeverityResult hate, ContentFilterSeverityResult selfHarm, IDictionary additionalBinaryDataProperties, ContentFilterDetectionResult profanity, ContentFilterBlocklistResult customBlocklists, ContentFilterDetectionResult jailbreak) : base(sexual, violence, hate, selfHarm, additionalBinaryDataProperties) + { + Profanity = profanity; + CustomBlocklists = customBlocklists; + Jailbreak = jailbreak; + } + + /// + /// A detection result that identifies whether crude, vulgar, or otherwise objection language is present in the + /// content. + /// + public ContentFilterDetectionResult Profanity { get; } + + /// A collection of binary filtering outcomes for configured custom blocklists. + public ContentFilterBlocklistResult CustomBlocklists { get; } + + /// + /// A detection result that describes user prompt injection attacks, where malicious users deliberately exploit + /// system vulnerabilities to elicit unauthorized behavior from the LLM. This could lead to inappropriate content + /// generation or violations of system-imposed restrictions. + /// + public ContentFilterDetectionResult Jailbreak { get; } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ResponseContentFilterResult.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ResponseContentFilterResult.Serialization.cs similarity index 57% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ResponseContentFilterResult.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ResponseContentFilterResult.Serialization.cs index a45212164..c33d4abe2 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ResponseContentFilterResult.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ResponseContentFilterResult.Serialization.cs @@ -10,6 +10,7 @@ namespace Azure.AI.OpenAI { + /// public partial class ResponseContentFilterResult : IJsonModel { void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) @@ -23,65 +24,64 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelR /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(ResponseContentFilterResult)} does not support writing '{format}' format."); } - - if (SerializedAdditionalRawData?.ContainsKey("sexual") != true && Optional.IsDefined(Sexual)) + if (Optional.IsDefined(Sexual) && _additionalBinaryDataProperties?.ContainsKey("sexual") != true) { writer.WritePropertyName("sexual"u8); writer.WriteObjectValue(Sexual, options); } - if (SerializedAdditionalRawData?.ContainsKey("hate") != true && Optional.IsDefined(Hate)) + if (Optional.IsDefined(Hate) && _additionalBinaryDataProperties?.ContainsKey("hate") != true) { writer.WritePropertyName("hate"u8); writer.WriteObjectValue(Hate, options); } - if (SerializedAdditionalRawData?.ContainsKey("violence") != true && Optional.IsDefined(Violence)) + if (Optional.IsDefined(Violence) && _additionalBinaryDataProperties?.ContainsKey("violence") != true) { writer.WritePropertyName("violence"u8); writer.WriteObjectValue(Violence, options); } - if (SerializedAdditionalRawData?.ContainsKey("self_harm") != true && Optional.IsDefined(SelfHarm)) + if (Optional.IsDefined(SelfHarm) && _additionalBinaryDataProperties?.ContainsKey("self_harm") != true) { writer.WritePropertyName("self_harm"u8); writer.WriteObjectValue(SelfHarm, options); } - if (SerializedAdditionalRawData?.ContainsKey("profanity") != true && Optional.IsDefined(Profanity)) + if (Optional.IsDefined(Profanity) && _additionalBinaryDataProperties?.ContainsKey("profanity") != true) { writer.WritePropertyName("profanity"u8); writer.WriteObjectValue(Profanity, options); } - if (SerializedAdditionalRawData?.ContainsKey("custom_blocklists") != true && Optional.IsDefined(CustomBlocklists)) + if (Optional.IsDefined(CustomBlocklists) && _additionalBinaryDataProperties?.ContainsKey("custom_blocklists") != true) { writer.WritePropertyName("custom_blocklists"u8); writer.WriteObjectValue(CustomBlocklists, options); } - if (SerializedAdditionalRawData?.ContainsKey("error") != true && Optional.IsDefined(Error)) - { - writer.WritePropertyName("error"u8); - writer.WriteObjectValue(Error, options); - } - if (SerializedAdditionalRawData?.ContainsKey("protected_material_text") != true && Optional.IsDefined(ProtectedMaterialText)) + if (Optional.IsDefined(ProtectedMaterialText) && _additionalBinaryDataProperties?.ContainsKey("protected_material_text") != true) { writer.WritePropertyName("protected_material_text"u8); writer.WriteObjectValue(ProtectedMaterialText, options); } - if (SerializedAdditionalRawData?.ContainsKey("protected_material_code") != true && Optional.IsDefined(ProtectedMaterialCode)) + if (Optional.IsDefined(ProtectedMaterialCode) && _additionalBinaryDataProperties?.ContainsKey("protected_material_code") != true) { writer.WritePropertyName("protected_material_code"u8); writer.WriteObjectValue(ProtectedMaterialCode, options); } - if (SerializedAdditionalRawData?.ContainsKey("ungrounded_material") != true && Optional.IsDefined(UngroundedMaterial)) + if (Optional.IsDefined(Error) && _additionalBinaryDataProperties?.ContainsKey("error") != true) + { + writer.WritePropertyName("error"u8); + writer.WriteObjectValue(Error, options); + } + if (Optional.IsDefined(UngroundedMaterial) && _additionalBinaryDataProperties?.ContainsKey("ungrounded_material") != true) { writer.WritePropertyName("ungrounded_material"u8); writer.WriteObjectValue(UngroundedMaterial, options); } - if (SerializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in SerializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { @@ -89,7 +89,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else using (JsonDocument document = JsonDocument.Parse(item.Value)) { @@ -100,22 +100,23 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - ResponseContentFilterResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + ResponseContentFilterResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ResponseContentFilterResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(ResponseContentFilterResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeResponseContentFilterResult(document.RootElement, options); } - internal static ResponseContentFilterResult DeserializeResponseContentFilterResult(JsonElement element, ModelReaderWriterOptions options = null) + internal static ResponseContentFilterResult DeserializeResponseContentFilterResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -126,111 +127,108 @@ internal static ResponseContentFilterResult DeserializeResponseContentFilterResu ContentFilterSeverityResult selfHarm = default; ContentFilterDetectionResult profanity = default; ContentFilterBlocklistResult customBlocklists = default; - InternalAzureContentFilterResultForChoiceError error = default; ContentFilterDetectionResult protectedMaterialText = default; ContentFilterProtectedMaterialResult protectedMaterialCode = default; + InternalAzureContentFilterResultForChoiceError error = default; ContentFilterTextSpanResult ungroundedMaterial = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("sexual"u8)) + if (prop.NameEquals("sexual"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - sexual = ContentFilterSeverityResult.DeserializeContentFilterSeverityResult(property.Value, options); + sexual = ContentFilterSeverityResult.DeserializeContentFilterSeverityResult(prop.Value, options); continue; } - if (property.NameEquals("hate"u8)) + if (prop.NameEquals("hate"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - hate = ContentFilterSeverityResult.DeserializeContentFilterSeverityResult(property.Value, options); + hate = ContentFilterSeverityResult.DeserializeContentFilterSeverityResult(prop.Value, options); continue; } - if (property.NameEquals("violence"u8)) + if (prop.NameEquals("violence"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - violence = ContentFilterSeverityResult.DeserializeContentFilterSeverityResult(property.Value, options); + violence = ContentFilterSeverityResult.DeserializeContentFilterSeverityResult(prop.Value, options); continue; } - if (property.NameEquals("self_harm"u8)) + if (prop.NameEquals("self_harm"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - selfHarm = ContentFilterSeverityResult.DeserializeContentFilterSeverityResult(property.Value, options); + selfHarm = ContentFilterSeverityResult.DeserializeContentFilterSeverityResult(prop.Value, options); continue; } - if (property.NameEquals("profanity"u8)) + if (prop.NameEquals("profanity"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - profanity = ContentFilterDetectionResult.DeserializeContentFilterDetectionResult(property.Value, options); + profanity = ContentFilterDetectionResult.DeserializeContentFilterDetectionResult(prop.Value, options); continue; } - if (property.NameEquals("custom_blocklists"u8)) + if (prop.NameEquals("custom_blocklists"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - customBlocklists = ContentFilterBlocklistResult.DeserializeContentFilterBlocklistResult(property.Value, options); + customBlocklists = ContentFilterBlocklistResult.DeserializeContentFilterBlocklistResult(prop.Value, options); continue; } - if (property.NameEquals("error"u8)) + if (prop.NameEquals("protected_material_text"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - error = InternalAzureContentFilterResultForChoiceError.DeserializeInternalAzureContentFilterResultForChoiceError(property.Value, options); + protectedMaterialText = ContentFilterDetectionResult.DeserializeContentFilterDetectionResult(prop.Value, options); continue; } - if (property.NameEquals("protected_material_text"u8)) + if (prop.NameEquals("protected_material_code"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - protectedMaterialText = ContentFilterDetectionResult.DeserializeContentFilterDetectionResult(property.Value, options); + protectedMaterialCode = ContentFilterProtectedMaterialResult.DeserializeContentFilterProtectedMaterialResult(prop.Value, options); continue; } - if (property.NameEquals("protected_material_code"u8)) + if (prop.NameEquals("error"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - protectedMaterialCode = ContentFilterProtectedMaterialResult.DeserializeContentFilterProtectedMaterialResult(property.Value, options); + error = InternalAzureContentFilterResultForChoiceError.DeserializeInternalAzureContentFilterResultForChoiceError(prop.Value, options); continue; } - if (property.NameEquals("ungrounded_material"u8)) + if (prop.NameEquals("ungrounded_material"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - ungroundedMaterial = ContentFilterTextSpanResult.DeserializeContentFilterTextSpanResult(property.Value, options); + ungroundedMaterial = ContentFilterTextSpanResult.DeserializeContentFilterTextSpanResult(prop.Value, options); continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new ResponseContentFilterResult( sexual, hate, @@ -238,17 +236,19 @@ internal static ResponseContentFilterResult DeserializeResponseContentFilterResu selfHarm, profanity, customBlocklists, - error, protectedMaterialText, protectedMaterialCode, + error, ungroundedMaterial, - serializedAdditionalRawData); + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -258,15 +258,18 @@ BinaryData IPersistableModel.Write(ModelReaderWrite } } - ResponseContentFilterResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + ResponseContentFilterResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ResponseContentFilterResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeResponseContentFilterResult(document.RootElement, options); } default: @@ -276,18 +279,22 @@ ResponseContentFilterResult IPersistableModel.Creat string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static ResponseContentFilterResult FromResponse(PipelineResponse response) + /// The to serialize into . + public static implicit operator BinaryContent(ResponseContentFilterResult responseContentFilterResult) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeResponseContentFilterResult(document.RootElement); + if (responseContentFilterResult == null) + { + return null; + } + return BinaryContent.Create(responseContentFilterResult, ModelSerializationExtensions.WireOptions); } - /// Convert into a . - internal virtual BinaryContent ToBinaryContent() + /// The to deserialize the from. + public static explicit operator ResponseContentFilterResult(ClientResult result) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeResponseContentFilterResult(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ResponseContentFilterResult.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ResponseContentFilterResult.cs new file mode 100644 index 000000000..2d7c6ec52 --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ResponseContentFilterResult.cs @@ -0,0 +1,84 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI +{ + /// A content filter result for a single response item produced by a generative AI system. + public partial class ResponseContentFilterResult + { + /// Keeps track of any properties unknown to the library. + private protected IDictionary _additionalBinaryDataProperties; + + internal ResponseContentFilterResult() + { + } + + internal ResponseContentFilterResult(ContentFilterSeverityResult sexual, ContentFilterSeverityResult hate, ContentFilterSeverityResult violence, ContentFilterSeverityResult selfHarm, ContentFilterDetectionResult profanity, ContentFilterBlocklistResult customBlocklists, ContentFilterDetectionResult protectedMaterialText, ContentFilterProtectedMaterialResult protectedMaterialCode, InternalAzureContentFilterResultForChoiceError error, ContentFilterTextSpanResult ungroundedMaterial, IDictionary additionalBinaryDataProperties) + { + Sexual = sexual; + Hate = hate; + Violence = violence; + SelfHarm = selfHarm; + Profanity = profanity; + CustomBlocklists = customBlocklists; + ProtectedMaterialText = protectedMaterialText; + ProtectedMaterialCode = protectedMaterialCode; + Error = error; + UngroundedMaterial = ungroundedMaterial; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// + /// A content filter category for language related to anatomical organs and genitals, romantic relationships, acts + /// portrayed in erotic or affectionate terms, pregnancy, physical sexual acts, including those portrayed as an + /// assault or a forced sexual violent act against one's will, prostitution, pornography, and abuse. + /// + public ContentFilterSeverityResult Sexual { get; } + + /// + /// A content filter category that can refer to any content that attacks or uses pejorative or discriminatory + /// language with reference to a person or identity group based on certain differentiating attributes of these groups + /// including but not limited to race, ethnicity, nationality, gender identity and expression, sexual orientation, + /// religion, immigration status, ability status, personal appearance, and body size. + /// + public ContentFilterSeverityResult Hate { get; } + + /// + /// A content filter category for language related to physical actions intended to hurt, injure, damage, or kill + /// someone or something; describes weapons, guns and related entities, such as manufactures, associations, + /// legislation, and so on. + /// + public ContentFilterSeverityResult Violence { get; } + + /// + /// A content filter category that describes language related to physical actions intended to purposely hurt, injure, + /// damage one's body or kill oneself. + /// + public ContentFilterSeverityResult SelfHarm { get; } + + /// + /// A detection result that identifies whether crude, vulgar, or otherwise objection language is present in the + /// content. + /// + public ContentFilterDetectionResult Profanity { get; } + + /// A collection of binary filtering outcomes for configured custom blocklists. + public ContentFilterBlocklistResult CustomBlocklists { get; } + + /// A detection result that describes a match against text protected under copyright or other status. + public ContentFilterDetectionResult ProtectedMaterialText { get; } + + /// A detection result that describes a match against licensed code or other protected source material. + public ContentFilterProtectedMaterialResult ProtectedMaterialCode { get; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ResponseImageContentFilterResult.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ResponseImageContentFilterResult.Serialization.cs similarity index 54% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ResponseImageContentFilterResult.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ResponseImageContentFilterResult.Serialization.cs index 7f34031a2..09de1cee2 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ResponseImageContentFilterResult.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ResponseImageContentFilterResult.Serialization.cs @@ -10,6 +10,7 @@ namespace Azure.AI.OpenAI { + /// public partial class ResponseImageContentFilterResult : IJsonModel { void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) @@ -23,35 +24,34 @@ void IJsonModel.Write(Utf8JsonWriter writer, M /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(ResponseImageContentFilterResult)} does not support writing '{format}' format."); } - - if (SerializedAdditionalRawData?.ContainsKey("sexual") != true && Optional.IsDefined(Sexual)) + if (Optional.IsDefined(Sexual) && _additionalBinaryDataProperties?.ContainsKey("sexual") != true) { writer.WritePropertyName("sexual"u8); writer.WriteObjectValue(Sexual, options); } - if (SerializedAdditionalRawData?.ContainsKey("violence") != true && Optional.IsDefined(Violence)) + if (Optional.IsDefined(Violence) && _additionalBinaryDataProperties?.ContainsKey("violence") != true) { writer.WritePropertyName("violence"u8); writer.WriteObjectValue(Violence, options); } - if (SerializedAdditionalRawData?.ContainsKey("hate") != true && Optional.IsDefined(Hate)) + if (Optional.IsDefined(Hate) && _additionalBinaryDataProperties?.ContainsKey("hate") != true) { writer.WritePropertyName("hate"u8); writer.WriteObjectValue(Hate, options); } - if (SerializedAdditionalRawData?.ContainsKey("self_harm") != true && Optional.IsDefined(SelfHarm)) + if (Optional.IsDefined(SelfHarm) && _additionalBinaryDataProperties?.ContainsKey("self_harm") != true) { writer.WritePropertyName("self_harm"u8); writer.WriteObjectValue(SelfHarm, options); } - if (SerializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in SerializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { @@ -59,7 +59,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else using (JsonDocument document = JsonDocument.Parse(item.Value)) { @@ -70,22 +70,23 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - ResponseImageContentFilterResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + ResponseImageContentFilterResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ResponseImageContentFilterResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(ResponseImageContentFilterResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeResponseImageContentFilterResult(document.RootElement, options); } - internal static ResponseImageContentFilterResult DeserializeResponseImageContentFilterResult(JsonElement element, ModelReaderWriterOptions options = null) + internal static ResponseImageContentFilterResult DeserializeResponseImageContentFilterResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -94,60 +95,59 @@ internal static ResponseImageContentFilterResult DeserializeResponseImageContent ContentFilterSeverityResult violence = default; ContentFilterSeverityResult hate = default; ContentFilterSeverityResult selfHarm = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("sexual"u8)) + if (prop.NameEquals("sexual"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - sexual = ContentFilterSeverityResult.DeserializeContentFilterSeverityResult(property.Value, options); + sexual = ContentFilterSeverityResult.DeserializeContentFilterSeverityResult(prop.Value, options); continue; } - if (property.NameEquals("violence"u8)) + if (prop.NameEquals("violence"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - violence = ContentFilterSeverityResult.DeserializeContentFilterSeverityResult(property.Value, options); + violence = ContentFilterSeverityResult.DeserializeContentFilterSeverityResult(prop.Value, options); continue; } - if (property.NameEquals("hate"u8)) + if (prop.NameEquals("hate"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - hate = ContentFilterSeverityResult.DeserializeContentFilterSeverityResult(property.Value, options); + hate = ContentFilterSeverityResult.DeserializeContentFilterSeverityResult(prop.Value, options); continue; } - if (property.NameEquals("self_harm"u8)) + if (prop.NameEquals("self_harm"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - selfHarm = ContentFilterSeverityResult.DeserializeContentFilterSeverityResult(property.Value, options); + selfHarm = ContentFilterSeverityResult.DeserializeContentFilterSeverityResult(prop.Value, options); continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new ResponseImageContentFilterResult(sexual, violence, hate, selfHarm, serializedAdditionalRawData); + return new ResponseImageContentFilterResult(sexual, violence, hate, selfHarm, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -157,15 +157,18 @@ BinaryData IPersistableModel.Write(ModelReader } } - ResponseImageContentFilterResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + ResponseImageContentFilterResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ResponseImageContentFilterResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeResponseImageContentFilterResult(document.RootElement, options); } default: @@ -175,18 +178,22 @@ ResponseImageContentFilterResult IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static ResponseImageContentFilterResult FromResponse(PipelineResponse response) + /// The to serialize into . + public static implicit operator BinaryContent(ResponseImageContentFilterResult responseImageContentFilterResult) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeResponseImageContentFilterResult(document.RootElement); + if (responseImageContentFilterResult == null) + { + return null; + } + return BinaryContent.Create(responseImageContentFilterResult, ModelSerializationExtensions.WireOptions); } - /// Convert into a . - internal virtual BinaryContent ToBinaryContent() + /// The to deserialize the from. + public static explicit operator ResponseImageContentFilterResult(ClientResult result) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeResponseImageContentFilterResult(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ResponseImageContentFilterResult.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ResponseImageContentFilterResult.cs new file mode 100644 index 000000000..825d42f35 --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/ResponseImageContentFilterResult.cs @@ -0,0 +1,63 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI +{ + /// A content filter result for an image generation operation's output response content. + public partial class ResponseImageContentFilterResult + { + /// Keeps track of any properties unknown to the library. + private protected IDictionary _additionalBinaryDataProperties; + + internal ResponseImageContentFilterResult() + { + } + + internal ResponseImageContentFilterResult(ContentFilterSeverityResult sexual, ContentFilterSeverityResult violence, ContentFilterSeverityResult hate, ContentFilterSeverityResult selfHarm, IDictionary additionalBinaryDataProperties) + { + Sexual = sexual; + Violence = violence; + Hate = hate; + SelfHarm = selfHarm; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + /// + /// A content filter category for language related to anatomical organs and genitals, romantic relationships, acts + /// portrayed in erotic or affectionate terms, pregnancy, physical sexual acts, including those portrayed as an + /// assault or a forced sexual violent act against one's will, prostitution, pornography, and abuse. + /// + public ContentFilterSeverityResult Sexual { get; } + + /// + /// A content filter category for language related to physical actions intended to hurt, injure, damage, or kill + /// someone or something; describes weapons, guns and related entities, such as manufactures, associations, + /// legislation, and so on. + /// + public ContentFilterSeverityResult Violence { get; } + + /// + /// A content filter category that can refer to any content that attacks or uses pejorative or discriminatory + /// language with reference to a person or identity group based on certain differentiating attributes of these groups + /// including but not limited to race, ethnicity, nationality, gender identity and expression, sexual orientation, + /// religion, immigration status, ability status, personal appearance, and body size. + /// + public ContentFilterSeverityResult Hate { get; } + + /// + /// A content filter category that describes language related to physical actions intended to purposely hurt, injure, + /// damage one's body or kill oneself. + /// + public ContentFilterSeverityResult SelfHarm { get; } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/UserSecurityContext.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/UserSecurityContext.Serialization.cs similarity index 51% rename from .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/UserSecurityContext.Serialization.cs rename to .dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/UserSecurityContext.Serialization.cs index ce8fcb983..b0aacd3bc 100644 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/UserSecurityContext.Serialization.cs +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/UserSecurityContext.Serialization.cs @@ -10,6 +10,7 @@ namespace Azure.AI.OpenAI { + /// public partial class UserSecurityContext : IJsonModel { void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) @@ -23,35 +24,34 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWri /// The client options for reading and writing models. protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(UserSecurityContext)} does not support writing '{format}' format."); } - - if (SerializedAdditionalRawData?.ContainsKey("application_name") != true && Optional.IsDefined(ApplicationName)) + if (Optional.IsDefined(ApplicationName) && _additionalBinaryDataProperties?.ContainsKey("application_name") != true) { writer.WritePropertyName("application_name"u8); writer.WriteStringValue(ApplicationName); } - if (SerializedAdditionalRawData?.ContainsKey("end_user_id") != true && Optional.IsDefined(EndUserId)) + if (Optional.IsDefined(EndUserId) && _additionalBinaryDataProperties?.ContainsKey("end_user_id") != true) { writer.WritePropertyName("end_user_id"u8); writer.WriteStringValue(EndUserId); } - if (SerializedAdditionalRawData?.ContainsKey("end_user_tenant_id") != true && Optional.IsDefined(EndUserTenantId)) + if (Optional.IsDefined(EndUserTenantId) && _additionalBinaryDataProperties?.ContainsKey("end_user_tenant_id") != true) { writer.WritePropertyName("end_user_tenant_id"u8); writer.WriteStringValue(EndUserTenantId); } - if (SerializedAdditionalRawData?.ContainsKey("source_ip") != true && Optional.IsDefined(SourceIP)) + if (Optional.IsDefined(SourceIP) && _additionalBinaryDataProperties?.ContainsKey("source_ip") != true) { writer.WritePropertyName("source_ip"u8); writer.WriteStringValue(SourceIP); } - if (SerializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in SerializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { if (ModelSerializationExtensions.IsSentinelValue(item.Value)) { @@ -59,7 +59,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else using (JsonDocument document = JsonDocument.Parse(item.Value)) { @@ -70,22 +70,23 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - UserSecurityContext IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + UserSecurityContext IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual UserSecurityContext JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(UserSecurityContext)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeUserSecurityContext(document.RootElement, options); } - internal static UserSecurityContext DeserializeUserSecurityContext(JsonElement element, ModelReaderWriterOptions options = null) + internal static UserSecurityContext DeserializeUserSecurityContext(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -93,45 +94,44 @@ internal static UserSecurityContext DeserializeUserSecurityContext(JsonElement e string applicationName = default; string endUserId = default; string endUserTenantId = default; - string sourceIp = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + string sourceIP = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("application_name"u8)) + if (prop.NameEquals("application_name"u8)) { - applicationName = property.Value.GetString(); + applicationName = prop.Value.GetString(); continue; } - if (property.NameEquals("end_user_id"u8)) + if (prop.NameEquals("end_user_id"u8)) { - endUserId = property.Value.GetString(); + endUserId = prop.Value.GetString(); continue; } - if (property.NameEquals("end_user_tenant_id"u8)) + if (prop.NameEquals("end_user_tenant_id"u8)) { - endUserTenantId = property.Value.GetString(); + endUserTenantId = prop.Value.GetString(); continue; } - if (property.NameEquals("source_ip"u8)) + if (prop.NameEquals("source_ip"u8)) { - sourceIp = property.Value.GetString(); + sourceIP = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new UserSecurityContext(applicationName, endUserId, endUserTenantId, sourceIp, serializedAdditionalRawData); + return new UserSecurityContext(applicationName, endUserId, endUserTenantId, sourceIP, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -141,15 +141,18 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions } } - UserSecurityContext IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + UserSecurityContext IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual UserSecurityContext PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data)) { - using JsonDocument document = JsonDocument.Parse(data); return DeserializeUserSecurityContext(document.RootElement, options); } default: @@ -159,18 +162,22 @@ UserSecurityContext IPersistableModel.Create(BinaryData dat string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static UserSecurityContext FromResponse(PipelineResponse response) + /// The to serialize into . + public static implicit operator BinaryContent(UserSecurityContext userSecurityContext) { - using var document = JsonDocument.Parse(response.Content); - return DeserializeUserSecurityContext(document.RootElement); + if (userSecurityContext == null) + { + return null; + } + return BinaryContent.Create(userSecurityContext, ModelSerializationExtensions.WireOptions); } - /// Convert into a . - internal virtual BinaryContent ToBinaryContent() + /// The to deserialize the from. + public static explicit operator UserSecurityContext(ClientResult result) { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); + using PipelineResponse response = result.GetRawResponse(); + using JsonDocument document = JsonDocument.Parse(response.Content); + return DeserializeUserSecurityContext(document.RootElement, ModelSerializationExtensions.WireOptions); } } } diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/UserSecurityContext.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/UserSecurityContext.cs new file mode 100644 index 000000000..581fefaba --- /dev/null +++ b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/Models/UserSecurityContext.cs @@ -0,0 +1,31 @@ +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI +{ + /// User security context contains several parameters that describe the application itself, and the end user that interacts with the application. These fields assist your security operations teams to investigate and mitigate security incidents by providing a comprehensive approach to protecting your AI applications. [Learn more](https://aka.ms/TP4AI/Documentation/EndUserContext) about protecting AI applications using Microsoft Defender for Cloud. + public partial class UserSecurityContext + { + /// Keeps track of any properties unknown to the library. + private protected IDictionary _additionalBinaryDataProperties; + + internal UserSecurityContext(string applicationName, string endUserId, string endUserTenantId, string sourceIP, IDictionary additionalBinaryDataProperties) + { + ApplicationName = applicationName; + EndUserId = endUserId; + EndUserTenantId = endUserTenantId; + SourceIP = sourceIP; + _additionalBinaryDataProperties = additionalBinaryDataProperties; + } + + internal IDictionary SerializedAdditionalRawData + { + get => _additionalBinaryDataProperties; + set => _additionalBinaryDataProperties = value; + } + } +} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/MongoDBChatDataSource.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/MongoDBChatDataSource.Serialization.cs deleted file mode 100644 index 9c68f12b6..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/MongoDBChatDataSource.Serialization.cs +++ /dev/null @@ -1,131 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; - -namespace Azure.AI.OpenAI.Chat -{ - public partial class MongoDBChatDataSource : IJsonModel - { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - /// The JSON writer. - /// The client options for reading and writing models. - protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(MongoDBChatDataSource)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - if (SerializedAdditionalRawData?.ContainsKey("parameters") != true) - { - writer.WritePropertyName("parameters"u8); - writer.WriteObjectValue(InternalParameters, options); - } - } - - MongoDBChatDataSource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(MongoDBChatDataSource)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMongoDBChatDataSource(document.RootElement, options); - } - - internal static MongoDBChatDataSource DeserializeMongoDBChatDataSource(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - InternalMongoDBChatDataSourceParameters parameters = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("parameters"u8)) - { - parameters = InternalMongoDBChatDataSourceParameters.DeserializeInternalMongoDBChatDataSourceParameters(property.Value, options); - continue; - } - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new MongoDBChatDataSource(type, serializedAdditionalRawData, parameters); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(MongoDBChatDataSource)} does not support writing '{options.Format}' format."); - } - } - - MongoDBChatDataSource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializeMongoDBChatDataSource(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(MongoDBChatDataSource)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static new MongoDBChatDataSource FromResponse(PipelineResponse response) - { - using var document = JsonDocument.Parse(response.Content); - return DeserializeMongoDBChatDataSource(document.RootElement); - } - - /// Convert into a . - internal override BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/PineconeChatDataSource.Serialization.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/PineconeChatDataSource.Serialization.cs deleted file mode 100644 index 578dc5248..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/PineconeChatDataSource.Serialization.cs +++ /dev/null @@ -1,131 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; - -namespace Azure.AI.OpenAI.Chat -{ - public partial class PineconeChatDataSource : IJsonModel - { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - writer.WriteStartObject(); - JsonModelWriteCore(writer, options); - writer.WriteEndObject(); - } - - /// The JSON writer. - /// The client options for reading and writing models. - protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(PineconeChatDataSource)} does not support writing '{format}' format."); - } - - base.JsonModelWriteCore(writer, options); - if (SerializedAdditionalRawData?.ContainsKey("parameters") != true) - { - writer.WritePropertyName("parameters"u8); - writer.WriteObjectValue(InternalParameters, options); - } - } - - PineconeChatDataSource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(PineconeChatDataSource)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializePineconeChatDataSource(document.RootElement, options); - } - - internal static PineconeChatDataSource DeserializePineconeChatDataSource(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - InternalPineconeChatDataSourceParameters parameters = default; - string type = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) - { - if (property.NameEquals("parameters"u8)) - { - parameters = InternalPineconeChatDataSourceParameters.DeserializeInternalPineconeChatDataSourceParameters(property.Value, options); - continue; - } - if (property.NameEquals("type"u8)) - { - type = property.Value.GetString(); - continue; - } - if (options.Format != "W") - { - rawDataDictionary ??= new Dictionary(); - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new PineconeChatDataSource(type, serializedAdditionalRawData, parameters); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(PineconeChatDataSource)} does not support writing '{options.Format}' format."); - } - } - - PineconeChatDataSource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializePineconeChatDataSource(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(PineconeChatDataSource)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static new PineconeChatDataSource FromResponse(PipelineResponse response) - { - using var document = JsonDocument.Parse(response.Content); - return DeserializePineconeChatDataSource(document.RootElement); - } - - /// Convert into a . - internal override BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/RequestContentFilterResult.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/RequestContentFilterResult.cs deleted file mode 100644 index 74a54e015..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/RequestContentFilterResult.cs +++ /dev/null @@ -1,60 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI -{ - /// A content filter result associated with a single input prompt item into a generative AI system. - public partial class RequestContentFilterResult - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - internal IDictionary SerializedAdditionalRawData { get; set; } - /// Initializes a new instance of . - internal RequestContentFilterResult() - { - } - - /// Initializes a new instance of . - /// The index of the input prompt associated with the accompanying content filter result categories. - /// The content filter category details for the result. - /// Keeps track of any properties unknown to the library. - internal RequestContentFilterResult(int? promptIndex, InternalAzureContentFilterResultForPromptContentFilterResults internalResults, IDictionary serializedAdditionalRawData) - { - PromptIndex = promptIndex; - InternalResults = internalResults; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/RequestImageContentFilterResult.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/RequestImageContentFilterResult.cs deleted file mode 100644 index e41fc322b..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/RequestImageContentFilterResult.cs +++ /dev/null @@ -1,85 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI -{ - /// A content filter result for an image generation operation's input request content. - public partial class RequestImageContentFilterResult : ResponseImageContentFilterResult - { - /// Initializes a new instance of . - /// - /// A detection result that describes user prompt injection attacks, where malicious users deliberately exploit - /// system vulnerabilities to elicit unauthorized behavior from the LLM. This could lead to inappropriate content - /// generation or violations of system-imposed restrictions. - /// - /// is null. - internal RequestImageContentFilterResult(ContentFilterDetectionResult jailbreak) - { - Argument.AssertNotNull(jailbreak, nameof(jailbreak)); - - Jailbreak = jailbreak; - } - - /// Initializes a new instance of . - /// - /// A content filter category for language related to anatomical organs and genitals, romantic relationships, acts - /// portrayed in erotic or affectionate terms, pregnancy, physical sexual acts, including those portrayed as an - /// assault or a forced sexual violent act against one's will, prostitution, pornography, and abuse. - /// - /// - /// A content filter category for language related to physical actions intended to hurt, injure, damage, or kill - /// someone or something; describes weapons, guns and related entities, such as manufactures, associations, - /// legislation, and so on. - /// - /// - /// A content filter category that can refer to any content that attacks or uses pejorative or discriminatory - /// language with reference to a person or identity group based on certain differentiating attributes of these groups - /// including but not limited to race, ethnicity, nationality, gender identity and expression, sexual orientation, - /// religion, immigration status, ability status, personal appearance, and body size. - /// - /// - /// A content filter category that describes language related to physical actions intended to purposely hurt, injure, - /// damage one's body or kill oneself. - /// - /// Keeps track of any properties unknown to the library. - /// - /// A detection result that identifies whether crude, vulgar, or otherwise objection language is present in the - /// content. - /// - /// A collection of binary filtering outcomes for configured custom blocklists. - /// - /// A detection result that describes user prompt injection attacks, where malicious users deliberately exploit - /// system vulnerabilities to elicit unauthorized behavior from the LLM. This could lead to inappropriate content - /// generation or violations of system-imposed restrictions. - /// - internal RequestImageContentFilterResult(ContentFilterSeverityResult sexual, ContentFilterSeverityResult violence, ContentFilterSeverityResult hate, ContentFilterSeverityResult selfHarm, IDictionary serializedAdditionalRawData, ContentFilterDetectionResult profanity, ContentFilterBlocklistResult customBlocklists, ContentFilterDetectionResult jailbreak) : base(sexual, violence, hate, selfHarm, serializedAdditionalRawData) - { - Profanity = profanity; - CustomBlocklists = customBlocklists; - Jailbreak = jailbreak; - } - - /// Initializes a new instance of for deserialization. - internal RequestImageContentFilterResult() - { - } - - /// - /// A detection result that identifies whether crude, vulgar, or otherwise objection language is present in the - /// content. - /// - public ContentFilterDetectionResult Profanity { get; } - /// A collection of binary filtering outcomes for configured custom blocklists. - public ContentFilterBlocklistResult CustomBlocklists { get; } - /// - /// A detection result that describes user prompt injection attacks, where malicious users deliberately exploit - /// system vulnerabilities to elicit unauthorized behavior from the LLM. This could lead to inappropriate content - /// generation or violations of system-imposed restrictions. - /// - public ContentFilterDetectionResult Jailbreak { get; } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ResponseContentFilterResult.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ResponseContentFilterResult.cs deleted file mode 100644 index 45fdc12f1..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ResponseContentFilterResult.cs +++ /dev/null @@ -1,131 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI -{ - /// A content filter result for a single response item produced by a generative AI system. - public partial class ResponseContentFilterResult - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - internal IDictionary SerializedAdditionalRawData { get; set; } - /// Initializes a new instance of . - internal ResponseContentFilterResult() - { - } - - /// Initializes a new instance of . - /// - /// A content filter category for language related to anatomical organs and genitals, romantic relationships, acts - /// portrayed in erotic or affectionate terms, pregnancy, physical sexual acts, including those portrayed as an - /// assault or a forced sexual violent act against one's will, prostitution, pornography, and abuse. - /// - /// - /// A content filter category that can refer to any content that attacks or uses pejorative or discriminatory - /// language with reference to a person or identity group based on certain differentiating attributes of these groups - /// including but not limited to race, ethnicity, nationality, gender identity and expression, sexual orientation, - /// religion, immigration status, ability status, personal appearance, and body size. - /// - /// - /// A content filter category for language related to physical actions intended to hurt, injure, damage, or kill - /// someone or something; describes weapons, guns and related entities, such as manufactures, associations, - /// legislation, and so on. - /// - /// - /// A content filter category that describes language related to physical actions intended to purposely hurt, injure, - /// damage one's body or kill oneself. - /// - /// - /// A detection result that identifies whether crude, vulgar, or otherwise objection language is present in the - /// content. - /// - /// A collection of binary filtering outcomes for configured custom blocklists. - /// If present, details about an error that prevented content filtering from completing its evaluation. - /// A detection result that describes a match against text protected under copyright or other status. - /// A detection result that describes a match against licensed code or other protected source material. - /// - /// Keeps track of any properties unknown to the library. - internal ResponseContentFilterResult(ContentFilterSeverityResult sexual, ContentFilterSeverityResult hate, ContentFilterSeverityResult violence, ContentFilterSeverityResult selfHarm, ContentFilterDetectionResult profanity, ContentFilterBlocklistResult customBlocklists, InternalAzureContentFilterResultForChoiceError error, ContentFilterDetectionResult protectedMaterialText, ContentFilterProtectedMaterialResult protectedMaterialCode, ContentFilterTextSpanResult ungroundedMaterial, IDictionary serializedAdditionalRawData) - { - Sexual = sexual; - Hate = hate; - Violence = violence; - SelfHarm = selfHarm; - Profanity = profanity; - CustomBlocklists = customBlocklists; - Error = error; - ProtectedMaterialText = protectedMaterialText; - ProtectedMaterialCode = protectedMaterialCode; - UngroundedMaterial = ungroundedMaterial; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - /// - /// A content filter category for language related to anatomical organs and genitals, romantic relationships, acts - /// portrayed in erotic or affectionate terms, pregnancy, physical sexual acts, including those portrayed as an - /// assault or a forced sexual violent act against one's will, prostitution, pornography, and abuse. - /// - public ContentFilterSeverityResult Sexual { get; } - /// - /// A content filter category that can refer to any content that attacks or uses pejorative or discriminatory - /// language with reference to a person or identity group based on certain differentiating attributes of these groups - /// including but not limited to race, ethnicity, nationality, gender identity and expression, sexual orientation, - /// religion, immigration status, ability status, personal appearance, and body size. - /// - public ContentFilterSeverityResult Hate { get; } - /// - /// A content filter category for language related to physical actions intended to hurt, injure, damage, or kill - /// someone or something; describes weapons, guns and related entities, such as manufactures, associations, - /// legislation, and so on. - /// - public ContentFilterSeverityResult Violence { get; } - /// - /// A content filter category that describes language related to physical actions intended to purposely hurt, injure, - /// damage one's body or kill oneself. - /// - public ContentFilterSeverityResult SelfHarm { get; } - /// - /// A detection result that identifies whether crude, vulgar, or otherwise objection language is present in the - /// content. - /// - public ContentFilterDetectionResult Profanity { get; } - /// A collection of binary filtering outcomes for configured custom blocklists. - public ContentFilterBlocklistResult CustomBlocklists { get; } - /// A detection result that describes a match against text protected under copyright or other status. - public ContentFilterDetectionResult ProtectedMaterialText { get; } - /// A detection result that describes a match against licensed code or other protected source material. - public ContentFilterProtectedMaterialResult ProtectedMaterialCode { get; } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ResponseImageContentFilterResult.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ResponseImageContentFilterResult.cs deleted file mode 100644 index 2a5b21055..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/ResponseImageContentFilterResult.cs +++ /dev/null @@ -1,105 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI -{ - /// A content filter result for an image generation operation's output response content. - public partial class ResponseImageContentFilterResult - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - internal IDictionary SerializedAdditionalRawData { get; set; } - /// Initializes a new instance of . - internal ResponseImageContentFilterResult() - { - } - - /// Initializes a new instance of . - /// - /// A content filter category for language related to anatomical organs and genitals, romantic relationships, acts - /// portrayed in erotic or affectionate terms, pregnancy, physical sexual acts, including those portrayed as an - /// assault or a forced sexual violent act against one's will, prostitution, pornography, and abuse. - /// - /// - /// A content filter category for language related to physical actions intended to hurt, injure, damage, or kill - /// someone or something; describes weapons, guns and related entities, such as manufactures, associations, - /// legislation, and so on. - /// - /// - /// A content filter category that can refer to any content that attacks or uses pejorative or discriminatory - /// language with reference to a person or identity group based on certain differentiating attributes of these groups - /// including but not limited to race, ethnicity, nationality, gender identity and expression, sexual orientation, - /// religion, immigration status, ability status, personal appearance, and body size. - /// - /// - /// A content filter category that describes language related to physical actions intended to purposely hurt, injure, - /// damage one's body or kill oneself. - /// - /// Keeps track of any properties unknown to the library. - internal ResponseImageContentFilterResult(ContentFilterSeverityResult sexual, ContentFilterSeverityResult violence, ContentFilterSeverityResult hate, ContentFilterSeverityResult selfHarm, IDictionary serializedAdditionalRawData) - { - Sexual = sexual; - Violence = violence; - Hate = hate; - SelfHarm = selfHarm; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - - /// - /// A content filter category for language related to anatomical organs and genitals, romantic relationships, acts - /// portrayed in erotic or affectionate terms, pregnancy, physical sexual acts, including those portrayed as an - /// assault or a forced sexual violent act against one's will, prostitution, pornography, and abuse. - /// - public ContentFilterSeverityResult Sexual { get; } - /// - /// A content filter category for language related to physical actions intended to hurt, injure, damage, or kill - /// someone or something; describes weapons, guns and related entities, such as manufactures, associations, - /// legislation, and so on. - /// - public ContentFilterSeverityResult Violence { get; } - /// - /// A content filter category that can refer to any content that attacks or uses pejorative or discriminatory - /// language with reference to a person or identity group based on certain differentiating attributes of these groups - /// including but not limited to race, ethnicity, nationality, gender identity and expression, sexual orientation, - /// religion, immigration status, ability status, personal appearance, and body size. - /// - public ContentFilterSeverityResult Hate { get; } - /// - /// A content filter category that describes language related to physical actions intended to purposely hurt, injure, - /// damage one's body or kill oneself. - /// - public ContentFilterSeverityResult SelfHarm { get; } - } -} diff --git a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/UserSecurityContext.cs b/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/UserSecurityContext.cs deleted file mode 100644 index fdce17d7b..000000000 --- a/.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src/Generated/UserSecurityContext.cs +++ /dev/null @@ -1,60 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI -{ - /// User security context contains several parameters that describe the application itself, and the end user that interacts with the application. These fields assist your security operations teams to investigate and mitigate security incidents by providing a comprehensive approach to protecting your AI applications. [Learn more](https://aka.ms/TP4AI/Documentation/EndUserContext) about protecting AI applications using Microsoft Defender for Cloud. - public partial class UserSecurityContext - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - internal IDictionary SerializedAdditionalRawData { get; set; } - - /// Initializes a new instance of . - /// The name of the application. Sensitive personal information should not be included in this field. - /// This identifier is the Microsoft Entra ID (formerly Azure Active Directory) user object ID used to authenticate end-users within the generative AI application. Sensitive personal information should not be included in this field. - /// The Microsoft 365 tenant ID the end user belongs to. It's required when the generative AI application is multitenant. - /// Captures the original client's IP address. - /// Keeps track of any properties unknown to the library. - internal UserSecurityContext(string applicationName, string endUserId, string endUserTenantId, string sourceIP, IDictionary serializedAdditionalRawData) - { - ApplicationName = applicationName; - EndUserId = endUserId; - EndUserTenantId = endUserTenantId; - SourceIP = sourceIP; - SerializedAdditionalRawData = serializedAdditionalRawData; - } - } -} diff --git a/.plugin.azure/.gitignore b/.plugin.azure/.gitignore new file mode 100644 index 000000000..fe620c83f --- /dev/null +++ b/.plugin.azure/.gitignore @@ -0,0 +1,184 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.sln.docstates +.vs/ +*.lock.json +developer/ +launch.json +launchSettings.json + +# Default Assets restore directory +.assets + +# Default TypeSpec output +tsp-output/ + +temp/ + +# Build results +/artifacts +binaries/ +[Dd]ebug*/ +[Rr]elease/ +build/ +restoredPackages/ +PolicheckOutput/ +tools/net46/ +tools/SdkBuildTools/ +tools/Microsoft.WindowsAzure.Build.Tasks/packages/ +PublishedNugets/ +src/NuGet.Config +tools/7-zip/ +#tools/LocalNugetFeed/Microsoft.Internal.NetSdkBuild.Mgmt.Tools.*.nupkg + +[Tt]est[Rr]esult +[Bb]uild[Ll]og.* + +*_i.c +*_p.c +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.vspscc +*.vssscc +.builds + +*.pidb + +*.log +*.scc +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf + +# Visual Studio profiler +*.psess +*.vsp + +# VS Code +**/.vscode/* +!.vscode/cspell.json + +# Code analysis +*.CodeAnalysisLog.xml + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ + +*.[Rr]e[Ss]harper + +# Rider IDE +.idea + +# NCrunch +*.ncrunch* +.*crunch*.local.xml + +# Installshield output folder +[Ee]xpress + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish + +# Publish Web Output +*.Publish.xml + +# Others +[Bb]in +[Oo]bj +TestResults +[Tt]est[Rr]esult* +*.Cache +ClientBin +~$* +*.dbmdl + +*.[Pp]ublish.xml + +Generated_Code #added for RIA/Silverlight projects + +# Build tasks +tools/*.dll + +# Sensitive files +*.keys +!Azure.Extensions.AspNetCore.DataProtection.Keys +!Azure.Security.KeyVault.Keys +*.pfx +TestConfigurations.xml +*.json.env +*.bicep.env + +# Backup & report files from converting an old project file to a newer +# Visual Studio version. Backup files are not needed, because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML + +# NuGet +packages +packages/repositories.config +testPackages + +# Mac development +.DS_Store + +# Specification DLLs +*.Specification.dll + +# Generated readme.txt files # +src/*/readme.txt + +build.out +.nuget/ + +# Azure Project +csx/ +*.GhostDoc.xml +pingme.txt + +# TS/Node files +dist/ +node_modules/ + +# MSBuild binary log files +msbuild.binlog + +# BenchmarkDotNet +BenchmarkDotNet.Artifacts + +artifacts +.assets + +# Temporary typespec folders for typespec generation +TempTypeSpecFiles/ diff --git a/.plugin.azure/emitter/src/emitter.ts b/.plugin.azure/emitter/src/emitter.ts new file mode 100644 index 000000000..fcbe21063 --- /dev/null +++ b/.plugin.azure/emitter/src/emitter.ts @@ -0,0 +1,12 @@ +import { EmitContext } from "@typespec/compiler"; + +import { + $onEmit as $OnMGCEmit, + NetEmitterOptions +} from "@typespec/http-client-csharp"; + +export async function $onEmit(context: EmitContext) { + context.options["plugin-name"] = "AzureOpenAILibraryPlugin"; + context.options["emitter-extension-path"] = import.meta.url; + await $OnMGCEmit(context); +} \ No newline at end of file diff --git a/.plugin.azure/emitter/src/index.ts b/.plugin.azure/emitter/src/index.ts new file mode 100644 index 000000000..8b2630d57 --- /dev/null +++ b/.plugin.azure/emitter/src/index.ts @@ -0,0 +1 @@ +export * from "./emitter.js"; \ No newline at end of file diff --git a/.plugin.azure/generator/AzureOpenAI.Library.Plugin.sln b/.plugin.azure/generator/AzureOpenAI.Library.Plugin.sln new file mode 100644 index 000000000..8ec10ceb0 --- /dev/null +++ b/.plugin.azure/generator/AzureOpenAI.Library.Plugin.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.11.35327.3 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AzureOpenAI.Library.Plugin", "src\AzureOpenAI.Library.Plugin.csproj", "{E46178E4-F3F0-4E2F-8D42-A7F021B23E63}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E46178E4-F3F0-4E2F-8D42-A7F021B23E63}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E46178E4-F3F0-4E2F-8D42-A7F021B23E63}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E46178E4-F3F0-4E2F-8D42-A7F021B23E63}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E46178E4-F3F0-4E2F-8D42-A7F021B23E63}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/.plugin.azure/generator/src/AzureOpenAI.Library.Plugin.csproj b/.plugin.azure/generator/src/AzureOpenAI.Library.Plugin.csproj new file mode 100644 index 000000000..230f57888 --- /dev/null +++ b/.plugin.azure/generator/src/AzureOpenAI.Library.Plugin.csproj @@ -0,0 +1,23 @@ + + + + net8.0 + enable + OpenAI.Microsoft.Generator.CSharp.ClientModel.Plugin + true + + + + + + + + + + + + + + + + diff --git a/.plugin.azure/generator/src/AzureOpenAILibraryPlugin.cs b/.plugin.azure/generator/src/AzureOpenAILibraryPlugin.cs new file mode 100644 index 000000000..ac32a0a3e --- /dev/null +++ b/.plugin.azure/generator/src/AzureOpenAILibraryPlugin.cs @@ -0,0 +1,26 @@ +using System.ComponentModel.Composition; +using Microsoft.Generator.CSharp; +using Microsoft.Generator.CSharp.ClientModel; + +namespace AzureOpenAILibraryPlugin +{ + [Export(typeof(CodeModelPlugin))] + [ExportMetadata("PluginName", nameof(AzureOpenAILibraryPlugin))] + public class AzureOpenAILibraryPlugin : ClientModelPlugin + { + [ImportingConstructor] + public AzureOpenAILibraryPlugin(GeneratorContext context) : base(context) { } + + public override void Configure() + { + base.Configure(); + + AddVisitor(new DocEditVisitor()); + AddVisitor(new AdditionalPropertiesVisitor()); + AddVisitor(new ModelSerializationEmptySentinelVisitor()); + AddVisitor(new WriteableSardVisitor()); + AddVisitor(new TypeRemovalVisitor()); + AddVisitor(new InternalSettablePropertiesVisitor()); + } + } +} \ No newline at end of file diff --git a/.plugin.azure/generator/src/Properties/launchSettings.json b/.plugin.azure/generator/src/Properties/launchSettings.json new file mode 100644 index 000000000..c6d6231e1 --- /dev/null +++ b/.plugin.azure/generator/src/Properties/launchSettings.json @@ -0,0 +1,9 @@ +{ + "profiles": { + "AzureOpenAIPlugin": { + "commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.Generator.CSharp.dll $(SolutionDir)/../../.dotnet.azure/sdk/openai/Azure.AI.OpenAI -p AzureOpenAILibraryPlugin", + "commandName": "Executable", + "executablePath": "dotnet" + } + } +} \ No newline at end of file diff --git a/.plugin.azure/generator/src/Visitors/AdditionalPropertiesVisitor.cs b/.plugin.azure/generator/src/Visitors/AdditionalPropertiesVisitor.cs new file mode 100644 index 000000000..0ccfe711a --- /dev/null +++ b/.plugin.azure/generator/src/Visitors/AdditionalPropertiesVisitor.cs @@ -0,0 +1,139 @@ +using Microsoft.Generator.CSharp.ClientModel; +using Microsoft.Generator.CSharp.ClientModel.Providers; +using Microsoft.Generator.CSharp.Primitives; +using Microsoft.Generator.CSharp.Providers; +using Microsoft.Generator.CSharp.Snippets; +using Microsoft.Generator.CSharp.Statements; +using System; +using System.Collections.Generic; +using System.Linq; +using static Microsoft.Generator.CSharp.Snippets.Snippet; + +namespace AzureOpenAILibraryPlugin; + +/// +/// This visitor ensures that each emitted model has an internal "additional raw data" dictionary property included +/// and used during the serialization and deserialization process. +/// +public class AdditionalPropertiesVisitor : ScmLibraryVisitor +{ + private const string RawDataPropertyName = "SerializedAdditionalRawData"; + private const string AdditionalPropertiesFieldName = "_additionalBinaryDataProperties"; + private const string WritePropertyNameMethodCall = "WritePropertyName(\""; + private const string IsSentinelValueMethodName = "IsSentinelValue"; + private const string JsonModelWriteCoreMethodName = "JsonModelWriteCore"; + + protected override TypeProvider Visit(TypeProvider type) + { + if (type is ModelProvider { BaseModelProvider: null }) + { + // Add an internal AdditionalProperties property to all base models + var additionalPropertiesField = type.Fields.Single(f => f.Name == AdditionalPropertiesFieldName); + var properties = new List(type.Properties) + { + new PropertyProvider($"", MethodSignatureModifiers.Internal, + typeof(IDictionary), RawDataPropertyName, + new ExpressionPropertyBody( + additionalPropertiesField, + type.DeclarationModifiers.HasFlag(TypeSignatureModifiers.ReadOnly) ? null : additionalPropertiesField.Assign(Value)), + type) + }; + + type.Update(properties: properties); + } + return type; + } + + protected override MethodProvider Visit(MethodProvider method) + { + if (method.Signature.Name != JsonModelWriteCoreMethodName) + { + return method; + } + + // If there are no body statements, return the method as is + if (method.BodyStatements == null) + { + return method; + } + + // If the body statements are not MethodBodyStatements, return the method as is + if (method.BodyStatements is not MethodBodyStatements statements) + { + return method; + } + + var updatedStatements = new List(); + var flattenedStatements = statements.Flatten().ToArray(); + + for (int line = 0; line < flattenedStatements.Length; line++) + { + var statement = flattenedStatements[line]; + + if (statement is IfStatement ifStatement) + { + var body = ifStatement.Body.ToDisplayString(); + + // If we already have an if statement that contains property writing, we need to add the condition to the existing if statement + if (body.Contains(WritePropertyNameMethodCall)) + { + ifStatement.Condition = ifStatement.Condition.As().And(GetContainsKeyCondition(body)); + } + + // Handle writing AdditionalProperties + else if (ifStatement.Body.Flatten().First() is ForeachStatement foreachStatement) + { + foreachStatement.Body.Insert( + 0, + new IfStatement( + Static(new ModelSerializationExtensionsDefinition().Type).Invoke( + IsSentinelValueMethodName, + foreachStatement.ItemVariable.Property("Value"))) + { + Continue + }); + } + + updatedStatements.Add(ifStatement); + continue; + } + + var displayString = statement.ToDisplayString(); + if (displayString.Contains(WritePropertyNameMethodCall)) + { + var ifSt = new IfStatement(GetContainsKeyCondition(displayString)) { statement }; + + // If this is a plain expression statement, we need to add the next statement as well which + // will either write the property value or start writing an array + if (statement is ExpressionStatement) + { + ifSt.Add(flattenedStatements[++line]); + // Include array writing in the if statement + if (flattenedStatements[line + 1] is ForeachStatement) + { + // Foreach + ifSt.Add(flattenedStatements[++line]); + // End array + ifSt.Add(flattenedStatements[++line]); + } + } + updatedStatements.Add(ifSt); + } + else + { + updatedStatements.Add(statement); + } + } + + method.Update(bodyStatements: updatedStatements); + return method; + } + + private static ScopedApi GetContainsKeyCondition(string displayString) + { + var propertyName = displayString.Split('"')[1]; + return This.Property(AdditionalPropertiesFieldName) + .NullConditional() + .Invoke("ContainsKey", Literal(propertyName)).NotEqual(True); + } +} diff --git a/.plugin.azure/generator/src/Visitors/DocEditVisitor.cs b/.plugin.azure/generator/src/Visitors/DocEditVisitor.cs new file mode 100644 index 000000000..8b55ab0b4 --- /dev/null +++ b/.plugin.azure/generator/src/Visitors/DocEditVisitor.cs @@ -0,0 +1,63 @@ +using Microsoft.Generator.CSharp.ClientModel; +using Microsoft.Generator.CSharp.Providers; +using Microsoft.Generator.CSharp.Snippets; +using Microsoft.Generator.CSharp.Statements; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace AzureOpenAILibraryPlugin; + +/// +/// This visitor ensures consistent formatting of XML doc comments, including normalization of lines +/// that mitigate newline injection causing malformed comments. +/// +public class DocEditVisitor : ScmLibraryVisitor +{ + protected override PropertyProvider? Visit(PropertyProvider property) + { + if (TryUpdateXmlDocs(property.XmlDocs)) + { + property.Update(xmlDocs: property.XmlDocs); + } + return base.Visit(property); + } + + protected override TypeProvider Visit(TypeProvider type) + { + if (TryUpdateXmlDocs(type.XmlDocs)) + { + type.Update(xmlDocs: type.XmlDocs); + } + return type; + } + + protected override MethodProvider? Visit(MethodProvider method) + { + if (TryUpdateXmlDocs(method.XmlDocs)) + { + method.Update(xmlDocProvider: method.XmlDocs); + } + return base.Visit(method); + } + + private static bool TryUpdateXmlDocs(XmlDocProvider? xmlDocs) + { + if (xmlDocs?.Summary?.Lines is IReadOnlyList existingSummaryLines + && existingSummaryLines.Count > 0) + { + List reprocessedSummaryLines = []; + foreach (var line in existingSummaryLines) + { + string[] linesInTheLine = line.ToString().Split('\n'); + reprocessedSummaryLines.AddRange(linesInTheLine.Select(lineInTheLine => (FormattableString)$"{lineInTheLine}")); + } + if (reprocessedSummaryLines.Count > existingSummaryLines.Count) + { + xmlDocs.Summary = new XmlDocSummaryStatement(reprocessedSummaryLines, [.. xmlDocs.Summary.InnerStatements]); + return true; + } + } + return false; + } +} diff --git a/.plugin.azure/generator/src/Visitors/InternalSettablePropertiesVisitor.cs b/.plugin.azure/generator/src/Visitors/InternalSettablePropertiesVisitor.cs new file mode 100644 index 000000000..01110441d --- /dev/null +++ b/.plugin.azure/generator/src/Visitors/InternalSettablePropertiesVisitor.cs @@ -0,0 +1,30 @@ +using Microsoft.Generator.CSharp.ClientModel; +using Microsoft.Generator.CSharp.Primitives; +using Microsoft.Generator.CSharp.Providers; + +namespace AzureOpenAILibraryPlugin; + +/// +/// This visitor ensures that all properties on internal types with "Internal" type prefix are settable. +/// +public class InternalSettablePropertiesVisitor : ScmLibraryVisitor +{ + protected override TypeProvider? Visit(TypeProvider type) + { + if (type.Name.Contains("Internal") && type.DeclarationModifiers.HasFlag(TypeSignatureModifiers.Internal)) + { + foreach (PropertyProvider property in type.Properties) + { + if (property.Body is AutoPropertyBody autoPropertyBody && !property.Body.HasSetter) + { + PropertyBody updatedBody = new AutoPropertyBody( + HasSetter: true, + autoPropertyBody.SetterModifiers, + autoPropertyBody.InitializationExpression); + property.Update(body: updatedBody); + } + } + } + return type; + } +} diff --git a/.plugin.azure/generator/src/Visitors/ModelSerializationEmptySentinelVisitor.cs b/.plugin.azure/generator/src/Visitors/ModelSerializationEmptySentinelVisitor.cs new file mode 100644 index 000000000..05b0c21aa --- /dev/null +++ b/.plugin.azure/generator/src/Visitors/ModelSerializationEmptySentinelVisitor.cs @@ -0,0 +1,63 @@ +using Microsoft.Generator.CSharp.ClientModel; +using Microsoft.Generator.CSharp.Primitives; +using Microsoft.Generator.CSharp.Providers; +using Microsoft.Generator.CSharp.Snippets; +using System; +using System.Collections.Generic; +using static Microsoft.Generator.CSharp.Snippets.Snippet; + +namespace AzureOpenAILibraryPlugin; + +/// +/// This visitor adds extensions for model serialization that use an empty sentinel value to serve as a suppression +/// flag for a named property on the additional binary data properties dictionary. +/// +public class ModelSerializationEmptySentinelVisitor : ScmLibraryVisitor +{ + private const string ModelSerializationExtensionsTypeName = "ModelSerializationExtensions"; + private const string SentinelValueFieldName = "_sentinelValue"; + private const string IsSentinelValueMethodName = "IsSentinelValue"; + + protected override TypeProvider Visit(TypeProvider type) + { + if (type.Name == ModelSerializationExtensionsTypeName) + { + // Add a static BinaryData field representing the sentinel value + var sentinelValueField = new FieldProvider( + FieldModifiers.Private | FieldModifiers.Static | FieldModifiers.ReadOnly, + typeof(BinaryData), + SentinelValueFieldName, + type, + $"", + BinaryDataSnippets.FromBytes(LiteralU8("\"__EMPTY__\"").Invoke("ToArray"))); + var fields = new List(type.Fields) + { + sentinelValueField + }; + + // Add the IsSentinelValue method + var valueParameter = new ParameterProvider("value", $"", typeof(BinaryData)); + var methods = new List(type.Methods) + { + new MethodProvider( + new MethodSignature( + IsSentinelValueMethodName, + $"", + MethodSignatureModifiers.Internal | MethodSignatureModifiers.Static, + typeof(bool), + $"", + [valueParameter]), + new[] + { + Declare("sentinelSpan", typeof(ReadOnlySpan), sentinelValueField.As().ToMemory().Property("Span"), out var sentinelVariable), + Declare("valueSpan", typeof(ReadOnlySpan), valueParameter.As().ToMemory().Property("Span"), out var valueVariable), + Return(sentinelVariable.Invoke("SequenceEqual", valueVariable)) + }, + type) + }; + + type.Update(fields: fields, methods: methods); + } + return type; + } +} diff --git a/.plugin.azure/generator/src/Visitors/TypeRemovalVisitor.cs b/.plugin.azure/generator/src/Visitors/TypeRemovalVisitor.cs new file mode 100644 index 000000000..c06279902 --- /dev/null +++ b/.plugin.azure/generator/src/Visitors/TypeRemovalVisitor.cs @@ -0,0 +1,56 @@ +using Microsoft.Generator.CSharp.ClientModel; +using Microsoft.Generator.CSharp.Providers; +using Microsoft.Generator.CSharp.Snippets; +using System.Linq; +using System.Text.RegularExpressions; + +namespace AzureOpenAILibraryPlugin; + +/// +/// This visitor suppresses the emission of types according to pattern matches in their names. +/// We do this to trim the set of generated files such that the library serves as an extension to +/// the underlying OpenAI library (rather than a standalone library in its own right). +/// +public class TypeRemovalVisitor : ScmLibraryVisitor +{ + private static readonly string[] PatternsToKeep = + [ + ".*BingSearchTool.*", + ".*DataSource.*", + ".*ContentFilter.*", + ".*OpenAI.*Error.*", + ".*Context.*", + ".*RetrievedDoc.*", + ".*ChatDocument.*", + ".*Citation.*", + "Argument", + "BinaryContentHelper", + "ChangeTracking.*", + "ClientPipelineExtensions", + "ClientUriBuilder", + "ErrorResult", + "ModelSerializationExtensions", + "Optional", + "PipelineRequestHeadersExtensions", + "TypeFormatters", + "Utf8JsonBinaryContent", + ]; + private static readonly string[] PatternsToStillDeleteAfterPatternsToKeep = + [ + "AzureOpenAIFile.*", + "BingSearchToolDefinition.cs", + ".*Elasticsearch*QueryType.*", + ".*FieldsMapping.*", + ".*ContentTextAnnotationsFileCitation.*" + ]; + + protected override TypeProvider? Visit(TypeProvider type) + { + if (PatternsToKeep.Any(patternToKeep => Regex.IsMatch(type.Name, patternToKeep) + && !PatternsToStillDeleteAfterPatternsToKeep.Any(patternToStillDelete => Regex.IsMatch(type.Name, patternToStillDelete)))) + { + return type; + } + return null; + } +} diff --git a/.plugin.azure/generator/src/Visitors/WriteableSardVisitor.cs b/.plugin.azure/generator/src/Visitors/WriteableSardVisitor.cs new file mode 100644 index 000000000..b425e13f8 --- /dev/null +++ b/.plugin.azure/generator/src/Visitors/WriteableSardVisitor.cs @@ -0,0 +1,24 @@ +using Microsoft.Generator.CSharp.ClientModel; +using Microsoft.Generator.CSharp.Primitives; +using Microsoft.Generator.CSharp.Providers; + +namespace AzureOpenAILibraryPlugin; + +/// +/// This visitor modifies the additional binary data properties field to be writeable (i.e. to exclude the +/// readonly modifier on the field). +/// +public class WriteableSardVisitor : ScmLibraryVisitor +{ + private const string AdditionalPropertiesFieldName = "_additionalBinaryDataProperties"; + + protected override FieldProvider Visit(FieldProvider field) + { + // Make the backing additional properties field not be read only as long as the type is not readonly. + if (field.Name == AdditionalPropertiesFieldName && !field.EnclosingType.DeclarationModifiers.HasFlag(TypeSignatureModifiers.ReadOnly)) + { + field.Modifiers &= ~FieldModifiers.ReadOnly; + } + return field; + } +} diff --git a/.plugin.azure/nuget.config b/.plugin.azure/nuget.config new file mode 100644 index 000000000..b6b1e7faf --- /dev/null +++ b/.plugin.azure/nuget.config @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/.plugin.azure/package.json b/.plugin.azure/package.json new file mode 100644 index 000000000..5be417a2c --- /dev/null +++ b/.plugin.azure/package.json @@ -0,0 +1,45 @@ +{ + "name": "@azure-openai/plugin", + "version": "1.0.0", + "description": "Azure OpenAI plugin", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/joseharriaga/openai-in-typespec.git" + }, + "bugs": { + "url": "https://github.com/joseharriaga/openai-in-typespec/issues" + }, + "type": "module", + "main": "dist/emitter/index.js", + "exports": { + ".": "./dist/emitter/index.js" + }, + "scripts": { + "clean": "rimraf ./dist ./emitter/temp && dotnet clean ./generator", + "build:emitter": "tsc -p ./tsconfig.build.json", + "build:generator": "dotnet build ./generator", + "build": "npm run build:emitter && npm run build:generator && copyfiles -E -f ../node_modules/@typespec/http-client-csharp/dist/generator/Microsoft.Generator.CSharp.runtimeconfig.json ./dist/generator", + "test:emitter": "vitest run -c ./emitter/vitest.config.ts", + "test:generator": "dotnet test ./generator", + "test": "npm run test:emitter && npm run test:generator" + }, + "files": [ + "dist/**" + ], + "dependencies": { + "@azure-tools/cadl-ranch-expect": "latest", + "@open-ai/plugin": "file:", + "@typespec/http-client-csharp": "latest" + }, + "devDependencies": { + "@types/node": "^22.8.1", + "@vitest/coverage-v8": "^1.4.0", + "@vitest/ui": "^1.4.0", + "c8": "^9.1.0", + "copyfiles": "^2.4.1", + "rimraf": "~5.0.5", + "typescript": "^5.6.3", + "vitest": "^1.4.0" + } +} diff --git a/.plugin.azure/tsconfig.build.json b/.plugin.azure/tsconfig.build.json new file mode 100644 index 000000000..20573897d --- /dev/null +++ b/.plugin.azure/tsconfig.build.json @@ -0,0 +1,11 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "noEmit": false, + "rootDir": "./emitter/src", + "outDir": "./dist/emitter", + "tsBuildInfoFile": "./emitter/temp/tsconfig.tsbuildinfo" + }, + "references": [], + "include": ["emitter/src"] + } \ No newline at end of file diff --git a/.plugin.azure/tsconfig.json b/.plugin.azure/tsconfig.json new file mode 100644 index 000000000..10e7b7230 --- /dev/null +++ b/.plugin.azure/tsconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + "noEmit": true, + "composite": true, + "alwaysStrict": true, + "forceConsistentCasingInFileNames": true, + "module": "Node16", + "moduleResolution": "Node16", + "esModuleInterop": true, + "noImplicitAny": true, + "noImplicitReturns": true, + "noImplicitThis": true, + "sourceMap": true, + "declarationMap": true, + "strict": true, + "declaration": true, + "stripInternal": true, + "noEmitHelpers": false, + "target": "ES2022", + "types": ["node"], + "lib": ["es2022", "DOM"], + "experimentalDecorators": true, + "newLine": "LF" + }, + "include": ["src/**/*.ts", "test/**/*.ts", "vitest.config.ts", "**/*.ts", "**/*.tsx", "**/.storybook/**/*.ts", "**/.storybook/**/*.tsx"], + "exclude": ["**/node_modules/", "**/dist/", "**/build/", "**/coverage/"] +} \ No newline at end of file diff --git a/.scripts.azure/Invoke-CodeGen.ps1 b/.scripts.azure/Invoke-CodeGen.ps1 index c0f426418..7262050e9 100644 --- a/.scripts.azure/Invoke-CodeGen.ps1 +++ b/.scripts.azure/Invoke-CodeGen.ps1 @@ -1,6 +1,4 @@ $repoRoot = Join-Path $PSScriptRoot .. -Resolve -$dotnetAzureFolder = Join-Path $repoRoot .dotnet.azure -$generatedFolder = Join-Path $dotnetAzureFolder sdk/openai/Azure.AI.OpenAI/src/Generated function Invoke([scriptblock]$script) { $scriptString = $script | Out-String @@ -8,83 +6,23 @@ function Invoke([scriptblock]$script) { & $script } -function Make-Internals-Settable { - Get-ChildItem "$generatedFolder" -File -Filter "Internal*.cs" | ForEach-Object { - $content = Get-Content $_.FullName -Raw - $newContent = $content -replace 'public(.*?)\{ get; \}', 'internal$1{ get; set; }' - Set-Content -Path $_.FullName -Value $newContent -NoNewline - } -} - -function Partialize-ClientPipelineExtensions { - $file = Get-ChildItem -Path "$generatedFolder\Internal\ClientPipelineExtensions.cs" - $content = Get-Content -Path $file -Raw - Write-Output "Editing $($file.FullName)" - $content = $content -creplace "internal static class ClientPipelineExtensions", "internal static partial class ClientPipelineExtensions" - $content | Set-Content -Path $file.FullName -NoNewline -} - -function Partialize-ClientUriBuilder { - $file = Get-ChildItem -Path "$generatedFolder\Internal\ClientUriBuilder.cs" - $content = Get-Content -Path $file -Raw - Write-Output "Editing $($file.FullName)" - $content = $content -creplace "internal class ClientUriBuilder", "internal partial class ClientUriBuilder" - $content | Set-Content -Path $file.FullName -NoNewline -} - -function Prune-Generated-Files { - $patternsToKeep = @( - "*BingSearchTool*", - "*DataSource*", - "*ContentFilter*", - "*OpenAI*Error*", - "*Context*", - "*RetrievedDoc*", - "*ChatDocument*", - "*Citation*" - ) - $patternsToDelete = @( - "AzureOpenAIFile*", - "BingSearchToolDefinition.cs", - "*Elasticsearch*QueryType*", - "*FieldsMapping*", - "*ContentTextAnnotationsFileCitation*" - ) - - Get-ChildItem "$generatedFolder" -File | ForEach-Object { - $generatedFile = $_; - $generatedFilename = $_.Name; - $keepFile = $false - foreach ($pattern in $patternsToKeep) { - if ($generatedFilename -like "$pattern") { - $keepFile = $true - foreach ($deletePattern in $patternsToDelete) { - if ($generatedFilename -like $deletePattern) { - $keepFile = $false - break - } - } - break - } - } - if (-not $keepFile) { - Write-Output "Removing: $generatedFilename" - Remove-Item $generatedFile - } - } -} +$scriptStartTime = Get-Date Push-Location $repoRoot + try { Invoke { npm ci } + Invoke { npm run build -w .plugin.azure } Set-Location $repoRoot/.typespec.azure Invoke { npm exec --no -- tsp format **/*tsp } Invoke { npm exec --no -- tsp compile . } - Prune-Generated-Files - Make-Internals-Settable - Partialize-ClientPipelineExtensions - Partialize-ClientUriBuilder } finally { Pop-Location } + +$scriptElapsed = $(Get-Date) - $scriptStartTime +$scriptElapsedSeconds = [math]::Round($scriptElapsed.TotalSeconds, 1) +$scriptName = $MyInvocation.MyCommand.Name + +Write-Host "${scriptName} complete. Time: ${scriptElapsedSeconds}s" \ No newline at end of file diff --git a/.typespec.azure/tspconfig.yaml b/.typespec.azure/tspconfig.yaml index 9adc4a453..53c4932f5 100644 --- a/.typespec.azure/tspconfig.yaml +++ b/.typespec.azure/tspconfig.yaml @@ -1,18 +1,13 @@ emit: - "@typespec/openapi3" - - "@azure-tools/typespec-csharp" + - "@azure-openai/plugin" options: "@typespec/openapi3": output-file: "{project-root}/../.openapi3.azure/openapi3-azure-openai-{version}-generated.yaml" omit-unreachable-types: true - "@azure-tools/typespec-csharp": + "@azure-openai/plugin": namespace: "Azure.AI.OpenAI" - emitter-output-dir: "{project-root}/../.dotnet.azure/sdk/openai/Azure.AI.OpenAI/src" - generate-convenience-methods: false + emitter-output-dir: "{project-root}/../.dotnet.azure/sdk/openai/Azure.AI.OpenAI" unreferenced-types-handling: keepAll - model-namespace: false - generate-test-project: false - single-top-level-client: true new-project: false - flavor: "unbranded" - enable-internal-raw-data: true + save-inputs: true diff --git a/package-lock.json b/package-lock.json index d9e349249..2eaf9990f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,10 +8,12 @@ "name": "openai-tsp", "version": "0.1.0", "workspaces": [ - ".plugin" + ".plugin", + ".plugin.azure" ], "dependencies": { "@autorest/csharp": "3.0.0-beta.20240904.1", + "@azure-openai/plugin": "file:.plugin.azure", "@azure-tools/typespec-csharp": "0.2.0-beta.20241201.1", "@open-ai/plugin": "file:.plugin", "@typespec/openapi3": "^0.62.0", @@ -38,6 +40,30 @@ "vitest": "^1.4.0" } }, + ".plugin.azure": { + "name": "@azure-openai/plugin", + "version": "1.0.0", + "license": "MIT", + "dependencies": { + "@azure-tools/cadl-ranch-expect": "latest", + "@open-ai/plugin": "file:", + "@typespec/http-client-csharp": "latest" + }, + "devDependencies": { + "@types/node": "^22.8.1", + "@vitest/coverage-v8": "^1.4.0", + "@vitest/ui": "^1.4.0", + "c8": "^9.1.0", + "copyfiles": "^2.4.1", + "rimraf": "~5.0.5", + "typescript": "^5.6.3", + "vitest": "^1.4.0" + } + }, + ".plugin.azure/node_modules/@open-ai/plugin": { + "resolved": ".plugin.azure", + "link": true + }, "node_modules/@ampproject/remapping": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz", @@ -61,6 +87,10 @@ "resolved": "https://registry.npmjs.org/@autorest/csharp/-/csharp-3.0.0-beta.20240904.1.tgz", "integrity": "sha512-fS5W+dQS0hMR/ubLN7L5VL834LzAJh26LkJSb4BLy2cWargem9T8xZf5GEwTKfVWosX7JC1sd/k5nX2z2Do+fg==" }, + "node_modules/@azure-openai/plugin": { + "resolved": ".plugin.azure", + "link": true + }, "node_modules/@azure-tools/cadl-ranch-expect": { "version": "0.15.6", "resolved": "https://registry.npmjs.org/@azure-tools/cadl-ranch-expect/-/cadl-ranch-expect-0.15.6.tgz", diff --git a/package.json b/package.json index fa1cead1b..b4de14d84 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,8 @@ { "name": "openai-tsp", "workspaces": [ - ".plugin" + ".plugin", + ".plugin.azure" ], "version": "0.1.0", "type": "module", @@ -9,6 +10,7 @@ "@autorest/csharp": "3.0.0-beta.20240904.1", "@azure-tools/typespec-csharp": "0.2.0-beta.20241201.1", "@open-ai/plugin": "file:.plugin", + "@azure-openai/plugin": "file:.plugin.azure", "@typespec/openapi3": "^0.62.0", "openai-tsp": "file:" },