From f4a188fa98febec3b58c358c91b780009b02cfdc Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 3 Apr 2025 18:30:36 +0000 Subject: [PATCH] CodeGen from PR 33707 in Azure/azure-rest-api-specs Merge ce8256d9672bda64e3d1b21736f5ad9ad0c566a3 into 32ce49f1d6d078aca05b3f88883dfd480d5af399 --- .../src/Generated/AIProjectsModelFactory.cs | 24 ++- .../src/Generated/AOAIModelConfig.cs | 6 +- .../Azure.AI.Projects/src/Generated/Agent.cs | 6 +- .../Generated/AgentsNamedToolChoiceType.cs | 3 + ...ustomSearchToolDefinition.Serialization.cs | 134 +++++++++++++++ .../BingCustomSearchToolDefinition.cs | 44 +++++ .../src/Generated/CreateAgentRequest.cs | 4 +- .../src/Generated/CreateRunRequest.cs | 4 +- .../Generated/CreateThreadAndRunRequest.cs | 4 +- .../src/Generated/MAASModelConfig.cs | 6 +- ...OpenApiFunctionDefinition.Serialization.cs | 33 +++- .../Generated/OpenApiFunctionDefinition.cs | 7 +- ...nStepCustomSearchToolCall.Serialization.cs | 151 +++++++++++++++++ .../Generated/RunStepCustomSearchToolCall.cs | 50 ++++++ .../RunStepOpenAPIToolCall.Serialization.cs | 151 +++++++++++++++++ .../src/Generated/RunStepOpenAPIToolCall.cs | 50 ++++++ .../RunStepToolCall.Serialization.cs | 2 + .../src/Generated/RunStepToolCall.cs | 2 +- .../src/Generated/RunStepToolCallDetails.cs | 6 +- .../SearchConfiguration.Serialization.cs | 150 +++++++++++++++++ .../src/Generated/SearchConfiguration.cs | 82 ++++++++++ .../SearchConfigurationList.Serialization.cs | 152 ++++++++++++++++++ .../src/Generated/SearchConfigurationList.cs | 85 ++++++++++ .../src/Generated/ThreadRun.cs | 6 +- .../Generated/ToolDefinition.Serialization.cs | 1 + .../src/Generated/ToolDefinition.cs | 2 +- .../src/Generated/UpdateAgentRequest.cs | 4 +- sdk/ai/Azure.AI.Projects/tsp-location.yaml | 2 +- 28 files changed, 1142 insertions(+), 29 deletions(-) create mode 100644 sdk/ai/Azure.AI.Projects/src/Generated/BingCustomSearchToolDefinition.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Projects/src/Generated/BingCustomSearchToolDefinition.cs create mode 100644 sdk/ai/Azure.AI.Projects/src/Generated/RunStepCustomSearchToolCall.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Projects/src/Generated/RunStepCustomSearchToolCall.cs create mode 100644 sdk/ai/Azure.AI.Projects/src/Generated/RunStepOpenAPIToolCall.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Projects/src/Generated/RunStepOpenAPIToolCall.cs create mode 100644 sdk/ai/Azure.AI.Projects/src/Generated/SearchConfiguration.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Projects/src/Generated/SearchConfiguration.cs create mode 100644 sdk/ai/Azure.AI.Projects/src/Generated/SearchConfigurationList.Serialization.cs create mode 100644 sdk/ai/Azure.AI.Projects/src/Generated/SearchConfigurationList.cs diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectsModelFactory.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectsModelFactory.cs index ed336da925ed..694ce19476f3 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectsModelFactory.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectsModelFactory.cs @@ -325,7 +325,7 @@ public static RunStepMessageCreationReference RunStepMessageCreationReference(st /// /// A list of tool call details for this run step. /// 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 . + /// The available derived classes include , , , , , , , and . /// /// A new instance for mocking. public static RunStepToolCallDetails RunStepToolCallDetails(IEnumerable toolCalls = null) @@ -454,6 +454,28 @@ public static RunStepMicrosoftFabricToolCall RunStepMicrosoftFabricToolCall(stri return new RunStepMicrosoftFabricToolCall("fabric_dataagent", id, serializedAdditionalRawData: null, microsoftFabric); } + /// Initializes a new instance of . + /// The ID of the tool call. This ID must be referenced when you submit tool outputs. + /// Reserved for future use. + /// A new instance for mocking. + public static RunStepCustomSearchToolCall RunStepCustomSearchToolCall(string id = null, IReadOnlyDictionary bingCustomSearch = null) + { + bingCustomSearch ??= new Dictionary(); + + return new RunStepCustomSearchToolCall("bing_custom_search", id, serializedAdditionalRawData: null, bingCustomSearch); + } + + /// Initializes a new instance of . + /// The ID of the tool call. This ID must be referenced when you submit tool outputs. + /// Reserved for future use. + /// A new instance for mocking. + public static RunStepOpenAPIToolCall RunStepOpenAPIToolCall(string id = null, IReadOnlyDictionary openAPI = null) + { + openAPI ??= new Dictionary(); + + return new RunStepOpenAPIToolCall("openapi", id, serializedAdditionalRawData: null, openAPI); + } + /// Initializes a new instance of . /// The error code for this error. /// The human-readable text associated with this error. diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AOAIModelConfig.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AOAIModelConfig.cs index b226cfb94368..1983a0c90b7b 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AOAIModelConfig.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AOAIModelConfig.cs @@ -14,7 +14,7 @@ namespace Azure.AI.Projects public partial class AOAIModelConfig : TargetModelConfig { /// Initializes a new instance of . - /// Endpoint URL for AOAI model. + /// Endpoint targetURI for AOAI model. /// API Key for AOAI model. /// Deployment name for AOAI model. /// , or is null. @@ -33,7 +33,7 @@ public AOAIModelConfig(string azureEndpoint, string apiKey, string azureDeployme /// Initializes a new instance of . /// Type of the model configuration. /// Keeps track of any properties unknown to the library. - /// Endpoint URL for AOAI model. + /// Endpoint targetURI for AOAI model. /// API Key for AOAI model. /// Deployment name for AOAI model. internal AOAIModelConfig(string type, IDictionary serializedAdditionalRawData, string azureEndpoint, string apiKey, string azureDeployment) : base(type, serializedAdditionalRawData) @@ -48,7 +48,7 @@ internal AOAIModelConfig() { } - /// Endpoint URL for AOAI model. + /// Endpoint targetURI for AOAI model. public string AzureEndpoint { get; set; } /// API Key for AOAI model. public string ApiKey { get; set; } diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/Agent.cs b/sdk/ai/Azure.AI.Projects/src/Generated/Agent.cs index 8d1ff839899f..a6f1538ccb10 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/Agent.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/Agent.cs @@ -56,7 +56,7 @@ public partial class Agent /// /// The collection of tools enabled for the agent. /// 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 . + /// The available derived classes include , , , , , , , , and . /// /// /// A set of resources that are used by the agent's tools. The resources are specific to the type of tool. For example, the `code_interpreter` @@ -104,7 +104,7 @@ internal Agent(string id, DateTimeOffset createdAt, string name, string descript /// /// The collection of tools enabled for the agent. /// 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 . + /// The available derived classes include , , , , , , , , and . /// /// /// A set of resources that are used by the agent's tools. The resources are specific to the type of tool. For example, the `code_interpreter` @@ -162,7 +162,7 @@ internal Agent() /// /// The collection of tools enabled for the agent. /// 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 . + /// The available derived classes include , , , , , , , , and . /// public IReadOnlyList Tools { get; } /// diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AgentsNamedToolChoiceType.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AgentsNamedToolChoiceType.cs index 8a5bfe61444d..265d120d70fc 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/AgentsNamedToolChoiceType.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/AgentsNamedToolChoiceType.cs @@ -29,6 +29,7 @@ public AgentsNamedToolChoiceType(string value) private const string MicrosoftFabricValue = "fabric_dataagent"; private const string SharepointValue = "sharepoint_grounding"; private const string AzureAISearchValue = "azure_ai_search"; + private const string BingCustomSearchValue = "bing_custom_search"; /// Tool type `function`. public static AgentsNamedToolChoiceType Function { get; } = new AgentsNamedToolChoiceType(FunctionValue); @@ -44,6 +45,8 @@ public AgentsNamedToolChoiceType(string value) public static AgentsNamedToolChoiceType Sharepoint { get; } = new AgentsNamedToolChoiceType(SharepointValue); /// Tool type `azure_ai_search`. public static AgentsNamedToolChoiceType AzureAISearch { get; } = new AgentsNamedToolChoiceType(AzureAISearchValue); + /// Tool type `bing_custom_search`. + public static AgentsNamedToolChoiceType BingCustomSearch { get; } = new AgentsNamedToolChoiceType(BingCustomSearchValue); /// Determines if two values are the same. public static bool operator ==(AgentsNamedToolChoiceType left, AgentsNamedToolChoiceType right) => left.Equals(right); /// Determines if two values are not the same. diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/BingCustomSearchToolDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/BingCustomSearchToolDefinition.Serialization.cs new file mode 100644 index 000000000000..fd4c1472bb76 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/BingCustomSearchToolDefinition.Serialization.cs @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Projects +{ + public partial class BingCustomSearchToolDefinition : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + 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(BingCustomSearchToolDefinition)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("bing_custom_search"u8); + writer.WriteObjectValue(BingCustomSearch, options); + } + + BingCustomSearchToolDefinition 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(BingCustomSearchToolDefinition)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBingCustomSearchToolDefinition(document.RootElement, options); + } + + internal static BingCustomSearchToolDefinition DeserializeBingCustomSearchToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + SearchConfigurationList bingCustomSearch = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("bing_custom_search"u8)) + { + bingCustomSearch = SearchConfigurationList.DeserializeSearchConfigurationList(property.Value, options); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new BingCustomSearchToolDefinition(type, serializedAdditionalRawData, bingCustomSearch); + } + + 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(BingCustomSearchToolDefinition)} does not support writing '{options.Format}' format."); + } + } + + BingCustomSearchToolDefinition 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeBingCustomSearchToolDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BingCustomSearchToolDefinition)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new BingCustomSearchToolDefinition FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeBingCustomSearchToolDefinition(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/BingCustomSearchToolDefinition.cs b/sdk/ai/Azure.AI.Projects/src/Generated/BingCustomSearchToolDefinition.cs new file mode 100644 index 000000000000..4e6749dbfe5b --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/BingCustomSearchToolDefinition.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// The input definition information for a Bing custom search tool as used to configure an agent. + public partial class BingCustomSearchToolDefinition : ToolDefinition + { + /// Initializes a new instance of . + /// The list of search configurations used by the bing custom search tool. + /// is null. + public BingCustomSearchToolDefinition(SearchConfigurationList bingCustomSearch) + { + Argument.AssertNotNull(bingCustomSearch, nameof(bingCustomSearch)); + + Type = "bing_custom_search"; + BingCustomSearch = bingCustomSearch; + } + + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + /// The list of search configurations used by the bing custom search tool. + internal BingCustomSearchToolDefinition(string type, IDictionary serializedAdditionalRawData, SearchConfigurationList bingCustomSearch) : base(type, serializedAdditionalRawData) + { + BingCustomSearch = bingCustomSearch; + } + + /// Initializes a new instance of for deserialization. + internal BingCustomSearchToolDefinition() + { + } + + /// The list of search configurations used by the bing custom search tool. + public SearchConfigurationList BingCustomSearch { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CreateAgentRequest.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CreateAgentRequest.cs index 9dda204238ad..bb43c6e09183 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/CreateAgentRequest.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CreateAgentRequest.cs @@ -65,7 +65,7 @@ internal CreateAgentRequest(string model) /// /// The collection of tools to enable for the new agent. /// 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 . + /// The available derived classes include , , , , , , , , and . /// /// /// A set of resources that are used by the agent's tools. The resources are specific to the type of tool. For example, the `code_interpreter` @@ -115,7 +115,7 @@ internal CreateAgentRequest() /// /// The collection of tools to enable for the new agent. /// 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 . + /// The available derived classes include , , , , , , , , and . /// public IReadOnlyList Tools { get; } /// diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CreateRunRequest.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CreateRunRequest.cs index 9b9969dd27eb..b32ae5c3f845 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/CreateRunRequest.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CreateRunRequest.cs @@ -70,7 +70,7 @@ internal CreateRunRequest(string assistantId) /// /// The overridden list of enabled tools that the agent should use to run the thread. /// 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 . + /// The available derived classes include , , , , , , , , and . /// /// /// If `true`, returns a stream of events that happen during the Run as server-sent events, @@ -145,7 +145,7 @@ internal CreateRunRequest() /// /// The overridden list of enabled tools that the agent should use to run the thread. /// 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 . + /// The available derived classes include , , , , , , , , and . /// public IReadOnlyList OverrideTools { get; } /// diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/CreateThreadAndRunRequest.cs b/sdk/ai/Azure.AI.Projects/src/Generated/CreateThreadAndRunRequest.cs index 58bc40b50d21..5cc281b7b2a4 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/CreateThreadAndRunRequest.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/CreateThreadAndRunRequest.cs @@ -65,7 +65,7 @@ internal CreateThreadAndRunRequest(string assistantId) /// /// The overridden list of enabled tools the agent should use to run the thread. /// 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 . + /// The available derived classes include , , , , , , , , and . /// /// Override the tools the agent can use for this run. This is useful for modifying the behavior on a per-run basis. /// @@ -136,7 +136,7 @@ internal CreateThreadAndRunRequest() /// /// The overridden list of enabled tools the agent should use to run the thread. /// 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 . + /// The available derived classes include , , , , , , , , and . /// public IReadOnlyList OverrideTools { get; } /// Override the tools the agent can use for this run. This is useful for modifying the behavior on a per-run basis. diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/MAASModelConfig.cs b/sdk/ai/Azure.AI.Projects/src/Generated/MAASModelConfig.cs index 024f0dd9bb72..92712dbc0601 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/MAASModelConfig.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/MAASModelConfig.cs @@ -14,7 +14,7 @@ namespace Azure.AI.Projects public partial class MAASModelConfig : TargetModelConfig { /// Initializes a new instance of . - /// Endpoint URL for MAAS model. + /// Endpoint targetURI for MAAS model. /// API Key for MAAS model. /// or is null. public MAASModelConfig(string azureEndpoint, string apiKey) @@ -30,7 +30,7 @@ public MAASModelConfig(string azureEndpoint, string apiKey) /// Initializes a new instance of . /// Type of the model configuration. /// Keeps track of any properties unknown to the library. - /// Endpoint URL for MAAS model. + /// Endpoint targetURI for MAAS model. /// API Key for MAAS model. internal MAASModelConfig(string type, IDictionary serializedAdditionalRawData, string azureEndpoint, string apiKey) : base(type, serializedAdditionalRawData) { @@ -43,7 +43,7 @@ internal MAASModelConfig() { } - /// Endpoint URL for MAAS model. + /// Endpoint targetURI for MAAS model. public string AzureEndpoint { get; set; } /// API Key for MAAS model. public string ApiKey { get; set; } diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiFunctionDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiFunctionDefinition.Serialization.cs index 6cb17dad942d..28d64aeadd41 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiFunctionDefinition.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiFunctionDefinition.Serialization.cs @@ -52,6 +52,16 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit #endif writer.WritePropertyName("auth"u8); writer.WriteObjectValue(Auth, options); + if (Optional.IsCollectionDefined(DefaultParams)) + { + writer.WritePropertyName("default_params"u8); + writer.WriteStartArray(); + foreach (var item in DefaultParams) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } if (options.Format != "W" && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -93,6 +103,7 @@ internal static OpenApiFunctionDefinition DeserializeOpenApiFunctionDefinition(J string description = default; BinaryData spec = default; OpenApiAuthDetails auth = default; + IList defaultParams = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) @@ -117,13 +128,33 @@ internal static OpenApiFunctionDefinition DeserializeOpenApiFunctionDefinition(J auth = OpenApiAuthDetails.DeserializeOpenApiAuthDetails(property.Value, options); continue; } + if (property.NameEquals("default_params"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + defaultParams = array; + continue; + } if (options.Format != "W") { rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } serializedAdditionalRawData = rawDataDictionary; - return new OpenApiFunctionDefinition(name, description, spec, auth, serializedAdditionalRawData); + return new OpenApiFunctionDefinition( + name, + description, + spec, + auth, + defaultParams ?? new ChangeTrackingList(), + serializedAdditionalRawData); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiFunctionDefinition.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiFunctionDefinition.cs index 8980b1cfe70e..b6ace6e72956 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiFunctionDefinition.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiFunctionDefinition.cs @@ -63,6 +63,7 @@ public OpenApiFunctionDefinition(string name, BinaryData spec, OpenApiAuthDetail Name = name; Spec = spec; Auth = auth; + DefaultParams = new ChangeTrackingList(); } /// Initializes a new instance of . @@ -74,13 +75,15 @@ public OpenApiFunctionDefinition(string name, BinaryData spec, OpenApiAuthDetail /// 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 . /// + /// List of OpenAPI spec parameters that will use user-provided defaults. /// Keeps track of any properties unknown to the library. - internal OpenApiFunctionDefinition(string name, string description, BinaryData spec, OpenApiAuthDetails auth, IDictionary serializedAdditionalRawData) + internal OpenApiFunctionDefinition(string name, string description, BinaryData spec, OpenApiAuthDetails auth, IList defaultParams, IDictionary serializedAdditionalRawData) { Name = name; Description = description; Spec = spec; Auth = auth; + DefaultParams = defaultParams; _serializedAdditionalRawData = serializedAdditionalRawData; } @@ -130,5 +133,7 @@ internal OpenApiFunctionDefinition() /// The available derived classes include , and . /// public OpenApiAuthDetails Auth { get; set; } + /// List of OpenAPI spec parameters that will use user-provided defaults. + public IList DefaultParams { get; } } } diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepCustomSearchToolCall.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepCustomSearchToolCall.Serialization.cs new file mode 100644 index 000000000000..196457e0a2ca --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepCustomSearchToolCall.Serialization.cs @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Projects +{ + public partial class RunStepCustomSearchToolCall : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + 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(RunStepCustomSearchToolCall)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("bing_custom_search"u8); + writer.WriteStartObject(); + foreach (var item in BingCustomSearch) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + + RunStepCustomSearchToolCall 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(RunStepCustomSearchToolCall)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepCustomSearchToolCall(document.RootElement, options); + } + + internal static RunStepCustomSearchToolCall DeserializeRunStepCustomSearchToolCall(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyDictionary bingCustomSearch = default; + string type = default; + string id = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("bing_custom_search"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + bingCustomSearch = dictionary; + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepCustomSearchToolCall(type, id, serializedAdditionalRawData, bingCustomSearch); + } + + 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(RunStepCustomSearchToolCall)} does not support writing '{options.Format}' format."); + } + } + + RunStepCustomSearchToolCall 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepCustomSearchToolCall(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepCustomSearchToolCall)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new RunStepCustomSearchToolCall FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepCustomSearchToolCall(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepCustomSearchToolCall.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepCustomSearchToolCall.cs new file mode 100644 index 000000000000..dd6618679e2c --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepCustomSearchToolCall.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// + /// A record of a call to a bing custom search tool, issued by the model in evaluation of a defined tool, that represents + /// executed search with bing custom search. + /// + public partial class RunStepCustomSearchToolCall : RunStepToolCall + { + /// Initializes a new instance of . + /// The ID of the tool call. This ID must be referenced when you submit tool outputs. + /// Reserved for future use. + /// or is null. + internal RunStepCustomSearchToolCall(string id, IReadOnlyDictionary bingCustomSearch) : base(id) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(bingCustomSearch, nameof(bingCustomSearch)); + + Type = "bing_custom_search"; + BingCustomSearch = bingCustomSearch; + } + + /// Initializes a new instance of . + /// The object type. + /// The ID of the tool call. This ID must be referenced when you submit tool outputs. + /// Keeps track of any properties unknown to the library. + /// Reserved for future use. + internal RunStepCustomSearchToolCall(string type, string id, IDictionary serializedAdditionalRawData, IReadOnlyDictionary bingCustomSearch) : base(type, id, serializedAdditionalRawData) + { + BingCustomSearch = bingCustomSearch; + } + + /// Initializes a new instance of for deserialization. + internal RunStepCustomSearchToolCall() + { + } + + /// Reserved for future use. + public IReadOnlyDictionary BingCustomSearch { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepOpenAPIToolCall.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepOpenAPIToolCall.Serialization.cs new file mode 100644 index 000000000000..1d23fe2a6498 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepOpenAPIToolCall.Serialization.cs @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Projects +{ + public partial class RunStepOpenAPIToolCall : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + 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(RunStepOpenAPIToolCall)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("openapi"u8); + writer.WriteStartObject(); + foreach (var item in OpenAPI) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + + RunStepOpenAPIToolCall 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(RunStepOpenAPIToolCall)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepOpenAPIToolCall(document.RootElement, options); + } + + internal static RunStepOpenAPIToolCall DeserializeRunStepOpenAPIToolCall(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyDictionary openapi = default; + string type = default; + string id = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("openapi"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + openapi = dictionary; + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepOpenAPIToolCall(type, id, serializedAdditionalRawData, openapi); + } + + 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(RunStepOpenAPIToolCall)} does not support writing '{options.Format}' format."); + } + } + + RunStepOpenAPIToolCall 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepOpenAPIToolCall(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepOpenAPIToolCall)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new RunStepOpenAPIToolCall FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRunStepOpenAPIToolCall(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepOpenAPIToolCall.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepOpenAPIToolCall.cs new file mode 100644 index 000000000000..309a45d57ea0 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepOpenAPIToolCall.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// + /// A record of a call to an OpenAPI tool, issued by the model in evaluation of a defined tool, that represents + /// executed OpenAPI operations. + /// + public partial class RunStepOpenAPIToolCall : RunStepToolCall + { + /// Initializes a new instance of . + /// The ID of the tool call. This ID must be referenced when you submit tool outputs. + /// Reserved for future use. + /// or is null. + internal RunStepOpenAPIToolCall(string id, IReadOnlyDictionary openAPI) : base(id) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(openAPI, nameof(openAPI)); + + Type = "openapi"; + OpenAPI = openAPI; + } + + /// Initializes a new instance of . + /// The object type. + /// The ID of the tool call. This ID must be referenced when you submit tool outputs. + /// Keeps track of any properties unknown to the library. + /// Reserved for future use. + internal RunStepOpenAPIToolCall(string type, string id, IDictionary serializedAdditionalRawData, IReadOnlyDictionary openAPI) : base(type, id, serializedAdditionalRawData) + { + OpenAPI = openAPI; + } + + /// Initializes a new instance of for deserialization. + internal RunStepOpenAPIToolCall() + { + } + + /// Reserved for future use. + public IReadOnlyDictionary OpenAPI { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepToolCall.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepToolCall.Serialization.cs index 3a545fa7adeb..52913e2c9a5f 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepToolCall.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepToolCall.Serialization.cs @@ -80,11 +80,13 @@ internal static RunStepToolCall DeserializeRunStepToolCall(JsonElement element, switch (discriminator.GetString()) { case "azure_ai_search": return RunStepAzureAISearchToolCall.DeserializeRunStepAzureAISearchToolCall(element, options); + case "bing_custom_search": return RunStepCustomSearchToolCall.DeserializeRunStepCustomSearchToolCall(element, options); case "bing_grounding": return RunStepBingGroundingToolCall.DeserializeRunStepBingGroundingToolCall(element, options); case "code_interpreter": return RunStepCodeInterpreterToolCall.DeserializeRunStepCodeInterpreterToolCall(element, options); case "fabric_dataagent": return RunStepMicrosoftFabricToolCall.DeserializeRunStepMicrosoftFabricToolCall(element, options); case "file_search": return RunStepFileSearchToolCall.DeserializeRunStepFileSearchToolCall(element, options); case "function": return RunStepFunctionToolCall.DeserializeRunStepFunctionToolCall(element, options); + case "openapi": return RunStepOpenAPIToolCall.DeserializeRunStepOpenAPIToolCall(element, options); case "sharepoint_grounding": return RunStepSharepointToolCall.DeserializeRunStepSharepointToolCall(element, options); } } diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepToolCall.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepToolCall.cs index 7b77b862d1a2..a800f6a76157 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepToolCall.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepToolCall.cs @@ -13,7 +13,7 @@ namespace Azure.AI.Projects /// /// An abstract representation of a detailed tool call as recorded within a run step for an existing run. /// 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 . + /// The available derived classes include , , , , , , , and . /// public abstract partial class RunStepToolCall { diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepToolCallDetails.cs b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepToolCallDetails.cs index f734d2d76efe..00e943d0854b 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepToolCallDetails.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepToolCallDetails.cs @@ -18,7 +18,7 @@ public partial class RunStepToolCallDetails : RunStepDetails /// /// A list of tool call details for this run step. /// 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 . + /// The available derived classes include , , , , , , , and . /// /// is null. internal RunStepToolCallDetails(IEnumerable toolCalls) @@ -35,7 +35,7 @@ internal RunStepToolCallDetails(IEnumerable toolCalls) /// /// A list of tool call details for this run step. /// 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 . + /// The available derived classes include , , , , , , , and . /// internal RunStepToolCallDetails(RunStepType type, IDictionary serializedAdditionalRawData, IReadOnlyList toolCalls) : base(type, serializedAdditionalRawData) { @@ -50,7 +50,7 @@ internal RunStepToolCallDetails() /// /// A list of tool call details for this run step. /// 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 . + /// The available derived classes include , , , , , , , and . /// public IReadOnlyList ToolCalls { get; } } diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/SearchConfiguration.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/SearchConfiguration.Serialization.cs new file mode 100644 index 000000000000..db3d6f44722d --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/SearchConfiguration.Serialization.cs @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Projects +{ + public partial class SearchConfiguration : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + 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(SearchConfiguration)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("connection_id"u8); + writer.WriteStringValue(ConnectionId); + writer.WritePropertyName("instance_name"u8); + writer.WriteStringValue(InstanceName); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + SearchConfiguration 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(SearchConfiguration)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSearchConfiguration(document.RootElement, options); + } + + internal static SearchConfiguration DeserializeSearchConfiguration(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string connectionId = default; + string instanceName = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("connection_id"u8)) + { + connectionId = property.Value.GetString(); + continue; + } + if (property.NameEquals("instance_name"u8)) + { + instanceName = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SearchConfiguration(connectionId, instanceName, 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(SearchConfiguration)} does not support writing '{options.Format}' format."); + } + } + + SearchConfiguration 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSearchConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SearchConfiguration)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static SearchConfiguration FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSearchConfiguration(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/SearchConfiguration.cs b/sdk/ai/Azure.AI.Projects/src/Generated/SearchConfiguration.cs new file mode 100644 index 000000000000..8885b81cd971 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/SearchConfiguration.cs @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.Projects +{ + /// A custom search configuration. + public partial class SearchConfiguration + { + /// + /// 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" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// A connection in a ToolConnectionList attached to this tool. + /// Name of the custom configuration instance given to config. + /// or is null. + public SearchConfiguration(string connectionId, string instanceName) + { + Argument.AssertNotNull(connectionId, nameof(connectionId)); + Argument.AssertNotNull(instanceName, nameof(instanceName)); + + ConnectionId = connectionId; + InstanceName = instanceName; + } + + /// Initializes a new instance of . + /// A connection in a ToolConnectionList attached to this tool. + /// Name of the custom configuration instance given to config. + /// Keeps track of any properties unknown to the library. + internal SearchConfiguration(string connectionId, string instanceName, IDictionary serializedAdditionalRawData) + { + ConnectionId = connectionId; + InstanceName = instanceName; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SearchConfiguration() + { + } + + /// A connection in a ToolConnectionList attached to this tool. + public string ConnectionId { get; set; } + /// Name of the custom configuration instance given to config. + public string InstanceName { get; set; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/SearchConfigurationList.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/SearchConfigurationList.Serialization.cs new file mode 100644 index 000000000000..91f01ba590a8 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/SearchConfigurationList.Serialization.cs @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.Projects +{ + public partial class SearchConfigurationList : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + 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(SearchConfigurationList)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("search_configurations"u8); + writer.WriteStartArray(); + foreach (var item in SearchConfigurations) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + SearchConfigurationList 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(SearchConfigurationList)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSearchConfigurationList(document.RootElement, options); + } + + internal static SearchConfigurationList DeserializeSearchConfigurationList(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList searchConfigurations = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("search_configurations"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(SearchConfiguration.DeserializeSearchConfiguration(item, options)); + } + searchConfigurations = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SearchConfigurationList(searchConfigurations, 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(SearchConfigurationList)} does not support writing '{options.Format}' format."); + } + } + + SearchConfigurationList 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSearchConfigurationList(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SearchConfigurationList)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static SearchConfigurationList FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSearchConfigurationList(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/SearchConfigurationList.cs b/sdk/ai/Azure.AI.Projects/src/Generated/SearchConfigurationList.cs new file mode 100644 index 000000000000..8847f00e6f20 --- /dev/null +++ b/sdk/ai/Azure.AI.Projects/src/Generated/SearchConfigurationList.cs @@ -0,0 +1,85 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.Projects +{ + /// A list of search configurations currently used by the `bing_custom_search` tool. + public partial class SearchConfigurationList + { + /// + /// 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" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// + /// The connections attached to this tool. There can be a maximum of 1 connection + /// resource attached to the tool. + /// + /// is null. + public SearchConfigurationList(IEnumerable searchConfigurations) + { + Argument.AssertNotNull(searchConfigurations, nameof(searchConfigurations)); + + SearchConfigurations = searchConfigurations.ToList(); + } + + /// Initializes a new instance of . + /// + /// The connections attached to this tool. There can be a maximum of 1 connection + /// resource attached to the tool. + /// + /// Keeps track of any properties unknown to the library. + internal SearchConfigurationList(IList searchConfigurations, IDictionary serializedAdditionalRawData) + { + SearchConfigurations = searchConfigurations; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SearchConfigurationList() + { + } + + /// + /// The connections attached to this tool. There can be a maximum of 1 connection + /// resource attached to the tool. + /// + public IList SearchConfigurations { get; } + } +} diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ThreadRun.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ThreadRun.cs index e26dcc9823d4..67aea1986f61 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ThreadRun.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ThreadRun.cs @@ -57,7 +57,7 @@ public partial class ThreadRun /// /// The overridden enabled tools used for this agent thread run. /// 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 . + /// The available derived classes include , , , , , , , , and . /// /// The Unix timestamp, in seconds, representing when this object was created. /// The Unix timestamp, in seconds, representing when this item expires. @@ -126,7 +126,7 @@ internal ThreadRun(string id, string threadId, string assistantId, RunStatus sta /// /// The overridden enabled tools used for this agent thread run. /// 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 . + /// The available derived classes include , , , , , , , , and . /// /// The Unix timestamp, in seconds, representing when this object was created. /// The Unix timestamp, in seconds, representing when this item expires. @@ -209,7 +209,7 @@ internal ThreadRun() /// /// The overridden enabled tools used for this agent thread run. /// 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 . + /// The available derived classes include , , , , , , , , and . /// public IReadOnlyList Tools { get; } /// The Unix timestamp, in seconds, representing when this object was created. diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ToolDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ToolDefinition.Serialization.cs index cf029a42c888..49f18c3eb0d4 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ToolDefinition.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ToolDefinition.Serialization.cs @@ -79,6 +79,7 @@ internal static ToolDefinition DeserializeToolDefinition(JsonElement element, Mo { case "azure_ai_search": return AzureAISearchToolDefinition.DeserializeAzureAISearchToolDefinition(element, options); case "azure_function": return AzureFunctionToolDefinition.DeserializeAzureFunctionToolDefinition(element, options); + case "bing_custom_search": return BingCustomSearchToolDefinition.DeserializeBingCustomSearchToolDefinition(element, options); case "bing_grounding": return BingGroundingToolDefinition.DeserializeBingGroundingToolDefinition(element, options); case "code_interpreter": return CodeInterpreterToolDefinition.DeserializeCodeInterpreterToolDefinition(element, options); case "fabric_dataagent": return MicrosoftFabricToolDefinition.DeserializeMicrosoftFabricToolDefinition(element, options); diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/ToolDefinition.cs b/sdk/ai/Azure.AI.Projects/src/Generated/ToolDefinition.cs index 212407f403df..46adb7e03811 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/ToolDefinition.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/ToolDefinition.cs @@ -13,7 +13,7 @@ namespace Azure.AI.Projects /// /// An abstract representation of an input tool definition that an agent can use. /// 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 . + /// The available derived classes include , , , , , , , , and . /// public abstract partial class ToolDefinition { diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/UpdateAgentRequest.cs b/sdk/ai/Azure.AI.Projects/src/Generated/UpdateAgentRequest.cs index 6768e4d7de9e..16676e8aeb33 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/UpdateAgentRequest.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/UpdateAgentRequest.cs @@ -60,7 +60,7 @@ internal UpdateAgentRequest() /// /// The modified collection of tools to enable for the agent. /// 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 . + /// The available derived classes include , , , , , , , , and . /// /// /// A set of resources that are used by the agent's tools. The resources are specific to the type of tool. For example, @@ -105,7 +105,7 @@ internal UpdateAgentRequest(string model, string name, string description, strin /// /// The modified collection of tools to enable for the agent. /// 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 . + /// The available derived classes include , , , , , , , , and . /// public IReadOnlyList Tools { get; } /// diff --git a/sdk/ai/Azure.AI.Projects/tsp-location.yaml b/sdk/ai/Azure.AI.Projects/tsp-location.yaml index 2c08336fedea..03dca6cdd528 100644 --- a/sdk/ai/Azure.AI.Projects/tsp-location.yaml +++ b/sdk/ai/Azure.AI.Projects/tsp-location.yaml @@ -1,4 +1,4 @@ directory: specification/ai/Azure.AI.Projects -commit: 366f7e94f14f6c2a4af81b9b0b6726751de97da7 +commit: 0dc7a1328084a211acb4a583b65a2e3e6f496217 repo: Azure/azure-rest-api-specs additionalDirectories: