diff --git a/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectsModelFactory.cs b/sdk/ai/Azure.AI.Projects/src/Generated/AIProjectsModelFactory.cs index ed336da925ed..c4b5caf2f0b1 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,17 @@ 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 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/OpenApiFunctionDefinition.Serialization.cs b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiFunctionDefinition.Serialization.cs index 6cb17dad942d..e4d94036fad8 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,26 @@ 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 (Optional.IsCollectionDefined(Functions)) + { + writer.WritePropertyName("functions"u8); + writer.WriteStartArray(); + foreach (var item in Functions) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } if (options.Format != "W" && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -93,6 +113,8 @@ internal static OpenApiFunctionDefinition DeserializeOpenApiFunctionDefinition(J string description = default; BinaryData spec = default; OpenApiAuthDetails auth = default; + IList defaultParams = default; + IList functions = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) @@ -117,13 +139,48 @@ 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 (property.NameEquals("functions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(InternalFunctionDefinition.DeserializeInternalFunctionDefinition(item, options)); + } + functions = 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(), + functions ?? 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..d3694e52714a 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiFunctionDefinition.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/OpenApiFunctionDefinition.cs @@ -63,6 +63,8 @@ public OpenApiFunctionDefinition(string name, BinaryData spec, OpenApiAuthDetail Name = name; Spec = spec; Auth = auth; + DefaultParams = new ChangeTrackingList(); + Functions = new ChangeTrackingList(); } /// Initializes a new instance of . @@ -74,13 +76,17 @@ 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. + /// List of functions returned in response. /// 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, IList functions, IDictionary serializedAdditionalRawData) { Name = name; Description = description; Spec = spec; Auth = auth; + DefaultParams = defaultParams; + Functions = functions; _serializedAdditionalRawData = serializedAdditionalRawData; } @@ -130,5 +136,9 @@ 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; } + /// List of functions returned in response. + public IList Functions { 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..c9f5ac4b1499 100644 --- a/sdk/ai/Azure.AI.Projects/src/Generated/RunStepToolCall.Serialization.cs +++ b/sdk/ai/Azure.AI.Projects/src/Generated/RunStepToolCall.Serialization.cs @@ -85,6 +85,7 @@ internal static RunStepToolCall DeserializeRunStepToolCall(JsonElement element, 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..0487e3d32019 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..0dc6e26ae8da 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/tsp-location.yaml b/sdk/ai/Azure.AI.Projects/tsp-location.yaml index 2c08336fedea..d39a38f1a0b0 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: 4df99f6f8ce4a6370d9180345cf1208171ad69ab repo: Azure/azure-rest-api-specs additionalDirectories: